示例#1
0
文件: Hillier.cpp 项目: corburn/ISIS
  /**
   * @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;
  }
示例#2
0
/**
 * @brief Retrieves the specified access profile
 * 
 * This method retrieves the named profile.  If no name is provided, the default
 * profile is returned.
 * 
 * There are two ways to specify the default.  The first source of a named
 * default comes from within the configuration file.  A keyword specified in the
 * Database object section named \b DefaultProfile can specify a named profile,
 * the value of the Name keyword in a \b Profile group.  The second source comes
 * from the application programmer.  In the constructor call to this object, the
 * application programmer can provide a named profile as the default, which
 * could ultimately come from the user (interface).
 * 
 * If no default is specified, then only the keywords contained in the Database
 * object section of the configuration file is returned when requesting an
 * unnamed profile.
 * 
 * @param name Optional name of the profile to return
 * 
 * @return const DbProfile The specified profile.  One should test the
 *         validatity of the profile returned as this is the only indication of
 *         success.
 */
const DbProfile DbAccess::getProfile(const std::string &name) const 
                                      throw (iException &) {
  string defName(name);
  if (defName.empty()) {
    defName = getDefaultProfileName();
  }
  else {
    if (!_profiles.exists(defName)) {
       return (DbProfile(defName));
    }
  }

//  We have identified the proper profile
  if (_profiles.exists(defName)) {
    //   Return the composite of this access scheme
    return(DbProfile(*this, _profiles.get(defName),defName));
  }
  else {
    //  Return only the high level database access keys and hope it is enough
    return (DbProfile(*this, DbProfile(),defName));
  }
}
示例#3
0
/**
 * @brief Returns the nth specified DbProfile in the list
 * 
 * This method allows user to iterate through the list of DbProfiles in this
 * access scheme.  If the caller provides an index that exceeds the number
 * contained, an exception is thrown.  Use profileCount() to determine the
 * number of profiles.
 * 
 * @param nth Zero-based index of profile to return
 * 
 * @return const DbProfile The requested nth profile
 */
const DbProfile DbAccess::getProfile(int nth) const throw (iException &) {
  const DbProfile &p = _profiles.getNth(nth);
  return(DbProfile(*this, p, p.Name()));
}