ocssw  1.0
/disk01/web/ocssw/build/src/geogen_modis/GEO_parameters.h (r8090/r7924)
Go to the documentation of this file.
00001 #ifndef GEO_PARAMETERS_H
00002 #define GEO_PARAMETERS_H
00003 #include "PGS_PC.h"
00004 #include "GEO_geo.h"
00005 #include "GEO_product.h"
00006 #include "hdfi.h"
00007 
00008 /*
00009 !C-INC**************************************************************************
00010 !Description:   The declaration of the global parameter variables for the
00011         Level-1A geolocation software
00012 
00013 !Input Parameters: N/A
00014 
00015 !Output Parameters: N/A
00016 
00017 !Revision History:
00018  * $Log: GEO_parameters.h,v $
00019  * Revision 6.9  2011/02/14 21:28:31  kuyper
00020  * Corrected to const-qualify *poly_coef.
00021  *
00022  * Revision 6.8  2010/07/01 19:38:43  kuyper
00023  * Corrected definition of INPUTPOINTERS.
00024  *
00025  * Revision 6.7  2010/04/23 14:55:09  kuyper
00026  * Converted new numbers controlling setting of quality flags into parameters
00027  *   retrieved from the parameter file.
00028  *
00029  * Revision 6.6  2010/04/08 18:01:21  kuyper
00030  * Dropped orbit and attitude globals that are no longer needed.
00031  * Helped resolve Bug 17 by adding field to fill_values_struct.
00032  *
00033  * Revision 6.5  2009/05/30 18:09:48  kuyper
00034  * Corrected size of u_tel.
00035  *
00036  * Revision 6.4  2009/05/22 16:33:43  xgeng
00037  * reinstated member qa_flag for frame_state_struct.
00038  *
00039  * Revision 6.3  2009/05/19 14:44:49  kuyper
00040  * Reinstated T_mirr2inst, u_tel globals; cannot be dropped until after
00041  * GEO_get_inst_mirr_normal() and GEO_get_view_vec() have been opened.
00042  *
00043  * Revision 6.2  2009/04/15 21:18:29  kuyper
00044  * Removed member from frame_state_struct.
00045  *
00046  * Revision 6.1  2009/03/12 17:59:47  kuyper
00047  * Changed MAX_DETECTORS to DETECTORS_QKM.
00048  * Added hires_scale.
00049  * Dropped globals no longer in use.
00050  *
00051  * Revision 5.4  2005/09/27 15:12:00  vlin
00052  * Four fieldnames added to orbit_validation_params_struct
00053  * vlin@saicmodis.com
00054  *
00055  * Revision 5.3  2004/08/30 21:15:23  kuyper
00056  * Entered first non-dummy value for NUM_SOL_ELEV.
00057  *
00058  * Revision 5.2  2004/08/23 18:56:31  vlin
00059  * fill_values_struct added, one member "fill_values" added to l1a_data_struct.
00060  *
00061  * Revision 5.1  2004/08/02 19:36:29  vlin
00062  * NCSA acknowledgement removed from prologue,
00063  * solar elevation correction matrix added.
00064  *
00065  * Revision 4.5  2003/08/22 22:18:52  kuyper
00066  * Changed T_inst2SD to T_sc2SD.
00067  *
00068  * Revision 4.4  2003/08/05 21:12:19  kuyper
00069  * Corrected location of processing metadata fields.
00070  *
00071  * Revision 4.3  2003/01/29 20:17:30  vlin
00072  * Corrected declaration for encoder_gap
00073  *
00074  * Revision 4.2  2002/11/21 22:54:59  kuyper
00075  * Added in packet_interval.
00076  *
00077  * Revision 4.1  2002/11/15 21:24:29  kuyper
00078  * Added items needed to support temperture retrieval, expanded input pointers,
00079  *   and reprocessing and processingenvironment metadata.
00080 
00081 !Team-unique Header:
00082 
00083                 This software is developed by the MODIS Science Data Support
00084                 Team for the National Aeronautics and Space Administration,
00085                 Goddard Space Flight Center, under contract NAS5-32373.
00086 
00087 !END****************************************************************************
00088 */
00089 
00090 /* Identifying tag required on first line of geolocation parameter file. */
00091 #define PARAM_TAG "MOD03_L1A_GEOLOCATION"
00092 #define SCAN_TYPE_LEN 10
00093 
00094 /**********************************************************
00095 Variables from the parameter file
00096 **********************************************************/
00097 
00098 /* polynomial coefficients for mirror encoder-to-angle conversion */
00099 extern double const * poly_coef;
00100 extern int poly_degree;
00101 
00102 /* mirr errors alpha, beta, gamma */
00103 extern double alpha;
00104 extern double beta;
00105 extern double gammaa;
00106 
00107 /* mirror side 1 angle range (radians) */
00108 extern double mirr_side1_range[2];
00109 
00110 /* telescope to instrument frame transformation matrix */
00111 extern double T_tel2inst[3][3];
00112 
00113 /* mirror to instrument frame transformation matrix */
00114 extern double T_mirr2inst[3][3];
00115 
00116 /* viewing vector in telescope coord */
00117 /*  This is derived from instrument geometry parameters */
00118 extern double u_tel[DETECTORS_QKM][3];
00119 
00120 /* scale factors for converting ancillary input data */
00121 typedef struct{
00122     double S_position;      /* orbit position (1/8 meters/count) */
00123     double S_velocity;      /* orbit velocity (1/4096 meters/sec/count) */
00124     double S_attitude;      /* attitude angles (1 arcsec/count) */
00125     double S_angvel;        /* angular velocity (0.5 arcsec/sec/count) */
00126 } ancil_scale_struct;
00127 
00128 /* location of data words in l1a data segments */
00129 extern int sector_word[2];      /* Earth sector encoder word [side 1/side 2] */
00130 extern int vernier_word[2];     /* Vernier count word [side 1/side 2] */
00131 typedef struct{
00132     int time_words[2];  /* ancillary time start word [current/prior] */
00133     int orbit_words[2]; /* orbit data start word [current/prior] */
00134     int attit_words[2]; /* attitude data start word [current/prior] */
00135 } ancil_word_struct;
00136 
00137 typedef struct{
00138     ancil_word_struct ancil_words;
00139     ancil_scale_struct ancil_scale_factors;
00140 } ancil_data_param_struct;
00141 
00142 typedef struct {
00143            uint8     num_impulse;   /* number of good impulse data */
00144            int       impulse_flag;  /* encoder data flag    */
00145            uint16    mirr_side;                       /* mirror side*/
00146            double    mirr_impulse_enc[MAX_IMPULSE_NUMBER];  /* mirror impulse encoder */
00147            double    mirr_impulse_time[MAX_IMPULSE_NUMBER]; /* times (TAI seconds)  */
00148            uint16    mirr_chan;
00149         } mirr_data_struct;
00150 
00151 typedef struct {
00152            int32    L1A_scan_id;
00153            int32    L1A_scan_quality[4]; /* Scan quality array              */
00154            float64  EV_start;            /* Earth View scan start time (TAI seconds) */
00155            int32    EV_frames;           /* Earth View frames in each scan  */
00156            float64  SD_start;            /* Solar Diffusor scan start times (TAI seconds) */
00157            int32    SD_frames;           /* Solar Diffusor frames in each scan */
00158            float64  SV_start;            /* Space View scan start times (TAI seconds)  */
00159            int32    SV_frames;           /* Space View frames in each */
00160            int8     SCI_ABNORM;          /* spacecraft in unusual state
00161                                             (i.e. maneuver) flag
00162                                             0 = maneuver
00163                                             1 = normal                     */
00164            int8     SCI_STATE;           /* instrument test mode flag
00165                                             0 = MODIS test mode
00166                                             1 = normal                     */
00167            char8    Scan_type[SCAN_TYPE_LEN]; /*'Day', 'Night', or 'Other'  */
00168         } frame_data_struct;
00169 
00170 typedef struct{
00171            float64  time;                /* frame (mid-)sample time, TAI seconds   */
00172            float64  positionECR[3];      /* ECR postion, meters                    */
00173            float64  velocityECR[3];      /* ECR velocity, meters/sec               */
00174            float64  eulerAngles[3];      /* attitude euler angles (roll, pitch, yaw) */
00175                                         /* wrt the orbital reference frame (?), radians. */
00176            float64  T_inst2ecr[3][3];    /* instrument to ecr coordinate transformation matrix. */
00177            int      qa_flag;          /*     kinematic state quality (FAIL, SUCCESS)  */
00178         } frame_state_struct;
00179 
00180 typedef struct {
00181        frame_state_struct sc;
00182            float64  sun_unit_vector[3];
00183            float64 SD_sun_zenith;
00184            float64 SD_sun_azimuth;
00185            float64 moon_unit_vector[3];
00186         } celestial_bodies_struct;
00187 /* extern celestial_bodies_struct cb_vectors; */
00188 
00189 typedef struct {
00190         int32   max_earth_frames;
00191         int32   max_sd_frames;
00192         int32   max_sv_frames;
00193         int32   incomplete_scans;
00194         int32   missing_packets;
00195         int32   bad_CRC_packets;
00196         int32   discarded_packets;
00197         int32   extractPixelOffset;
00198         int32   extractPixelCount;
00199         int32   extractLineOffset;
00200         int32   extractLineCount;
00201        } l1a_metadata_struct;
00202 
00203 typedef struct {
00204         char    localversionid[17];
00205         char    pgeversion[11];
00206         char    processversion[11];
00207         char    productionhistory[32];
00208     char    processingenvironment[PGSd_PC_VALUE_LENGTH_MAX];
00209     char    reprocessingplanned[PGSd_PC_VALUE_LENGTH_MAX];
00210     char    reprocessingactual[PGSd_PC_VALUE_LENGTH_MAX];
00211       } version_metadata_struct;
00212 
00213 typedef struct {
00214         char    rangebeginningdate[11];
00215         char    rangebeginningtime[16];
00216         char    rangeendingdate[11];
00217         char    rangeendingtime[16];
00218         char    operationmode[8];
00219         char    localinputgranuleid[PGSd_PC_FILE_PATH_MAX];
00220         char    granulenumber[8];
00221         char    platformshortname[20];
00222         version_metadata_struct version_metadata;
00223       } ECS_metadata_struct;
00224 
00225 typedef struct {
00226         PGSt_integer    orbitnumber;
00227         PGSt_double     equatorcrossinglongitude;
00228         char            equatorcrossingdate[11];
00229         char            equatorcrossingtime[16];
00230       } EPH_metadata_struct;
00231 
00232 typedef struct {
00233            int16     scan_number;
00234            float64   EV_start_time;
00235            float64   SD_start_time;
00236            float64   SV_start_time;
00237            float32   SD_sun_zenith;
00238            float32   SD_sun_azimuth;
00239            float32   moon_vector;
00240            float32   sun_ref;
00241            uint16    mirr_side;
00242        uint16    raw_mir_enc;
00243            float64   impulse_enc;
00244            float64   impulse_time;
00245            int32     L1_scan_quality;
00246            int8      geo_scan_quality;
00247            float64   EV_center_time;
00248            float64   orb_pos;
00249            float64   orb_vel;
00250            float64   T_inst2ECR;
00251            float64   attitude_angels;
00252            int32     EV_frames;
00253            int32     SD_frames;
00254            int32     SV_frames;
00255            uint8     num_impulse;
00256            char8     Scan_type[SCAN_TYPE_LEN];
00257         } fill_values_struct;
00258 
00259 #define NUM_TEMPS   6
00260 #define NUM_SOL_ELEV    36
00261 
00262 typedef struct {
00263             int         num_scans;
00264             frame_data_struct   frame_data[MAX_SCAN_NUMBER];
00265             mirr_data_struct    mirr_data[MAX_SCAN_NUMBER];
00266             l1a_metadata_struct granule_metadata;
00267             ECS_metadata_struct ECS_metadata;
00268         float32     temperatures[NUM_TEMPS];
00269             fill_values_struct  fill_values;
00270         } l1a_data_struct;
00271 /* extern l1a_data_struct l1a_data; */
00272 
00273 typedef struct {
00274             int     band_number; /* band number to geolocate (0 is ideal band) */
00275             double  t_reset;     /* time to reset sample at beginning of frame */
00276             double  t_frame;     /* sample frame time */
00277             /* offset in IFOV units to get time of first sample for a band */
00278             double  F_offset[MAX_BAND_NUMBER+1];
00279             /*  number of samples per frame for each band */
00280             uint16  N_samp[MAX_BAND_NUMBER+1];
00281             float64 focal_length[MAX_BAND_NUMBER+1]; /* focal length */
00282             /* detector position for each band */
00283             float64 det_space[MAX_BAND_NUMBER+1];
00284             float64 det_position[MAX_BAND_NUMBER+1][2];
00285             float64 band_position[MAX_BAND_NUMBER+3]; /* band center position */
00286         } focal_plane_geometry_struct;
00287 /* extern focal_plane_geometry_struct geometry_params; */
00288 
00289 typedef struct {
00290     /* Number of sample periods from sector start to start of data collection  */
00291             double  N_reset;
00292             double  mirr_abs_limit[2]; /* mirror encoder time absolute limits */
00293             double  mirr_del_limit; /* mirror encoder time delta limits */
00294             int     sample_impulse; /* encoder sample period in impulses */
00295             int     sector_word[2]; /* Earth sector encoder word [side 1/side 2] */
00296             int     vernier_word[2]; /* Vernier count word [side 1/side 2] */
00297             double  t_encoder; /* encoder time scale factor */
00298             double  t_vernier; /* vernier offset count time */
00299         double  encoder_gap[2]; /* Range affected by encoder_adjustment. */
00300         double  encoder_adjustment; /* Size of encoder correction.  */
00301         double  packet_interval;    /* Interval between ancillary packets.*/
00302         }  mirror_preparation_struct;
00303 /* extern  mirror_preparation_struct       mirror_prep_params; */
00304 /* offsets into mirr_abs_limit */
00305 enum {lower_limit, upper_limit};
00306 
00307 typedef struct {
00308             double  mirr_side1_range[2]; /* mirror side 1 angle range (radians) */
00309             float64 alpha;
00310             float64 beta;
00311             float64 gammaa;
00312         }  mirror_model_struct;
00313 /* extern  mirror_model_struct  mirror_model; */
00314 
00315 typedef struct {
00316             double position_abs_limit[2]; /* orbit position absolute limits */
00317             double position_mag_limit[2]; /* orbit position magnitude limits */
00318             double velocity_abs_limit[2]; /* orbit velocity absolute limits */
00319             double velocity_mag_limit[2]; /* orbit velocity magnitude limits */
00320             double ang_mom_limit[2];      /* angular momentum magnitude limits */
00321             double ang_mom_z_limit[2];    /* angular momentum Z component */
00322             /* orbit position/velocity consistency limit */
00323             double orbit_consistency;
00324             double descend_time_0[2];
00325                   /* the descend time corresponding to orbit number 0 */
00326             double orbit_tolerance[2];
00327             double period[2];
00328             int    transition_orbit;
00329         double eph_max_short_gap;   /* Maximum length of a short gap */
00330         } orbit_validation_params_struct;
00331 /* extern orbit_validation_params_struct  orbit_valid_params; */
00332 
00333 typedef struct {
00334             double  angvel_abs_limit[2]; /* angular velocity absolute limits */
00335             double  angvel_del_limit; /* angular velocity delta limits */
00336             double  attitude_abs_limit[2]; /* attitude angle absolute limits */
00337             double  attitude_del_limit; /* attitude angle delta limits */
00338             double  attit_consistency;     /* angle/angular velocity consistency limit */
00339         double att_max_short_gap;   /* Maximum length of a short gap. */
00340         short  att_valid_range[2];  /* Limits for valid entrained attitude */
00341         } attitude_valid_struct;
00342 /* extern attitude_valid_struct       attit_valid_params; */
00343 
00344 typedef struct {
00345             float64 T_inst2sc[3][3];    /* instrument to spacecraft */
00346             float64 T_mirr2inst[3][3];  /* mirror to instrument frame */
00347             float64 T_tel2inst[3][3];   /* telescope to instrument frame */
00348             float64 T_sc2SD[3][3];  /* spacecraft to solar diffuser */
00349         int     rpy_count;          /* count of rows in rpy_inst2sc */
00350         double  (*rpy_inst2sc)[3];  /* Roll/Pitch/Yaw corrections for
00351                      * T_inst2sc */
00352         double  *rpy_times;     /* The corresponding TAI times */
00353         } internal_coord_trans_struct;
00354 /* extern internal_coord_trans_struct coord_trans; */
00355 
00356 /*
00357  * ELEC_SIDES has two possible values, which are defined below.
00358  */
00359 #define CHAN_A 0
00360 #define CHAN_B 1
00361 
00362 #define NUM_TEMP_EQNS   7
00363 #define TEMP_ORDER  6
00364 
00365 typedef struct {
00366         char            revision[32];
00367             focal_plane_geometry_struct geometry_params;
00368             mirror_preparation_struct   mirror_prep_params;
00369             mirror_model_struct         mirror_model;
00370             ancil_data_param_struct     ancil_params;
00371         double          max_non_gap;
00372         /* Minimum interval between packets that is considered a gap. */
00373             orbit_validation_params_struct    orbit_valid_params;
00374             attitude_valid_struct       attit_valid_params;
00375             internal_coord_trans_struct coord_trans;
00376             /* number of detectors for band_number */
00377             int                         num_detectors;
00378             /* telescope view vector in meters. */
00379             double                      u_tel[DETECTORS_QKM][3];
00380             /* maximum orbit/attitude extrapolation limit (seconds) */
00381             double                      max_extrap;
00382             /* polynomial coefficients for mirror encoder-to-angle conversion */
00383             double                      poly_coef[ELEC_SIDES][MAX_POLY_DEGREE+1];
00384             int                         poly_degree;
00385             /* scale factors for scaling geolocation output values:  */
00386             double                      angle_scale; /* counts/radian   */
00387             double                      hires_scale; /* kilometers IFOV */
00388             double                      range_scale; /* counts/meter    */
00389             float32                     RMS_error; /* estimated geo RMS error (meters). */
00390         char            spacecraft_ID[8];
00391 
00392         float32         temp_range[NUM_TEMP_EQNS][2];
00393         /* The valid output range of the temperature conversion functions.*/
00394         float32         temp_coeff[NUM_TEMP_EQNS][TEMP_ORDER];
00395             double                      sol_elev_cor[NUM_SOL_ELEV][3];
00396         /* The polynomial coefficients of the temperature conversion
00397          * functions.
00398          */
00399         } GEO_param_struct;
00400 
00401 typedef struct {
00402             char  exclusionflag[2]; /*  Flag indicating whether points
00403                                         are on an inner (exclusion) G-ring.*/
00404             int   sequenceno[4]; /*     Sequence numbers corresponding to
00405                                         perimeter latitudes and longitudes. */
00406             double  latitude[4]; /*     Latitudes of a series of points
00407                                         representing the perimeter of the
00408                                         granule spatial coverage. */
00409             double  longitude[4]; /*    Longitudes of a series of points
00410                                         representing the perimeter of the
00411                                         granule spatial coverage. */
00412 } GEO_GRing_struct;
00413 
00414 #define INPUTPOINTERS (2 + 2*MAX_EA_FILES)
00415 typedef struct {
00416     char    inputpointer[INPUTPOINTERS][PGSd_PC_UREF_LENGTH_MAX];
00417 } pointer_metadata_struct;
00418 
00419 typedef struct {
00420     int no_of_pixels;   /* total number of pixels in granule */
00421     int missingdata;    /* no. of pixels for which there are
00422                   insufficient data to perform geolocation */
00423     int outofboundsdata;/* no. of pixels that have un-
00424                   geolocatable views */
00425         int     retval;         /* FAIL/SUCCESS, depending upon whether a
00426                                   fatal error was detected */
00427         char    rms_error[9];   /*      string value of RMS geolocation error*/
00428         uint32  cumulated_gflags[8]; /* Cumulated count of pixels for which the
00429                                         corresponding bit of gflags was set.
00430                                         LSB corresponds to first element.*/
00431 
00432 } qa_metadata_struct;
00433 
00434 #endif
00435