⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msg_data_radiometricproc.cpp

📁 HRIT读取,用于在LINUX下显示高束数据图像
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------////  File        : MSG_data_RadiometricProc.cpp//  Description : MSG HRIT-LRIT format interface//  Project     : Meteosatlib//  Author      : Graziano Giuliani//  References  : MSG/SPE/057 LRIT-HRIT Mission Specific Implementation,//                V. 4.1 9 Mar 2001////  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 <fstream>#include <cstring>#include <iomanip>#include <cmath>#include <MSG_data_RadiometricProc.h>std::string MSG_image_quality_flag(t_enum_MSG_image_quality_flag iqf){  std::string v;  switch (iqf)  {    case MSG_IMPF_CAL_OK:      v = "IMPF Calibration OK";      break;    case MSG_IMPF_CAL_DUBIOUS:      v = "IMPF Calibration Dubious";      break;    case MSH_IMPF_CAL_USE_MPEF_CAL:      v = "Use MPEF calibration";      break;    default:      v = "Unknown";      break;  }  return v;}std::string MSG_reference_data_flag(t_enum_MSG_reference_data_flag rd){  std::string v;  switch (rd)  {    case MSG_REFERENCE_DATA_NOT_CALCULATED:      v = "Not calculated";      break;    case MSG_REFERENCE_DATA_MET_DATA:      v = "Meteorological data";      break;    case MSG_REFERENCE_DATA_FSD:      v = "Foreign satellite data";      break;    case MSG_REFERENCE_DATA_MIXED_MET_FSD:      v = "Both meteo and foreign satellite";      break;    default:      v = "Unknown";      break;  }  return v;}std::string MSG_absolute_calibration_method(                          t_enum_MSG_absolute_calibration_method acm){  std::string v;  switch (acm)  {    case MSG_ABSOLUTE_CALIBRATION_NOT_CHANGED:      v = "Not changed";      break;    case MSG_ABSOLUTE_CALIBRATION_EXTERNAL:      v = "External";      break;    case MSG_ABSOLUTE_CALIBRATION_VICARIOUS:      v = "Vicarious";      break;    case MSG_ABSOLUTE_CALIBRATION_CROSS_SATELLITE:      v = "Cross satellite";      break;    case MSG_ABSOLUTE_CALIBRATION_MIXED_VIC_XSAT:      v = "Mixed vicarious and cross satellite";      break;    default:      v = "Unknown";      break;  }  return v;}size_t MSG_Image_Calibration::read_from( unsigned const char_1 *buff ){  Cal_Slope  = get_r8(buff);  Cal_Offset = get_r8(buff+8);  return 16;}std::ostream& operator<< ( std::ostream& os, MSG_Image_Calibration &c ){  os << "Calibration Slope   : " << c.Cal_Slope << std::endl     << "Calibration Offset  : " << c.Cal_Offset << std::endl;  return os;}size_t MSG_ExtractedBBData::read_from( unsigned const char_1 *buff ){  NumberOfPixelsUsed   = get_ui4(buff);  MeanCount            = get_r4(buff+4);  RMS                  = get_r4(buff+8);  MaxCount             = get_ui2(buff+12);  MinCount             = get_ui2(buff+14);  BB_Processing_Slope  = get_r8(buff+16);  BB_Processing_Offset = get_r8(buff+24);  return 32;}std::ostream& operator<< ( std::ostream& os, MSG_ExtractedBBData &b ){  os << "Number of Pix. Used : " << b.NumberOfPixelsUsed << std::endl     << "Mean Count          : " << b.MeanCount << std::endl     << "RMS                 : " << b.RMS << std::endl     << "Max Count           : " << b.MaxCount << std::endl     << "Min Count           : " << b.MinCount << std::endl     << "Processing Slope    : " << b.BB_Processing_Slope << std::endl     << "Processing Offset   : " << b.BB_Processing_Offset << std::endl;  return os;}size_t MSG_IMPF_CAL_Data::read_from( unsigned const char_1 *buff ){  ImageQualityFlag = (t_enum_MSG_image_quality_flag) *(buff);  ReferenceDataFlag = (t_enum_MSG_reference_data_flag) *(buff+1);  AbsCalMethod = (t_enum_MSG_absolute_calibration_method) *(buff+2);  // skip 1 byte;  AbsCalWeightVic = get_r4(buff+4);  AbsCalWeightXsat = get_r4(buff+8);  AbsCalCoeff = get_r4(buff+12);  AbsCalError = get_r4(buff+16);  CalMonBias = get_r4(buff+20);  CalMonRms = get_r4(buff+24);  OffsetCount = get_r4(buff+28);  return 32;}size_t MSG_RPSummary::read_from( unsigned const char_1 *buff ){  for (int i = 0; i < 12; i ++)    RadianceLinearization[i] = *(buff+i) ? true : false;  for (int i = 0; i < 12; i ++)    DetectorEqualization[i] = *(buff+12+i) ? true : false;  for (int i = 0; i < 12; i ++)    OnboardCalibrationResult[i] = *(buff+24+i) ? true : false;  for (int i = 0; i < 12; i ++)    MPEFCalFeedBack[i] = *(buff+36+i) ? true : false;  for (int i = 0; i < 12; i ++)    MTFAdaptation[i] = *(buff+48+i) ? true : false;  for (int i = 0; i < 12; i ++)    StraylightCorrectionFlag[i] = *(buff+60+i) ? true : false;  return 72;}std::ostream& operator<< ( std::ostream& os, MSG_RPSummary &s ){  os << "Radiance Lin.       : ";  for (int i = 0; i < 12; i ++)    os << s.RadianceLinearization[i] << " ";  os << std::endl     << "Detector Eq.        : ";  for (int i = 0; i < 12; i ++)    os << s.DetectorEqualization[i] << " ";  os << std::endl     << "OnBoard Cal. Result : ";  for (int i = 0; i < 12; i ++)    os << s.OnboardCalibrationResult[i] << " ";  os << std::endl     << "MPEF Cal. Feedback  : ";  for (int i = 0; i < 12; i ++)    os << s.MPEFCalFeedBack[i] << " ";  os << std::endl     << "MTF Adaptation      : ";  for (int i = 0; i < 12; i ++)    os << s.MTFAdaptation[i] << " ";  os << std::endl     << "Straylight Correct. : ";  for (int i = 0; i < 12; i ++)    os << s.StraylightCorrectionFlag[i] << " ";  return os;}size_t MSG_RadProcMTFAdaptation::read_from( unsigned const char_1 *buff ){  size_t position = 0;  for (int i = 0; i < 33; i ++)    for (int j = 0; j < 16; j ++)      VIS_IRMTFCorrectionE_W[i][j] = get_r4(buff+position+i*64+j*4);  position += 33*16*4;  for (int i = 0; i < 33; i ++)    for (int j = 0; j < 16; j ++)      VIS_IRMTFCorrectionN_S[i][j] = get_r4(buff+position+i*64+j*4);  position += 33*16*4;  for (int i = 0; i < 9; i ++)    for (int j = 0; j < 16; j ++)      HRVIRMTFCorrectionE_W[i][j] = get_r4(buff+position+i*64+j*4);  position += 9*16*4;  for (int i = 0; i < 9; i ++)    for (int j = 0; j < 16; j ++)      HRVIRMTFCorrectionN_S[i][j] = get_r4(buff+position+i*64+j*4);  position += 9*16*4;  return position;}std::ostream& operator<< (std::ostream& os, MSG_RadProcMTFAdaptation &f){  for (int i = 0; i < 33; i ++)  {    os << "VIS IR MTF E/W " << std::setw(2) << std::setfill('0') << i+1       << "   : " << std::endl;    for(int j = 0; j < 16; j += 4)    {      os << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionE_W[i][j]   << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionE_W[i][j+1] << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionE_W[i][j+2] << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionE_W[i][j+3]         << std::endl;    }   }  for (int i = 0; i < 33; i ++)  {    os << "VIS IR MTF N/S " << std::setw(2) << std::setfill('0') << i+1       << "   : " << std::endl;    for(int j = 0; j < 16; j += 4)    {      os << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionN_S[i][j]   << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionN_S[i][j+1] << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionN_S[i][j+2] << " "         << std::setw(12) << std::setfill(' ')         << f.VIS_IRMTFCorrectionN_S[i][j+3]         << std::endl;    }   }  for (int i = 0; i < 9; i ++)  {    os << "HRV MTF E/W " << std::setw(2) << std::setfill('0') << i+1       << "      : " << std::endl;    for(int j = 0; j < 16; j += 4)    {      os << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionE_W[i][j]   << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionE_W[i][j+1] << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionE_W[i][j+2] << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionE_W[i][j+3]         << std::endl;    }   }  for (int i = 0; i < 9; i ++)  {    os << "HRV MTF N/S " << std::setw(2) << std::setfill('0') << i+1       << "      : " << std::endl;    for(int j = 0; j < 16; j += 4)    {      os << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionN_S[i][j]   << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionN_S[i][j+1] << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionN_S[i][j+2] << " "         << std::setw(12) << std::setfill(' ')         << f.HRVIRMTFCorrectionN_S[i][j+3]         << std::endl;    }   }  return os;}size_t MSG_MPEFCalFeedback::read_from( unsigned const char_1 *buff ){  size_t position = 0;  for (int i = 0; i < 12; i ++)    position += IMPF_CAL_Data[i].read_from(buff+position);  return position;}std::ostream& operator<< (std::ostream& os, MSG_MPEFCalFeedback &f){  for (int i = 0; i < 12; i ++)    os << "CHANNEL " << std::setw(2) << std::setfill('0') << i+1 << std::endl       << f.IMPF_CAL_Data[i];  return os;}std::ostream& operator<< ( std::ostream& os, MSG_IMPF_CAL_Data &b ){  os << "Image Quality       : " << MSG_image_quality_flag(b.ImageQualityFlag)     << std::endl     << "Reference data      : " << MSG_reference_data_flag(b.ReferenceDataFlag)     << std::endl     << "Absolute Cal. Meth. : "     << MSG_absolute_calibration_method(b.AbsCalMethod) << std::endl     << "Abs Cal Weight Vic. : " << b.AbsCalWeightVic << std::endl     << "Abs Cal Weight Xsat.: " << b.AbsCalWeightXsat << std::endl     << "Abs Cal Coefficient : " << b.AbsCalCoeff << std::endl     << "Abs Cal Error       : " << b.AbsCalError << std::endl     << "Cal Mon Bias        : " << b.CalMonBias << std::endl     << "Cal Mon RMS         : " << b.CalMonRms << std::endl     << "Offset Count        : " << b.OffsetCount << std::endl;  return os;}size_t MSG_BlackBodyDataUsed::read_from( unsigned const char_1 *buff ){  size_t position = 0;  position += BBObservationUTC.read_from(buff+position);  position += OnBoardBBTime.read_from(buff+position);  for (int i = 0; i < 42; i ++)    MDUOutGain[i] = get_ui2(buff+position+i*2);  position += 42*2;  for (int i = 0; i < 42; i ++)    MDUCoarseGain[i] = *(buff+position+i);  position += 42;  for (int i = 0; i < 42; i ++)    MDUFineGain[i] = get_ui2(buff+position+i*2);  position += 42*2;  for (int i = 0; i < 42; i ++)    MDUNumerical_Offset[i] = get_ui2(buff+position+i*2);  position += 42*2;  for (int i = 0; i < 42; i ++)    PUGain[i] = get_ui2(buff+position+i*2);  position += 42*2;  for (int i = 0; i < 27; i ++)    PUOffset[i] = get_ui2(buff+position+i*2);  position += 27*2;  for (int i = 0; i < 15; i ++)    PUBias[i] = get_ui2(buff+position+i*2);  position += 15*2;  memcpy(DCRValues, buff, 63);  position += 63;  XDeepSpaceWindowPosition = (t_enum_MSG_DeepSpace_Window_Position)                             *(buff+position);  position += 1;  FCUNominalColdFocalPlaneTemp = get_ui2(buff+position);  position += 2;  FCURedundantColdFocalPlaneTemp = get_ui2(buff+position);  position += 2;  FCUNominalWarmFocalPlaneVHROTemp = get_ui2(buff+position);  position += 2;  FCURedundantWarmFocalPlaneVHROTemp = get_ui2(buff+position);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -