//----------------------------------------------------------------------------------------- // Function: read_fov_file (string fovfile) // // Reads the FOV data file. // // Input: // file.....the complete path + name of the FOV data file // // Notes: // The FOV file format is 5 header lines, then a matrix (# of bands+1, # elevation angles), // where each row is: elevation angle, then FOV response for bands 1-nband // // Source: Mark Hervig, GATS //----------------------------------------------------------------------------------------- #include "sofiefov.h" #include "fortranfunctions.h" #include #include #include #include void sofiefov::read_fov_file (const std::string& fovfile, int* reverse) { fov_response.resize(16); /* THis function is expecting to read a file with the following convention. + elevations values mean towards the ground - elevation angles are toward space */ char header[512]; // for header lines in the file std::ifstream inputFile; //the input file inputFile.open(fovfile.c_str(), std::ios_base::in); // open the file inputFile.getline(header,511); // read a header line inputFile.getline(header,511); inputFile >> nel; // read the number of elevation angles inputFile.getline(header,511); inputFile >> nband; // read the number of bands inputFile.getline(header,511); inputFile.getline(header,511); std::cout << nel << " elevation angles and " << nband << " bands" << std::endl; double temp_sc; for (int i = 0; i < nel; i++) { // loop over elevation // temp_ar.clear(); // if (j == 0) { // the elevation inputFile >> temp_sc; elevation.push_back(temp_sc); // std::cout << temp_sc; // } for (int j = 0; j < nband; j++) { // loop over bands // if (j > 0) { // the FOV response data inputFile >> temp_sc; fov_response[j].push_back(temp_sc); // std::cout << " " << temp_sc; // } } // fov_response.push_back(temp_ar); // std::cout << std::endl; } inputFile.close(); /* file sofie_fov_elevation_V1.3.txt has + angles toward space - toward ground we reverse that here so positive is toward ground and - is toward space */ if(*reverse != 0) { std::reverse(elevation.begin(),elevation.end() ); std::transform(elevation.begin(), elevation.end(), elevation.begin(),std::negate() ); for (int j = 0; j < nband; j++) { // loop over bands std::reverse(fov_response[j].begin(), fov_response[j].end()) ; } std::cout << " reversed FOV arrays " << std::endl; } } std::vector sofiefov::get_fov_elev(const int band) { assert(band > 0 && band <= 16); return elevation; } std::vector sofiefov::get_fov_response(const int band) { assert(band > 0 && band <= 16); return fov_response.at(band-1); }