This module includes classes to create the datasets.
The BaseDataset class is a template to be used for the several types of datasets we are going to use. The methods BaseDataset.list_files, BaseDataset.find_dates and BaseDataset.open are just placeholders to be defined individually for each data source as they will depend on the filenames and file types.
The remaining methods of BaseDataset listed below are already defined but some may need to be redifined for particular datasets with different characteristics.
Example:
iop = InOutPath('../data', '../data')
R = Region('PI', [-10, 36, 5, 44], 0.01)
bands = ['Reflectance_M5', 'Reflectance_M7', 'Reflectance_M10', 'Radiance_M12',
'Radiance_M15', 'SolarZenithAngle', 'SatelliteZenithAngle']
merge_tiles = MergeTiles('SatelliteZenithAngle', ignore=['R'])
mir_calc = MirCalc('SolarZenithAngle', 'Radiance_M12', 'Radiance_M15')
rename = BandsRename(['Reflectance_M5', 'Reflectance_M7'], ['Red', 'NIR'])
bfilter = BandsFilter(['Red', 'NIR', 'MIR'])
data = Viirs750Dataset(iop, R, bands=bands)
test_eq(data.name, 'VIIRS750')
data.times
test_eq(str(data.times[0]), '2017-10-27 00:00:00')
out = data.process_one(time=data.times[0], max_size=2000,
proc_funcs=[merge_tiles, mir_calc, rename, bfilter],
save=False)
test_eq([k for k in out], ['MIR', 'Red', 'NIR'])
test_eq(np.nanmean(out['NIR']).astype(np.float64).round(4), 0.0474)
class Viirs750Dataset2(Viirs750Dataset):
_use_netcdf4 = True
data2 = Viirs750Dataset2(iop, R, bands=bands)
out2 = data2.process_one(time=data.times[0], max_size=2000,
proc_funcs=[merge_tiles, mir_calc, rename, bfilter],
save=False)
test_eq(np.nanmean(out['NIR']).round(7), np.nanmean(out2['NIR']).round(7))
test_eq(np.nanmean(out['Red']).round(7), np.nanmean(out2['Red']).round(7))
test_eq(np.nanmean(out['MIR']).round(7), np.nanmean(out2['MIR']).round(7))