diff --git a/hires_module.py b/hires_module.py index b0e0eb039a8f7b12f01729efa66e864e1a0e6159..bbca3fab23ef37cd004a43e8d29c060e40c86a1c 100644 --- a/hires_module.py +++ b/hires_module.py @@ -1,6 +1,7 @@ import numpy as np import xarray as xr import netCDF4 as nc +import sys from glob import glob @@ -22,13 +23,13 @@ importlib.reload(tst) # TEST CASE # data: _datapath = '/ships19/hercules/pveglio/mvcm_viirs_hires' -_fname_mod02 = glob(f'{_datapath}/VNP02MOD.A2022173.1454.001.*.uwssec_bowtie_corrected.nc')[0] -_fname_mod03 = glob(f'{_datapath}/VNP03MOD.A2022173.1454.001.*.uwssec.nc')[0] -_fname_img02 = glob(f'{_datapath}/VNP02IMG.A2022173.1454.001.*.uwssec_bowtie_corrected.nc')[0] -_fname_img03 = glob(f'{_datapath}/VNP03IMG.A2022173.1454.001.*.uwssec.nc')[0] +_fname_mod02 = '' +_fname_mod03 = '' +_fname_img02 = '' +_fname_img03 = '' # MVCM output -_cld_mask = f'{_datapath}/CLDMSK_L2_VIIRS_SNPP.A2022173.1454.001.2022174035130.nc' +_cld_mask = '' # thresholds: _threshold_file = '/home/pveglio/mvcm/thresholds.mvcm.snpp.v0.0.1.yaml' @@ -60,13 +61,8 @@ def main(*, geos_constants: str = _geos_constants, ndvi_file: str = _ndvi_file, sst_file: str = _sst_file, - cloud_mask_file=_cld_mask) -> None: + out_fname: str = 'temp.nc') -> None: - f = nc.Dataset(cloud_mask_file) - - cm = f['geophysical_data/Cloud_Mask'][:] - - f.close() check = nc.Dataset(mod02) if 'M01' not in list(check['observation_data'].variables): check.close() @@ -75,6 +71,7 @@ def main(*, if check.isopen(): check.close() + print(threshold_file) with open(threshold_file) as f: text = f.read() thresholds = yml.safe_load(text) @@ -99,14 +96,14 @@ def main(*, if 'I01' not in viirs_data: return - cm_flag = np.array((np.array(cm[0, :, :], np.byte) & - (pow(2, 1) + pow(2, 2)))/pow(2, 1)) - - mvcm_conf = np.ones(cm_flag.shape) - # conf[cm_flag == 3] = 1 - mvcm_conf[cm_flag == 2] = 0.95 - mvcm_conf[cm_flag == 1] = 0.66 - mvcm_conf[cm_flag == 0] = 0 +# cm_flag = np.array((np.array(cm[0, :, :], np.byte) & +# (pow(2, 1) + pow(2, 2)))/pow(2, 1)) +# +# mvcm_conf = np.ones(cm_flag.shape) +# # conf[cm_flag == 3] = 1 +# mvcm_conf[cm_flag == 2] = 0.95 +# mvcm_conf[cm_flag == 1] = 0.66 +# mvcm_conf[cm_flag == 0] = 0 viirs_lores = rd.read_data('viirs', mod02, data_path + '/' + mod03) @@ -170,11 +167,10 @@ def main(*, date = mod02.split('.')[1] time = mod02.split('.')[2] - mvcm_confidence = mvcm_conf.repeat(2, 0).repeat(2, 1) +# mvcm_confidence = mvcm_conf.repeat(2, 0).repeat(2, 1) out_xr = xr.Dataset( data_vars=dict( hires_confidence=(['number_of_lines', 'number_of_pixels'], confidence), - mvcm_confidence=(['number_of_lines', 'number_of_pixels'], mvcm_confidence), ocean_day_mask=(['number_of_lines', 'number_of_pixels'], viirs_data.Ocean_Day.values), ), coords=dict( @@ -214,4 +210,19 @@ def read_bits(byte, bits): if __name__ == "__main__": - main() + main(data_path=sys.argv[1], + mod02=sys.argv[2], + mod03=sys.argv[3], + img02=sys.argv[4], + img03=sys.argv[5], + threshold_file=sys.argv[6], + geos_atm_1=sys.argv[7], + geos_atm_2=sys.argv[8], + geos_land=sys.argv[9], + geos_ocean=sys.argv[10], + geos_constants=sys.argv[11], + ndvi_file=sys.argv[12], + sst_file=sys.argv[13], + out_fname=sys.argv[14]) + + diff --git a/scene.py b/scene.py index 0e37c57d84ad942c78fa4ee21044ce3d4a831282..c921417bcaafe26da08569b49e6bcbcdf403ed95 100644 --- a/scene.py +++ b/scene.py @@ -38,14 +38,14 @@ night = 200 # #################################################################### # # TEST CASE # data: -datapath = '/ships19/hercules/pveglio/mvcm_viirs_hires' -fname_mod02 = glob(f'{datapath}/VNP02MOD.A2022173.1448.001.*.uwssec*.nc')[0] -fname_mod03 = glob(f'{datapath}/VNP03MOD.A2022173.1448.001.*.uwssec.nc')[0] -fname_img02 = glob(f'{datapath}/VNP02IMG.A2022173.1448.001.*.uwssec*.nc')[0] -fname_img03 = glob(f'{datapath}/VNP03IMG.A2022173.1448.001.*.uwssec.nc')[0] +#datapath = '/ships19/hercules/pveglio/mvcm_viirs_hires' +#fname_mod02 = glob(f'{datapath}/VNP02MOD.A2022173.1448.001.*.uwssec*.nc')[0] +#fname_mod03 = glob(f'{datapath}/VNP03MOD.A2022173.1448.001.*.uwssec.nc')[0] +#fname_img02 = glob(f'{datapath}/VNP02IMG.A2022173.1448.001.*.uwssec*.nc')[0] +#fname_img03 = glob(f'{datapath}/VNP03IMG.A2022173.1448.001.*.uwssec.nc')[0] # thresholds: -threshold_file = '/home/pveglio/mvcm_leo/thresholds/new_thresholds.mvcm.snpp.v1.0.0.yaml' +#threshold_file = '/home/pveglio/mvcm_leo/thresholds/new_thresholds.mvcm.snpp.v1.0.0.yaml' # ancillary files: geos_atm_1 = 'GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4' diff --git a/setup.py b/setup.py index 2d1cc3206e30bfad7bb7cc129d914fe853019356..192f920fcd412fe3cfd636130a63a61790d64452 100644 --- a/setup.py +++ b/setup.py @@ -26,12 +26,15 @@ sourcefiles = ['src/get_Reynolds_SST.c', # SST ] include_dirs = ['include', - '/opt/hdfeos2/2.20-gcc-8.3/include', - '/opt/netcdf4/4.7.0-gcc-8.3/include', + '/opt/hdf4/4.2.9-gcc-4.9.2/include', + '/opt/hdfeos2/2.19-gcc-4.9.2/include', + '/opt/netcdf4/4.3.3-gcc-4.9.2/include', numpy.get_include(), ] -library_dirs = ['/opt/hdfeos2/2.20-gcc-8.3/lib', - '/opt/netcdf4/4.7.0-gcc-8.3/lib'] +library_dirs = ['/opt/hdf4/4.2.9-gcc-4.9.2/lib', + '/opt/hdfeos2/2.19-gcc-4.9.2/lib', + '/opt/netcdf4/4.3.3-gcc-4.9.2/lib', + ] extensions = [Extension('ancillary_data', sourcefiles, include_dirs=include_dirs, diff --git a/sort_inputs.py b/sort_inputs.py index 1734c2013ac08813f27869db725f30c9a89a5ef1..df8a9ac1244fb47a6f4ddbf421920a51c1f25ebc 100644 --- a/sort_inputs.py +++ b/sort_inputs.py @@ -63,7 +63,8 @@ def create_filenames(vnp02mod_fname): 'data_path': datapath, 'cloud_mask_file': cld_msk } - + for k in list(out_fnames): + print(f'{k}: {out_fnames[k]}') return out_fnames @@ -93,4 +94,4 @@ def call_mvcm(): if __name__ == "__main__": - call_mvcm() + create_filenames