OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l2brsgen.h
Go to the documentation of this file.
1 #ifndef L2BRSGEN_H /* avoid re-inclusion */
2 #define L2BRSGEN_H
3 
4 #include <stdio.h>
5 #include <string.h>
6 #include <time.h>
7 
8 #include "hdf.h"
9 #include "mfhdf.h"
10 //#include "hdfhdr.h"
11 //#include "hdfmac.h"
12 //#include "usrhdr.h"
13 #include "usrmac.h"
14 
15 #include <clo.h>
16 #include <readL2scan.h>
17 #include <get_product_table.h>
18 
19 #define VERSION "2.0"
20 
21 #define IOERR -1
22 #define RDERR -2
23 #define MEMERR -3
24 
25 #define MAXVAL 255
26 
27 #define CHL_START (l2_data + 8*nsamp)
28 #define CHL_END (l2_data + 9*nsamp)
29 #define LAT_START (l2_str.latitude)
30 #define LAT_END (l2_str.latitude + max_samp_used+1)
31 #define LON_START (l2_str.longitude)
32 #define LON_END (l2_str.longitude + max_samp_used+1)
33 
34 #define MAXTILTS 20
35 #define NFLAGS 16
36 
37 /* Time Conversion Constants */
38 #define MSECHOUR 3600000
39 #define MSECMIN 60000
40 #define MSECSEC 1000
41 
42 #define LONGNAME "long_name"
43 #define RANGE "valid_range"
44 
45 /* Global (file-level) Attributes */
46 /* Constants defined for attributes defined in sec.5.3.1 of product specs */
47 
48 #define L2B_PNAME "Product Name"
49 #define L2B_TITLE "Title"
50 #define LEGEND "Legend"
51 #define TITLE_VAL " Level-2 Browse Data"
52 #define DCENTER "Data Center"
53 #define DCENTER_VAL "NASA/GSFC SeaWiFS Data Processing Center"
54 #define L2BRS_MISSION "Mission"
55 #define MSNCHAR "Mission Characteristics"
56 #define SENSOR_NAME "Sensor Name"
57 #define SENSOR "Sensor"
58 #define SNSCHAR "Sensor Characteristics"
59 
60 
61 #define REPLACES "Replacement Flag"
62 #define SOFTID "Software ID"
63 #define SOFTID_VAL "?????"
64 #define SOFT_NAME "Software Name"
65 #define SOFT_VER "Software Version"
66 #define PTIME "Processing Time"
67 #define L2BRS_INFILES "Input Files"
68 #define PROC_CON "Processing Control"
69 #define PROC_LOG "Processing Log"
70 
71 /* Constants defined for attributes defined in sec.5.3.2 of product specs */
72 
73 #define PINFILES "Parent Input Files"
74 #define PPNAME "Parent Product Name"
75 #define DTYPE "Data Type"
76 #define NSAMP "Parent Pixels per Scan Line"
77 #define NREC "Parent Number of Scan Lines"
78 #define SNCNTR "Scene Center Scan Line"
79 #define NFREC "Filled Scan Lines"
80 #define FFLAG1 "FF Missing Frames"
81 #define FFLAG2 "SDPS Missing Frames"
82 #define L2BRS_PCTFLAG "Flag Percentages"
83 
84 /* Constants defined for attributes defined in sec.5.3.3 of product specs */
85 #define STIME "Start Time"
86 #define END_TIME "End Time"
87 #define CTIME "Scene Center Time"
88 #define NTIME "Node Crossing Time"
89 #define SYEAR "Start Year"
90 #define SDAY "Start Day"
91 #define SMSEC "Start Millisec"
92 #define EYEAR "End Year"
93 #define EDAY "End Day"
94 #define EMSEC "End Millisec"
95 #define SNODE "Start Node"
96 #define ENODE "End Node"
97 #define ORBNUM "Orbit Number"
98 #define NORAD1 "NORAD Line 1"
99 #define NORAD2 "NORAD Line 2"
100 
101 /* Constants defined for attributes defined in sec.5.3.4 of product specs */
102 #define LATUNITS "Latitude Units"
103 #define LATUNITS_VAL "degrees North"
104 #define LONUNITS "Longitude Units"
105 #define LONUNITS_VAL "degrees East"
106 #define CLAT "Scene Center Latitude"
107 #define CLON "Scene Center Longitude"
108 #define SCSOL_Z "Scene Center Solar Zenith"
109 #define ULLAT "Upper Left Latitude"
110 #define ULLON "Upper Left Longitude"
111 #define URLAT "Upper Right Latitude"
112 #define URLON "Upper Right Longitude"
113 #define LLLAT "Lower Left Latitude"
114 #define LLLON "Lower Left Longitude"
115 #define LRLAT "Lower Right Latitude"
116 #define LRLON "Lower Right Longitude"
117 #define NLAT "Northernmost Latitude"
118 #define SLAT "Southernmost Latitude"
119 #define WLON "Westernmost Longitude"
120 #define ELON "Easternmost Longitude"
121 #define STCLAT "Start Center Latitude"
122 #define STCLON "Start Center Longitude"
123 #define ENDCLAT "End Center Latitude"
124 #define ENDCLON "End Center Longitude"
125 #define NODEL "Orbit Node Longitude"
126 
127 /* Constants defined for attributes defined in sec.5.3.4 of product specs */
128 #define PARAM "Parameter"
129 #define PARAM_VAL "Chlorophyll a concentration"
130 #define UNITS "Units"
131 #define UNITS_VAL "mg m^-3"
132 #define PX_START "Start Pixel"
133 #define PX_END "End Pixel"
134 #define LAC_PX_ST "LAC Pixel Start Number"
135 #define PX_SUBSAMP "Pixel Subsampling Rate"
136 #define LAC_PX_SUBSAMP "LAC Pixel Subsampling"
137 #define PX_NUM "Pixels per Scan Line"
138 #define SC_START "Start Scan"
139 #define SC_END "End Scan"
140 #define SC_SUBSAMP "Scan Subsampling Rate"
141 #define SC_NUM "Number of Scan Lines"
142 #define PX_LL_NUM "Pixel Coordinates"
143 #define SC_LL_NUM "Scan Coordinates"
144 #define SC_TYPE "Scaling"
145 #define SC_TY_VAL "logarithmic"
146 #define SC_EQN "Scaling Equation"
147 #define SC_EQN_VAL "Base**((Slope*brs_data) + Intercept) = chlorophyll a"
148 #define BASE "Base"
149 #define BASE_VAL 10.0
150 #define SLOPE "Slope"
151 #define SLOPE_VAL 0.015
152 #define INTERCEPT "Intercept"
153 #define INTERCEPT_VAL -2.0
154 #define SCALE_OFF "Scale Offset"
155 
156 /* Constants defined for attributes defined in sec.5.4.1 of product specs */
157 #define PX_LL_FIRST "px_ll_first"
158 #define PX_LL_FST_ATTR "Lat/lon of pixels along first scan line"
159 #define PX_LL_LAST "px_ll_last"
160 #define PX_LL_LST_ATTR "Lat/lon of pixels along last scan line"
161 #define SC_LL_FIRST "sc_ll_first"
162 #define SC_LL_FST_ATTR "Lat/lon of starts of scan lines"
163 #define SC_LL_LAST "sc_ll_last"
164 #define SC_LL_LST_ATTR "Lat/lon of ends of scan lines"
165 
166 /* Constants defined for attributes defined in sec.5.4.2 of product specs */
167 #define NTILTS "ntilts"
168 #define NTILTS_NAME "Number of scene tilt states"
169 #define T_FLAGS "tilt_flags"
170 #define T_FLAGS_NAME "Tilt indicators"
171 #define T_RANGES "tilt_ranges"
172 #define T_RANGES_NAME "Scan-line number ranges of scene tilt states"
173 #define T_LATS "tilt_lats"
174 #define T_LATS_NAME "Latitudes of tilt-range scan line end points"
175 #define T_LONS "tilt_lons"
176 #define T_LONS_NAME "Longitudes of tilt-range scan line end points"
177 
178 /* Constants defined for navigation data */
179 #define ORBVEC "orb_vec"
180 #define ORBVEC_NAME "Orbit position vector at scan line time"
181 #define ORBVEC_UNITS "kilometers"
182 #define LVERT "l_vert"
183 #define LVERT_NAME "Local vertical vector in ECEF frame"
184 #define SUNREF "sun_ref"
185 #define SUNREF_NAME "Reference Sun vector in ECEF frame"
186 #define ATTANG "att_ang"
187 #define ATTANG_NAME "Computed yaw, roll, pitch"
188 #define SENMAT "sen_mat"
189 #define SENMAT_NAME "ECEF-to-sensor-frame matrix"
190 #define SCANELL "scan_ell"
191 #define SCANELL_NAME "Scan-track ellipse coefficients"
192 #define NFLAG "nflag"
193 #define NFLAG_NAME "Navigation flags"
194 #define CNTLPTCOLS "cntl_pt_cols"
195 #define CNTLPTCOLS_NAME "Control point column values"
196 
197 #define CNTLPTLAT "latitude"
198 #define CNTLPTLAT_NAME "Latitude values"
199 #define CNTLPTLON "longitude"
200 #define CNTLPTLON_NAME "Longitude values"
201 
202 
203 extern char ERR_MSG[1024];
204 
205 
207 int l2brsgen_read_options(clo_optionList_t* list, int argc, char* argv[],
208  l2_prod *l2_str, meta_l2Type *meta_l2);
209 int32 put_l2brs(char *l2brs_path, char *replaces, char *ptime, char *infiles,
210  int32 px_start, int32 px_end, int32 px_subsamp, int32 brs_nsamp,
211  int32 sc_start, int32 sc_end, int32 sc_subsamp, int32 brs_nrec,
212  char *l2brs_name, float32 *l2brs_data, int32 *l2brs_flags,
213  char *flag_names, char *mskflg, unsigned char *palette,
214  float32 *px_ll_first, float32 *px_ll_last, float32 *sc_ll_first,
215  float32 *sc_ll_last, char *proc_con, int16 syear, int16 sday,
216  int32 smsec, int16 eyear, int16 eday, int32 emsec, char *dtype,
217  int32 nrec, int32 nsamp, int32 ntilts, short *tilt_flags,
218  int16 *tilt_ranges, int16 *cntl_pt_lat, int16 *cntl_pt_lon,
219  meta_l2Type *meta_l2, product_table_t *ptable_rec, const char* oformat, int32 apply_pal);
220 
221 void write_attrs(int32 sdfid, char *l2brs_path, char *replaces, char *ptime,
222  char *infiles, int32 px_start, int32 px_end, int32 px_subsamp,
223  int32 brs_nsamp, int32 sc_start, int32 sc_end, int32 sc_subsamp,
224  int32 brs_nrec, char *l2brs_name, char *proc_con, int16 syear,
225  int16 sday, int32 smsec, int16 eyear, int16 eday, int32 emsec,
226  char *dtype, int32 nrec, int32 nsamp, meta_l2Type *meta_l2);
227 
228 int32 write_image(char *l2brs_path, unsigned char *l2brs_data, int32 brs_nsamp,
229  int32 brs_nrec, uint8 *palette);
230 
231 int32 write_SDS(int32 sdfid, char *label, int32 ntype, int32 rank,
232  int32 *dimsizes, int32 *start, void *buf);
233 
234 int32 write_tilt_sets(int32 fid, int32 sdfid, int32 ntilts, int16 *tilt_flags,
235  int16 *tilt_ranges);
236 
237 int32 write_nav_sets(int32 fid, int32 sdfid, int32 brs_nrec, int32 brs_nsamp,
238  int16 *cntl_pt_lat, int16 *cntl_pt_lon);
239 
240 
241 #endif /* L2BRSGEN_H */
void write_attrs(int32 sdfid, char *l2brs_path, char *replaces, char *ptime, char *infiles, int32 px_start, int32 px_end, int32 px_subsamp, int32 brs_nsamp, int32 sc_start, int32 sc_end, int32 sc_subsamp, int32 brs_nrec, char *l2brs_name, char *proc_con, int16 syear, int16 sday, int32 smsec, int16 eyear, int16 eday, int32 emsec, char *dtype, int32 nrec, int32 nsamp, meta_l2Type *meta_l2)
Definition: put_l2brs.c:466
integer, parameter int16
Definition: cubeio.f90:3
int16 eday
Definition: l1_czcs_hdf.c:17
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
Definition: CMakeLists.txt:7
int l2brsgen_read_options(clo_optionList_t *list, int argc, char *argv[], l2_prod *l2_str, meta_l2Type *meta_l2)
char ERR_MSG[1024]
Definition: extract_sub.c:119
int16 eyear
Definition: l1_czcs_hdf.c:17
int syear
Definition: l1_czcs_hdf.c:15
int32 smsec
Definition: l1_czcs_hdf.c:16
int32 write_nav_sets(int32 fid, int32 sdfid, int32 brs_nrec, int32 brs_nsamp, int16 *cntl_pt_lat, int16 *cntl_pt_lon)
Definition: put_l2brs.c:756
int sday
Definition: l1_czcs_hdf.c:15
int32 put_l2brs(char *l2brs_path, char *replaces, char *ptime, char *infiles, int32 px_start, int32 px_end, int32 px_subsamp, int32 brs_nsamp, int32 sc_start, int32 sc_end, int32 sc_subsamp, int32 brs_nrec, char *l2brs_name, float32 *l2brs_data, int32 *l2brs_flags, char *flag_names, char *mskflg, unsigned char *palette, float32 *px_ll_first, float32 *px_ll_last, float32 *sc_ll_first, float32 *sc_ll_last, char *proc_con, int16 syear, int16 sday, int32 smsec, int16 eyear, int16 eday, int32 emsec, char *dtype, int32 nrec, int32 nsamp, int32 ntilts, short *tilt_flags, int16 *tilt_ranges, int16 *cntl_pt_lat, int16 *cntl_pt_lon, meta_l2Type *meta_l2, product_table_t *ptable_rec, const char *oformat, int32 apply_pal)
Definition: put_l2brs.c:137
int32 write_image(char *l2brs_path, unsigned char *l2brs_data, int32 brs_nsamp, int32 brs_nrec, uint8 *palette)
int32 write_SDS(int32 sdfid, char *label, int32 ntype, int32 rank, int32 *dimsizes, int32 *start, void *buf)
Definition: put_l2brs.c:710
int l2brsgen_init_options(clo_optionList_t *list)
int32 emsec
Definition: l1_czcs_hdf.c:18
dtype
Definition: DDataset.hpp:31
char * flag_names[]
Definition: l2lists.h:46
Extra metadata that will be written to the HDF4 file l2prod rank
int32 write_tilt_sets(int32 fid, int32 sdfid, int32 ntilts, int16 *tilt_flags, int16 *tilt_ranges)