NASA Logo
Ocean Color Science Software

ocssw V2022
common.h
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdint.h>
3 #include <stdlib.h>
4 #include <cmath>
5 #include <vector>
6 #include <netcdf>
7 #include <sstream>
8 
9 // Chunking the arrays
10 #define CHUNK_CACHE_SIZE 256 * 1024 * 1024 // 256MiB of cache memory.
11 #define CHUNK_CACHE_NELEMS 1033
12 #define CHUNK_CACHE_PREEMPTION .75
13 #define VARCHUNK_CACHE_SIZE 4 * 1024 * 1024 // 4Mib of cache memory.
14 #define VARCHUNK_CACHE_NELEMS 1033
15 #define VARCHUNK_CACHE_PREEMPTION .75
16 #define CHUNKBANDS 40
17 #define CHUNKPIXELS 2000
18 #define CHUNKLINES 16
19 // Do something like this
20 // vector<size_t> chunkVec{CHUNKBANDS,CHUNKPIXELS,CHUNKLINES};
21 // for dimensions less than these defaults, fix it to the dimension, e.g.:
22 // if (dimBands < CHUNKBANDS)
23 // chunkVec[0] = dimBands;
24 
25 typedef struct {
26  double master_clock;
27  double MCE_clock;
28 
29  double sc_to_tilt[3][3];
30  double tilt_axis[3];
31  double tilt_angles[2];
32  double tilt_home;
33  double tilt_to_oci_mech[3][3];
34  double oci_mech_to_oci_opt[3][3];
35  double rta_axis[3];
36  double ham_axis[3];
37  double ham_at_angles[2];
38  double ham_ct_angles[2];
39  double rta_enc_scale;
40  double ham_enc_scale;
41 
42  int32_t rta_nadir[2];
43 
44  double as_planarity[5];
45  double at_planarity[5];
46 } geo_struct;
47 
48 #define SWAP_2(x) ( (((x) & 0xff) << 8) | ((unsigned short)(x) >> 8) )
49 
50 #define SWAP_4(x) ( ((x) << 24) | \
51  (((x) << 8) & 0x00ff0000) | \
52  (((x) >> 8) & 0x0000ff00) | \
53  ((x) >> 24) )
54 
55 int geolocate_oci( std::string l1a_filename, std::string geo_lut_filename,
56  geo_struct& geoLUT,
57  std::string l1b_filename, std::string dem_file,
58  bool radiance, std::string doi, const std::string ephFile, std::string pversion);
59 
60 int read_mce_tlm( netCDF::NcFile *l1afile, geo_struct& geo_lut,
61  netCDF::NcGroup egid,
62  uint32_t nmcescan, uint32_t nenc, int32_t& ppr_off,
63  double& revpsec, double&secpline, int16_t& board_id,
64  int32_t *mspin, int32_t *ot_10us,
65  uint8_t *enc_count, float **hamenc, float **rtaenc,
66  int16_t &iret);
67 
68 int get_ev( double secpline, int16_t *dtype, int16_t *lines, int16_t *iagg,
69  uint16_t& pcdim, uint16_t& psdim, double& ev_toff,
70  float *clines, float *slines, double *deltc, double *delts,
71  bool dark, int16_t& iret);
72 
73 int get_oci_vecs( uint32_t nscan, uint16_t pdim, double as_planarity[5],
74  double at_planarity[5], int32_t *rta_nadir,
75  double ham_ct_angles[2], double ev_toff, int32_t spin,
76  uint8_t hside, float *clines,
77  double *delt, double revpsec, int32_t ppr_off,
78  int16_t board_id, uint32_t nmcescan, int32_t *mspin,
79  uint8_t *enc_count, float **hamenc, float **rtaenc,
80  float **pview, double *theta, int16_t& iret);
81 
82 int createField( netCDF::NcGroup &ncGrp, const char *sname, const char *lname,
83  const char *standard_name, const char *units,
84  const char *description,
85  void *fill_value, const char *flag_values,
86  const char *flag_meanings,
87  double low, double high,
88  double scale, double offset,
89  int nt, std::vector<netCDF::NcDim>& varVec,
90  std::string coordinates);
91 
92 int get_nib_nbb( uint32_t ntaps, size_t *ia, uint32_t ntb[16], int16_t jagg[16],
93  uint32_t& nib, uint32_t& nbb);
94 
95 int get_agg_mat( size_t *ia, int16_t jagg[16], uint32_t ntb[16],
96  uint32_t nib, uint32_t nbb, float **amat, float **gmat);
97 
98 int check_scan_times( uint32_t nscan, double *sstime, short *sfl);
int read_mce_tlm(netCDF::NcFile *l1afile, geo_struct &geo_lut, netCDF::NcGroup egid, uint32_t nmcescan, uint32_t nenc, int32_t &ppr_off, double &revpsec, double &secpline, int16_t &board_id, int32_t *mspin, int32_t *ot_10us, uint8_t *enc_count, float **hamenc, float **rtaenc, int16_t &iret)
int get_agg_mat(size_t *ia, int16_t jagg[16], uint32_t ntb[16], uint32_t nib, uint32_t nbb, float **amat, float **gmat)
Definition: common.cpp:777
void spin(double st, double *pos1, double *pos2)
@ string
int get_oci_vecs(uint32_t nscan, uint16_t pdim, double as_planarity[5], double at_planarity[5], int32_t *rta_nadir, double ham_ct_angles[2], double ev_toff, int32_t spin, uint8_t hside, float *clines, double *delt, double revpsec, int32_t ppr_off, int16_t board_id, uint32_t nmcescan, int32_t *mspin, uint8_t *enc_count, float **hamenc, float **rtaenc, float **pview, double *theta, int16_t &iret)
Definition: common.cpp:195
double ham_enc_scale
Definition: common.h:40
int geolocate_oci(std::string l1a_filename, std::string geo_lut_filename, geo_struct &geoLUT, std::string l1b_filename, std::string dem_file, bool radiance, std::string doi, const std::string ephFile, std::string pversion)
double rta_enc_scale
Definition: common.h:39
int get_nib_nbb(uint32_t ntaps, size_t *ia, uint32_t ntb[16], int16_t jagg[16], uint32_t &nib, uint32_t &nbb)
Definition: common.cpp:742
int createField(netCDF::NcGroup &ncGrp, const char *sname, const char *lname, const char *standard_name, const char *units, const char *description, void *fill_value, const char *flag_values, const char *flag_meanings, double low, double high, double scale, double offset, int nt, std::vector< netCDF::NcDim > &varVec, std::string coordinates)
double MCE_clock
Definition: common.h:27
double master_clock
Definition: common.h:26
description
Definition: setup.py:16
double tilt_home
Definition: common.h:32
int check_scan_times(uint32_t nscan, double *sstime, short *sfl)
Definition: common.cpp:863
dtype
Definition: DDataset.hpp:31
l2prod offset
These two strings are used for the product XML output If product_id is not set then prefix is used If the last char of the name_prefix is _ then it is removed If algorithm_id is not set then name_suffix is used If the first char is _ then it is removed l2prod standard_name[0]
int get_ev(double secpline, int16_t *dtype, int16_t *lines, int16_t *iagg, uint16_t &pcdim, uint16_t &psdim, double &ev_toff, float *clines, float *slines, double *deltc, double *delts, bool dark, int16_t &iret)
Definition: common.cpp:142