ocssw  1.0
/disk01/web/ocssw/build/inc/swfinc/l2.h
Go to the documentation of this file.
00001 /*
00002 
00003 $Header: /app/shared/RCS/irix-5.2/seawifsd/src/hdfio/L2.V4.4/l2.h,v 4.15 1995/12/07 19:28:52 seawifsd Exp seawifsd $
00004 $Log: l2.h,v $
00005 Revision 4.15  1995/12/07 19:28:52  seawifsd
00006 supported alternative count value for some of the L2 products
00007 and  made it IO_SPEC_V4.4, PROD_SPEC_V2.8 and NONPROD_SPEC_V13
00008 compliant.[l2.h, l2w.c]
00009 
00010 Revision 4.14  1995/05/31 13:13:37  seawifsd
00011 1. added definition of browse_rec_l2Struct structure.
00012 2. added clipping algorithm to RL2MAP, STRUCT_RL2MAP, ...
00013 3. IO_SPEC_V43 compliant.
00014 
00015 Revision 4.13  1995/04/03 21:18:06  seawifsd
00016 made CDL_DEFAULT_CONST_TYPE to be float.
00017 
00018 Revision 4.12  1995/04/03 16:12:37  seawifsd
00019 renamed 'e_765_865' to 'eps_78' and 'epsilon' to 'eps_68'.
00020 changed implementation of mapping functions(*MAP) so that the value
00021 will be correctly set to deal with the problem only occurred in SGI.
00022 
00023 Revision 4.11  1995/02/15 19:05:55  seawifsd
00024 1. renamed macro LAKSHMI to EXTRA_FOR_BROWSE.
00025 2. defined macro constants to indicate the sequence of all the
00026 goephysical parameters in the L2 and QC files.
00027 3. removed La_865 from Q/C geophysical parameter list.
00028 4. defined macro AX_PLUS_B(X,A,B) and R_AX_PLUS_B(Y,A,B) for
00029 implementing slope/intercept.
00030 5. defined macro RL2MAP, STRUCT_RL2MAP, RL2QCMAP, STRUCT_RL2QCMAP,
00031 and L2MAP, STRUCT_L2MAP that use AX_PLUS_B() or R_AX_PLUS_B() in
00032 the calculation of the geophysical parameters.
00033 6. all geophysical parameters for the Q/C file are saved as short or
00034 byte(v.s. float in previous version).
00035 7. added support of 'cal_entry_year', 'cal_entry_day', 'scsol_z' and
00036 'csol_z' objects.
00037 8. revised structure definition of l2_dataType, l2_qc_dataType and
00038 added structure fl2_dataType, and fl2_qc_dataType.
00039 
00040 Revision 4.10  1995/01/17 20:04:07  seawifsd
00041 Jan. 17, 1994 V4.1
00042 
00043 Revision 4.1  1995/01/17 14:13:12  seawifsd
00044 Jan. 9, 1994, 4.0
00045 
00046 Revision 3.5  1994/12/16 16:46:07  seawifsd
00047 made infiles defined in meta_l2 because the requirement of l2 browse product.
00048 
00049 Revision 3.4  1994/12/13 16:10:25  seawifsd
00050 modified to fit the changes/additions in IO_SPEC_V40, PROD_SPEC_V24 and
00051 NONPROD_SPEC_V10.
00052 
00053 Revision 3.3  1994/11/08 18:46:02  seawifsd
00054 Nov. 8, 1994, 3.3a3
00055 
00056 Revision 3.3  1994/11/08 15:03:59  seawifsd
00057 Nov. 8, 1994, 3.3a2
00058 
00059 Revision 1.1.1.1  1994/10/05 20:46:34  frank
00060 modified according to i/o spec. 3.3 and product spec. 1.0.
00061 
00062 Revision 1.2  1994/05/10 18:45:09  seawifst
00063 May 6, 1994 version 1.2
00064 
00065 Revision 1.1  1994/04/19 13:24:35  seawifst
00066 Initial revision
00067 
00068 Changed SEQ_QC_HUMIDITY to SEQ_QC_P_WATER
00069 Removed SEQ_QC_PIXEL_LAT and SEQ_QC_PIXEL_LON definitions
00070 Added SEQ_QC_LT_443 and SEQ_QC_EPS_FLAG definitions
00071 Renumbered SEQ_QC_* #defines
00072 Removed humidity, pixel_lat, and pixel_lon from qc_dataType structures
00073 and added p_water, Lt_443, and eps_flag.
00074 Norman Kuring       4-Nov-1996
00075 
00076 Removed all code that was only compiled when GENERAL was defined.
00077 Norman Kuring       5-Nov-1996
00078 
00079 Added Calibration Vgroup members to struct meta_l2Struct.
00080 Norman Kuring       5-Nov-1996
00081 
00082 Removed all code that was only compiled when EVERYTHING was defined.
00083 Norman Kuring       7-Nov-1996
00084 
00085 W. Robinson, GSC, 29 May 97  add 19th QC item: Carder_chlor
00086 W. Robinson, GSC, 8 Aug 97  add 20th QC item: NDVI
00087 W. Robinson, GSC, 28 Apr 98  replace solar_a with albedo_865
00088 
00089  */
00090 
00091 
00092 #ifndef L2_H_
00093 #define L2_H_
00094 
00095 #include <limits.h>
00096 
00097 #ifndef UCHAR_MAX
00098 #define (
00099 UCHAR_MAX is not defined )
00100 #endif /* !UCHAR_MAX */
00101 
00102 #ifndef SHRT_MAX
00103 #define (
00104 SHRT_MAX is not defined )
00105 #endif /* !SHRT_MAX */
00106 
00107 #ifndef SHRT_MIN
00108 #define (
00109 SHRT_MIN is not defined )
00110 #endif /* !SHRT_MIN */
00111 
00112 #define BMAPMAX UCHAR_MAX
00113 #define BMAPMIN 0
00114 #define SMAPMAX SHRT_MAX
00115 #define SMAPMIN SHRT_MIN
00116 #define SNOMAPMAX   1024
00117 #define SNOMAPMIN   -1
00118 
00119 #ifndef CDL_DEFAULT_CONST_TYPE
00120 #define CDL_DEFAULT_CONST_TYPE  float
00121 #endif /* !CDL_DEFAULT_CONST_TYPE */
00122 
00123 #define CONST_TYPE  CDL_DEFAULT_CONST_TYPE
00124 
00125 #include "navigation.h"
00126 
00127 /* l2 values will depend on mask value and l2_flags value for each pixel */
00128 #define ALT_L2_COUNTS
00129 
00130 #ifdef ALT_L2_COUNTS
00131 
00132 #define USE_ALT_COUNTS  1
00133 #define NO_ALT_COUNTS   0
00134 #define DEFAULT_ALT_COUNTS  USE_ALT_COUNTS
00135 
00136 #endif /* ALT_L2_COUNTS */
00137 
00138 #define EXTRA_FOR_BROWSE
00139 #include "level_2_index.h"
00140 #define PFLAG   PFLAG_DIMS_2
00141 
00142 #ifndef MAX_HDF
00143 #define MAX_HDF 16
00144 #endif
00145 
00146 #ifndef MAX_HDF_L2GET
00147 #define MAX_HDF_L2GET   4
00148 #endif
00149 #ifndef MAX_HDF_L2PUT
00150 #define MAX_HDF_L2PUT   4
00151 #endif
00152 
00153 #define GEO_DATA_MAX        12
00154 #define GEO_DATA_SPARE      0
00155 #define GEO_DATA_VALID      (GEO_DATA_MAX - GEO_DATA_SPARE)
00156 #define QC_GEO_DATA_MAX     20
00157 #define QC_GEO_DATA_SPARE   0
00158 #define QC_GEO_DATA_VALID   (QC_GEO_DATA_MAX - QC_GEO_DATA_SPARE)
00159 
00160 #define SEQ_NLW_412     0
00161 #define SEQ_NLW_443     1
00162 #define SEQ_NLW_490     2
00163 #define SEQ_NLW_510     3
00164 #define SEQ_NLW_555     4
00165 #define SEQ_LA_670      5
00166 #define SEQ_LA_865      6
00167 #define SEQ_CZCS_PIGMENT    7
00168 #define SEQ_CHLOR_A     8
00169 #define SEQ_K_490       9
00170 #define SEQ_EPS_78      10
00171 #define SEQ_TAU_865     11
00172 
00173 #define SEQ_QC_ZONAL_WIND   0
00174 #define SEQ_QC_MERID_WIND   1
00175 #define SEQ_QC_PRESSURE     2
00176 #define SEQ_QC_P_WATER      3
00177 #define SEQ_QC_OZONE        4
00178 #define SEQ_QC_SOLAR_Z      5
00179 #define SEQ_QC_ALBEDO_865   6
00180 #define SEQ_QC_SENSOR_Z     7
00181 #define SEQ_QC_SENSOR_A     8
00182 #define SEQ_QC_NLW_670      9
00183 #define SEQ_QC_LA_765       10
00184 #define SEQ_QC_LT_443       11
00185 #define SEQ_QC_RAYLEIGH_443 12
00186 #define SEQ_QC_LG_865       13
00187 #define SEQ_QC_LF_865       14
00188 #define SEQ_QC_AER_MODEL1   15
00189 #define SEQ_QC_AER_MODEL2   16
00190 #define SEQ_QC_EPS_FLAG     17
00191 #define SEQ_QC_CARDER_CHLOR 18
00192 #define SEQ_QC_NDVI         19
00193 
00194 #ifndef AX_PLUS_B
00195 #define AX_PLUS_B(X,A,B)    (A) * (X) + (B)
00196 #endif /* !AX_PLUS_B */
00197 #ifndef R_AX_PLUS_B
00198 #define R_AX_PLUS_B(Y,A,B)  ((Y) - (B))/(A)
00199 #endif /* !R_AX_PLUS_B */
00200 
00201 #define ROUNDING_V 0.5
00202 #define ROUNDING(x) ((((x) >= 0)?ROUNDING_V:-ROUNDING_V) + (x))
00203 
00204 /* used in l2.c X -> Y using Y=AX_PLUS_B(X,A,B)= A*X+B          */
00205 #define L2MAP(name,seq,i)       **(fl2_data + seq *npix + i) = AX_PLUS_B(local_l2_data.name[i],local_l2_scale[prod_ID][seq],local_l2_offset[prod_ID][seq])
00206 #define STRUCT_L2MAP(name,seq,i)    fl2_data->name[i] = AX_PLUS_B(local_l2_data.name[i],local_l2_scale[prod_ID][seq],local_l2_offset[prod_ID][seq])
00207 
00208 /*
00209    this is used to deal with the case that in IRIX 5.x, when using
00210    char = float;
00211    if the value of 'float' is an out-of-range negative value, the value
00212    of 'char' will be 255. No problem on IRIX 4.x, SUN 4.x, Solaris 2.x, OSF/1
00213  */
00214 static int tmp_int_storage;
00215 
00216 /* used in l2w.c Y -> X using X= R_AX_PLUS_B(Y,A,B)= (Y-B)/A        */
00217 #define RL2MAP(type,name,seq,i,high,low)        (type(WIFS->name.data))[roff*nsamp+i] = tmp_int_storage = MAXV(low,MINV(high,ROUNDING(R_AX_PLUS_B(fl2_data[seq*nsamp + i],local_l2_scale[prod_ID][seq],local_l2_offset[prod_ID][seq]))))
00218 #define RL2NOMAP(type,name,seq,i,high,low)      (type(WIFS->name.data))[roff*nsamp+i] = tmp_int_storage = MAXV(low,MINV(high,ROUNDING(fl2_data[seq*nsamp + i])))
00219 #define STRUCT_RL2MAP(type,name,seq,i,high,low) (type(WIFS->name.data))[roff*nsamp+i] = tmp_int_storage =  MAXV(low,MINV(high,ROUNDING(R_AX_PLUS_B(fl2_data.name[i],local_l2_scale[prod_ID][seq],local_l2_offset[prod_ID][seq]))))
00220 #define STRUCT_RL2NOMAP(type,name,seq,i,high,low)   (type(WIFS->name.data))[roff*nsamp+i] = tmp_int_storage =  MAXV(low,MINV(high,ROUNDING(fl2_data.name[i])))
00221 #define RL2QCMAP(type,name,seq,i,high,low)  (type(QCWIFS->name.data))[roff*nsamp+i] = tmp_int_storage = MAXV(low,MINV(high,ROUNDING(R_AX_PLUS_B(fl2_qc_data[seq*nsamp + i],local_l2_qc_scale[prod_ID][seq],local_l2_qc_offset[prod_ID][seq]))))
00222 #define STRUCT_RL2QCMAP(type,name,seq,i,high,low)   (type(QCWIFS->name.data))[roff*nsamp+i] = tmp_int_storage = MAXV(low,MINV(high,ROUNDING(R_AX_PLUS_B(fl2_qc_data.name[i],local_l2_qc_scale[prod_ID][seq],local_l2_qc_offset[prod_ID][seq]))))
00223 
00224 typedef struct meta_l2Struct {
00225 #if defined(EXTRA_FOR_BROWSE)
00226     char    *product_name;  /* ATTR Product name(file name)     */
00227 #endif /* EXTRA_FOR_BROWSE */
00228     char    *data_center;   /* ATTR data_center, processing center  */
00229     char    *station;   /* ATTR station             */
00230     float   station_lat;    /* ATTR station latitude        */
00231     float   station_lon;    /* ATTR station longitude       */
00232     char    *mission;   /* ATTR mission             */
00233     char    *mission_char;  /* ATTR Mission Characteristics     */
00234     char    *sensor;    /* ATTR sensor              */
00235     char    *sensor_char;   /* ATTR Sensor Characteristics      */
00236     char    *sw_id;     /* ATTR Software ID         */
00237     char    *infiles;   /* ATTR Input files         */
00238     char    *stime;     /* ATTR Start time          */
00239     char    *etime;     /* ATTR End time            */
00240     char    *ctime;     /* ATTR scene center time       */
00241     char    *ntime;     /* ATTR Node crossing time      */
00242     char    *snode;     /* ATTR Start Node          */
00243     char    *enode;     /* ATTR End Node            */
00244     int orbnum;     /* ATTR orbit number            */
00245     char    *norad1;    /* ATTR NORAD elements, first line  */
00246     char    *norad2;    /* ATTR NORAD elements, second line */
00247     int pix_start;  /* ATTR LAC Pixel Start Number      */
00248     int pix_sub;    /* ATTR LAC Pixel Subsampling       */
00249     int ncrec;      /* ATTR scene center scan line      */
00250     int nfrec;      /* ATTR number of filled scan line  */
00251     byte    ff_mis;     /* ATTR FF missing frames       */
00252     byte    sd_mis;     /* ATTR SDPS missing frames     */
00253 #if defined(EXTRA_FOR_BROWSE)
00254     float   flags_pc[PFLAG];/* MFSD % data for each quality flag    */
00255 #endif /* EXTRA_FOR_BROWSE */
00256     char    *lat_units; /* ATTR Latitude units          */
00257     char    *lon_units; /* ATTR Longitude units         */
00258     float   sclat;      /* ATTR scene center latitude       */
00259     float   sclon;      /* ATTR scene center longitude      */
00260     float   scsol_z;    /* ATTR scene center solar zenith angle */
00261     float   ullat;      /* ATTR scene upper left latitude   */
00262     float   ullon;      /* ATTR scene upper left longitude  */
00263     float   urlat;      /* ATTR scene upper right latitude  */
00264     float   urlon;      /* ATTR scene upper right longitude */
00265     float   lllat;      /* ATTR scene lower left latitude   */
00266     float   lllon;      /* ATTR scene lower left longitude  */
00267     float   lrlat;      /* ATTR scene lower right latitude  */
00268     float   lrlon;      /* ATTR scene lower right longitude */
00269     float   northlat;   /* ATTR Northernmost latitude       */
00270     float   southlat;   /* ATTR Southernmost latitude       */
00271     float   westlon;    /* ATTR Westernmost longitude       */
00272     float   eastlon;    /* ATTR Easternmost longitude       */
00273     float   startclat;  /* ATTR Start Center Latitude       */
00274     float   startclon;  /* ATTR Start Center Longitude      */
00275     float   endclat;    /* ATTR End Center Latitude     */
00276     float   endclon;    /* ATTR End Center Longitude        */
00277     float   nodel;      /* ATTR Orbit node longitude        */
00278     int ntilts;     /* MFSD Sensor Tilt         */
00279     /* MFSD tilt indicators                     */
00280     short   tilt_flags[MTILT_DIMS_2];
00281     /* MFSD scan-line range of scene tilt               */
00282     short   tilt_ranges[MTILT_DIMS_2][LTILT_DIMS_2];
00283     /* MFSD lat of tilt-range scan-line end pt          */
00284     float   tilt_lats[MTILT_DIMS_2][LTILT_DIMS_2][PTILT_DIMS_2];
00285     /* MFSD lon of tilt-range scan-line end pt          */
00286     float   tilt_lons[MTILT_DIMS_2][LTILT_DIMS_2][PTILT_DIMS_2];
00287     /* Calibration Vgroup */
00288     short   entry_year;
00289     short   entry_day;
00290     short   ref_year;
00291     short   ref_day;
00292     short   ref_minute;
00293     float   mirror[SIDES_DIMS_2][BANDS_DIMS_2];
00294     double  t_const[BANDS_DIMS_2];
00295     double  t_linear[BANDS_DIMS_2];
00296     double  t_quadratic[BANDS_DIMS_2];
00297     float   cal_offs[BANDS_DIMS_2];
00298     float   counts[BANDS_DIMS_2][GAINS_DIMS_2][KNEES_DIMS_2];
00299     float   rads[BANDS_DIMS_2][GAINS_DIMS_2][KNEES_DIMS_2];
00300 } meta_l2Type;
00301 
00302 typedef struct browse_rec_l2Struct {
00303     navblockType    nav;
00304 } browse_rec_l2Type;
00305 
00306 typedef struct rec_l2Struct {
00307     float       *slat;      /* MFSD Scan start pixel latitude*/
00308     float       *slon;      /* MFSD Scan start pixel longitude*/
00309     float       *clat;      /* MFSD Scan center pixel lat   */
00310     float       *clon;      /* MFSD Scan center pixel long  */
00311     float       *csol_z;    /* MFSD Scan center solar zenith*/
00312     float       *elat;      /* MFSD Scan end pixel latitude */
00313     float       *elon;      /* MFSD Scan end pixel longitude*/
00314     float       *tilt;      /* MFSD tilt angle for scan line*/
00315     float       *inst_ana;  /* MFSD Inst analog telemetry   */
00316     byte        *inst_dis;  /* MFSD Inst discrete telemetry */
00317     navblockType    nav;
00318 } rec_l2Type;
00319 
00320 
00321 typedef struct fl2_dataStruct {
00322     float   *nLw_412; /* MFSD Normalized water-leaving radiance at 412 nm*/
00323     float   *nLw_443; /* MFSD Normalized water-leaving radiance at 443 nm*/
00324     float   *nLw_490; /* MFSD Normalized water-leaving radiance at 490 nm*/
00325     float   *nLw_510; /* MFSD Normalized water-leaving radiance at 510 nm*/
00326     float   *nLw_555; /* MFSD Normalized water-leaving radiance at 555 nm*/
00327     float   *La_670;  /* MFSD Aerosol radiance at 670 nm        */
00328     float   *La_865;  /* MFSD Aerosol radiance at 865 nm        */
00329     float   *CZCS_pigment; /* MFSD CZCS-like pigment concentration  */
00330     float   *chlor_a; /* MFSD Chlorophyll a concentration       */
00331     float   *K_490; /* MFSD Diffuse attenuation coefficient at 490nm*/
00332     float   *eps_78; /* MFSD Epsilon of aerosol correction  */
00333     float   *tau_865; /* MFSD Aerosol optical thickness at 865 nm   */
00334 } fl2_dataType;
00335 typedef struct l2_dataStruct {
00336     short   *nLw_412; /* MFSD Normalized water-leaving radiance at 412 nm*/
00337     short   *nLw_443; /* MFSD Normalized water-leaving radiance at 443 nm*/
00338     short   *nLw_490; /* MFSD Normalized water-leaving radiance at 490 nm*/
00339     short   *nLw_510; /* MFSD Normalized water-leaving radiance at 510 nm*/
00340     short   *nLw_555; /* MFSD Normalized water-leaving radiance at 555 nm*/
00341     short   *La_670;  /* MFSD Aerosol radiance at 670 nm        */
00342     short   *La_865;  /* MFSD Aerosol radiance at 865 nm        */
00343     short   *CZCS_pigment; /* MFSD CZCS-like pigment concentration  */
00344     short   *chlor_a; /* MFSD Chlorophyll a concentration       */
00345     short   *K_490; /* MFSD Diffuse attenuation coefficient at 490nm*/
00346     byte    *eps_78; /* MFSD Epsilon of aerosol correction      */
00347     byte    *tau_865; /* MFSD Aerosol optical thickness at 865 nm   */
00348 } l2_dataType;
00349 
00350 typedef struct fl2_qc_dataStruct {
00351     float       *zonal_wind;
00352     float       *merid_wind;
00353     float       *pressure;
00354     float       *p_water;
00355     float       *ozone;
00356     float       *solar_z;
00357     float       *albedo_865;
00358     float       *sensor_z;
00359     float       *sensor_a;
00360     float       *nLw_670;
00361     float       *La_765;
00362     float       *Lt_443;
00363     float       *Rayleigh_443;
00364     float       *Lg_865;
00365     float       *Lf_865;
00366     float       *aer_model1;
00367     float       *aer_model2;
00368     float       *eps_flag;
00369     float       *Carder_chlor;
00370     float       *NDVI;
00371 } fl2_qc_dataType;
00372 typedef struct l2_qc_dataStruct {
00373     short       *zonal_wind;
00374     short       *merid_wind;
00375     byte        *pressure;
00376     byte        *p_water;
00377     short       *ozone;
00378     short       *solar_z;
00379     short       *albedo_865;
00380     short       *sensor_z;
00381     short       *sensor_a;
00382     short       *nLw_670;
00383     short       *La_765;
00384     short       *Lt_443;
00385     short       *Rayleigh_443;
00386     short       *Lg_865;
00387     short       *Lf_865;
00388     byte        *aer_model1;
00389     byte        *aer_model2;
00390     byte        *eps_flag;
00391     short       *Carder_chlor;
00392     short       *NDVI;
00393 } l2_qc_dataType;
00394 
00395 #endif /* L2_H_ */