NASA Logo
Ocean Color Science Software

ocssw V2022
l1c.h
Go to the documentation of this file.
1 /*
2  * File: l1c.h
3  * Author: mmontes
4  *
5  * Created on November 4, 2020, 8:45 AM
6  * // last version 8/15/2022
7  */
8 
9 #ifndef L1C_H
10 #define L1C_H
11 
12 #include <stdio.h>
13 #include <string>
14 #include <vector>
15 #include <filetype.h>
16 #include "l1c_filehandle.h"
17 #include "l1c_str.h"
18 #include "l2_str.h"
19 #include "l1c_input.h"
20 #include "hawkeye_methods.h"
21 #include <boost/assign/list_of.hpp> // for 'list_of()'
22 #include <boost/assert.hpp>
23 #include <boost/algorithm/string.hpp>
24 #include <boost/geometry.hpp>
25 #include <boost/geometry/geometries/point_xy.hpp>
26 #include <boost/geometry/geometries/polygon.hpp>
27 #include <boost/geometry/geometries/box.hpp>
28 #include <boost/foreach.hpp>
29 #include <GeographicLib/Geodesic.hpp>
30 #include <GeographicLib/Constants.hpp>
31 #include <netcdf>
32 
33 #define READ 0
34 #define WRITE 1
35 
36 namespace bg = boost::geometry;
37 typedef bg::model::point<double, 2, bg::cs::geographic<bg::degree>> Point_t;
38 typedef bg::model::polygon<Point_t> Polygon_t;
39 typedef bg::model::box<Point_t> Box_t;
40 typedef double orb_array2[3];
41 
42 namespace l1c {
43 
44 class L1C {
45  protected:
46  public:
47  // methods--------------------------------------
48  L1C();
49  virtual ~L1C();
50 
51  virtual int32_t load_l1c_filehandle4(l1c_filehandle *l1cfile, L1C_input *l1cinput);
52 
53  virtual int32_t ect_swt(l1c_filehandle *l1cfile, int ix1, int ix2, double *tswt_tot, double *latswt_tot,
54  double *lonswt_tot, double *ovel_tot, double *gvel_tot, double *tswt,
55  double *latswt, double *lonswt, float *tcross, float *loncross, double *ovel,
56  double *gvel);
57  virtual int32_t create_time_swt(int num_gridlines, double tfile_ini_sec, double *tmgvf,
58  double tswt_ini_sec, double tswt_end_sec, std::string *tswt_ini,
59  std::string *tswt_ini_file, std::string *tswt_mid,std::string *tswt_end);
60  virtual int32_t swtime_swt2(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs,
61  double *tswt, double tcross, double mgv, double *tmgv);
62  virtual int32_t swtime_swt2_segment(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs,
63  double *tswt, double tcross, double mgv, double *tmgv);
64  virtual int32_t write_L1C_granule2(int swtd, l1c_filehandle *l1cfile, L1C_input *l1cinput, double *tmgv,
65  float **lat_gd, float **lon_gd, float **alt_gd,double *orb_time_tot);
66  virtual int32_t open_l1atol1c3(L1C_input *l1cinput, l1c_filehandle *l1cfile);
67  virtual int search_l1cgen(L1C_input *l1cinput, l1c_str *l1cstr, l1c_filehandle *l1cfile, short **gdindex);
68  virtual int32_t create_SOCEA2(int swtd, L1C_input *l1cinput, l1c_filehandle *l1cfile, float **lat_gd,
69  float **lon_gd, float **altitude, double *tswt);
70  virtual int32_t openL1Cgrid3(l1c_str *l1cstr, l1c_filehandle *l1cfile, L1C_input *l1cinput);
71  virtual int32_t l1_cloud_correct(L1C_input *l1cinput, l1c_filehandle *l1cfile);
72  virtual int32_t add_proc_group_l1c(L1C_input *l1cinput,l1c_filehandle *l1cfile,const char* filename);
73 
74  //---------------------------------------------
75  // global attributes----
76  std::string l1b_name; // just the input l1b filenamed
77  size_t sd_id;
78 
79  // more L1C input vars
80  size_t l1c_pflag; // L1C processing
81  std::vector<std::string> cust_l1cprod; // list of L1c products to be included, flexible approach
82 
83  file_type format; // file type, netcdf4 or hdf4/5
84  // size_t mode;//l1c processing mode ---
85  size_t length; // data block
86  size_t sensorID; // original int32 changed to size_t type
87  size_t subsensorID;
88  float res_spat; // spatial resolution in km
89  float res_spec; // spectral resolution in nm
90 
91  // dimensions--
92  size_t ndets;
93  size_t nscan;
94  size_t n_views; // sensor views
95  size_t npols; // polarization states
96  size_t nbands; // number of total bands
97  size_t nband_blue; // this includes uv + visible bands
98  size_t nband_red; // this inc
99  size_t nband_swir;
100  size_t npix; // num
101 
102  // sensor characteritics
103  float *views; // indexes are not defined
104  size_t pols[3]; //[1 0 0] non-pol, [1 1 0]: non+cross, [1 1 1]: non+cross+parall
105  float *bbands; // array with bands wavelengths
106  float *rbands;
107  float *swirbands;
108 
109  // navigation attributes
110  // fred attr here
111  size_t orbit_number;
112  size_t orb_dir; // asc or desc orbit
113  float orbit_node_lon; // long at which is crossing the equator asc or desc
114 
115  // geolocation attributes
118  float *cloud_height; // should be in geolocation group nc file
119 
120  // calibration attributes
121  float *Fobar;
122 
123  // projection attributes-
124  // std::string proj_type;
125  size_t projection;
126  float grid_resolution; // grid resolution in km
127  // these params go to proj class
128 
129  // multi attributes (view, pol, bands)
130  float *view_agg; // views to be aggregated for later products such as vsfs etc
131  float *pol_agg; // polarization states to be aggregated for post-processing products, linear
132  // depolarization ratio etc
133  float *band_agg; // specific bands for future merged products
134  bool overlap_vflag; // tells if we want merged views
135  bool overlap_pflag; // tells if we want merged polarizations
136  bool overlap_bflag; // tells if we want merged spectral bands
137  // uncertainty params for merged l1c products
138  size_t unc_meth; // 0: no error calculation, 1: propagation, 2: Monte Carlo
139  float unc_thres_v; // uncertainity threshold of angular merged products as %
140  float unc_thres_p; // same but for polarization
141  float unc_thres_b; // same but for spectral bands
142  // ancill info, requested products?
143  // float *cloud_h;//this is cloud_height
144 };
145 
146 // protos---
147 int32_t load_l1c_filehandle4(l1c_filehandle *l1cfile, L1C_input *l1cinput);
148 int32_t ect_swt(l1c_filehandle *l1cfile, int ix1, int ix2, double *tswt_tot, double *latswt_tot,
149  double *lonswt_tot, double *ovel_tot, double *gvel_tot, double *tswt, double *latswt,
150  double *lonswt, float *tcross, float *loncross, double *ovel, double *gvel);
151 int32_t create_time_swt(int num_gridlines, double tfile_ini_sec, double *tmgvf, double tswt_ini_sec,
152  double tswt_end_sec, std::string *tswt_ini, std::string *tswt_ini_file,std::string *tswt_mid,
153  std::string *tswt_end);
154 int32_t swtime_swt2(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs, double *tswt,
155  double tcross, double mgv, double *tmgv);
156 int32_t swtime_swt2_segment(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs,
157  double *tswt, double tcross, double mgv, double *tmgv);
158 int32_t write_L1C_granule2(int swtd, l1c_filehandle *l1cfile, L1C_input *l1cinput, double *tmgv,
159  float **lat_gd, float **lon_gd, float **alt_gd,double *orb_time_tot);
160 int32_t open_l1atol1c3(L1C_input *l1cinput, l1c_filehandle *l1cfile);
161 int search_l1cgen(L1C_input *l1cinput, l1c_str *l1cstr, l1c_filehandle *l1cfile, short **gdindex);
162 int32_t create_SOCEA2(int swtd, L1C_input *l1cinput, l1c_filehandle *l1cfile, float **lat_gd, float **lon_gd,
163  float **altitude, double *tswt);
164 int32_t openL1Cgrid3(l1c_str *l1cstr, l1c_filehandle *l1cfile, L1C_input *l1cinput);
165 int32_t add_proc_group_l1c(L1C_input *l1cinput,l1c_filehandle *l1cfile,const char* filename);
166 
167 } // namespace l1c
168 #endif
size_t subsensorID
Definition: l1c.h:87
float * Fobar
Definition: l1c.h:121
std::string l1b_name
Definition: l1c.h:76
float orbit_node_lon
Definition: l1c.h:113
int32_t open_l1atol1c3(L1C_input *l1cinput, l1c_filehandle *l1cfile)
float grid_resolution
Definition: l1c.h:126
bool overlap_pflag
Definition: l1c.h:135
float * swirbands
Definition: l1c.h:107
virtual int32_t openL1Cgrid3(l1c_str *l1cstr, l1c_filehandle *l1cfile, L1C_input *l1cinput)
Definition: l1c.cpp:2813
virtual int32_t swtime_swt2_segment(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs, double *tswt, double tcross, double mgv, double *tmgv)
Definition: l1c.cpp:661
size_t orbit_number
Definition: l1c.h:111
float * band_agg
Definition: l1c.h:133
virtual int32_t ect_swt(l1c_filehandle *l1cfile, int ix1, int ix2, double *tswt_tot, double *latswt_tot, double *lonswt_tot, double *ovel_tot, double *gvel_tot, double *tswt, double *latswt, double *lonswt, float *tcross, float *loncross, double *ovel, double *gvel)
Definition: l1c.cpp:784
int32_t swtime_swt2_segment(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs, double *tswt, double tcross, double mgv, double *tmgv)
bg::model::polygon< Point_t > Polygon_t
Definition: l1c.h:38
size_t ndets
Definition: l1c.h:92
size_t nband_red
Definition: l1c.h:98
virtual int32_t create_SOCEA2(int swtd, L1C_input *l1cinput, l1c_filehandle *l1cfile, float **lat_gd, float **lon_gd, float **altitude, double *tswt)
Definition: l1c.cpp:2149
size_t unc_meth
Definition: l1c.h:138
size_t n_views
Definition: l1c.h:94
int32_t swtime_swt2(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs, double *tswt, double tcross, double mgv, double *tmgv)
size_t projection
Definition: l1c.h:125
int32_t write_L1C_granule2(int swtd, l1c_filehandle *l1cfile, L1C_input *l1cinput, double *tmgv, float **lat_gd, float **lon_gd, float **alt_gd, double *orb_time_tot)
size_t npix
Definition: l1c.h:100
@ string
float * pol_agg
Definition: l1c.h:131
int32_t ect_swt(l1c_filehandle *l1cfile, int ix1, int ix2, double *tswt_tot, double *latswt_tot, double *lonswt_tot, double *ovel_tot, double *gvel_tot, double *tswt, double *latswt, double *lonswt, float *tcross, float *loncross, double *ovel, double *gvel)
double orb_array2[3]
Definition: l1c.h:40
size_t terrain_corrected
Definition: l1c.h:116
float unc_thres_p
Definition: l1c.h:140
L1C()
Definition: l1c.cpp:73
float unc_thres_b
Definition: l1c.h:141
Definition: l1c.h:44
size_t npols
Definition: l1c.h:95
virtual ~L1C()
Definition: l1c.cpp:76
float unc_thres_v
Definition: l1c.h:139
size_t nband_swir
Definition: l1c.h:99
size_t cloud_corrected
Definition: l1c.h:117
size_t nband_blue
Definition: l1c.h:97
size_t length
Definition: l1c.h:85
float res_spat
Definition: l1c.h:88
float * cloud_height
Definition: l1c.h:118
int32_t load_l1c_filehandle4(l1c_filehandle *l1cfile, L1C_input *l1cinput)
virtual int search_l1cgen(L1C_input *l1cinput, l1c_str *l1cstr, l1c_filehandle *l1cfile, short **gdindex)
Definition: l1c.cpp:2655
virtual int32_t open_l1atol1c3(L1C_input *l1cinput, l1c_filehandle *l1cfile)
Definition: l1c.cpp:1061
int32_t add_proc_group_l1c(L1C_input *l1cinput, l1c_filehandle *l1cfile, const char *filename)
std::vector< std::string > cust_l1cprod
Definition: l1c.h:81
virtual int32_t swtime_swt2(int swt, L1C_input *l1cinput, l1c_filehandle *l1cfile, int32_t norbs, double *tswt, double tcross, double mgv, double *tmgv)
Definition: l1c.cpp:724
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
virtual int32_t add_proc_group_l1c(L1C_input *l1cinput, l1c_filehandle *l1cfile, const char *filename)
Definition: l1c.cpp:79
float * bbands
Definition: l1c.h:105
size_t l1c_pflag
Definition: l1c.h:80
Definition: l1c.cpp:71
int32_t create_time_swt(int num_gridlines, double tfile_ini_sec, double *tmgvf, double tswt_ini_sec, double tswt_end_sec, std::string *tswt_ini, std::string *tswt_ini_file, std::string *tswt_mid, std::string *tswt_end)
size_t nscan
Definition: l1c.h:93
float * view_agg
Definition: l1c.h:130
size_t sensorID
Definition: l1c.h:86
file_type
Definition: filetype.h:11
float res_spec
Definition: l1c.h:89
virtual int32_t l1_cloud_correct(L1C_input *l1cinput, l1c_filehandle *l1cfile)
Definition: l1c.cpp:245
file_type format
Definition: l1c.h:83
subroutine geometry
size_t nbands
Definition: l1c.h:96
virtual int32_t write_L1C_granule2(int swtd, l1c_filehandle *l1cfile, L1C_input *l1cinput, double *tmgv, float **lat_gd, float **lon_gd, float **alt_gd, double *orb_time_tot)
Definition: l1c.cpp:2921
size_t sd_id
Definition: l1c.h:77
size_t pols[3]
Definition: l1c.h:104
virtual int32_t load_l1c_filehandle4(l1c_filehandle *l1cfile, L1C_input *l1cinput)
Definition: l1c.cpp:3479
bg::model::box< Point_t > Box_t
Definition: l1c.h:39
float * views
Definition: l1c.h:103
bg::model::point< double, 2, bg::cs::geographic< bg::degree > > Point_t
Definition: l1c.h:37
float * rbands
Definition: l1c.h:106
int32_t openL1Cgrid3(l1c_str *l1cstr, l1c_filehandle *l1cfile, L1C_input *l1cinput)
virtual int32_t create_time_swt(int num_gridlines, double tfile_ini_sec, double *tmgvf, double tswt_ini_sec, double tswt_end_sec, std::string *tswt_ini, std::string *tswt_ini_file, std::string *tswt_mid, std::string *tswt_end)
Definition: l1c.cpp:925
bool overlap_vflag
Definition: l1c.h:134
int32_t create_SOCEA2(int swtd, L1C_input *l1cinput, l1c_filehandle *l1cfile, float **lat_gd, float **lon_gd, float **altitude, double *tswt)
int search_l1cgen(L1C_input *l1cinput, l1c_str *l1cstr, l1c_filehandle *l1cfile, short **gdindex)
bool overlap_bflag
Definition: l1c.h:136
size_t orb_dir
Definition: l1c.h:112