Example #1
0
void Parser::parseAtom (QString s)
{
    initAtom();
    atom=s;
    QRegExp re;
    int pos;

    // Strip WS at beginning
    re.setPattern ("\\w");
    re.setMinimal (true);
    pos=re.indexIn (atom);
    if (pos>=0)
	s=s.right(s.length()-pos);

    // Get command
    re.setPattern ("\\b(.*)(\\s|\\()");
    pos=re.indexIn (s);
    if (pos>=0)
	com=re.cap(1);

    // Get parameters
    paramList.clear();
    QString t;
    int leftParenthesis;
    int rightParenthesis;
    if (!nextParenthesisContents(s, leftParenthesis, rightParenthesis, t)) return;


    paramList=findParameters(t);
}
Example #2
0
  /**
   * @brief Initialize class from input PVL and Cube files
   *
   * This method is typically called at class instantiation time,
   * but is reentrant.  It reads the parameter PVL file and
   * extracts Photometric model and Normalization models from it.
   * The cube is needed to match all potential profiles for each
   * band.
   *
   * @param pvl  Input PVL parameter files
   * @param cube Input cube file to correct
   *
   * @author Kris Becker - 2/22/2010
   * @history 2010-02-25 Kris Becker Added check for valid incidence angle
   */
  void Hillier::init(PvlObject &pvl, Cube &cube) {

    //  Make it reentrant
    _profiles.clear();
    _bandpho.clear();

    //  Interate over all Photometric groups
    _normProf = DbProfile(pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse));
    _iRef = toDouble(ConfKey(_normProf, "IncRef", toString(30.0)));
    _eRef = toDouble(ConfKey(_normProf, "EmaRef", toString(0.0)));
    _gRef = toDouble(ConfKey(_normProf, "PhaRef", toString(_iRef)));

    // Check for valid incidence angle
    if(_iRef > fabs(90.0)) {
      ostringstream mess;
      mess << "Invalid incidence angle (" << _iRef
           << " >= 90.0) provided in PVL config file " << pvl.fileName();
      throw IException(IException::User, mess.str(), _FILEINFO_);
    }


    PvlObject &phoObj = pvl.findObject("PhotometricModel");
    DbProfile phoProf = DbProfile(phoObj);
    PvlObject::PvlGroupIterator algo = phoObj.beginGroup();
    while(algo != phoObj.endGroup()) {
      if(algo->name().toLower() == "algorithm") {
        _profiles.push_back(DbProfile(phoProf, DbProfile(*algo)));
      }
      ++algo;
    }

    Pvl *label = cube.label();
    PvlKeyword center = label->findGroup("BandBin", Pvl::Traverse)["Center"];
    QString errs("");
    for(int i = 0; i < cube.bandCount() ; i++) {
      Parameters parms = findParameters(toDouble(center[i]));
      if(parms.IsValid()) {
        parms.band = i + 1;
        _camera->SetBand(i + 1);
        parms.phoStd = photometry(parms, _iRef, _eRef, _gRef);
        _bandpho.push_back(parms);
      }
      else {  // Appropriate photometric parameters not found
        ostringstream mess;
        mess << "Band " << i + 1 << " with wavelength Center = " << center[i]
             << " does not have PhotometricModel Algorithm group/profile";
        IException e(IException::User, mess.str(), _FILEINFO_);
        errs += e.toString() + "\n";
      }
    }

    // Check for errors and throw them all at the same time
    if(!errs.isEmpty()) {
      errs += " --> Errors in the input PVL file \"" + pvl.fileName() + "\"";
      throw IException(IException::User, errs, _FILEINFO_);
    }

    return;
  }