NASA Logo
Ocean Color Science Software

ocssw V2022
geolocate_oci.h
Go to the documentation of this file.
1 #ifndef _GEOLOCATE_OCI_H_
2 #define _GEOLOCATE_OCI_H_
3 
4 #include "common.h"
5 
6 #include <netcdf>
7 
8 using namespace netCDF;
9 using namespace netCDF::exceptions;
10 /*
11 #define SWAP_2(x) ( (((x) & 0xff) << 8) | ((unsigned short)(x) >> 8) )
12 
13 #define SWAP_4(x) ( ((x) << 24) | \
14  (((x) << 8) & 0x00ff0000) | \
15  (((x) >> 8) & 0x0000ff00) | \
16  ((x) >> 24) )
17 */
18 typedef float quat_array[4];
19 typedef float orb_array[3];
20 
21 double constexpr PI = 3.14159265358979323846;
22 double constexpr RADEG = 180 / PI;
23 double constexpr DTOR = PI / 180;
24 
25 float constexpr focal_length = 45.184;
26 
27 
28 class geoFile {
29  // netCDF::NcFile *geofile;
30 
31  std::string fileName;
32 
33  int ngrps;
34  int ndims;
35 
36  netCDF::NcDim ncDims[1000];
37 
38  public:
39  geoFile();
40  ~geoFile();
41 
42  netCDF::NcFile *geofile;
43  netCDF::NcGroup ncGrps[10];
44 
45  int createFile( const char* filename, const char* cdlfile,
46  size_t sdim, int *ncid, int *gid,
47  uint32_t bbb, uint32_t rbb,
48  int16_t pcdim, int16_t psdim, size_t nswband, int32_t *rta_nadir,
49  bool radiance);
50 
51  int parseDims( std::string dimString, std::vector<netCDF::NcDim>& varDims);
52 
53  int close();
54 };
55 
56 int get_nbands( uint32_t ntaps, int16_t jagg[16], uint32_t& nbb);
57 
58 int j2000_to_ecr(int32_t iyr, int32_t idy, double sec, double ecmat[3][3]);
59 int j2000_to_mod(int32_t iyr, int32_t idy, double sec, double j2mod[3][3]);
60 int get_nut(int32_t iyr, int32_t idy, double xnut[3][3]);
61 int get_ut1(int32_t iyr, int32_t idy, double &ut1utc);
62 int ephparms(double t, double &xls, double &gs, double &xlm, double &omega);
63 int nutate(double t, double xls, double gs, double xlm, double omega,
64  double &dpsi, double &eps, double &epsm);
65 int gha2000(int32_t iyr, double day, double &gha);
66 int mtoq(double rm[3][3], double q[4]);
67 int qprod(double q1[4], float q2[4], double q3[4]);
68 int qprod(float q1[4], float q2[4], float q3[4]);
69 int orb_interp(size_t n_SC_rec, size_t sdim,
70  double *torb, orb_array *p, orb_array *v,
71  double *time, orb_array *posi, orb_array *veli);
72 int q_interp(size_t n_SC_rec, size_t sdim, double *tq, quat_array *q,
73  double *time, quat_array *qi);
74 int tilt_interp(size_t n_tilts, size_t sdim, double *ttilt, float *tiltin,
75  double *time, float *tilt);
76 int l_sun(size_t sdim, int32_t iyr, int32_t iday,
77  double *sec, orb_array *sunr, double *rs);
78 int sun2000(size_t sdim, int32_t iyr, int32_t idy,
79  double *sec, orb_array *sun, double *rs);
80 int qtom(float quat[4], double rm[3][3]);
81 int scan_ell(float p[3], double sm[3][3], double coef[10]);
82 
83 int oci_geonav(const char* dem_file, float pos[3], float vel[3],
84  double smat[3][3], double coef[10],
85  float sunr[3], float **pview, size_t npix, double *delt,
86  float *xlat, float *xlon, short *solz, short *sola,
87  short *senz, short *sena, short *height,
88  float& lonwest, float& loneast,
89  float& latsouth, float& latnorth);
90 
91 int mat2rpy(float pos[3], float vel[3], double smat[3][3], float rpy[3]);
92 
93 
94 
95 inline
96 int expandEnvVar( std::string *sValue) {
97  if ( (*sValue).find_first_of( "$" ) == std::string::npos) return 0;
98  std::string::size_type posEndIdx = (*sValue).find_first_of( "/" );
99  if ( posEndIdx == std::string::npos) return 0;
100  const std::string envVar = sValue->substr (1, posEndIdx - 1);
101  char *envVar_str = getenv(envVar.c_str());
102  if (envVar_str == 0x0) {
103  printf("Environment variable: %s not defined.\n", sValue->c_str());
104  exit(1);
105  }
106  *sValue = envVar_str + (*sValue).substr( posEndIdx);
107 
108  return 0;
109 }
110 
111 
113 
114 }
115 
116 
118 
119 }
120 
121 
122 #endif // _GEOLOCATE_OCI_H_
constexpr float focal_length
Definition: geolocate_oci.h:25
data_t q
Definition: decode_rs.h:74
data_t t[NROOTS+1]
Definition: decode_rs.h:77
int get_nbands(uint32_t ntaps, int16_t jagg[16], uint32_t &nbb)
int nutate(double t, double xls, double gs, double xlm, double omega, double &dpsi, double &eps, double &epsm)
int32_t day
int get_ut1(int32_t iyr, int32_t idy, double &ut1utc)
int ephparms(double t, double &xls, double &gs, double &xlm, double &omega)
int mtoq(double rm[3][3], double q[4])
int createFile(const char *filename, const char *cdlfile, size_t sdim, int *ncid, int *gid)
Definition: hawkeyeUtil.cpp:39
int qprod(double q1[4], float q2[4], double q3[4])
float32 * pos
Definition: l1_czcs_hdf.c:35
float orb_array[3]
Definition: geolocate_oci.h:19
constexpr double PI
Definition: geolocate_oci.h:21
double dpsi
Definition: sun2000.c:6
double eps
Definition: gha2000.c:3
@ string
constexpr double RADEG
Definition: geolocate_oci.h:22
int sun2000(size_t sdim, int32_t iyr, int32_t idy, double *sec, orb_array *sun, double *rs)
float quat_array[4]
Definition: geolocate_oci.h:18
int expandEnvVar(std::string *sValue)
Definition: geolocate_oci.h:96
int j2000_to_ecr(int32_t iyr, int32_t idy, double sec, double ecmat[3][3])
netCDF::NcFile * geofile
Definition: geolocate_oci.h:42
data_t omega[NROOTS+1]
Definition: decode_rs.h:77
int j2000_to_mod(int32_t iyr, int32_t idy, double sec, double j2mod[3][3])
int oci_geonav(const char *dem_file, float pos[3], float vel[3], double smat[3][3], double coef[10], float sunr[3], float **pview, size_t npix, double *delt, float *xlat, float *xlon, short *solz, short *sola, short *senz, short *sena, short *height, float &lonwest, float &loneast, float &latsouth, float &latnorth)
int tilt_interp(size_t n_tilts, size_t sdim, double *ttilt, float *tiltin, double *time, float *tilt)
int scan_ell(float p[3], double sm[3][3], double coef[10])
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
int parseDims(int ncid, int ndims, string dimString, int *numDims, int *dimid, int *varDims)
float xlon[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:93
int orb_interp(size_t n_SC_rec, size_t sdim, double *torb, orb_array *p, orb_array *v, double *time, orb_array *posi, orb_array *veli)
constexpr double DTOR
Definition: geolocate_oci.h:23
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start time
Definition: HISTORY.txt:248
int l_sun(size_t sdim, int32_t iyr, int32_t iday, double *sec, orb_array *sunr, double *rs)
int get_nut(int32_t iyr, int32_t idy, double xnut[3][3])
int mat2rpy(float pos[3], float vel[3], double smat[3][3], float rpy[3])
int qtom(float quat[4], double rm[3][3])
int32_t idy
Definition: atrem_corl1.h:161
int16_t * tilt
Definition: l2bin.cpp:80
int32_t iyr
Definition: atrem_corl1.h:161
int q_interp(size_t n_SC_rec, size_t sdim, double *tq, quat_array *q, double *time, quat_array *qi)
int npix
Definition: get_cmp.c:28
float p[MODELMAX]
Definition: atrem_corl1.h:131
int gha2000(int32_t iyr, double day, double &gha)