/*************************************************************************** * Copyright (C) 2005 by Nicolas PASCAL * * nicolas.pascal@icare.univ-lille1.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "parasolfilerecord.h" /**************************************************/ /******** LEADER FILE DESCRIPTOR RECORD *********/ /**************************************************/ void * LeaderFileDescriptorRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return ref_doc_id; // Reference Document Identification else if (entry_index==3) return ref_doc_version; // Reference Document Version Number else if (entry_index==4) return soft_version; // Software Version Number else if (entry_index==5) return file_nb; // File Number else if (entry_index==6) return filename; // File Name else if (entry_index==7) return &nb_header_rec; // Number of "Header" records in the file else if (entry_index==8) return &header_rec_len; // Length of the "Header" record else if (entry_index==9) return &nb_spatio_temp_char_rec; // Number of "Spatio-Temporal Characteristics" records in the file else if (entry_index==10) return &spatio_temp_char_rec_len; // Length of the "Spatio-Temporal Characteristics" record else if (entry_index==11) return &nb_instr_setting_param_rec; // Number of "Instrument setting parameters" records in the file else if (entry_index==12) return &instr_setting_param_rec_len; // Length of the "Instrument setting parameters" record else if (entry_index==13) return &nb_tech_param_rec; // Number of "Technological parameters" records in the file else if (entry_index==14) return &tech_param_rec_len; // Length of the "Technological parameters" record else if (entry_index==15) return &nb_data_proc_param_rec; // Number of "Data processing parameters" records in the file else if (entry_index==16) return &data_proc_param_rec_len; // Length of the "Data processing parameters" record else if (entry_index==17) return &nb_scaling_factor_rec; // Number of "Scaling factors" records in the file else if (entry_index==18) return &scaling_factor_rec_len; // Length of the "Scaling factors" record else if (entry_index==19) return &nb_annot_rec; // Number of "Annotation" records in the file else if (entry_index==20) return &annot_rec_len; // Length of the "Annotation" record else return (void*)(0); } const int LeaderFileDescriptorRecord::get_record_size( const Record & record ) { if (record==LEADER_FILE_DESCRIPTOR) return rec_len; else if (record==HEADER) return header_rec_len; else if (record==SPATIO_TEMPORAL_CHARACTERISTICS) return spatio_temp_char_rec_len; else if (record==INSTRUMENT_SETTING_PARAMETERS) return instr_setting_param_rec_len; else if (record==TECHNOLOGICAL_PARAMETERS) return tech_param_rec_len; else if (record==DATA_PROCESSING_PARAMETERS) return data_proc_param_rec_len; else if (record==SCALING_FACTORS) return scaling_factor_rec_len; else if (record==ANNOTATIONS) return annot_rec_len; else return 0; } const int DataFileDescriptorRecord::get_record_size( const Record & record ) { if (record==DATA_FILE_DESCRIPTOR) return rec_len; else if (record==DATA) return nb_data_rec*one_data_rec_len; else return 0; } void * HeaderRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return phone_nb; // Information Point Phone Number else if (entry_index==3) return product_id; // Product Identification else if (entry_index==4) return sat_id; // Satellite identificator else if (entry_index==5) return instr_id; // Instrument identificator else if (entry_index==6) return spatial_cover; // Spatial Coverage else if (entry_index==7) return pix_size; // Pixel size of the POLDER/Parasol grid else if (entry_index==8) return ellips_name; // Name of the ellipsoid used for the data registration else if (entry_index==9) return ellips_minor_axis_len; // Length of the ellipsoid minor axis else if (entry_index==10) return ellips_major_axis_len; // Length of the ellipsoid major axis else if (entry_index==11) return DEM_name; // Name of the DEM used for the data registration else if (entry_index==12) return DEM_spatial_res_lat; // Spatial resolution of the DEM along the latitudes else if (entry_index==13) return DEM_spatial_res_lon; // Spatial resolution of the DEM along the longitudes else return (void*)(0); } void * SpatioTemporalCharacteristicsRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return cycle_nb; // Cycle number else if (entry_index==3) return orbit_nb; // Orbit Number in the cycle else if (entry_index==4) return subsat_track_nb; // Sub satellite track number else if (entry_index==5) return desc_node_lon; // Descending Node Longitude else if (entry_index==6) return desc_node_date; // Descending Node date else if (entry_index==7) return first_acq_date; // Date first acquisition else if (entry_index==8) return last_acq_date; // Date last acquisition else if (entry_index==9) return nb_seq; // Number of sequences else if (entry_index==10) return line_nb_northern_pix; // Line number of northern most pixel else if (entry_index==11) return line_nb_southern_pix; // Line number of southern most pixel else return (void*)(0); } void * InstrumentSettingParametersRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return SIA_duration; // SIA duration else if (entry_index==3) return LIA_duration; // LIA duration else if (entry_index==4) return integration_time_def_type_A; // Integration Time Definition for sequence type A else if (entry_index==5) return integration_time_def_type_B; // Integration Time Definition for sequence type B else if (entry_index==6) return &seq_type; // Sequence Type else if (entry_index==7) return analog_gain_nb; // Analogic Gain Number else return (void*)(0); } void * DataProcessingParametersRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return l0_creation_country; // Level-0 creation country else if (entry_index==3) return l0_creation_agency; // Level-0 creation agency else if (entry_index==4) return l0_creation_facility; // Level-0 creation facility else if (entry_index==5) return l0_creation_date; // Level-0 creation date else if (entry_index==6) return l0_process_soft_version; // Level-0 processing software version else if (entry_index==7) return l1_creation_country; // Level-1 creation country else if (entry_index==8) return l1_creation_agency; // Level-1 creation agency else if (entry_index==9) return l1_creation_facility; // Level-1 creation facility else if (entry_index==10) return l1_creation_date; // Level-1 creation date else if (entry_index==11) return l1_process_soft_version; // Level-1 processing software version else if (entry_index==12) return l0_input_parasol_data_id; // Identificator of level-0 Input PARASOL data else if (entry_index==13) return calib_data_version; // Version of data used for Calibration else if (entry_index==14) return calib_creation_date; // Date of Calibration File Creation else if (entry_index==15) return calib_applic_date; // Date of Begining of Calibration Applicability else if (entry_index==16) return geo_process_data_version; // Version of data for Geometric Processing else if (entry_index==17) return geo_file_creation_date; // Date of Geometric File Creation else if (entry_index==18) return geo_applic_date; // Date of Begining of Geometric Applicability else if (entry_index==19) return &product_confidence; // Product Confidence Data else if (entry_index==20) return l2_creation_country; // Level-2 creation country else if (entry_index==21) return l2_creation_agency; // Level-2 creation agency else if (entry_index==22) return l2_creation_facility; // Level-2 creation facility else if (entry_index==23) return l2_creation_date; // Level-2 creation date else if (entry_index==24) return process_line_id; // Processing Line Identification else if (entry_index==25) return product_them_id; // Product Thematic identification else if (entry_index==26) return l2_process_soft_version; // Level-2 processing software version else if (entry_index==27) return l1_input_parasol_data_id; // Identificator of level-1 Input PARASOL data else if (entry_index==28) return l3_input_parasol_data_num1_id; // Identificator of 1st level-3 Input PARASOL data else if (entry_index==29) return l3_input_parasol_data_num2_id; // Identificator of 2nd level-3 Input PARASOL data else if (entry_index==30) return l3_input_parasol_data_num3_id; // Identificator of 3rd level-3 Input PARASOL data else if (entry_index==31) return input_meteo_data_num1_id; // Identificator of 1st input Meteo data else if (entry_index==32) return input_meteo_data_num2_id; // Identificator of 2nd input Meteo data else if (entry_index==33) return input_meteo_data_num3_id; // Identificator of 3rd input Meteo data else if (entry_index==34) return input_TOMS_data_num1_id; // Identificator of 1st input TOMS data else if (entry_index==35) return input_TOMS_data_num2_id; // Identificator of 2nd input TOMS data else if (entry_index==36) return &product_confidence_intern; // Product Confidence Data (internal use) else return (void*)(0); } void * ScalingFactorsRecord::get_entry(const int& entry_index, const vector< int > v_ival) { int i_param = -1; if (v_ival.size() > 0) i_param = v_ival[0]; if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return interleave_id; // Interleaving indicator else if (entry_index==3) return byte_order; // Byte ordering standard else if (entry_index==4) return nb_pix_param; // Nb parameters per pixel else if (entry_index==5) return nb_pix_bytes; // Nb bytes per pixel else if (entry_index==6) return nb_bytes[i_param]; // the number of bytes of each parameter else if (entry_index==7) return slope[i_param]; // the scaling slope of each parameter else if (entry_index==8) return offset[i_param]; // the scaling offset of each parameter else return (void*)(0); } void * AnnotationsRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return l2_dummy_data_percent; // % of Dummy data in level-2 product else if (entry_index==3) return l2_non_significant_data_percent; // % of non significant data in level-2 product else if (entry_index==4) return l2_land_pix_percent; // % of Land pixels in level-2 product else if (entry_index==5) return l2_ocean_pix_percent; // % of Ocean pixels in level-2 product else if (entry_index==6) return l2_coast_pix_percent; // % of Coast pixels in level-2 product else if (entry_index==7) return &cloudy_pix_percent_per_lat_band; // % of cloudy pixels for 10� latitude band # else if (entry_index==8) return nb_non_empty_grid_line; // Nb grid lines with at least one pixel else if (entry_index==9) return &nb_pix_per_line; // Nb pixel for line # else return (void*)(0); } void * TechnologicalParametersRecord::get_entry(const int& entry_index, const vector< int > v_ival) { int i_seq = -1; if (v_ival.size() > 0) i_seq = v_ival[0]; int i_img = -1; if (v_ival.size() > 1) i_img = v_ival[1]; switch (entry_index) { case 0 : return &rec_len; case 1 : return &rec_nb; case 2 : return seq_nb; case 3 : return intern_lens_temp; case 4 : return extern_lens_temp; case 5 : return short_acq_time_duration; case 6 : return long_acq_time_duration; // sequential group entries case 7 : return img_nb [i_seq][i_img]; case 8 : return time_acq [i_seq][i_img]; case 9 : return x_sat [i_seq][i_img]; case 10 : return y_sat [i_seq][i_img]; case 11 : return z_sat [i_seq][i_img]; case 12 : return vx_sat [i_seq][i_img]; case 13 : return vy_sat [i_seq][i_img]; case 14 : return vz_sat [i_seq][i_img]; case 15 : return yaw_sat [i_seq][i_img]; case 16 : return pitch_sat [i_seq][i_img]; case 17 : return roll_sat [i_seq][i_img]; default : string msg ( "Invalid entry index " + MyTools::to_string(entry_index) ) ; g_exception e( __FILE__ , __LINE__ , msg ); throw e; break; } } void * DataFileDescriptorRecord::get_entry(const int& entry_index, const vector< int > v_ival) { if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return ref_doc_id; // Reference Document Identification else if (entry_index==3) return ref_doc_version; // Reference Document Version Number else if (entry_index==4) return soft_version; // Software Version Number else if (entry_index==5) return file_nb; // File Number else if (entry_index==6) return filename; // File Name else if (entry_index==7) return &nb_data_rec; // Number of "Data" records in the file else if (entry_index==8) return &one_data_rec_len; // Length of one "Data" record else if (entry_index==9) return &data_rec_prefix_len; // Length of the Prefix in the Record Data else if (entry_index==10) return &data_rec_data_len; // Length of the Datas in the Record Data else if (entry_index==11) return &data_rec_suffix_len; // Length of the Suffix in the Record Data else return (void*)(0); } void * RB2_DataRecord::get_entry(const int& entry_index, const vector< int > v_ival) { // direction number for directionnal parameters. Also used as pressure level indice for temperature and water vapor data int i_dir = -1; if (v_ival.size() > 0) i_dir = v_ival[0]; if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return &line_nb; else if (entry_index==3) return &col_nb; else if (entry_index==4) return &mean_alt; else if (entry_index==5) return &land_percent; else if (entry_index==6) return &dsqtrait; else if (entry_index==7) return &obs_time_hr; // Observation UTC time (hours) else if (entry_index==8) return &obs_time_min; // Observation UTC time (min) else if (entry_index==9) return &nb_view_dir; // Nb Viewing Directions else if (entry_index==10) return &nb_Pray_dir; // Nb Directions for Pray Estimation else if (entry_index==11) return &minmax_glint_dir; // First and Last directions contamined by glint else if (entry_index==12) return &solar_zenith_angle_cos; // Cosine of Solar Zenith angle else if (entry_index==13) return &mean_albedo; // Mean Albedo at 670/865 nm else if (entry_index==14) return &spatial_stddev_albedo; // Relative spatial std dev of the albedos else if (entry_index==15) return &angular_stddev_albedo; // Relative angular std dev of the albedos else if (entry_index==16) return &albedo_QI; // Albedo Quality Index else if (entry_index==17) return &scene_albedo; // Scene Albedo else if (entry_index==18) return &angular_stddev_scene_albedo; // Relative Angular std dev of the Scene Albedo else if (entry_index==19) return &clear_albedo; // Clear Albedo at 670/865 nm else if (entry_index==20) return &sw_albedo; // Shortwave Albedo else if (entry_index==21) return &clear_sw_albedo; // Clear Shortwave Albedo else if (entry_index==22) return &cloud_cover; // Cloud Cover else if (entry_index==23) return &indet2clear_pix_fraction; // Fraction of Pix firstly indetermined Finally Clear/cloudy else if (entry_index==24) return &cloud_cover_QI; // Cloud Cover Quality Index else if (entry_index==25) return &water_vapor_column; // Water Vapor Column else if (entry_index==26) return &water_vapor_stddev; // Water Vapor Standard Deviation else if (entry_index==27) return &mean_po2; // Mean Cloud oxygen pressure else if (entry_index==28) return &angular_stddev_po2; // Cloud oxygen pressure angular Standard Deviation else if (entry_index==29) return &mean_pray; // Mean Cloud Rayleigh pressure else if (entry_index==30) return &angular_stddev_pray; // Cloud Rayleigh pressure angular Standard Deviation else if (entry_index==31) return &opt_th; // Cloud Optical Thickness (Linear Mean) else if (entry_index==32) return &stddev_opt_th; // Relative Std Dev of Optical Thickness else if (entry_index==33) return &homogeneity_coef_opt_th; // Homogeneity Coef of Optical Thickness else if (entry_index==34) return &sperical_albedo; // Cloud Spherical Albedo at 670/865 nm else if (entry_index==35) return &cloud_phase; // Cloud Phase else if (entry_index==36) return &ice_shape_idx; // Ice Crystal Shape Index else if (entry_index==37) return &strato_aero_opt_th; // Stratospheric Aerosol Optical Thickness else if (entry_index==38) return &ozone_total_column; // Ozone Total Column else if (entry_index==39) return &surf_wind_speed; // Surface Wind Speed else if (entry_index==40) return &surf_wind_dir; // Surface Wind Direction else if (entry_index==41) return &surf_pressure; // Surface Pressure else if (entry_index==42) return &temp_prof[i_dir]; // Temperature Profile : for each pressure level else if (entry_index==43) return &water_vapor_prof[i_dir]; // Water Vapor Profile // directionnal parametres group else if (entry_index==44) return &view_zenith_angle[i_dir]; // View Zenith Angle else if (entry_index==45) return &azimuth_angle[i_dir]; // Relative Azimuth Angle else if (entry_index==46) return &reflectance[i_dir]; // Reflectance Corrected for gas Absorption else if (entry_index==47) return &narrow_albedo[i_dir]; // Narrowband Albedo else if (entry_index==48) return &dir_sw_reflectance[i_dir]; // Shortwave Reflectance else if (entry_index==49) return &dir_sw_albedo[i_dir]; // Shortwave Albedo else if (entry_index==50) return &polar_radiance[i_dir]; // Polarized Radiance at 865 nm else if (entry_index==51) return &clear_cloudy_pix_fraction[i_dir]; // Clear/CLoudy Pix Fraction else if (entry_index==52) return &dir_cloud_cover[i_dir]; // Directional Cloud Cover else if (entry_index==53) return &dir_spherical_albedo[i_dir]; // Directional Cloud Spherical Albedo at 670/865 nm else return (void*)(0); } void * BASIC_1_DataRecord::get_entry(const int& entry_index, const vector< int > v_ival) { // direction number for directionnal parameters. Also used as pressure level indice for temperature and water vapor data int i_dir = -1; if (v_ival.size() > 0) i_dir = v_ival[0]; if (entry_index==0) return &rec_nb; // Record Number in the file else if (entry_index==1) return &rec_len; // Length of this record else if (entry_index==2) return &line_nb; // Pixel line Number else if (entry_index==3) return &col_nb; // Pixel Column Number else if (entry_index==4) return &alt; // Pixel altitude else if (entry_index==5) return &land_percent; // surface tpe indicator : 100->land, 0->Water, 50->Mixed else if (entry_index==6) return &dqx; // Pixel Quality Index else if (entry_index==7) return &rough_cloud_ind; // Rough Cloud Indicator (0:clear, 100:cloudy, 50:undetermined) else if (entry_index==8) return &phis; // Solar Azimuth Angle else if (entry_index==9) return ∋ // Number of available viewing directions else if (entry_index==10) return &seq_arrang; // Sequence Arrangement Indicator // directionnal group entries else if (entry_index==11) return &seq_nb[i_dir]; // Sequence Number else if (entry_index==12) return &ccd_lin[i_dir]; // Line number of the CCD matrix detector which has observed the pixel for filter 670P2 else if (entry_index==13) return &ccd_col[i_dir]; // Column number of the CCD matrix detector which has observed the pixel for filter 670P2 else if (entry_index==14) return &thetas[i_dir]; // Solar Zenith Angle else if (entry_index==15) return &thetav[i_dir]; // View Zenith Angle for filter 670P2 else if (entry_index==16) return &phi[i_dir]; // Relative Azimuth Angle for filter 670P2 else if (entry_index==17) return &delta_thetav_cosphi[i_dir]; // Delta(Thetav.cos(phi)) : relative variation of viewing geometry between the filters else if (entry_index==18) return &delta_thetav_sinphi[i_dir]; // Delta(Thetav.sin(phi)) : relative variation of viewing geometry between the filters else if (entry_index==19) return &rad443NP[i_dir]; // Normalized radiance for channel 443NP else if (entry_index==20) return &rad490P[i_dir]; // Normalized radiance for channel 490P else if (entry_index==21) return &rad1020NP[i_dir]; // Normalized radiance for channel 1020NP else if (entry_index==22) return &rad565NP[i_dir]; // Normalized radiance for channel 565NP else if (entry_index==23) return &rad670P[i_dir]; // Normalized radiance for channel 670P else if (entry_index==24) return &rad763NP[i_dir]; // Normalized radiance for channel 763NP else if (entry_index==25) return &rad765NP[i_dir]; // Normalized radiance for channel 765NP else if (entry_index==26) return &rad865P[i_dir]; // Normalized radiance for channel 865NP else if (entry_index==27) return &rad910NP[i_dir]; // Normalized radiance for channel 910NP else if (entry_index==28) return &Q490P[i_dir]; // Second component of Stokes Vector (Q) for channel 490P else if (entry_index==29) return &Q670P[i_dir]; // Second component of Stokes Vector (Q) for channel 670P else if (entry_index==30) return &Q865P[i_dir]; // Second component of Stokes Vector (Q) for channel 865P else if (entry_index==31) return &U490P[i_dir]; // Second component of Stokes Vector (Q) for channel 490P else if (entry_index==32) return &U670P[i_dir]; // Second component of Stokes Vector (Q) for channel 670P else if (entry_index==33) return &U865P[i_dir]; // Second component of Stokes Vector (Q) for channel 865P else return (void*)(0); } void TechnologicalParametersRecord::get_xyz_sat(double * v_x_sat, double * v_y_sat, double * v_z_sat) { int ibuf = 0; char * pEnd; for (int sn = 0 ; sn < NB_MAX_PARASOL_SEQUENCE ; ++sn) { ibuf = sn * NB_MAX_PARASOL_IMAGE_PER_SEQUENCE; for (int i_img = 0 ; i_img < NB_MAX_PARASOL_IMAGE_PER_SEQUENCE ; ++i_img) { v_x_sat[ibuf] = strtod (x_sat [sn][i_img], &pEnd) * 1e3; // km -> m v_y_sat[ibuf] = strtod (y_sat [sn][i_img], &pEnd) * 1e3; // km -> m v_z_sat[ibuf] = strtod (z_sat [sn][i_img], &pEnd) * 1e3; // km -> m // cout << "[" << sn << "," << i_img << "]" << endl; // cout << "\tstr -> " << x_sat [sn][i_img] << " " << y_sat [sn][i_img] << " " << z_sat [sn][i_img] << endl; // cout << "\tnum -> " << v_x_sat[ibuf] << " " << v_y_sat[ibuf] << " " << v_z_sat[ibuf] << endl; ++ibuf; } } }