// // C++ Implementation: test_caliop_l1_filedata // // Description: // // // Author: Nicolas PASCAL , (C) 2012 // // Copyright: See COPYING file that comes with this distribution // // History: // // #include "caliopfiledata.h" #include "viewing_geometry.h" int main(int argc, char *argv[]) { string fname("/DATA/LIENS/CALIOP/CAL_LID_L1/2009/2009_01_01/CAL_LID_L1-ValStage1-V3-01.2009-01-01T05-50-48ZD.hdf"); CALIOPFileData fd(fname); /* read geolocation data */ fd.load_geolocation_data(); float32 * v_lat = fd.get_lat_data(); float32 * v_lon = fd.get_lon_data(); float32 * v_alt = (float32 *)(fd.read_data (NULL, "Surface_Elevation")); // km /* load earth to sat viewing geometry datasets */ float32 * v_vza = (float32 *)(fd.read_data (NULL, "Viewing_Zenith_Angle")); // degrees float32 * v_vaa = (float32 *)(fd.read_data (NULL, "Viewing_Azimuth_Angle")); // degrees float32 * v_alt_sat = (float32 *)(fd.read_data (NULL, "Spacecraft_Altitude")); // km /* compute satellite position from viewing angles */ int nrec = fd.get_nb_geo_points(); // km -> m unit conversions transform (v_alt, v_alt + nrec, v_alt, bind2nd(multiplies(), 1000.)); transform (v_alt_sat, v_alt_sat + nrec, v_alt_sat, bind2nd(multiplies(), 1000.)); Geodetic::Point3D p_earth; // earth observer position (ECR lat, lon, alt coords) Carthesian::Point3D p_sat; // satellite position (ECR Carthesian coords) for (int irec = 0 ; irec < nrec ; ++irec) { p_earth.set (v_lat[irec], v_lon[irec], v_alt[irec]); Viewing::earth_to_sat_from_alt(p_earth, v_vza[irec], v_vaa[irec], v_alt_sat[irec], p_sat); // printf("%d\t%f\t%f\t%f\n", irec, p_sat.x, p_sat.y, p_sat.z); } /* --- check pixels viewing directions --- */ cout << "--- check pixels viewing directions ---" << endl; vector v_ipix(1); vector v_obs; fd.load_viewing_directions_data(); v_ipix [0] = 0; fd.get_viewing_directions(v_ipix, v_obs); for (vector ::iterator it_obs = v_obs.begin() ; it_obs != v_obs.end() ; ++it_obs) { cout << *it_obs << endl; cout << "Geodetic " << it_obs->viewing.get_p1().to_geodetic() << " -> " << it_obs->viewing.get_p2().to_geodetic() << endl; } fd.free_viewing_directions_data(); /* free allocations */ fd.free_geolocation_data(); delete[] v_alt, v_alt = NULL; delete[] v_vza, v_vza = NULL; delete[] v_vaa, v_vaa = NULL; delete[] v_alt_sat, v_alt_sat = NULL; return 0; }