-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc_refl.py
44 lines (35 loc) · 1.2 KB
/
calc_refl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import xarray as xr
import sys
from dask.diagnostics import ProgressBar
from utils import extract_references
from radiometry import compute_reflectance
ref_coords = {
'filename': [
'_I50_L0-511_3-10-2018_10.59.48_White',
'_I50_L0-511_3-10-2018_13.17.29_White',
'_I50_L0-511_3-10-2018_13.33.40_White',
'_I50_L0-511_3-10-2018_13.47.54_PTFE_bottom',
'_I50_L0-511_3-10-2018_13.50.8_PTFE_',
'_I50_L0-511_3-10-2018_13.52.45_PTFE_top'
]
}
def main(argv):
inputfile = argv[0]
output = argv[1]
variable = argv[2]
print(f'Calculating reflectances from dataset {inputfile} for')
print(f'all and saving result to {output}.')
ds = xr.open_dataset(inputfile, chunks={'filename': 1})
ds = extract_references(ds, variable, ref_coords)
found_refs = "\n".join(ds["reference_filename"].data)
print(f'Found references \n{found_refs}')
ok = input('Is this right? [y/n]')
if ok != 'y':
print('Aborting...')
exit()
print('Computing reflectances...')
ds = compute_reflectance(ds, variable, f'reference_{variable}')
with ProgressBar():
ds.to_netcdf(output)
if __name__ == '__main__':
main(sys.argv[1:])