OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
mtl_geometry.h
Go to the documentation of this file.
1 /*
2  * Name: mtl_geometry.h
3  *
4  * Purpose: Include file defining structures and function prototypes
5  * for MTL file geometric processing, including scene gridding,
6  * for angle generation.
7  */
8 #ifndef _MTL_GEOMETRY_
9 #define _MTL_GEOMETRY_
10 
11 #include <math.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include "smeta.h"
15 #include "smeta_exploit.h"
16 #include "smeta_geometry.h"
17 
18 #define MIN(a,b) (a<b?a:b)
19 #define MAX(a,b) (a>b?a:b)
20 
21 typedef struct WRS2
22 {
23  double semimajor; /* Earth semi-major axis in meters */
24  double semiminor; /* Earth semi-minor axis in meters */
25  double inertialvel; /* Earth inertial angular velocity in radians/second */
26  double orbitincl; /* Orbital inclination in degrees */
27  double orbitrad; /* Orbital radius in meters */
28  double path1long; /* Longitude of path 1 descending node in degrees */
29  int numpath; /* Number of WRS paths (233) */
30  int numrow; /* Number of WRS rows (248) */
31  int cycle; /* Number of days in one WRS2 cycle (16) */
32  int row0lat; /* Equator crossing row (60) */
33 } WRS2;
34 
35 typedef struct VECTOR
36 {
37  double x; /* X coordinate */
38  double y; /* Y coordinate */
39  double z; /* Z coordinate */
40 } VECTOR;
41 
42 int frame_scene( /* Fits the nominal WRS to the MTL scene frame */
43  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
44  SMETA smeta, /* I: Input scene metadata structure */
45  double *dellon, /* O: WRS longitude offset */
46  double *delrow ); /* O: Scene length in fractional WRS rows */
47 
48 /* different variant for older LS algo */
49 int frame_scene_ls( /* Fits the nominal WRS to the MTL scene frame */
50  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
51  SMETA smeta, /* I: Input scene metadata structure */
52  double *dellon, /* O: WRS longitude offset */
53  double *delrow ); /* O: Scene length in fractional WRS rows */
54 
55 
56 int project_point( /* Projects a LOS vector to the Earth */
57  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
58  SMETA smeta, /* I: Input scene metadata structure */
59  double dellon, /* I: WRS longitude offset */
60  int band, /* I: Band number (user band) */
61  int sca, /* I: SCA number (1 to nsca) */
62  double frow, /* I: Fractional WRS row coordinate */
63  double ndet, /* I: Normalized detector coordinate */
64  double *l1t_line, /* O: Projected line coordinate */
65  double *l1t_samp ); /* O: Projected sample coordinate */
66 
67 /* Slightly different variant for older LS */
68 int project_point_ls( /* Projects a LOS vector to the Earth */
69  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
70  SMETA smeta, /* I: Input scene metadata structure */
71  double dellon, /* I: WRS longitude offset */
72  int band, /* I: Band number (user band) */
73  double frow, /* I: Fractional WRS row coordinate */
74  double nsamp, /* I: Sample coordinate */
75  double nline, /* I: Line coordinate */
76  double *l1t_line, /* O: Projected line coordinate */
77  double *l1t_samp ); /* O: Projected sample coordinate */
78 
79 void pathrow_to_latlon( /* Calculates nominal WRS scene center */
80  WRS2 parms, /* I: WRS2 system parameters */
81  int path, /* I: WRS2 path */
82  double wrsrow, /* I: WRS2 fractional row */
83  double *lat, /* O: Nominal latitude */
84  double *lon ); /* O: Nominal longitude */
85 
86 double dotprod( /* Returns the dot product of two vectors */
87  VECTOR a, /* I: First input vector */
88  VECTOR b ); /* I: Second input vector */
89 
90 void crossprod( /* Computes vector cross product */
91  VECTOR a, /* I: First input vector */
92  VECTOR b, /* I: Second input vector */
93  VECTOR *c ); /* O: Output vector */
94 
95 double vecnorm( /* Returns vector magnitude */
96  VECTOR a ); /* I: Input vector */
97 
98 void unitvec( /* Normalizes input vector */
99  VECTOR a, /* I: Input vector */
100  VECTOR *b); /* O: Normalized output vector */
101 
102 void rotatevec(
103  double mat[3][3], /* I: 3-by-3 rotation matrix */
104  VECTOR a, /* I: Original vector */
105  VECTOR *b ); /* O: Rotated vector */
106 
107 int calc_yaw_steering_gp( /* Returns 0 for success and -1 for failure */
108  WRS2 parms, /* I: WRS2 system parameters */
109  VECTOR pos, /* I: Position vector */
110  VECTOR vel, /* I: Velocity vector */
111  VECTOR i_los, /* I: Instrument line-of-sight unit vector */
112  double roll, /* I: Off-nadir roll angle (in degrees) */
113  double *gp_lat, /* O: Ground point geodetic latitude (in degrees) */
114  double *gp_lon); /* O: Ground point geodetic longitude (in degrees) */
115 
116 /* variant of calc_yaw_steering_gp for other LS */
117 int calc_yaw_steering_gp_ls( /* Returns 0 for success and -1 for failure */
118  WRS2 parms, /* I: WRS2 system parameters */
119  VECTOR pos, /* I: Position vector */
120  VECTOR vel, /* I: Velocity vector */
121  VECTOR i_los, /* I: Instrument line-of-sight unit vector */
122  double roll, /* I: Off-nadir roll angle (in degrees) */
123  double *gp_lat, /* O: Ground point geodetic latitude (in degrees) */
124  double *gp_lon); /* O: Ground point geodetic longitude (in degrees) */
125 
126 int calc_los(
127  SMETA_BAND band_smeta, /* I: Metadata band structure */
128  int sca, /* I: SCA number */
129  double ndet, /* I: Normalized detector coordinate */
130  VECTOR *los ); /* O: Line of sight unit vector */
131 
132 /* Slightly different variant for older LS */
133 int calc_los_ls(
134  SMETA_BAND_LS band_smeta, /* I: Metadata band structure */
135  double frow, /* I: Fractional row */
136  double npix, /* I: Sample number */
137  double ndet, /* I: Line number */
138  VECTOR *los ); /* O: Line of sight unit vector */
139 
140 void pathrow_to_posvel(
141  WRS2 parms, /* I: WRS2 system parameters */
142  int path, /* I: WRS2 path */
143  double dellon, /* I: Path longitude adjustment (in degrees) */
144  double wrsrow, /* I: WRS2 fractional row */
145  VECTOR *pos, /* O: Nominal position vector */
146  VECTOR *vel ); /* O: Nominal velocity vector */
147 
148 int get_ecfsun(
149  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
150  SMETA smeta, /* I: Input scene metadata structure */
151  double dellon, /* I: WRS longitude offset */
152  VECTOR *ecfsun ); /* O: Sun vector in ECEF coordinates */
153 
154 /* Slightly different variant for older LS */
155 int get_ecfsun_ls(
156  WRS2 wrsparms, /* I: Structure of WRS-2 parameters */
157  SMETA smeta, /* I: Input scene metadata structure */
158  double dellon, /* I: WRS longitude offset */
159  VECTOR *ecfsun ); /* O: Sun vector in ECEF coordinates */
160 #endif
double y
Definition: mtl_geometry.h:38
void crossprod(VECTOR a, VECTOR b, VECTOR *c)
int get_ecfsun(WRS2 wrsparms, SMETA smeta, double dellon, VECTOR *ecfsun)
Definition: mtl_geometry.c:849
double inertialvel
Definition: mtl_geometry.h:25
int numrow
Definition: mtl_geometry.h:30
int calc_los_ls(SMETA_BAND_LS band_smeta, double frow, double npix, double ndet, VECTOR *los)
Definition: mtl_geometry.c:52
int frame_scene(WRS2 wrsparms, SMETA smeta, double *dellon, double *delrow)
Definition: mtl_geometry.c:419
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second band
double semimajor
Definition: mtl_geometry.h:23
float32 * pos
Definition: l1_czcs_hdf.c:35
void pathrow_to_posvel(WRS2 parms, int path, double dellon, double wrsrow, VECTOR *pos, VECTOR *vel)
float * lat
int calc_los(SMETA_BAND band_smeta, int sca, double ndet, VECTOR *los)
Definition: mtl_geometry.c:19
int calc_yaw_steering_gp_ls(WRS2 parms, VECTOR pos, VECTOR vel, VECTOR i_los, double roll, double *gp_lat, double *gp_lon)
Definition: mtl_geometry.c:265
void pathrow_to_latlon(WRS2 parms, int path, double wrsrow, double *lat, double *lon)
Definition: mtl_geometry.c:959
int project_point(WRS2 wrsparms, SMETA smeta, double dellon, int band, int sca, double frow, double ndet, double *l1t_line, double *l1t_samp)
Definition: mtl_geometry.c:722
double orbitincl
Definition: mtl_geometry.h:26
string path
Definition: color_dtdb.py:221
double semiminor
Definition: mtl_geometry.h:24
double vecnorm(VECTOR a)
int numpath
Definition: mtl_geometry.h:29
int cycle
Definition: mtl_geometry.h:31
double dotprod(VECTOR a, VECTOR b)
int frame_scene_ls(WRS2 wrsparms, SMETA smeta, double *dellon, double *delrow)
Definition: mtl_geometry.c:591
int row0lat
Definition: mtl_geometry.h:32
int calc_yaw_steering_gp(WRS2 parms, VECTOR pos, VECTOR vel, VECTOR i_los, double roll, double *gp_lat, double *gp_lon)
Definition: mtl_geometry.c:100
double path1long
Definition: mtl_geometry.h:28
double x
Definition: mtl_geometry.h:37
data_t b[NROOTS+1]
Definition: decode_rs.h:77
int project_point_ls(WRS2 wrsparms, SMETA smeta, double dellon, int band, double frow, double nsamp, double nline, double *l1t_line, double *l1t_samp)
Definition: mtl_geometry.c:781
void rotatevec(double mat[3][3], VECTOR a, VECTOR *b)
float * lon
double orbitrad
Definition: mtl_geometry.h:27
void unitvec(VECTOR a, VECTOR *b)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan c
Definition: HISTORY.txt:464
double z
Definition: mtl_geometry.h:39
Definition: smeta.h:118
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
int npix
Definition: get_cmp.c:27
int get_ecfsun_ls(WRS2 wrsparms, SMETA smeta, double dellon, VECTOR *ecfsun)
Definition: mtl_geometry.c:900