示例#1
0
/***********************************************************************//**
 * @brief Return maximum energy
 *
 * @return Maximum energy.
 *
 * Returns the maximum energy.
 ***************************************************************************/
inline
GEnergy GModelSpectralPlaw2::emax(void) const
{
    GEnergy energy;
    energy.MeV(m_emax.value());
    return energy;
}
/***********************************************************************//**
 * @brief Return breakenergy energy
 *
 * @return breakenergy energy.
 *
 * Returns the breakenergy energy.
 ***************************************************************************/
inline
GEnergy GModelSpectralBrokenPlaw::breakenergy(void) const
{
    GEnergy energy;
    energy.MeV(m_breakenergy.value());
    return energy;
}
/***********************************************************************//**
 * @brief Return pivot energy
 *
 * @return Pivot energy.
 *
 * Returns the pivot energy.
 ***************************************************************************/
inline
GEnergy GModelSpectralPlaw::pivot(void) const
{
    GEnergy energy;
    energy.MeV(m_pivot.value());
    return energy;
}
/***********************************************************************//**
 * @brief Return exponential cut-off energy
 *
 * @return Exponential cut-off energy.
 *
 * Returns the exponential cut-off energy.
 ***************************************************************************/
inline
GEnergy GModelSpectralSuperExpPlaw::cutoff(void) const
{
    GEnergy energy;
    energy.MeV(m_ecut.value());
    return energy;
}
示例#5
0
/***********************************************************************//**
 * @brief Test binned optimizer
 *
 * @param[in] datadir Directory of test data.
 * @param[in] irf Instrument response function.
 * @param[in] fit_results Expected fit result.
 *
 * Verifies the ability optimize binned Fermi/LAT data.
 ***************************************************************************/
