NASA Logo
Ocean Color Science Software

ocssw V2022
l1c_latlongrid.h
Go to the documentation of this file.
1 #ifndef L1C_LATLONGRID_H
2 #define L1C_LATLONGRID_H
3 
4 #include "filehandle.h"
5 #include "l1.h"
6 #include <netcdf.h>
7 #include <unistd.h>
8 #include <nc4utils.h>
9 #include <netcdf>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 class bin_str {
16  protected:
17  public:
18  bin_str();
19  virtual ~bin_str();
20  virtual int alloc_bin(bin_str *binstr);
21  virtual int close_bin(bin_str *binstr);
22 
23  // global attributes
28  int sensor;
29 
30  // dims
31  int16_t num_gridlines;
32  int16_t nbinx;
33  int16_t nviews;
34  int16_t nbands;
35  int32_t num_pixels;
36  int32_t nscans;
37  bool verbose;
38 
39  // geo
40  int gdshift;
41  float **lat_gd;
42  float **lon_gd;
43  double ***time_l1b;
44  double *time_gd;
45  float **alt;
46 
47  // binned vars
48  short **nrec_2D; // row/col
49  short ***nrec_3D; // row/col/view
50  short ***nrec_3D_view;
51  float ****nrec_4D_band; // row/col/view/bands
52  float **alt_mean;
53  float **alt_rmse;
54  short **alt_2D;
55  short **alt_diff2; // row/col
56  float ***suna_3D;
57  float ***sunz_3D;
58  float ***sena_3D;
59  float ***senz_3D;
60  float ***sca_3D; // row/col/view
61  float ***rot_angle;
62  float ****QC_bitwise_4D; // row/col/view/bands
63  float ***QC_4D; // row/col/view
64  float ****I_4D; // row/col/view/bands
65  float ****i_diff2;
66  float ****I_noise_4D; // #pixels
67 
68  // OCIS line by line
69  short *obs_per_view;
70  float *QC_bitwise;
71  float *QC;
72  float *I;
73  float *I_noise;
74 
76 
77  filehandle *l1file;
80 
81  short fillval1 = -32767;
82  float fillval2 = -32767.;
83  double fillval3 = -32767.;
84 
85  int32_t inpix; // in l1c grid
86  int32_t outpix; // out l1c grid
87  int32_t badgeo; // fillvalue or no geolocation or bad
88 
89  double tini_l1c;
90  double tend_l1c;
91  double tini_l1b;
92  double tend_l1b;
94 
95  int bintype; // 0: discrete, 1: area-weighting
96 
97  char outlist[FILENAME_MAX];
98  char l1c_anc[FILENAME_MAX];
100  int cloud_type; // 0 water and 1 ice
101  int dem_flag;//geoid or orthometric = dem height flag
102 };
103 
104 int close_bin(bin_str *binstr);
105 int alloc_bin(bin_str *binstr);
106 
107 int meta_l1c_grid(char *gridname, bin_str *binstr, int16_t num_gridlines, netCDF::NcFile *nc_output);
108 int meta_l1c_global(char *gridname, bin_str *binl1c,int16_t num_gridlines, netCDF::NcFile *nc_output);
109 int meta_l1c_full(filehandle *l1file, bin_str *binstr, const char *l1c_grid, netCDF::NcFile *nc_output);
110 int meta_l1c_bin(filehandle *l1file, bin_str *binstr, netCDF::NcFile *nc_output);
111 int meta_l1c_altvar(bin_str *binstr, netCDF::NcFile *nc_output); // computes rmse for height
112 
113 int open_l1c(const char *l1c_grid, size_t *ybins, size_t *xbins, float **lat_gd, float **lon_gd);
114 int open_l1c_grid(const char *l1c_grid, bin_str *binstr, float **lat_gd, float **lon_gd, float **height_gd);
115 int search_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex);
116 int search2_l1c(size_t ybins, size_t xbins, float lat, float lon, float **lat_gd, float **lon_gd, short *row,
117  short *col);
118 int search_l1c_parallax(filehandle *l1file, float *lat_new, float *lon_new, bin_str *binl1c, short **gdindex);
119 int bin_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex, netCDF::NcFile *nc_output);
120 int bintime_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex, double scantime,
121  netCDF::NcFile *nc_output);
122 int check_l1c_time(const char *l1b_file, const char *l1c_grid,
123  bin_str *binstr); // check if chosen l1c grid is correct for the chosen l1b granule used
124  // for binning and FULL l1c
125 
126 int rmse_l1c_alt(filehandle *l1file, bin_str *binstr, l1str *l1rec,
127  short **gdindex); // computes diff squared for rmse for height
128 double rot_angle(double senz, double solz, double sena, double suna);
129 int parallax(filehandle *l1file, const char *l1c_anc, const char *l1c_grid, l1str *l1rec, bin_str *binl1c,
130  short **gdindex, netCDF::NcFile *nc_output,int32_t sline,int firstcall);
131 int interp2d_l1c(netCDF::NcFile *nc_output);
132 
133 #ifdef __cplusplus
134 } // extern "C"
135 #endif
136 
137 #endif
int meta_l1c_bin(filehandle *l1file, bin_str *binstr, netCDF::NcFile *nc_output)
filehandle * l1file
int32 l1file(int32 sdfid, int32 *nsamp, int32 *nscans, int16 *dtynum)
Definition: l1stat_chk.c:586
int cloud_type
float *** sca_3D
float ** lat_gd
int close_bin(bin_str *binstr)
std::string doi
float * I_noise
virtual int alloc_bin(bin_str *binstr)
virtual ~bin_str()
short *** nrec_3D
float *** senz_3D
int16_t nbands
int bin_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex, netCDF::NcFile *nc_output)
float **** I_noise_4D
read l1rec
int open_l1c_grid(const char *l1c_grid, bin_str *binstr, float **lat_gd, float **lon_gd, float **height_gd)
int meta_l1c_altvar(bin_str *binstr, netCDF::NcFile *nc_output)
int16_t nviews
std::string l1cgrid
float *** suna_3D
short * obs_per_view
@ string
int parallax(filehandle *l1file, const char *l1c_anc, const char *l1c_grid, l1str *l1rec, bin_str *binl1c, short **gdindex, netCDF::NcFile *nc_output, int32_t sline, int firstcall)
float **** i_diff2
float **** QC_bitwise_4D
file_format format
short ** alt_2D
char outlist[FILENAME_MAX]
int32_t badgeo
double *** time_l1b
short fillval1
double tini_l1b
int search2_l1c(size_t ybins, size_t xbins, float lat, float lon, float **lat_gd, float **lon_gd, short *row, short *col)
int search_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex)
int meta_l1c_global(char *gridname, bin_str *binl1c, int16_t num_gridlines, netCDF::NcFile *nc_output)
float *** rot_angle
short *** nrec_3D_view
float fillval2
int32_t num_pixels
int interp2d_l1c(netCDF::NcFile *nc_output)
int check_l1c_time(const char *l1b_file, const char *l1c_grid, bin_str *binstr)
std::string date_mid_grid
int bintime_l1c(filehandle *l1file, l1str *l1rec, bin_str *binstr, short **gdindex, double scantime, netCDF::NcFile *nc_output)
virtual int close_bin(bin_str *binstr)
float * I
float *** QC_4D
double tend_l1b
short ** alt_diff2
int16_t num_gridlines
int meta_l1c_full(filehandle *l1file, bin_str *binstr, const char *l1c_grid, netCDF::NcFile *nc_output)
float **** nrec_4D_band
float ** alt_mean
int16_t nbinx
float ** lon_gd
float ** alt
double * time_gd
float * QC
int open_l1c(const char *l1c_grid, size_t *ybins, size_t *xbins, float **lat_gd, float **lon_gd)
double rot_angle(double senz, double solz, double sena, double suna)
int cloudem_flag
short ** nrec_2D
float * QC_bitwise
int meta_l1c_grid(char *gridname, bin_str *binstr, int16_t num_gridlines, netCDF::NcFile *nc_output)
char l1c_anc[FILENAME_MAX]
int search_l1c_parallax(filehandle *l1file, float *lat_new, float *lon_new, bin_str *binl1c, short **gdindex)
double fillval3
int32_t outpix
int32_t nscans
std::string version
float **** I_4D
double tend_l1c
int32_t inpix
int rmse_l1c_alt(filehandle *l1file, bin_str *binstr, l1str *l1rec, short **gdindex)
bool verbose
float *** sena_3D
std::string history
int alloc_bin(bin_str *binstr)
double tini_l1c
float ** alt_rmse
std::string full_l1cgrid
float *** sunz_3D
std::string pversion