Skip to content

Commit

Permalink
improvements to allow Test_FU_images
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Silva committed Sep 29, 2022
1 parent 8b5fd99 commit 5a6afb0
Show file tree
Hide file tree
Showing 4 changed files with 538 additions and 992 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Works with both point data (observations) and images (satellite).
Notebooks:

* forel_ule_OLCI.ipynb - Example or loading, preprocessing, calculating and ploting FU from example OLCI images.
* prep_test_images.ipynb - Utility to generate test images included.
* Test_FU - compares this implementation with the published formulae in Woerd and Wernand (2015)
* Test_FU_images - Applies FU to test images
* forel_ule_tutorial.ipynb - Step by step calculation, with formulae and references.
* prep_test_images.ipynb - Utility to generate test images included.

Module fume
```
Expand Down
488 changes: 488 additions & 0 deletions Test_FU_images.ipynb

Large diffs are not rendered by default.

988 changes: 0 additions & 988 deletions forel_ule_MERIS.ipynb

This file was deleted.

51 changes: 48 additions & 3 deletions fume.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import matplotlib.pyplot as plt
from matplotlib import cm
import xarray as xr
from matplotlib.colors import LinearSegmentedColormap


sensor_corr_file = 'data/sensor_hue_corr_WW2015.csv'

Expand Down Expand Up @@ -45,7 +47,6 @@ def calc_ForelUle_image(wavelength, reflectance,
sensor_coef = sensorcorrdf.loc[sensorcorr].values

cmf = pd.read_csv(sep = "\t", filepath_or_buffer = cmf)
#fui = pd.read_csv(sep = "\t", filepath_or_buffer = "data/FUI_ATAN210.tsv", names = ["value", "atan"])
fui = pd.read_csv(sep = ",", filepath_or_buffer = fucalibration, header=0)

Delta = cmf['wavelength'][1] - cmf['wavelength'][0]
Expand Down Expand Up @@ -126,7 +127,7 @@ def calc_ForelUle_image(wavelength, reflectance,
for c in range(1, len(fui)-1):
fu_i[ (a_i < fui["lowerlimit"].iloc[c-1]) & (a_i >= fui["lowerlimit"].iloc[c]) ] = fui['FU'].iloc[c]

return fu_i
return (fu_i,a_i)


def calc_fu_WW2015(wavelength, reflec,sensor):
Expand Down Expand Up @@ -260,4 +261,48 @@ def calc_fu_WW2015(wavelength, reflec,sensor):
elif (hueanglPcorr < 19):
FUSentinel3Pcorr = 21

return FUSentinel3Pcorr
return (FUSentinel3Pcorr, hueanglPcorr)


def forelulecmap():
# Returns Forel Ule colormap

fuh ={"1":"#2158bc",
"2":"#316dc5",
"3":"#327cbb",
"4":"#4b80a0",
"5":"#568f96",
"6":"#6d9298",
"7":"#698c86",
"8":"#759e72",
"9":"#7ba654",
"10":"#7dae38",
"11":"#95b645",
"12":"#94b660",
"13":"#a5bc76",
"14":"#aab86d",
"15":"#adb55f",
"16":"#a8a965",
"17":"#ae9f5c",
"18":"#b3a053",
"19":"#af8a44",
"20":"#a46905",
"21":"#a14d04"}

def _hex_to_rgb(value):
'''
Converts hex to rgb colours
value: string of 6 characters representing a hex colour.
Returns: list length 3 of RGB values'''
value = value.strip("#") # removes hash symbol if present
lv = len(value)
return tuple(int(value[i:i + lv // 3], 16)/256 for i in range(0, lv, lv // 3))

furgb = [_hex_to_rgb(hexstr) for hexstr in fuh.values()]

cm = LinearSegmentedColormap.from_list('ForelUle',furgb,N=21)
cm.set_under(color='k', alpha=None)
cm.set_over(color='k', alpha=None)
cm.set_bad(color='k', alpha=0)

return cm

0 comments on commit 5a6afb0

Please sign in to comment.