void TestGLATOptimize::test_one_binned_optimizer(const std::string& datadir,
                                                 const std::string& irf,
                                                 const double*      fit_results)
{
    // Set filenames
    std::string lat_srcmap    = datadir+"/srcmap.fits";
    std::string lat_expmap    = datadir+"/binned_expmap.fits";
    std::string lat_ltcube    = datadir+"/ltcube.fits";
    std::string lat_model_xml = datadir+"/source_model.xml";

    // Setup GObservations for optimizing
    GObservations   obs;
    GLATObservation run;
    test_try("Setup for optimization");
    try {
        run.load_binned(lat_srcmap, lat_expmap, lat_ltcube);
        run.response(irf, lat_caldb);
        obs.append(run);
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Load models from XML file
    obs.models(lat_model_xml);

    // Setup LM optimizer
    test_try("Perform LM optimization");
    try {
        GOptimizerLM opt;
        opt.max_iter(1000);
        obs.optimize(opt);
        obs.errors(opt);
        test_try_success();
        for (int i = 0, j = 0; i < obs.models().size(); ++i) {
            const GModel* model = obs.models()[i];
            for (int k = 0; k < model->size(); ++k) {
                GModelPar par  = (*model)[k];
                std::string msg = "Verify optimization result for " + par.print();
                test_value(par.value(), fit_results[j++], 5.0e-5, msg);
                test_value(par.error(), fit_results[j++], 5.0e-5, msg);
            }
        }
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Exit test
    return;

}
示例#6
0
/***********************************************************************//**
 * @brief Returns model scale factor for a given instrument
 *
 * @param[in] instrument Instrument.
 *
 * Returns the model scale factor for a given @p instrument. The search is
 * case sensitive.
 *
 * If the @p instrument is not found, the method returns a scale factor of
 * unity.
 ***************************************************************************/
GModelPar GModel::scale(const std::string& instrument) const
{
    // Initialise unit scale factor
    GModelPar scale;
    scale.value(1.0);
    scale.name(instrument);
    scale.fix();

    // Search for instrument and recover scale factor if the instrument
    // has been found.
    for (int i = 0; i < m_scales.size(); ++i) {
        if (m_scales[i].name() == instrument) {
            scale = m_scales[i];
            break;
        }
    }

    // Return scale factor
    return scale;
}
/***********************************************************************//**
 * @brief Set breakenergy energy
 *
 * @param[in] breakenergy breakenergy energy.
 *
 * Sets the breakenergy energy.
 ***************************************************************************/
inline
void GModelSpectralBrokenPlaw::breakenergy(const GEnergy& breakenergy)
{
    m_breakenergy.value(breakenergy.MeV());
    return;
}
/***********************************************************************//**
 * @brief Set power law index2
 *
 * @param[in] index2 Power law index2.
 *
 * Sets the power law index2.
 ***************************************************************************/
inline
void GModelSpectralBrokenPlaw::index2(const double& index2)
{
    m_index2.value(index2);
    return;
}
/***********************************************************************//**
 * @brief Return power law index
 *
 * @return Power law index.
 *
 * Returns the power law index.
 ***************************************************************************/
inline
double GModelSpectralPlaw::index(void) const
{
    return (m_index.value());
}
/***********************************************************************//**
 * @brief Set pre factor 
 *
 * @param[in] prefactor Pre factor (ph/cm2/s/MeV).
 *
 * Sets the pre factor.
 ***************************************************************************/
inline
void GModelSpectralBrokenPlaw::prefactor(const double& prefactor)
{
    m_norm.value(prefactor);
    return;
}
/***********************************************************************//**
 * @brief Return power law index2
 *
 * @return Power law index2.
 *
 * Returns the power law index2.
 ***************************************************************************/
inline
double GModelSpectralBrokenPlaw::index2(void) const
{
    return (m_index2.value());
}
示例#12
0
/***********************************************************************//**
 * @brief Set power law index 
 *
 * @param[in] index Power law index.
 *
 * Sets the power law index.
 ***************************************************************************/
inline
void GModelSpectralPlaw::index(const double& index)
{
    m_index.value(index);
    return;
}
/***********************************************************************//**
 * @brief Return pre factor
 *
 * @return Pre factor (ph/cm2/s/MeV).
 *
 * Returns the pre factor.
 ***************************************************************************/
inline
double GModelSpectralBrokenPlaw::prefactor(void) const
{
    return (m_norm.value());
}
/***********************************************************************//**
 * @brief Return semi-major axis of ellipse
 *
 * @return Semi-major axis of ellipse (degrees).
 *
 * Returns the semi-major axis of the ellipse in degrees.
 ***************************************************************************/
inline
double GModelSpatialEllipticalDisk::semimajor(void) const
{
    return (m_semimajor.value());
}
示例#15
0
/***********************************************************************//**
 * @brief Return normalization factor
 *
 * @return Normalization factor.
 *
 * Returns the normalization factor.
 ***************************************************************************/
inline
double GModelSpectralFunc::norm(void) const
{
    return (m_norm.value());
}
示例#16
0
/***********************************************************************//**
 * @brief Return Right Ascencion of model centre
 *
 * @return Right Ascencion of model centre (degrees).
 *
 * Returns the Right Ascension of the model centre in degrees.
 ***************************************************************************/
inline
double GModelSpatialRadial::ra(void) const
{
    return (m_ra.value());
}
示例#17
0
/***********************************************************************//**
 * @brief Return Declination of model centre
 *
 * @return Declination of model centre (degrees).
 *
 * Returns the Declination of the model centre in degrees.
 ***************************************************************************/
inline
double GModelSpatialRadial::dec(void) const
{
    return (m_dec.value());
}
/***********************************************************************//**
 * @brief Set model value
 *
 * @param[in] value Model value.
 *
 * Set the value of the spatial map model.
 ***************************************************************************/
inline
void GModelSpatialDiffuseMap::value(const double& value)
{
    m_value.value(value);
    return;
}
/***********************************************************************//**
 * @brief Get model value
 *
 * @return Model value.
 *
 * Returns the value of the spatial map model.
 ***************************************************************************/
inline
double GModelSpatialDiffuseMap::value(void) const
{
    return (m_value.value());
}
/***********************************************************************//**
 * @brief Set model value
 *
 * @param[in] value Model value (ph/cm2/s/MeV).
 *
 * Sets the model value.
 ***************************************************************************/
inline
void GModelSpectralConst::value(const double& value)
{
    m_norm.value(value);
    return;
}
/***********************************************************************//**
 * @brief Return model value
 *
 * @return Model value (ph/cm2/s/MeV).
 *
 * Returns the model value.
 ***************************************************************************/
inline
double GModelSpectralConst::value(void) const
{
    return (m_norm.value());
}
示例#22
0
/***********************************************************************//**
 * @brief Set pivot energy
 *
 * @param[in] pivot Pivot energy.
 *
 * Sets the pivot energy.
 ***************************************************************************/
inline
void GModelSpectralPlaw::pivot(const GEnergy& pivot)
{
    m_pivot.value(pivot.MeV());
    return;
}
示例#23
0
/***********************************************************************//**
 * @brief Set Right Ascencion of model centre
 *
 * @param[in] ra Right Ascension (degrees).
 *
 * Sets the Right Ascension of the model centre in degrees.
 ***************************************************************************/
inline
void GModelSpatialRadial::ra(const double& ra)
{
    m_ra.value(ra);
    return;
}
/***********************************************************************//**
 * @brief Return Position Angle of model
 *
 * @return Position Angle of model (degrees).
 *
 * Returns the Position Angle of model in degrees, measured counterclockwise
 * from celestial North.
 ***************************************************************************/
inline
double GModelSpatialElliptical::posangle(void) const
{
    return (m_posangle.value());
}
示例#25
0
/***********************************************************************//**
 * @brief Set Declination of model centre
 *
 * @param[in] dec Declination (degrees).
 *
 * Sets the Declination of the model centre in degrees.
 ***************************************************************************/
inline
void GModelSpatialRadial::dec(const double& dec)
{
    m_dec.value(dec);
    return;
}
/***********************************************************************//**
 * @brief Set Position Angle of model
 *
 * @param[in] posangle Position Angle of model (degrees).
 *
 * Sets the Position Angle of model in degrees, measured counterclockwise
 * from celestial North.
 ***************************************************************************/
inline
void GModelSpatialElliptical::posangle(const double& posangle)
{
    m_posangle.value(posangle);
    return;
}
/***********************************************************************//**
 * @brief Set semi-major axis of ellipse
 *
 * @param[in] semimajor Semi-major axis of ellipse (degrees)
 *
 * Sets the semi-major axis of the ellipse in degrees.
 ***************************************************************************/
inline
void GModelSpatialEllipticalDisk::semimajor(const double& semimajor)
{
    m_semimajor.value(semimajor);
    return;
}
示例#28
0
/***********************************************************************//**
 * @brief Return disk radius
 *
 * @return Disk radius (degrees).
 *
 * Returns the radius of the disk in degrees.
 ***************************************************************************/
inline
double GModelSpatialRadialDisk::radius(void) const
{
    return (m_radius.value());
}
示例#29
0
/***********************************************************************//**
 * @brief Set normalization factor 
 *
 * @param[in] norm Normalization factor.
 *
 * Sets the normalization factor.
 ***************************************************************************/
inline
void GModelSpectralFunc::norm(const double& norm)
{
    m_norm.value(norm);
    return;
}
示例#30
0
/***********************************************************************//**
 * @brief Set disk radius
 *
 * @param[in] radius Disk radius (degrees).
 *
 * Sets the radius of the disk in degrees.
 ***************************************************************************/
inline
void GModelSpatialRadialDisk::radius(const double& radius)
{
    m_radius.value(radius);
    return;
}