OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
nc_gridutils.h
Go to the documentation of this file.
1 #ifndef _NC_GRIDUTILS_
2 #define _NC_GRIDUTILS_
3 
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <float.h>
10 #include <math.h>
11 #include <netcdf.h>
12 
13 #define BAD_VALUE -32767
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /* Datatype Definitions */
20 
21 typedef struct grid_info_struct {
22  char file[NC_MAX_NAME]; // file path
23  int ncid; // netCDF file ID
24  int varid; // netCDF variable ID
25  char varname[NC_MAX_NAME]; // netCDF variable name
26  double FillValue;
27  int nodeOffset; // 0=grid-registered, 1=cell-registered
28 
29  size_t numLat;
30  double startLat;
31  double deltaLat;
32  double validLat[2];
33  int globalLat; // 0=regional, 1=global
34 
35  size_t numLon;
36  double startLon;
37  double deltaLon;
38  double validLon[2];
39  int globalLon; // 0=regional, 1=global
40 
41 } grid_info_t;
42 
43 typedef struct var_info_struct {
44  char name[NC_MAX_NAME]; /* variable name */
45  int ndims; /* number of dimensions */
46  int dimids[NC_MAX_VAR_DIMS]; /* dimension IDs */
47  size_t dimlen[NC_MAX_VAR_DIMS]; /* dimension lengths */
48  double FillValue; /* fill value */
49 } var_info_t;
50 
51 typedef struct grid_area_t {
52  grid_info_t *grid;
53  size_t numLat;
54  double startLat;
55  double endLat;
56  size_t numLon;
57  double startLon;
58  double endLon;
59  double *values;
60 } grid_area_t;
61 
62 /* Function Prototypes */
63 void handle_nc_error(int status, char *file, int line);
64 
65 var_info_t* allocate_varinfo();
66 int find_varid(int ncid, const char *varnames[], int *varid);
67 var_info_t *load_varinfo(int ncid, int varid);
68 
69 grid_info_t* allocate_gridinfo();
70 int init_gridinfo(char *filename, const char *varnames[], grid_info_t *grid);
71 int fix_latlon(float *lat, float *lon);
72 int latlon_findex(grid_info_t *grid, float lat, float lon, double *findex);
73 int latlon_index(grid_info_t *grid, float lat, float lon, size_t *index);
74 int get_bylatlon(grid_info_t *grid, float lat, float lon, double *value);
75 int get_grid_area(grid_info_t *grid,
76  float north, float south, float east, float west,
77  grid_area_t *area);
78 int interp_gridvar(grid_info_t *grid, float lat, float lon, double *result);
79 
80 void print_gridinfo(grid_info_t grid);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif /* ndef _NC_GRIDUTILS_ */
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
int32 value
Definition: Granule.c:1235
double endLon
Definition: nc_gridutils.h:58
double validLon[2]
Definition: nc_gridutils.h:38
int status
Definition: l1_czcs_hdf.c:32
void print_gridinfo(grid_info_t grid)
Definition: nc_gridutils.c:592
char varname[NC_MAX_NAME]
Definition: nc_gridutils.h:25
grid_info_t * grid
Definition: nc_gridutils.h:52
int dimids[NC_MAX_VAR_DIMS]
Definition: nc_gridutils.h:46
float * lat
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
double * values
Definition: nc_gridutils.h:59
int get_grid_area(grid_info_t *grid, float north, float south, float east, float west, grid_area_t *area)
Definition: nc_gridutils.c:406
size_t dimlen[NC_MAX_VAR_DIMS]
Definition: nc_gridutils.h:47
var_info_t * load_varinfo(int ncid, int varid)
Definition: nc_gridutils.c:52
double startLon
Definition: nc_gridutils.h:57
int find_varid(int ncid, const char *varnames[], int *varid)
Definition: nc_gridutils.c:83
int latlon_index(grid_info_t *grid, float lat, float lon, size_t *index)
Definition: nc_gridutils.c:342
char name[NC_MAX_NAME]
Definition: nc_gridutils.h:44
char file[NC_MAX_NAME]
Definition: nc_gridutils.h:22
double endLat
Definition: nc_gridutils.h:55
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
int latlon_findex(grid_info_t *grid, float lat, float lon, double *findex)
Definition: nc_gridutils.c:312
double validLat[2]
Definition: nc_gridutils.h:32
grid_info_t * allocate_gridinfo()
Definition: nc_gridutils.c:107
size_t numLon
Definition: nc_gridutils.h:56
double startLat
Definition: nc_gridutils.h:54
int interp_gridvar(grid_info_t *grid, float lat, float lon, double *result)
Definition: nc_gridutils.c:529
int get_bylatlon(grid_info_t *grid, float lat, float lon, double *value)
Definition: nc_gridutils.c:368
size_t numLat
Definition: nc_gridutils.h:53
float * lon
int init_gridinfo(char *filename, const char *varnames[], grid_info_t *grid)
Definition: nc_gridutils.c:132
var_info_t * allocate_varinfo()
Definition: nc_gridutils.c:34
int fix_latlon(float *lat, float *lon)
Definition: nc_gridutils.c:281
void handle_nc_error(int status, char *file, int line)
Definition: nc_gridutils.c:21