Exemplo n.º 1
0
//------------------------------------------------------------------------------
HarmonicField::HarmonicField(const std::string &name, const std::string &typeName,
                             Integer maxDeg, Integer maxOrd) :
GravityBase             (typeName, name),
hMinitialized           (false),
maxDegree               (maxDeg),
maxOrder                (maxOrd),
degree                  (4),
order                   (4),
filename                (""),
fileRead                (false),
usingDefaultFile        (false),
isFirstTimeDefault      (true),
inputCSName             ("EarthMJ2000Eq"),
fixedCSName             ("EarthFixed"),
targetCSName            ("EarthMJ2000Eq"),
potPath                 (""),
inputCS                 (NULL),
fixedCS                 (NULL),
targetCS                (NULL),
eop                     (NULL)
{
   objectTypeNames.push_back("HarmonicField");
   parameterCount = HarmonicFieldParamCount;
   r = s = t = u = 0.0;
   
   FileManager *fm = FileManager::Instance();
   potPath = fm->GetAbsPathname(bodyName + "_POT_PATH");
   
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
HarmonicField::HarmonicField(const std::string &name, const std::string &typeName,
                             Integer maxDeg, Integer maxOrd) :
    GravityBase             (typeName, name),
    hMinitialized           (false),
    maxDegree               (maxDeg),
    maxOrder                (maxOrd),
    degree                  (4),
    order                   (4),
    filename                (""),
    filenameFullPath        (""),
    fileRead                (false),
    usingDefaultFile        (false),
    isFirstTimeDefault      (true),
    inputCSName             ("EarthMJ2000Eq"),
    fixedCSName             ("EarthFixed"),
    targetCSName            ("EarthMJ2000Eq"),
    potPath                 (""),
    inputCS                 (NULL),
    fixedCS                 (NULL),
    targetCS                (NULL),
    eop                     (NULL)
{
    objectTypeNames.push_back("HarmonicField");
    parameterCount = HarmonicFieldParamCount;
    r = s = t = u = 0.0;

    FileManager *fm = FileManager::Instance();
    potPath = fm->GetAbsPathname(bodyName + "_POT_PATH");
#ifdef DEBUG_EOP_FILE
    MessageInterface::ShowMessage
    ("HarmonicField() constructor, this=<%p>, name='%s'\n", this, name.c_str());
#endif
}
Exemplo n.º 3
0
//------------------------------------------------------------------------------
// virtual void LoadData()
//------------------------------------------------------------------------------
void TextEphemFileDialog::LoadData()
{
   // Get default path for ephemeris file
   FileManager *fm = FileManager::Instance();
   mEphemDirectory = fm->GetAbsPathname(FileManager::OUTPUT_PATH).c_str();
   
   // Append first spacecraft to selected listbox
   int scCount = mSpacecraftListBox->GetCount();
   if (scCount > 0)
   {
      wxString scName = mSpacecraftListBox->GetStringSelection();
      mSelectedScListBox->Append(scName);
      mSelectedScListBox->SetStringSelection(scName);
      
      // set default ephemeris  file using spacecraft name
      wxString fname = scName + "_Ephem.txt";
      mEphemFileTextCtrl->SetValue(mEphemDirectory + fname);
      
      theOkButton->Enable();
   }
   else
   {
      mEphemFileTextCtrl->SetValue(mEphemDirectory +
                                   wxString("/TextEphemHeader.txt"));
      
      theOkButton->Disable();
   }

   // Show last position
   mEphemFileTextCtrl->SetInsertionPointEnd();
   
   mCoordSysComboBox->SetSelection(0);
   
   // Load the epoch formats
   StringArray reps = TimeConverterUtil::GetValidTimeRepresentations();
   for (unsigned int i = 0; i < reps.size(); i++)
      mEpochFormatComboBox->Append(reps[i].c_str());
   
   mEpochFormatComboBox->SetSelection(0);
   
   // Change label
   theOkButton->SetLabel("Run and Create Ephemeris File");
}
Exemplo n.º 4
0
//------------------------------------------------------------------------------
bool HarmonicField::SetStringParameter(const Integer id,
                                       const std::string &value)
{
   if (id == FILENAME)
   {
      if (GmatStringUtil::IsBlank(value))
      {
         ODEModelException ome;
         ome.SetDetails(errorMessageFormatUnnamed.c_str(),
                       value.c_str(), "PotentialFile", "non-blank file name");
         throw ome;
      }

      std::string newValue = value;
      // if value has no file extension, add .cof as default (loj: 2008.10.14)
      if (value.find(".") == value.npos)
         newValue = value + ".cof";
      
      return SetFilename(newValue);  
   }
   if (id == INPUT_COORD_SYSTEM)
   {
      #ifdef DEBUG_HARMONIC_FIELD
         char str[1024];
         strcpy(str, value.c_str());
         
         MessageInterface::ShowMessage(
                "Setting input coordinate system name to \"%s\"\n", str);
      #endif
      inputCSName = value;
      
      return true;
   }
   if (id == FIXED_COORD_SYSTEM)
   {
      #ifdef DEBUG_HARMONIC_FIELD
         char str[1024];
         strcpy(str, value.c_str());
         
         MessageInterface::ShowMessage(
                "Setting fixed coordinate system name to \"%s\"\n", str);
      #endif
      fixedCSName = value;
      
      return true;
   }
   if (id == TARGET_COORD_SYSTEM)
   {
      #ifdef DEBUG_HARMONIC_FIELD
         char str[1024];
         strcpy(str, value.c_str());
         
         MessageInterface::ShowMessage(
                "Setting target coordinate system name to \"%s\"\n", str);
      #endif
      targetCSName = value;
      
      return true;
   }
   if (id == BODY_NAME)
   {      
      if (GravityBase::SetStringParameter(id, value))
      {
         // set default potential file path for the body
         FileManager *fm = FileManager::Instance();
         try
         {
            potPath = fm->GetAbsPathname(bodyName + "_POT_PATH");
         }
         catch (BaseException &ex)
         {
//            MessageInterface::ShowMessage("**** WARNING ****: %s\n",
//                  ex.GetFullMessage().c_str());
            ; // ignore this for now - GMT-2873
         }
         
         #ifdef DEBUG_HARMONIC_FIELD
         MessageInterface::ShowMessage
            ("Setting potential file path to \"%s\"\n", potPath.c_str());
         #endif
         
         fixedCSName = value + "Fixed";
         return true;
      }
      return false;
   }
   
   return GravityBase::SetStringParameter(id, value);
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
bool SolarFluxReader::LoadFluxData(const std::string &obsFile, const std::string &predictFile)
{
   std::string theLine;

   if (!obsFile.empty())
      obsFileName = obsFile;
   if (!predictFile.empty())
      predictFileName = predictFile;

   obsFluxData.clear();
   predictFluxData.clear();

   FileManager *fm = FileManager::Instance();

   if (obsFileName != "")
   {
      std::string weatherfile = obsFileName;
      if (fm->DoesFileExist(weatherfile) == false)
         weatherfile = fm->GetAbsPathname("ATMOSPHERE_PATH") + weatherfile;
      if (fm->DoesFileExist(weatherfile) == false)
         throw SolarSystemException("Cannot open the historic space weather file " +
               obsFileName + ", nor the file at the location " + weatherfile);

      obsFileName = weatherfile;
   }

   if (predictFileName != "")
   {
      std::string weatherfile = predictFileName;
      if (fm->DoesFileExist(weatherfile) == false)
         weatherfile = fm->GetAbsPathname("ATMOSPHERE_PATH") + weatherfile;
      if (fm->DoesFileExist(weatherfile) == false)
         throw SolarSystemException("Cannot open the predicted space weather file " +
               predictFileName + ", nor the file at the location " + weatherfile);

      predictFileName = weatherfile;
   }

   // Open the files to load
   Open();
   
   if (obsFileName != "")
   {
      if (inObs.is_open())
      {
         inObs.seekg(0, std::ios_base::beg);

         while (!inObs.eof())
         {
            GmatFileUtil::GetLine(&inObs, theLine);

            if (theLine.find(beg_ObsTag) != std::string::npos)
            {
               begObs = inObs.tellg();
            }
            else if (theLine.find(end_ObsTag) != std::string::npos)
            {
               endObs = inObs.tellg();
               endObs = endObs - theLine.length() - 2;
               break;
            }
         }
         LoadObsData();
      }
      else
      {
         //throw an exception
         throw SolarSystemException("SolarFluxReader: Historic/Observed File " +
               obsFileName + " could not be opened.\n");
      }
   }

   if (predictFileName != "")
   {
      if (inPredict.is_open())
      {
         inPredict.seekg(0, std::ios_base::beg);
         while (!inPredict.eof())
         {
            GmatFileUtil::GetLine(&inPredict, theLine);

            if ((theLine.find("NOMINAL TIMING") != std::string::npos) &&
                (theLine.find("EARLY TIMING") != std::string::npos))
            {
               GmatFileUtil::GetLine(&inPredict, theLine);
               break;
            }
         }
         LoadPredictData();
      }
      else
      {
         //throw an exception
         throw SolarSystemException("SolarFluxReader: The Schatten predict "
               "file " + predictFileName + " could not be opened.\n");
      }
   }

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("Spans: [%lf %lf], [%lf %lf]\n",
            historicStart, historicEnd, predictStart, predictEnd);
   #endif

   return(Close());
}