Skip to content
Snippets Groups Projects
Commit a42b93da authored by Paolo Veglio's avatar Paolo Veglio
Browse files

solve issue with fixed size of arrays that determine granule size

parent 050818c4
No related branches found
No related tags found
No related merge requests found
Pipeline #49070 failed
# cython: language_level=3 # cython: language_level=3
# cython: c_string_Type=unicode, c_string_encoding=utf8 # cython: c_string_Type=unicode, c_string_encoding=utf8
cdef extern void get_Reynolds_SST(float *, float *, int, char *, char *, float *) cdef extern void get_Reynolds_SST(float *, float *, int, int, int, char *, char *, float *)
cdef extern void get_NDVI_background(float *, float *, int, char *, char *, float *) cdef extern void get_NDVI_background(float *, float *, int, int, int, char *, char *, float *)
cdef extern void get_Olson_eco(float *, float *, int, int, int, char *, unsigned char *) cdef extern void get_Olson_eco(float *, float *, int, int, int, char *, unsigned char *)
cdef extern void get_GEOS(float *, float *, int, char *, char *, char *, char *, char *, char *, char *, cdef extern void get_GEOS(float *, float *, int, int, int, char *, char *, char *, char *, char *, char *, char *,
float *, float *, float *, float *, float *, float *) float *, float *, float *, float *, float *, float *)
cdef extern void snow_mask(char *, unsigned char) cdef extern void snow_mask(char *, unsigned char)
cdef extern float cithr(int, float, float) cdef extern float cithr(int, float, float)
...@@ -27,7 +27,8 @@ DTYPE = np.float32 ...@@ -27,7 +27,8 @@ DTYPE = np.float32
@cython.wraparound(False) @cython.wraparound(False)
@cython.initializedcheck(False) @cython.initializedcheck(False)
def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat, def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat,
np.ndarray[float, ndim=1] lon, res, np.ndarray[float, ndim=1] lon,
n_eles, n_lines, res,
char *anc_dir, char *sst_file, sst): char *anc_dir, char *sst_file, sst):
# cdef np.ndarray sst = np.zeros((3232*3200, ), order='C', dtype=np.float32) # cdef np.ndarray sst = np.zeros((3232*3200, ), order='C', dtype=np.float32)
...@@ -36,7 +37,7 @@ def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat, ...@@ -36,7 +37,7 @@ def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat,
cdef float[::1] sst_mv = sst cdef float[::1] sst_mv = sst
get_Reynolds_SST(&lat[0], &lon[0], res, anc_dir, sst_file, &sst_mv[0]) get_Reynolds_SST(&lat[0], &lon[0],n_eles, n_lines, res, anc_dir, sst_file, &sst_mv[0])
return sst return sst
...@@ -45,7 +46,8 @@ def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat, ...@@ -45,7 +46,8 @@ def py_get_Reynolds_SST(np.ndarray[float, ndim=1] lat,
@cython.wraparound(False) @cython.wraparound(False)
@cython.initializedcheck(False) @cython.initializedcheck(False)
def py_get_NDVI_background(np.ndarray[float, ndim=1] lat, def py_get_NDVI_background(np.ndarray[float, ndim=1] lat,
np.ndarray[float, ndim=1] lon, res, np.ndarray[float, ndim=1] lon,
n_eles, n_lines, res,
char *anc_dir, char *ndvi_file, ndvi): char *anc_dir, char *ndvi_file, ndvi):
if not ndvi.flags['C_CONTIGUOUS']: if not ndvi.flags['C_CONTIGUOUS']:
...@@ -53,7 +55,7 @@ def py_get_NDVI_background(np.ndarray[float, ndim=1] lat, ...@@ -53,7 +55,7 @@ def py_get_NDVI_background(np.ndarray[float, ndim=1] lat,
cdef float[::1] ndvi_mv = ndvi cdef float[::1] ndvi_mv = ndvi
get_NDVI_background(&lat[0], &lon[0], res, anc_dir, ndvi_file, &ndvi_mv[0]) get_NDVI_background(&lat[0], &lon[0], n_eles, n_lines, res, anc_dir, ndvi_file, &ndvi_mv[0])
return ndvi return ndvi
...@@ -79,9 +81,9 @@ def py_get_Olson_eco(np.ndarray[float, ndim=1] lat, ...@@ -79,9 +81,9 @@ def py_get_Olson_eco(np.ndarray[float, ndim=1] lat,
@cython.boundscheck(False) @cython.boundscheck(False)
@cython.wraparound(False) @cython.wraparound(False)
@cython.initializedcheck(False) @cython.initializedcheck(False)
def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, int res, char *startTime, 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 *anc_dir, char *geos1, char *geos2, char *geos_lnd, char *geos_ocn, char *geos_cnst, char *startTime, char *anc_dir, char *geos1, char *geos2,
geos_data): char *geos_lnd, char *geos_ocn, char *geos_cnst, geos_data):
for v in geos_data: for v in geos_data:
if not geos_data[v].flags['C_CONTIGUOUS']: if not geos_data[v].flags['C_CONTIGUOUS']:
...@@ -94,7 +96,7 @@ def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, in ...@@ -94,7 +96,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] landicefr_mv = geos_data['land_ice_fraction']
cdef float[::1] sfct_mv = geos_data['surface_temperature'] cdef float[::1] sfct_mv = geos_data['surface_temperature']
get_GEOS(&lat[0], &lon[0], res, startTime, anc_dir, geos1, geos2, geos_lnd, geos_ocn, geos_cnst, get_GEOS(&lat[0], &lon[0], n_eles, n_lines, res, startTime, anc_dir, 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]) &tpw_mv[0], &snowfr_mv[0], &icefr_mv[0], &ocnfr_mv[0], &landicefr_mv[0], &sfct_mv[0])
geos_dict = {'tpw': geos_data['tpw'], geos_dict = {'tpw': geos_data['tpw'],
......
...@@ -43,7 +43,7 @@ Calls: ...@@ -43,7 +43,7 @@ Calls:
/******************************************************************************/ /******************************************************************************/
int assign_geos_vals(float *lat, float *lon, int res) int assign_geos_vals(float *lat, float *lon, int n_eles, int n_lines, int res)
{ {
...@@ -53,8 +53,8 @@ int assign_geos_vals(float *lat, float *lon, int res) ...@@ -53,8 +53,8 @@ int assign_geos_vals(float *lat, float *lon, int res)
extern double fabs(double); extern double fabs(double);
const int eles=3200*res; const int eles=n_eles*res;
const int lines=3232*res; const int lines=n_lines*res;
int row, col; int row, col;
int i, j, ij, i1, i2, j1, j2, ic, jc; int i, j, ij, i1, i2, j1, j2, ic, jc;
......
...@@ -56,7 +56,7 @@ Comments: ...@@ -56,7 +56,7 @@ Comments:
/******************************************************************************/ /******************************************************************************/
void get_GEOS(float *lat, float *lon, int res, char *granule_start_time, char *anc_dir, char *geos1, char *geos2, char *geos_lnd, 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, char *geos_ocn, char *geos_cnst, float *tpw, float *snowfr, float *icefr, float *geos_ocnfr,
float *landicefr, float *sfct) float *landicefr, float *sfct)
...@@ -70,13 +70,13 @@ void get_GEOS(float *lat, float *lon, int res, char *granule_start_time, char *a ...@@ -70,13 +70,13 @@ void get_GEOS(float *lat, float *lon, int res, char *granule_start_time, char *a
extern int get_geos_times(char[64], char[64], int*, int*); extern int get_geos_times(char[64], char[64], int*, int*);
extern int get_ti_weights(float, int, int, float*); extern int get_ti_weights(float, int, int, float*);
extern int get_ti_vars(float); extern int get_ti_vars(float);
extern int assign_geos_vals(float *, float *, int); extern int assign_geos_vals(float *, float *, int, int, int);
extern int read_GEOS(char[256], int); extern int read_GEOS(char[256], int);
extern int read_GEOS_lndocn(char[256], char[256]); extern int read_GEOS_lndocn(char[256], char[256]);
extern int read_GEOS_constants(char[256]); extern int read_GEOS_constants(char[256]);
const int eles=3200*res; const int eles=n_eles*res;
const int lines=3232*res; const int lines=n_lines*res;
char geos1_wpath[256]; char geos1_wpath[256];
char geos2_wpath[256]; char geos2_wpath[256];
...@@ -181,7 +181,7 @@ void get_GEOS(float *lat, float *lon, int res, char *granule_start_time, char *a ...@@ -181,7 +181,7 @@ void get_GEOS(float *lat, float *lon, int res, char *granule_start_time, char *a
// Assign GEOS variable values to each pixel location in the input L1b granule. // Assign GEOS variable values to each pixel location in the input L1b granule.
// Also spatially interpolates GEOS values to pixel locations if desired. // Also spatially interpolates GEOS values to pixel locations if desired.
// Pointers to inputs and outputs are stored in ancillary.h. // Pointers to inputs and outputs are stored in ancillary.h.
irt = assign_geos_vals(lat, lon, res); irt = assign_geos_vals(lat, lon, n_eles, n_lines, res);
/******************************************************************************/ /******************************************************************************/
......
...@@ -44,7 +44,7 @@ Calls: ...@@ -44,7 +44,7 @@ Calls:
/******************************************************************************/ /******************************************************************************/
void get_NDVI_background(float *lat, float *lon, 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 *anc_dir, char *NDVI_file, float *g_ndvi_background)
{ {
...@@ -71,8 +71,8 @@ void get_NDVI_background(float *lat, float *lon, int res, char *anc_dir, char *N ...@@ -71,8 +71,8 @@ void get_NDVI_background(float *lat, float *lon, int res, char *anc_dir, char *N
int16 *ndvi_arr; int16 *ndvi_arr;
int fnday[23] = {1, 17, 33, 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 273, 289, 305, 321, 337, 353}; int fnday[23] = {1, 17, 33, 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 273, 289, 305, 321, 337, 353};
const int eles=3200*res; const int eles=n_eles*res;
const int lines=3232*res; const int lines=n_lines*res;
int return_code = 0; int return_code = 0;
......
...@@ -38,7 +38,7 @@ Calls: ...@@ -38,7 +38,7 @@ Calls:
/******************************************************************************/ /******************************************************************************/
void get_Reynolds_SST(float *lat, float *lon, 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 *anc_dir, char *SST_file, float *sstInterp)
{ {
...@@ -70,8 +70,8 @@ void get_Reynolds_SST(float *lat, float *lon, int res, char *anc_dir, char *SST_ ...@@ -70,8 +70,8 @@ void get_Reynolds_SST(float *lat, float *lon, int res, char *anc_dir, char *SST_
int i, j, xindx, yindx; int i, j, xindx, yindx;
int ok; int ok;
const int eles=3200*res; const int eles=n_eles*res;
const int lines=3232*res; const int lines=n_lines*res;
FILE * sst_file_ptr; FILE * sst_file_ptr;
size_t bytes_read; size_t bytes_read;
......
...@@ -589,6 +589,8 @@ class ReadAncillary(CollectInputs): ...@@ -589,6 +589,8 @@ class ReadAncillary(CollectInputs):
sst = anc.py_get_Reynolds_SST( sst = anc.py_get_Reynolds_SST(
self.latitude.ravel(), self.latitude.ravel(),
self.longitude.ravel(), self.longitude.ravel(),
self.latitude.shape[0],
self.latitude.shape[1],
self.resolution, self.resolution,
self.ancillary_dir, self.ancillary_dir,
self.sst_file, self.sst_file,
...@@ -615,6 +617,8 @@ class ReadAncillary(CollectInputs): ...@@ -615,6 +617,8 @@ class ReadAncillary(CollectInputs):
ndvi = anc.py_get_NDVI_background( ndvi = anc.py_get_NDVI_background(
self.latitude.ravel(), self.latitude.ravel(),
self.longitude.ravel(), self.longitude.ravel(),
self.latitude.shape[0],
self.latitude.shape[1],
self.resolution, self.resolution,
self.ancillary_dir, self.ancillary_dir,
self.ndvi_file, self.ndvi_file,
...@@ -687,6 +691,8 @@ class ReadAncillary(CollectInputs): ...@@ -687,6 +691,8 @@ class ReadAncillary(CollectInputs):
geos_data = anc.py_get_GEOS( geos_data = anc.py_get_GEOS(
self.latitude.ravel(), self.latitude.ravel(),
self.longitude.ravel(), self.longitude.ravel(),
self.latitude.shape[0],
self.latitude.shape[1],
self.resolution, self.resolution,
self.get_granule_time(), self.get_granule_time(),
self.ancillary_dir, self.ancillary_dir,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment