|
ocssw
1.0
|
00001 //-*- Mode: C++; -*- 00002 00003 #ifndef hdf5_Aquarius_h 00004 #define hdf5_Aquarius_h 00005 00006 #include "hdf5.h" 00007 #define VOIDP void* 00008 00009 #define BLOCKS_PER_FRAME 4 00010 #define RADIOMETER_SUBCYCLES 12 00011 #define RADIOMETER_SIGNALS_PER_SUBCYCLE 5 00012 #define NUMBER_OF_BEAMS 3 00013 #define RADIOMETER_POLARIZATIONS 4 00014 #define RADIOMETER_LONG_ACCUM 8 00015 #define SCATTEROMETER_POLARIZATIONS 6 00016 #define SCATTEROMETER_SUBCYCLES 8 00017 00018 #define SCATTEROMETER_TLM_OFFSET 164 00019 #define SCATTEROMETER_SCI_OFFSET 201 00020 00021 #define RADIOMETER_SCI_OFFSET 537 00022 #define RADIOMETER_ACCUM_OFFSET 599 // 537+62 00023 00024 #define DPLY_TLM_OFFSET 12 00025 #define ICDS_STS_OFFSET 17 00026 #define ICDS_TLM_OFFSET 29 00027 #define EXTT_TLM_OFFSET 53 00028 #define APDU_TLM_OFFSET 123 00029 #define ATC_TLM_OFFSET 128 00030 #define ATC_TLM_SIZE 36 00031 00032 #define NUMCALTEMPS 85 00033 00034 // Pass/Cycle parameters 00035 // 2011-08-25T00:25:39.8 corresponds to 998267154.8 00036 00037 #define NORBITCYCLE 103 00038 #define FIRSTORBIT 1110 00039 #define FIRSTTIME 998267154.8 00040 00041 #define SWAP_2(x) ( (((x) & 0xff) << 8) | ((unsigned short)(x) >> 8) ) 00042 00043 #define SWAP_4(x) ( ((x) << 24) | \ 00044 (((x) << 8) & 0x00ff0000) | \ 00045 (((x) >> 8) & 0x0000ff00) | \ 00046 ((x) >> 24) ) 00047 00048 #define MAXSCAN 5200 00049 00050 #include <string> 00051 00052 #define MAXNAQPROD 200 00053 00054 enum { TAV, TAH, TA3, 00055 TFV, TFH, TF3, 00056 TAV0, TAH0, TA30, 00057 TFV0, TFH0, TF30, 00058 TOIV, TOIH, TOI3, 00059 TOAV, TOAH, 00060 FARTAH, 00061 TAGALDV, TAGALDH, TAGALD3, 00062 TAGALRV, TAGALRH, TAGALR3, 00063 TASUNDV, TASUNDH, TASUND3, 00064 TASUNRV, TASUNRH, TASUNR3, 00065 TASUNBV, TASUNBH, TASUNB3, 00066 TAMONRV, TAMONRH, TAMONR3, 00067 TBRAIN, 00068 TBV, TBH, TBVRC, TBHRC, 00069 TBVRCLC, TBHRCLC, 00070 TBVNORCLC, TBHNORCLC, 00071 TBCON, TBCONLC, 00072 SSS, SSSERR, SSSLC, SSSERRLC, 00073 TOAVLC, TOAHLC, HHWINDSPD, HHHWINDSPD, 00074 SRGHCORR, 00075 VVANT, HHANT, HVANT, VHANT, 00076 VVEXP, HHEXP, HVEXP, VHEXP, 00077 VVTOA, HHTOA, HVTOA, VHTOA, TOTTOA, 00078 VVKPCANT, HHKPCANT, HVKPCANT, VHKPCANT, 00079 VVKPCTOA, HHKPCTOA, HVKPCTOA, VHKPCTOA, TOTKPCTOA, 00080 SWINDUNC, 00081 SWINDSPD, ESURFV, ESURFH, ESURFVUNC, ESURFHUNC, 00082 AWINDSPD, AWINDDIR, ASURTEMP, ASURP, ACWAT, ASM, ASUBTEMP, 00083 ASWE, ASSS, AFLARE, 00084 ATRANS, ATBUP, ATBDW, 00085 RLANDFRC, RICEFRC, RGICE, SLANDFRC, SICEFRC, 00086 EXPTAV, EXPTAH, EXPTA3, EXPTBV, EXPTBH, EXPTBV0, EXPTBH0, VSM}; 00087 00088 #ifdef AQUARIUS_L2PROD_DEFINE 00089 std::string shortProdName[MAXNAQPROD] = 00090 {"rad_TaV", "rad_TaH", "rad_Ta3", 00091 "rad_TfV", "rad_TfH", "rad_Tf3", 00092 "rad_TaV0", "rad_TaH0", "rad_Ta30", 00093 "rad_TfV0", "rad_TfH0", "rad_Tf30", 00094 "rad_toi_V", "rad_toi_H", "rad_toi_3", 00095 "rad_toa_V_nolc", "rad_toa_H_nolc", 00096 "rad_far_TaH", 00097 "rad_galact_Ta_dir_V", "rad_galact_Ta_dir_H", "rad_galact_Ta_dir_3", 00098 "rad_galact_Ta_ref_V", "rad_galact_Ta_ref_H", "rad_galact_Ta_ref_3", 00099 "rad_solar_Ta_dir_V", "rad_solar_Ta_dir_H", "rad_solar_Ta_dir_3", 00100 "rad_solar_Ta_ref_V", "rad_solar_Ta_ref_H", "rad_solar_Ta_ref_3", 00101 "rad_solar_Ta_bak_V", "rad_solar_Ta_bak_H", "rad_solar_Ta_bak_3", 00102 "rad_moon_Ta_ref_V", "rad_moon_Ta_ref_H", "rad_moon_Ta_ref_3", 00103 "rad_rain_Tb", 00104 "rad_TbV_nolc", "rad_TbH_nolc", "rad_TbV_rc_nolc", "rad_TbH_rc_nolc", 00105 "rad_TbV_rc", "rad_TbH_rc", 00106 "rad_TbV", "rad_TbH", 00107 "rad_Tb_consistency_nolc", "rad_Tb_consistency", 00108 "SSS_nolc", "SSS_error_nolc", "SSS", "SSS_error", 00109 "rad_toa_V", "rad_toa_H", 00110 "rad_hh_wind_speed", "rad_hhh_wind_speed", 00111 "scat_rough_corr", 00112 "scat_VV_ant", "scat_HH_ant", "scat_HV_ant", "scat_VH_ant", 00113 "scat_VV_exp", "scat_HH_exp", "scat_HV_exp", "scat_VH_exp", 00114 "scat_VV_toa", "scat_HH_toa", "scat_HV_toa", "scat_VH_toa", 00115 "scat_tot_toa", 00116 "Kpc_VV_ant", "Kpc_HH_ant", "Kpc_HV_ant", "Kpc_VH_ant", 00117 "Kpc_VV_toa", "Kpc_HH_toa", "Kpc_HV_toa", "Kpc_VH_toa", 00118 "Kpc_total", 00119 "wind_uncertainty", 00120 "scat_wind_speed", "scat_esurf_V", "scat_esurf_H", 00121 "scat_esurf_V_uncertainty", "scat_esurf_H_uncertainty", 00122 "anc_wind_speed", "anc_wind_dir", "anc_surface_temp", 00123 "anc_surface_pressure", "anc_cwat", "anc_sm", "anc_subsurf_temp", 00124 "anc_swe", "anc_SSS", "anc_flare", 00125 "anc_trans", "anc_Tb_up", "anc_Tb_dw", 00126 "rad_land_frac", "rad_ice_frac", "rad_gice", 00127 "scat_land_frac", "scat_ice_frac", 00128 "rad_exp_TaV", "rad_exp_TaH", "rad_exp_Ta3", 00129 "rad_exp_TbV", "rad_exp_TbH", "rad_exp_TbV0", "rad_exp_TbH0", 00130 "rad_sm"}; 00131 #endif 00132 00133 #define MAXCYC 5000 // Compatibility with Wentz fortran arrays 00134 00135 // Gain/Offset structure 00136 typedef struct gain_off_temp_struct { 00137 float gvv[MAXCYC][NUMBER_OF_BEAMS]; 00138 float ghh[MAXCYC][NUMBER_OF_BEAMS]; 00139 float ov [MAXCYC][NUMBER_OF_BEAMS]; 00140 float oh [MAXCYC][NUMBER_OF_BEAMS]; 00141 float op [MAXCYC][NUMBER_OF_BEAMS]; 00142 float om [MAXCYC][NUMBER_OF_BEAMS]; 00143 float gpv[MAXCYC][NUMBER_OF_BEAMS]; 00144 float gph[MAXCYC][NUMBER_OF_BEAMS]; 00145 float gmv[MAXCYC][NUMBER_OF_BEAMS]; 00146 float gmh[MAXCYC][NUMBER_OF_BEAMS]; 00147 float gpp[MAXCYC][NUMBER_OF_BEAMS]; 00148 float gmm[MAXCYC][NUMBER_OF_BEAMS]; 00149 float gpU[MAXCYC][NUMBER_OF_BEAMS]; 00150 float gmU[MAXCYC][NUMBER_OF_BEAMS]; 00151 float hpU[MAXCYC][NUMBER_OF_BEAMS]; 00152 float hmU[MAXCYC][NUMBER_OF_BEAMS]; 00153 } gainoff; 00154 00155 float crs_dspl_temp_10( uint16_t tel_16); 00156 float crs_dspl_temp_12( uint16_t tel_16); 00157 float pls_dspl_temp_12( uint16_t tel_16); 00158 float mns_dspl_temp_12( uint16_t tel_16); 00159 float pls_dspl_ohms_12( uint16_t tel_16); 00160 float mns_dspl_ohms_12( uint16_t tel_16); 00161 float crs_dspl_ohms_12( uint16_t tel_16); 00162 00163 float fnep_ohms( float tel_16, float *extram); 00164 float fnen_ohms( float tel_16, float *extram); 00165 float finep_temp_12( uint16_t tel_16, float *extram, 00166 float const_a, float const_b, float const_r0); 00167 float finen_temp_12( uint16_t tel_16, float *extram, 00168 float const_a, float const_b, float const_r0); 00169 float coarse_temp_12( uint16_t tel_16, float *extram); 00170 float coarse_temp_10( uint16_t tel_16, float *extram); 00171 00172 float ie_volt( uint8_t tel_8); 00173 00174 float resist_16bit_norm_disp( uint16_t tel_16); 00175 float resist_16bit_ext_disp( uint16_t tel_16); 00176 00177 float temp_8bit_ext_fine( uint8_t tel_8, 00178 float const_a, float const_b, float const_r0); 00179 float temp_8bit_norm_fine( uint8_t tel_8, 00180 float const_a, float const_b, float const_r0); 00181 00182 float temp_8bit_ext( uint8_t tel_8); 00183 float temp_8bit_rad6k( uint8_t tel_8); 00184 float temp_8bit_norm( uint8_t tel_8); 00185 float temp_apdu_8bit( uint8_t tel_8, float const_ap); 00186 float temp_8bit_norm_abr0( uint8_t tel_8, 00187 float const_a, float const_b, float const_r0); 00188 float temp_8bit_ext_abr0( uint8_t tel_8, 00189 float const_a, float const_b, float const_r0); 00190 float temp_8bit_norm_scat( uint8_t tel_8, 00191 float const_a, float const_b, float const_r0); 00192 float temp_16bit_norm_disp( uint16_t tel_16, float gain, float offset, 00193 float const_a, float const_b, float const_r0); 00194 float temp_16bit_ext_disp( uint16_t tel_16, float gain, float offset, 00195 float const_a, float const_b, float const_r0, 00196 float const_h_r); 00197 float temp_16bit_norm_fine( uint16_t tel_16, uint16_t *extram_et, 00198 float const_a, float const_b, float const_r0); 00199 float temp_16bit_ext_fine( uint16_t tel_16, uint16_t *extram_et, 00200 float const_a, float const_b, float const_r0, 00201 float const_h_r); 00202 float temp_resist( float a, float b, float r0, float resist); 00203 float dwnlk_fltg_pt( uint16_t tel_16); 00204 uint16_t in32_out16( uint32_t i32, uint16_t nbits, uint16_t mask); 00205 00206 00207 namespace Hdf { 00208 00209 class hdf5_Aquarius { 00210 hid_t h5fid; 00211 hid_t grp0, grp1, grp2, grp3, grp4, grp5; 00212 uint32_t maxscan; 00213 int32_t blknum; 00214 uint8_t offset_corr; 00215 int32_t rad_frmnum; 00216 int32_t atc_frmnum; 00217 unsigned openFlags; 00218 int32_t nProd; 00219 00220 bool first_write; 00221 uint32_t first_icds_blknum; 00222 uint8_t first_atc_subframe; 00223 00224 double granuleStart; 00225 double granuleStop; 00226 double orbitStart; 00227 double orbitStop; 00228 int32_t orbitNumber; 00229 int32_t cycleNumber; 00230 int32_t passNumber; 00231 double nodeCrossingTime; 00232 float nodeLongitude; 00233 public: 00234 hdf5_Aquarius(); 00235 ~hdf5_Aquarius(); 00236 00237 int createl1( char* l1_filename, int32_t numBlocks, 00238 int32_t num_SACD_HKT, double granStart, 00239 char* inputFiles, char* processControl, 00240 char *softwareId); 00241 int writel1( char* ptr); 00242 int readl1_radiometer( int32_t blknum, int32_t frmnum, uint8_t subframe, 00243 double *blkSec, 00244 unsigned short *radiomHdr, 00245 unsigned short *radiomEar, 00246 unsigned short *radiomCnd, 00247 unsigned short *radiomCal); 00248 int readl1_frame_info( int32_t blknum, 00249 int32_t *atc_frmnum, uint8_t *atc_subframe, 00250 int32_t *rad_frmnum, uint8_t *rad_subframe); 00251 int writel1_frame_info( int32_t blknum, 00252 int32_t *atc_frmnum, uint8_t *atc_subframe, 00253 int32_t *rad_frmnum, uint8_t *rad_subframe); 00254 int readl1_icds_blknum( int32_t blknum, int32_t *icds_blknum); 00255 int readl1_dpu_status_tlm( int32_t rad_frmnum, int32_t rad_subframe, 00256 int32_t status_byte, uint8_t *dpu_status_tlm); 00257 int readl1_radiom_nrt_tlm( int32_t rad_frmnum, int32_t rad_subframe, 00258 int32_t status_byte, uint8_t *radiom_nrt_tlm); 00259 int closel1(); 00260 int closel1( double granuleStop); 00261 int closel1( double granuleStart, double granuleStop, 00262 double nodeCrossingTime, float nodeLongitude, 00263 int32_t *oplut_accum, float percent_non_default, 00264 int32_t missingBlks); 00265 int openl1( char* l1_filename, unsigned flags); 00266 int createl1_eph( int32_t numOrbVec); 00267 int writel1_eph( int32_t numOrbVec, double *time, 00268 double *pos, double *vel); 00269 int setOrbVec( int32_t numOrbVec); 00270 int createl1_att( int32_t numAttSamp); 00271 int writel1_att( int32_t numAttSamp, double *time, 00272 double *ang, double *quat, 00273 uint32_t *flags); 00274 int setAttSamp( int32_t numAttSamp); 00275 00276 int readl1_caltemps( int32_t blknum, int32_t frmnum, uint8_t subframe, 00277 float *caltemps); 00278 int readl1_eph( uint32_t *numOrbVec); 00279 int readl1_eph( double *time, double *pos, double *vel); 00280 00281 int readl1_att( uint32_t *numAttSamp); 00282 int readl1_att( double *time, double *ang, double *quat); 00283 00284 int readl1_hkt( uint32_t *numHktRec); 00285 int readl1_hkttme( uint32_t numHktRec, uint32_t *time); 00286 int readl1_hktacsmode( uint32_t numHktRec, uint8_t *acsmode); 00287 int writel1_hkt( uint32_t recnum, uint8_t *hktrec); 00288 00289 int createl2( char* l2_filename, int32_t numBlocks, 00290 int32_t nprod, int8_t *l2activeprodflag, 00291 double granStart, 00292 double nodeCrossingTime, float nodeLongitude, 00293 int32_t orbitNumber, int32_t cycleNumber, 00294 int32_t passNumber, 00295 char* inputFiles, char* processControl, 00296 char* processControlScat, 00297 char *softver, char *pversion, bool iopt_cal); 00298 00299 int createl2sm( char* l2_filename, int32_t numBlocks, 00300 char* starttime, char* endtime, 00301 double nodeCrossingTime, float nodeLongitude, 00302 int32_t orbitNumber, int32_t cycleNumber, 00303 int32_t passNumber, 00304 char* inputFiles, char* processControl, 00305 char *softver, char *pversion, char *ancillary_files, 00306 char *nominalNav, char *anomaly_status); 00307 00308 int openl2( char* l2_filename, unsigned flags, int32_t *numBlks, 00309 double *granstart, double *granstop); 00310 int writel2_nav( int32_t nBlks, bool *inout, 00311 double *pos, double *vel, 00312 double *ang, 00313 float *clat, float *clon, 00314 float *celtht, float *celphi, 00315 float *suntht, float *sunphi, 00316 float *sunglt, float *moonglt, 00317 float *glxlat, float *glxlon, 00318 float *cellatfoot, float *cellonfoot, 00319 double *sund, double *sunr, double *moond, 00320 double *zang, 00321 double *sclon, double *sclat, double *scalt, 00322 float *scat_clon, float *scat_clat, 00323 float *scat_elon, float *scat_elat, 00324 float *scat_polarization_roll, 00325 uint8_t *acsmode, 00326 bool browse, bool iopt_cal); 00327 int writel2_navsm( int32_t nBlks, float *clat, float *clon, 00328 double *zang, double *ang); 00329 int readl2_nav( float *beam_clat, float *beam_clon, double *zang); 00330 int readl2_nav( float *beam_clat, float *beam_clon, 00331 float *cellatfoot, float *cellonfoot); 00332 int readl2radflag( int32_t iblk, hid_t grp, VOIDP data); 00333 int readl2radflagsm( int32_t iblk, hid_t grp, VOIDP data); 00334 00335 int writel2( int32_t numBlocks, hid_t grp, char *prodName, VOIDP data); 00336 int writel2radflag( int32_t iblk, hid_t grp, VOIDP data); 00337 int writel2radflagsm( int32_t iblk, hid_t grp, VOIDP data); 00338 int writel2radrfi( int32_t iblk, hid_t grp, VOIDP data); 00339 int writel2scatrfi( int32_t iblk, hid_t grp, VOIDP data); 00340 int writel2samples( int32_t iblk, hid_t grp, 00341 char *prodName, VOIDP data); 00342 int writel2sec( int32_t iblk, hid_t grp, VOIDP data); 00343 int writeSolarXrayFlux( int32_t iblk, hid_t grp, VOIDP data); 00344 int writel2_caltemps( int32_t iblk, VOIDP data); 00345 int writel2_gainoff( int32_t iblk, gainoff *gainOff, bool iopt_cal); 00346 int readl2sec( int32_t iblk, hid_t grp, VOIDP data); 00347 int readl2( int32_t numBlocks, hid_t grp, char *prodName, VOIDP data); 00348 00349 int copyl1( int32_t recIdx, int32_t frmIdx, int32_t wrtIdx, 00350 hid_t grp[2], char *dsName); 00351 int closel2(); 00352 int closel2( double granuleStop, float percentWater, 00353 float percentRFI, float *solar_attr, 00354 std::string *rad_anc_files, std::string *scat_anc_files, 00355 std::string *rad_calfiles, std::string *rad_tables, 00356 char *anomaly_status, float *c_deltaTND, 00357 const char *radLimitsStr, const char *nominalNav, 00358 float *offset_corr); 00359 hid_t getH5fid(); 00360 int getH5gid( hid_t, hid_t*); 00361 uint32_t nBlks(); 00362 int incBlks(); 00363 int setFrameNums( int32_t out_rad_frmnum, int32_t out_atc_frmnum); 00364 int getGranuleTimes(double *granStart, double *granStop); 00365 int getOrbitTimes(double *orbStart, double *orbStop, int32_t *orbNumber, 00366 int32_t *cycNumber, int32_t *psNumber); 00367 int getNodeInfo(double *, float *); 00368 int writeOrbitTimes(hid_t grp, double orbStart, double orbStop); 00369 }; 00370 00371 } 00372 00373 #endif 00374
1.7.6.1