diff --git a/mvcm/ancillary.pyx b/mvcm/ancillary.pyx index 5f44c5b0d5dc0b50b576bec7b22b1efe202a2742..235e3be75bc53dfa2461929fb2e3070be5b719a5 100644 --- a/mvcm/ancillary.pyx +++ b/mvcm/ancillary.pyx @@ -1,10 +1,10 @@ # cython: language_level=3 # cython: c_string_Type=unicode, c_string_encoding=utf8 -cdef extern void get_Reynolds_SST(float *, float *, int, int, int, char *, char *, float *) -cdef extern void get_NDVI_background(float *, float *, int, int, int, char *, char *, float *) +cdef extern void get_Reynolds_SST(float *, float *, int, int, int, char *, float *) +cdef extern void get_NDVI_background(float *, float *, int, int, int, char *, float *) cdef extern void get_Olson_eco(float *, float *, int, int, int, char *, unsigned char *) -cdef extern void get_GEOS(float *, float *, int, int, int, char *, char *, char *, char *, char *, char *, char *, +cdef extern void get_GEOS(float *, float *, int, int, int, char *, char *, char *, char *, char *, char *, float *, float *, float *, float *, float *, float *) cdef extern void snow_mask(char *, unsigned char) cdef extern float cithr(int, float, float) @@ -50,14 +50,14 @@ def py_conf_test(np.ndarray[float, ndim=1] rad, def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, n_eles, n_lines, res, - char *anc_dir, char *sst_file, sst): + char *sst_file, sst): if not sst.flags['C_CONTIGUOUS']: sst = np.ascontiguousarray(sst) cdef float[::1] sst_mv = sst - get_Reynolds_SST(&lat[0], &lon[0], n_eles, n_lines, res, anc_dir, sst_file, &sst_mv[0]) + get_Reynolds_SST(&lat[0], &lon[0], n_eles, n_lines, res, sst_file, &sst_mv[0]) return sst @@ -68,14 +68,14 @@ def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat, def py_get_NDVI_background(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, n_eles, n_lines, res, - char *anc_dir, char *ndvi_file, ndvi): + char *ndvi_file, ndvi): if not ndvi.flags['C_CONTIGUOUS']: ndvi = np.ascontiguousarray(ndvi) cdef float[::1] ndvi_mv = ndvi - get_NDVI_background(&lat[0], &lon[0], n_eles, n_lines, res, anc_dir, ndvi_file, &ndvi_mv[0]) + get_NDVI_background(&lat[0], &lon[0], n_eles, n_lines, res, ndvi_file, &ndvi_mv[0]) return ndvi @@ -86,14 +86,14 @@ def py_get_NDVI_background(np.ndarray[float, ndim=1] lat, def py_get_Olson_eco(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, n_eles, scan_lines, res, - char *anc_dir, eco): + char *eco_file, eco): if not eco.flags['C_CONTIGUOUS']: eco = np.ascontiguousarray(eco) cdef unsigned char[::1] eco_mv = eco - get_Olson_eco(&lat[0], &lon[0], n_eles, scan_lines, res, anc_dir, &eco_mv[0]) + get_Olson_eco(&lat[0], &lon[0], n_eles, scan_lines, res, eco_file, &eco_mv[0]) return eco @@ -102,7 +102,7 @@ def py_get_Olson_eco(np.ndarray[float, ndim=1] lat, @cython.wraparound(False) @cython.initializedcheck(False) def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, int n_eles, int n_lines, int res, - char *startTime, char *anc_dir, char *geos1, char *geos2, + char *startTime, char *geos1, char *geos2, char *geos_lnd, char *geos_ocn, char *geos_cnst, geos_data): for v in geos_data: @@ -116,7 +116,7 @@ def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, in cdef float[::1] landicefr_mv = geos_data['land_ice_fraction'] cdef float[::1] sfct_mv = geos_data['surface_temperature'] - get_GEOS(&lat[0], &lon[0], n_eles, n_lines, res, startTime, anc_dir, geos1, geos2, geos_lnd, geos_ocn, geos_cnst, + get_GEOS(&lat[0], &lon[0], n_eles, n_lines, res, startTime, geos1, geos2, geos_lnd, geos_ocn, geos_cnst, &tpw_mv[0], &snowfr_mv[0], &icefr_mv[0], &ocnfr_mv[0], &landicefr_mv[0], &sfct_mv[0]) geos_dict = {'tpw': geos_data['tpw'], diff --git a/mvcm/c_tools/get_GEOS.c b/mvcm/c_tools/get_GEOS.c index e1e8c57fecee85cf20bb95dbc5333743a87b5fa5..a9394867423a93ceebd941882333619a9364ba8a 100644 --- a/mvcm/c_tools/get_GEOS.c +++ b/mvcm/c_tools/get_GEOS.c @@ -56,8 +56,8 @@ Comments: /******************************************************************************/ -void get_GEOS(float *lat, float *lon, int n_eles, int n_lines, int res, char *granule_start_time, char *anc_dir, char *geos1, char *geos2, char *geos_lnd, - char *geos_ocn, char *geos_cnst, float *tpw, float *snowfr, float *icefr, float *geos_ocnfr, +void get_GEOS(float *lat, float *lon, int n_eles, int n_lines, int res, char *granule_start_time, char *geos1, char *geos2, char *geos_land, + char *geos_ocean, char *geos_constants, float *tpw, float *snowfr, float *icefr, float *geos_ocnfr, float *landicefr, float *sfct) { @@ -71,19 +71,14 @@ void get_GEOS(float *lat, float *lon, int n_eles, int n_lines, int res, char *gr extern int get_ti_weights(float, int, int, float*); extern int get_ti_vars(float); extern int assign_geos_vals(float *, float *, int, int, int); - extern int read_GEOS(char[256], int); - extern int read_GEOS_lndocn(char[256], char[256]); - extern int read_GEOS_constants(char[256]); + extern int read_GEOS(char *, int); + extern int read_GEOS_lndocn(char *, char *); + extern int read_GEOS_constants(char *); const int eles=n_eles*res; const int lines=n_lines*res; - char geos1_wpath[256]; - char geos2_wpath[256]; - char geosland_wpath[256]; - char geosocean_wpath[256]; - char geosconstants_wpath[256]; - char s1[64], s2[64]; + char s1[256], s2[256]; char search[2]; char *token; int irt; @@ -97,44 +92,35 @@ void get_GEOS(float *lat, float *lon, int n_eles, int n_lines, int res, char *gr /******************************************************************************/ -/* Get complete file names. */ - strcpy(geos1_wpath,anc_dir);strcat(geos1_wpath,"/");strcat(geos1_wpath,geos1); - printf("\nGEOS file1: %s\n", geos1_wpath); - strcpy(geos2_wpath,anc_dir);strcat(geos2_wpath,"/");strcat(geos2_wpath,geos2); - printf("GEOS file2: %s\n", geos2_wpath); - strcpy(geosland_wpath,anc_dir);strcat(geosland_wpath,"/");strcat(geosland_wpath,geos_lnd); - printf("GEOS LAND file: %s\n", geosland_wpath); - strcpy(geosocean_wpath,anc_dir);strcat(geosocean_wpath,"/");strcat(geosocean_wpath,geos_ocn); - printf("GEOS OCEAN file: %s\n", geosocean_wpath); - strcpy(geosconstants_wpath,anc_dir);strcat(geosconstants_wpath,"/");strcat(geosconstants_wpath,geos_cnst); - printf("GEOS CONSTANTS file: %s\n\n", geosconstants_wpath); - -/******************************************************************************/ - + printf("GEOS 1: %s\n", geos1); + printf("GEOS 2: %s\n", geos2); + printf("GEOS land: %s\n", geos_land); + printf("GEOS ocean: %s\n", geos_ocean); + printf("GEOS constants: %s\n", geos_constants); // Read GEOS time-independent (constants) file. // Get land/sea tags (fraction ocean) and surface elevation (geopotential ht.). - irt = read_GEOS_constants(geosconstants_wpath); + irt = read_GEOS_constants(geos_constants); // Read snow and ice fractions from GEOS land and ocean property files. // Variables listed in read_GEOS_lndocn.c // Pointers to GEOS snow and ice fractions are stored in ancillary.h. - irt = read_GEOS_lndocn(geosland_wpath, geosocean_wpath); + irt = read_GEOS_lndocn(geos_land, geos_ocean); // Read selected variables from GEOS 3-hourly analysis files. // Variables listed in read_GEOS.c // Pointers to GEOS variables are stored in ancillary.h. GEOS_time_index = 1; - irt = read_GEOS(geos1_wpath, GEOS_time_index); + irt = read_GEOS(geos1, GEOS_time_index); if(irt != 0) { - printf("read_GEOS unsuccessful: %s\n", geos1_wpath); + printf("read_GEOS unsuccessful: %s\n", geos1); // return (-1); } GEOS_time_index = 2; - irt = read_GEOS(geos2_wpath, GEOS_time_index); + irt = read_GEOS(geos2, GEOS_time_index); if(irt != 0) { - printf("read_GEOS unsuccessful: %s\n", geos2_wpath); + printf("read_GEOS unsuccessful: %s\n", geos2); // return (-2); } diff --git a/mvcm/c_tools/get_NDVI_background.c b/mvcm/c_tools/get_NDVI_background.c index 5a0c054506f5488f1918ea3c6289ad157853be17..c3fd6af75e020b530f4b93f4842e761536fbc81b 100644 --- a/mvcm/c_tools/get_NDVI_background.c +++ b/mvcm/c_tools/get_NDVI_background.c @@ -44,7 +44,7 @@ Calls: /******************************************************************************/ -void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int res, char *anc_dir, char *NDVI_file, float *g_ndvi_background) +void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int res, char *NDVI_file, float *g_ndvi_background) { @@ -54,12 +54,10 @@ void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int re /******************************************************************************/ - char NDVI_file_wpath[256]; char NDVI_data[23][80]; char SDS_name[10]; char * ndvi_sub="/NDVI/"; float map_res, wm_lon, nm_lat; - //float *g_ndvi_background; long int nncols = 21600; long int nnrows = 10800; long int xindex, yindex, indx, idx; @@ -76,14 +74,6 @@ void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int re int return_code = 0; -/******************************************************************************/ - -// Construct file name. - - (void) strcpy(NDVI_file_wpath, anc_dir); - (void) strcat(NDVI_file_wpath, "/"); - (void) strcat(NDVI_file_wpath, NDVI_file); -// printf("NDVI file: %s\n", NDVI_file_wpath); /******************************************************************************/ @@ -92,9 +82,9 @@ void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int re /******************************************************************************/ // Open file. */ - id = SDstart(NDVI_file_wpath, DFACC_READ); + id = SDstart(NDVI_file, DFACC_READ); if (id <= 0) { - printf("Could not open NDVI file %s\n",NDVI_file_wpath); + printf("Could not open NDVI file %s\n",NDVI_file); //return (-1); } @@ -113,7 +103,7 @@ void get_NDVI_background(float *lat, float *lon, int n_eles, int n_lines, int re sds_id = SDselect(id, sds_index); irt = SDreaddata(sds_id, start, stride, edge, ndvi_arr); if (irt < 0) { - printf("Could not read NDVI file %s\n",NDVI_file_wpath); + printf("Could not read NDVI file %s\n",NDVI_file); //return (-2); } diff --git a/mvcm/c_tools/get_Olson_eco.c b/mvcm/c_tools/get_Olson_eco.c index b3a5a07cd7586718ba63f0637d84975eebe70d27..15167e452ae4442babad50de50f93343177552d0 100644 --- a/mvcm/c_tools/get_Olson_eco.c +++ b/mvcm/c_tools/get_Olson_eco.c @@ -41,7 +41,7 @@ Calls: /******************************************************************************/ -int get_Olson_eco(float *lat, float *lon, int n_eles, int scan_lines, int res, char *anc_dir, unsigned char *granule_ecotype) +int get_Olson_eco(float *lat, float *lon, int n_eles, int scan_lines, int res, char *eco_file, unsigned char *granule_ecotype) { @@ -54,7 +54,6 @@ int get_Olson_eco(float *lat, float *lon, int n_eles, int scan_lines, int res, c extern long int lround(double); extern void getcoord_(double*, double*, double*, double*); - char eco_file[256]; unsigned char eco_index; //unsigned char *granule_ecotype; double lt, ln, ltt, lnn; @@ -71,19 +70,10 @@ int get_Olson_eco(float *lat, float *lon, int n_eles, int scan_lines, int res, c size_t bytes_read; FILE *eco_file_ptr; -// Define static ecosystem file name. - char eco_file_name[] = "goge1_2_img.v1"; - int return_code = 0; /******************************************************************************/ -/* Get file name */ - (void) strcpy(eco_file, anc_dir); - (void) strcat(eco_file, "/"); - (void) strcat(eco_file, eco_file_name); -// printf("ecosystem file: %s \n", eco_file); - /* Open file */ eco_file_ptr = fopen(eco_file, "r"); if(eco_file_ptr == NULL) { diff --git a/mvcm/c_tools/get_Reynolds_SST.c b/mvcm/c_tools/get_Reynolds_SST.c index 5af9e8a0a9a7b55a8bb8cddcf53823ed2cbee9df..bdd1cca76d93f6a4a2c863e9fc3db24365910686 100644 --- a/mvcm/c_tools/get_Reynolds_SST.c +++ b/mvcm/c_tools/get_Reynolds_SST.c @@ -38,7 +38,7 @@ Calls: /******************************************************************************/ -void get_Reynolds_SST(float *lat, float *lon, int n_eles, int n_lines, int res, char *anc_dir, char *SST_file, float *sstInterp) +void get_Reynolds_SST(float *lat, float *lon, int n_eles, int n_lines, int res, char *SST_file, float *sstInterp) { @@ -59,11 +59,9 @@ void get_Reynolds_SST(float *lat, float *lon, int n_eles, int n_lines, int res, long int npoints_y = 180; /* the 2 possible sizes of an SST file (formatted/unformatted) */ long int unfSize = 583264; - char sst_file_wpath[256]; char fileFormat[4] = "unk"; float xlon, ytemp; - //float * sstInterp; float tempVal; long int fileSize; long int indx; @@ -81,15 +79,10 @@ void get_Reynolds_SST(float *lat, float *lon, int n_eles, int n_lines, int res, /******************************************************************************/ - strcpy(sst_file_wpath, anc_dir); - strcat(sst_file_wpath, "/"); - strcat(sst_file_wpath, SST_file); -// printf("SST file: %s \n", sst_file_wpath); - /* Open file */ - sst_file_ptr = fopen(sst_file_wpath, "rb"); + sst_file_ptr = fopen(SST_file, "rb"); if(sst_file_ptr == NULL) { - printf("Cannot open Reynolds SST file %s\n", sst_file_wpath); + printf("Cannot open Reynolds SST file %s\n", SST_file); // return (-1); } /* Get the file size */ diff --git a/mvcm/c_tools/get_geos_times.c b/mvcm/c_tools/get_geos_times.c index 17a107ece4f2c5d9714a032ef3732a2f514fcebd..84d1c32fa19839465554c34d1ab1287bac7a2199 100644 --- a/mvcm/c_tools/get_geos_times.c +++ b/mvcm/c_tools/get_geos_times.c @@ -28,10 +28,11 @@ Calls: #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <libgen.h> /******************************************************************************/ -int get_geos_times(char s1[64], char s2[64], int *geoshr1, int *geoshr2) +int get_geos_times(char s1[256], char s2[256], int *geoshr1, int *geoshr2) { @@ -42,6 +43,8 @@ int get_geos_times(char s1[64], char s2[64], int *geoshr1, int *geoshr2) char search[4]; char *geos_time = "0"; char *token; + char *fname1; + char *fname2; int return_code = 0; @@ -51,9 +54,11 @@ int get_geos_times(char s1[64], char s2[64], int *geoshr1, int *geoshr2) // printf("get time 1: %s\n", s1); // printf("get time 2: %s\n", s2); + fname1 = basename(s1); + fname2 = basename(s2); (void) strcpy(search, "_"); - token = strtok(s1, search); + token = strtok(fname1, search); token = strtok(NULL, search); token = strtok(NULL, search); token = strtok(NULL, search); @@ -63,7 +68,7 @@ int get_geos_times(char s1[64], char s2[64], int *geoshr1, int *geoshr2) *(geoshr1) = atoi(geos_time); (void) strcpy(search, "_"); - token = strtok(s2, search); + token = strtok(fname2, search); token = strtok(NULL, search); token = strtok(NULL, search); token = strtok(NULL, search); diff --git a/mvcm/main.py b/mvcm/main.py index 31871d10f4fc7ca9629c36ccc5fb0495b3b7fe26..dc5230f3c5328e9f3d5a60358b4947c021534897 100644 --- a/mvcm/main.py +++ b/mvcm/main.py @@ -182,44 +182,7 @@ def main( verbose_level = np.minimum(verbose, 4) logging.basicConfig(level=LOG_LEVELS[verbose_level]) - if os.path.exists(mod02) is False: - mod02_err = f"File {mod02} not found" - raise FileNotFoundError(mod02_err) - if os.path.exists(mod03) is False: - mod03_err = f"File {mod03} not found" - raise FileNotFoundError(mod03_err) - if img02 != "" and os.path.exists(img02) is False: - img02_err = f"File {img02} not found" - raise FileNotFoundError(img02_err) - if img03 != "" and os.path.exists(img03) is False: - img03_err = f"File {img03} not found" - raise FileNotFoundError(img03_err) - if os.path.exists(geos_atm_1) is False: - geos_atm_1_err = f"File {geos_atm_1} not found" - raise FileNotFoundError(geos_atm_1_err) - if os.path.exists(geos_atm_2) is False: - geos_atm_2_err = f"File {geos_atm_2} not found" - raise FileNotFoundError(geos_atm_2_err) - if os.path.exists(geos_land) is False: - geos_land_err = f"File {geos_land} not found" - raise FileNotFoundError(geos_land_err) - if os.path.exists(geos_ocean) is False: - geos_ocean_err = f"File {geos_ocean} not found" - raise FileNotFoundError(geos_ocean_err) - if os.path.exists(geos_constants) is False: - geos_constants_err = f"File {geos_constants} not found" - raise FileNotFoundError(geos_constants_err) - if os.path.exists(ndvi_file) is False: - ndvi_file_err = f"File {ndvi_file} not found" - raise FileNotFoundError(ndvi_file_err) - if os.path.exists(sst_file) is False: - sst_file_err = f"File {sst_file} not found" - raise FileNotFoundError(sst_file_err) - if os.path.exists(eco_file) is False: - eco_file_err = f"File {eco_file} not found" - raise FileNotFoundError(eco_file_err) - - if img02 != "" or img03 != "": + if img02 is None or img03 is None: use_hires = False else: use_hires = True @@ -253,8 +216,9 @@ def main( except KeyError: logger.info(f"Band {b} not found in file. No output will be written.") return + logger.info(f"All bands found in file {file_names['IMG02']}. The code will run.") - logger.info(f"Reading VNP02: {file_names['MOD02']}") + # logger.info(f"Reading VNP02: {file_names['MOD02']}") viirs_data = rd.get_data(satellite, sensor, file_names, hires=use_hires) @@ -775,8 +739,8 @@ if __name__ == "__main__": data_path = args.path or _datapath mod02 = args.l1b mod03 = args.geolocation - img02 = args.hires_l1b or "" - img03 = args.hires_geo or "" + img02 = args.hires_l1b or None + img03 = args.hires_geo or None threshold_file = args.threshold or _threshold_file geos_atm_1 = args.atmos_1 or _geos_atm_1 geos_atm_2 = args.atmos_2 or _geos_atm_2 diff --git a/mvcm/read_data.py b/mvcm/read_data.py index 004f975534e765f7faeeb6dba875ca003b738ace..3459f6c0445523796634f8902eb49fe1cad965e5 100644 --- a/mvcm/read_data.py +++ b/mvcm/read_data.py @@ -122,81 +122,22 @@ class CollectInputs: name of the dimensions for the arrays in the xarray.Dataset output """ - file_name_geo: str = field( - default=f"{_datapath}/VNP03MOD.A2022173.1312.001.2022174012746.uwssec.nc", - validator=[ - validators.instance_of(str), - ], - ) - file_name_l1b: str = field( - default=f"{_datapath}/VNP02MOD.A2022173.1312.001.2022174011547.uwssec.nc", - validator=[ - validators.instance_of(str), - ], - ) - ancillary_dir: str = field( - default=f"{_datapath}/ancillary", - validator=[ - validators.instance_of(str), - ], - ) - sst_file: str = field( - default="oisst.20220622", - validator=[ - validators.instance_of(str), - ], - ) - eco_file: str = field( - default="goge1_2_img.v1", - validator=[ - validators.instance_of(str), - ], - ) - ndvi_file: str = field( - default="NDVI.FM.c004.v2.0.WS.00-04.177.hdf", - validator=[ - validators.instance_of(str), - ], - ) - geos_file_1: str = field( - default="GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4", - validator=[ - validators.instance_of(str), - ], - ) - geos_file_2: str = field( - default="GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1500.V01.nc4", - validator=[ - validators.instance_of(str), - ], - ) - geos_land: str = field( - default="GEOS.fpit.asm.tavg1_2d_lnd_Nx.GEOS5124.20220622_1330.V01.nc4", - validator=[ - validators.instance_of(str), - ], - ) - geos_ocean: str = field( - default="GEOS.fpit.asm.tavg1_2d_ocn_Nx.GEOS5124.20220622_1330.V01.nc4", - validator=[ - validators.instance_of(str), - ], - ) - geos_constants: str = field( - default="GEOS.fp.asm.const_2d_asm_Nx.00000000_0000.V01.nc4", - validator=[ - validators.instance_of(str), - ], - ) - log_level: str = field(default="INFO") - logging.basicConfig(level=log_level) + file_name_geo: str = "" + file_name_l1b: str = "" + ancillary_dir: str = "" + sst_file: str = "" + eco_file: str = "goge1_2_img.v1" + ndvi_file: str = "" + geos_file_1: str = "" + geos_file_2: str = "" + geos_land: str = "" + geos_ocean: str = "" + geos_constants: str = "GEOS.fp.asm.const_2d_asm_Nx.00000000_0000.V01.nc4" + log_level: str = "INFO" + + dims: tuple = ("number_of_lines", "number_of_pixels") - dims: tuple = field( - default=("number_of_lines", "number_of_pixels"), - validator=[ - validators.instance_of(tuple), - ], - ) + logging.basicConfig(level=log_level) @define(slots=True, kw_only=True) @@ -217,7 +158,7 @@ class ReadData(CollectInputs): satellite: str = field(validator=[validators.instance_of(str), validators.in_(["snpp"])]) sensor: str = field(validator=[validators.instance_of(str), validators.in_(["viirs"])]) - hires: bool = field(default=False, validator=[validators.instance_of(bool)]) + hires: bool = field(default=False, validator=[validators.instance_of(bool)]) # type: ignore logger.debug("Instance of ReadData created") @@ -235,6 +176,12 @@ class ReadData(CollectInputs): dataset containing all geolocation data """ logger.debug(f"Reading {self.file_name_geo}") + + if os.path.exists(self.file_name_geo) is False: + logger.error("Geolocation file not found") + err_msg = f"Could not find the file {self.file_name_geo}" + raise FileNotFoundError(err_msg) + geo_data = xr.open_dataset(self.file_name_geo, group="geolocation_data", engine="netcdf4") relazi = self.relative_azimuth_angle( @@ -266,6 +213,12 @@ class ReadData(CollectInputs): solar zenith angle derived from the geolocation file """ logger.debug(f"Reading {self.file_name_l1b}") + + if os.path.exists(self.file_name_l1b) is False: + logger.error("L1b file not found") + err_msg = f"Could not find the file {self.file_name_l1b}" + raise FileNotFoundError(err_msg) + l1b_data = xr.open_dataset( self.file_name_l1b, group="observation_data", decode_cf=False, engine="netcdf4" ) @@ -585,7 +538,8 @@ class ReadAncillary(CollectInputs): sst: npt.NDArray[float] array containing the Reynolds SST interpolated at the sensor's resolution """ - if not os.path.isfile(os.path.join(self.ancillary_dir, self.sst_file)): + logger.debug(f"Reading SST file {self.sst_file}") + if not os.path.isfile(self.sst_file): logger.error("SST file not found") sst = np.empty(self.out_shape, dtype=np.float32).ravel() sst = anc.py_get_Reynolds_SST( @@ -594,7 +548,6 @@ class ReadAncillary(CollectInputs): self.latitude.shape[0], self.latitude.shape[1], self.resolution, - self.ancillary_dir, self.sst_file, sst, ) @@ -613,7 +566,8 @@ class ReadAncillary(CollectInputs): ndvi: npt.NDArray[float] NDVI interpolated at the sensor's resolution """ - if not os.path.isfile(os.path.join(self.ancillary_dir, self.ndvi_file)): + logger.debug(f"Reading NDVI file {self.ndvi_file}") + if not os.path.isfile(self.ndvi_file): logger.error("NDVI file not found") ndvi = np.empty(self.out_shape, dtype=np.float32).ravel() ndvi = anc.py_get_NDVI_background( @@ -622,7 +576,6 @@ class ReadAncillary(CollectInputs): self.latitude.shape[0], self.latitude.shape[1], self.resolution, - self.ancillary_dir, self.ndvi_file, ndvi, ) @@ -641,6 +594,10 @@ class ReadAncillary(CollectInputs): eco: npt.NDArray[float] Olson ecosystem type interpolated at the sensor's resolution """ + logger.debug(f"Reading Ecosystem file {self.eco_file}") + if not os.path.isfile(self.eco_file): + logger.error("Ecosystem file not found") + eco = np.empty(self.out_shape, dtype=np.ubyte).ravel() eco = anc.py_get_Olson_eco( self.latitude.ravel(), @@ -648,7 +605,7 @@ class ReadAncillary(CollectInputs): self.out_shape[0], self.out_shape[1], self.resolution, - self.ancillary_dir, + self.eco_file, eco, ) logger.debug("Olson ecosystem file read successfully") @@ -667,16 +624,25 @@ class ReadAncillary(CollectInputs): dictionary containing all quantities required by MVCM (see geos_variables here below) """ - if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_1)): + logger.debug("Reading GEOS-5 files") + logger.debug(f"Reading GEOS-5 file 1 {self.geos_file_1}") + logger.debug(f"Reading GEOS-5 file 2 {self.geos_file_2}") + logger.debug(f"Reading GEOS-5 land file {self.geos_land}") + logger.debug(f"Reading GEOS-5 ocean file {self.geos_ocean}") + logger.debug(f"Reading GEOS-5 constants file {self.geos_constants}") + if not os.path.isfile(self.geos_file_1): logger.error("GEOS-5 file 1 not found") - if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_2)): - logger.error("GEOS-5 file 2 not found") - if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_land)): - logger.error("GEOS-5 land file not found") - if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_ocean)): - logger.error("GEOS-5 ocean file not found") - if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_constants)): - logger.error("GEOS-5 constants file not found") + + # if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_1)): + # logger.error("GEOS-5 file 1 not found") + # if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_file_2)): + # logger.error("GEOS-5 file 2 not found") + # if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_land)): + # logger.error("GEOS-5 land file not found") + # if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_ocean)): + # logger.error("GEOS-5 ocean file not found") + # if not os.path.isfile(os.path.join(self.ancillary_dir, self.geos_constants)): + # logger.error("GEOS-5 constants file not found") geos_variables = [ "tpw", @@ -697,7 +663,6 @@ class ReadAncillary(CollectInputs): self.latitude.shape[1], self.resolution, self.get_granule_time(), - self.ancillary_dir, self.geos_file_1, self.geos_file_2, self.geos_land,