GammaLib
2.1.0.dev
|
Spectral bins model class. More...
#include <GModelSpectralBins.hpp>
Public Member Functions | |
GModelSpectralBins (void) | |
Void constructor. More... | |
GModelSpectralBins (const GModelSpectral &model, const GEbounds &ebounds, const double &index=-2.0) | |
Spectral model constructor. More... | |
GModelSpectralBins (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpectralBins (const GModelSpectralBins &model) | |
Copy constructor. More... | |
virtual | ~GModelSpectralBins (void) |
Destructor. More... | |
virtual GModelSpectralBins & | operator= (const GModelSpectralBins &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear spectral bins model. More... | |
virtual GModelSpectralBins * | clone (void) const |
Clone spectral bins model. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual std::string | type (void) const |
Return model type. More... | |
virtual double | eval (const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const |
Evaluate function. More... | |
virtual double | flux (const GEnergy &emin, const GEnergy &emax) const |
Returns model photon flux between emin, emax More... | |
virtual double | eflux (const GEnergy &emin, const GEnergy &emax) const |
Returns model energy flux between emin, emax More... | |
virtual GEnergy | mc (const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const |
Returns MC energy between [emin, emax]. More... | |
virtual void | read (const GXmlElement &xml) |
Read model from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write model into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print bin function information. More... | |
int | bins (void) const |
Return number of bins. More... | |
void | append (const GEnergy &emin, const GEnergy &emax, const double &intensity) |
Append bin. More... | |
void | insert (const int &index, const GEnergy &emin, const GEnergy &emax, const double &intensity) |
Insert bin. More... | |
void | remove (const int &index) |
Remove bin. More... | |
void | reserve (const int &num) |
Reserve space for bins. More... | |
void | extend (const GModelSpectralBins &bins) |
Append bins from bin function. More... | |
double | index (void) const |
Return spectral power law index. More... | |
void | index (const double &index) |
Set spectral power law index. More... | |
GEnergy | emin (const int &index) const |
Return lower energy limit of bin. More... | |
GEnergy | emax (const int &index) const |
Return upper energy limit of bin. More... | |
void | emin (const int &index, const GEnergy &emin) |
Set lower energy limit of bin. More... | |
void | emax (const int &index, const GEnergy &emax) |
Set upper energy limit of bin. More... | |
double | intensity (const int &index) const |
Return bin intensity. More... | |
void | intensity (const int &index, const double &intensity) |
Set bin intensity. More... | |
double | error (const int &index) const |
Return intensity error of bin. More... | |
Public Member Functions inherited from GModelSpectral | |
GModelSpectral (void) | |
Void constructor. More... | |
GModelSpectral (const GModelSpectral &model) | |
Copy constructor. More... | |
virtual | ~GModelSpectral (void) |
Destructor. More... | |
virtual GModelSpectral & | operator= (const GModelSpectral &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns reference to model parameter. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns reference to model parameter (const version) More... | |
GModelPar & | at (const int &index) |
Returns model parameter. More... | |
const GModelPar & | at (const int &index) const |
Returns model parameter (const version) More... | |
bool | has_par (const std::string &name) const |
Checks if parameter name exists. More... | |
int | size (void) const |
Return number of parameters. More... | |
void | autoscale (void) |
Autoscale parameters. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelSpectralBins &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
int | bin_index (const GEnergy &energy) const |
Return bin index for energy. More... | |
void | update_pars (void) |
Update parameter mapping. More... | |
void | set_cache (void) const |
Set cache. More... | |
void | mc_update (const GEnergy &emin, const GEnergy &emax) const |
Set MC pre-computation cache. More... | |
Protected Member Functions inherited from GModelSpectral | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelSpectral &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GModelPar | m_index |
Spectral index of all bins. More... | |
std::vector< GModelPar > | m_emin |
Lower energy limits. More... | |
std::vector< GModelPar > | m_emax |
Upper energy limits. More... | |
std::vector< GModelPar > | m_values |
Bin values. More... | |
std::vector< double > | m_epivot |
Power-law pivot energies in MeV. More... | |
GEnergy | m_mc_emin |
Minimum energy. More... | |
GEnergy | m_mc_emax |
Maximum energy. More... | |
std::vector< double > | m_mc_cum |
Cumulative distribution. More... | |
std::vector< double > | m_mc_min |
Lower boundary for MC. More... | |
std::vector< double > | m_mc_max |
Upper boundary for MC. More... | |
std::vector< double > | m_mc_exp |
Exponent for MC. More... | |
Protected Attributes inherited from GModelSpectral | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Spectral bins model class.
This class implements spectral bins that have a constant intensity within their boundaries. A spectral bin is defined by a lower and upper energy limit, with the lower limit included and the upper limit excluded from an energy bin.
Definition at line 54 of file GModelSpectralBins.hpp.
GModelSpectralBins::GModelSpectralBins | ( | void | ) |
Void constructor.
Constructs an empty spectral bin model.
Definition at line 81 of file GModelSpectralBins.cpp.
References init_members().
Referenced by clone().
GModelSpectralBins::GModelSpectralBins | ( | const GModelSpectral & | model, |
const GEbounds & | ebounds, | ||
const double & | index = -2.0 |
||
) |
Spectral model constructor.
[in] | model | Spectral model. |
[in] | ebounds | Energy boundaries. |
[in] | index | Spectral index. |
Constructs a spectral bins model from any spectral model using the energy boundaries that are specified by ebounds
. Within each spectral bin the intensity follows a power law with spectral index index
.
Definition at line 102 of file GModelSpectralBins.cpp.
References append(), GEbounds::elogmean(), GEbounds::emax(), GEbounds::emin(), GModelSpectral::eval(), index(), init_members(), and GEbounds::size().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Construct spectral bins model by extracting information from an XML element. See the read() method for more information about the expected structure of the XML element.
Definition at line 132 of file GModelSpectralBins.cpp.
References init_members(), and read().
GModelSpectralBins::GModelSpectralBins | ( | const GModelSpectralBins & | model | ) |
Copy constructor.
[in] | model | Spectral bins model. |
Definition at line 151 of file GModelSpectralBins.cpp.
References copy_members(), and init_members().
|
virtual |
void GModelSpectralBins::append | ( | const GEnergy & | emin, |
const GEnergy & | emax, | ||
const double & | intensity | ||
) |
Append bin.
[in] | emin | Lower energy limit. |
[in] | emax | Upper energy limit. |
[in] | intensity | Bin intensity. |
GException::invalid_argument | Lower energy limit is larger than upper energy limit. |
Appends one bin to the bin function. By default the lower and upper energy limit of the bin is fixed while the intensity of the bin is free.
Definition at line 753 of file GModelSpectralBins.cpp.
References GOptimizerPar::fix(), GOptimizerPar::free(), G_APPEND, GOptimizerPar::has_grad(), m_emax, m_emin, m_values, GEnergy::MeV(), GOptimizerPar::name(), GEnergy::print(), set_cache(), GOptimizerPar::unit(), update_pars(), and GOptimizerPar::value().
Referenced by GModelSpectralBins().
|
protected |
Return bin index for energy.
[in] | energy | Energy. |
Definition at line 1337 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, and GEnergy::MeV().
Referenced by eval().
|
inline |
Return number of bins.
Returns the number of bins in the bin function model.
Definition at line 174 of file GModelSpectralBins.hpp.
References m_values.
Referenced by bin_index(), eflux(), emax(), emin(), error(), extend(), flux(), insert(), intensity(), mc_update(), print(), read(), remove(), set_cache(), update_pars(), and write().
|
inlinevirtual |
Return class name.
Implements GModelSpectral.
Definition at line 146 of file GModelSpectralBins.hpp.
|
virtual |
Clear spectral bins model.
Implements GModelSpectral.
Definition at line 223 of file GModelSpectralBins.cpp.
References GModelSpectral::free_members(), free_members(), GModelSpectral::init_members(), and init_members().
|
virtual |
Clone spectral bins model.
Implements GModelSpectral.
Definition at line 241 of file GModelSpectralBins.cpp.
References GModelSpectralBins().
|
protected |
Copy class members.
[in] | model | Spectral bin function. |
Definition at line 1294 of file GModelSpectralBins.cpp.
References m_emax, m_emin, m_epivot, m_index, m_mc_cum, m_mc_emax, m_mc_emin, m_mc_exp, m_mc_max, m_mc_min, m_values, and update_pars().
Referenced by GModelSpectralBins(), and operator=().
Returns model energy flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes
\[ \int_{\tt emin}^{\tt emax} S_{\rm E}(E | t) E \, dE \]
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 415 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, m_epivot, m_index, m_values, GEnergy::MeV(), gammalib::MeV2erg, gammalib::plaw_energy_flux(), and GOptimizerPar::value().
GEnergy GModelSpectralBins::emax | ( | const int & | index | ) | const |
Return upper energy limit of bin.
[in] | index | Bin index [0,...,bins()-1]. |
index
.GException::out_of_range | Index is out of range. |
Returns the upper energy limit of bin index
.
Definition at line 1053 of file GModelSpectralBins.cpp.
References bins(), G_EMAX_GET, m_emax, and GEnergy::MeV().
Referenced by mc_update(), read(), and write().
void GModelSpectralBins::emax | ( | const int & | index, |
const GEnergy & | emax | ||
) |
Set upper energy limit of bin.
[in] | index | Bin index [0,...,bins()-1]. |
[in] | emax | Upper energy limit of bin index . |
GException::out_of_range | Index is out of range. |
Sets the upper energy limit of bin index
.
Definition at line 1113 of file GModelSpectralBins.cpp.
References bins(), G_EMAX_SET, index(), m_emax, GEnergy::MeV(), and set_cache().
GEnergy GModelSpectralBins::emin | ( | const int & | index | ) | const |
Return lower energy limit of bin.
[in] | index | Bin index [0,...,bins()-1]. |
index
.GException::out_of_range | Index is out of range. |
Returns the lower energy limit of bin index
.
Definition at line 1024 of file GModelSpectralBins.cpp.
References bins(), G_EMIN_GET, m_emin, and GEnergy::MeV().
Referenced by mc_update(), read(), and write().
void GModelSpectralBins::emin | ( | const int & | index, |
const GEnergy & | emin | ||
) |
Set lower energy limit of bin.
[in] | index | Bin index [0,...,bins()-1]. |
[in] | emin | Lower energy limit of bin index . |
GException::out_of_range | Index is out of range. |
Sets the lower energy limit of bin index
.
Definition at line 1082 of file GModelSpectralBins.cpp.
References bins(), G_EMIN_SET, index(), m_emin, GEnergy::MeV(), and set_cache().
double GModelSpectralBins::error | ( | const int & | index | ) | const |
Return intensity error of bin.
[in] | index | Bin index [0,...,bins()-1]. |
index
.GException::out_of_range | Index is out of range. |
Returns the intensity error of bin index
.
Definition at line 1169 of file GModelSpectralBins.cpp.
References bins(), G_ERROR_GET, and m_values.
|
virtual |
Evaluate function.
[in] | srcEng | True photon energy. |
[in] | srcTime | True photon arrival time. |
[in] | gradients | Compute gradients? |
Implements GModelSpectral.
Definition at line 258 of file GModelSpectralBins.cpp.
References bin_index(), GOptimizerPar::factor_gradient(), index(), GOptimizerPar::is_free(), gammalib::is_infinite(), gammalib::is_notanumber(), log(), m_epivot, m_index, m_values, GEnergy::MeV(), pow(), GOptimizerPar::scale(), and GOptimizerPar::value().
void GModelSpectralBins::extend | ( | const GModelSpectralBins & | bins | ) |
Append bins from bin function.
[in] | bins | Bin function. |
Appends all bins from a bin function to current object.
Definition at line 949 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, m_values, reserve(), set_cache(), and update_pars().
Returns model photon flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes
\[ \int_{\tt emin}^{\tt emax} S_{\rm E}(E | t) dE \]
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 342 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, m_epivot, m_index, m_values, GEnergy::MeV(), gammalib::plaw_photon_flux(), and GOptimizerPar::value().
Referenced by mc_update().
|
protected |
Delete class members.
Definition at line 1324 of file GModelSpectralBins.cpp.
Referenced by clear(), operator=(), and ~GModelSpectralBins().
double GModelSpectralBins::index | ( | void | ) | const |
Return spectral power law index.
Returns the spectral power law index.
Definition at line 989 of file GModelSpectralBins.cpp.
References m_index, and GOptimizerPar::value().
Referenced by emax(), emin(), eval(), GModelSpectralBins(), insert(), intensity(), mc_update(), read(), remove(), and write().
void GModelSpectralBins::index | ( | const double & | index | ) |
Set spectral power law index.
[in] | index | Spectrel power law index. |
Set spectral power law index.
Definition at line 1003 of file GModelSpectralBins.cpp.
References m_index, and GOptimizerPar::value().
|
protected |
Initialise class members.
Definition at line 1253 of file GModelSpectralBins.cpp.
References GEnergy::clear(), GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_emax, m_emin, m_epivot, m_index, m_mc_cum, m_mc_emax, m_mc_emin, m_mc_exp, m_mc_max, m_mc_min, m_values, GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), update_pars(), and GOptimizerPar::value().
Referenced by clear(), GModelSpectralBins(), and operator=().
void GModelSpectralBins::insert | ( | const int & | index, |
const GEnergy & | emin, | ||
const GEnergy & | emax, | ||
const double & | intensity | ||
) |
Insert bin.
[in] | index | Bin index [0,...,bins()-1]. |
[in] | emin | Lower energy limit. |
[in] | emax | Upper energy limit. |
[in] | intensity | Bin intensity. |
GException::out_of_range | Bin index is out of range. |
GException::invalid_argument | Lower energy limit is larger than upper energy limit. |
Inserts a bin into the bin function before the bin with the specified index
. By default the lower and upper energy limit of the bin is fixed while the intensity of the bin is free.
Definition at line 825 of file GModelSpectralBins.cpp.
References bins(), GOptimizerPar::fix(), GOptimizerPar::free(), G_INSERT, GOptimizerPar::has_grad(), index(), m_emax, m_emin, m_values, GEnergy::MeV(), GOptimizerPar::name(), GEnergy::print(), set_cache(), GOptimizerPar::unit(), update_pars(), and GOptimizerPar::value().
double GModelSpectralBins::intensity | ( | const int & | index | ) | const |
Return bin intensity.
[in] | index | Bin index [0,...,bins()-1]. |
index
.GException::out_of_range | Index is out of range. |
Returns the intensity of bin index
.
Definition at line 1144 of file GModelSpectralBins.cpp.
References bins(), G_INTENSITY_GET, and m_values.
void GModelSpectralBins::intensity | ( | const int & | index, |
const double & | intensity | ||
) |
Set bin intensity.
[in] | index | Bin index [0,...,bins()-1]. |
[in] | intensity | Intensity of bin index . |
GException::out_of_range | Index is out of range. |
Set the intensity of bin index
.
Definition at line 1194 of file GModelSpectralBins.cpp.
References bins(), G_INTENSITY_SET, index(), and m_values.
|
virtual |
Returns MC energy between [emin, emax].
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
[in] | time | True photon arrival time. |
[in,out] | ran | Random number generator. |
GException::invalid_return_value | No valid Monte Carlo cache |
Returns Monte Carlo energy by randomly drawing from bin function.
Implements GModelSpectral.
Definition at line 489 of file GModelSpectralBins.cpp.
References gammalib::check_energy_interval(), exp(), G_MC, log(), m_mc_cum, m_mc_exp, m_mc_max, m_mc_min, mc_update(), GEnergy::MeV(), GEnergy::print(), and GRan::uniform().
Set MC pre-computation cache.
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
This method sets up an array of indices and the cumulative distribution function needed for MC simulations.
Definition at line 1440 of file GModelSpectralBins.cpp.
References abs(), bins(), emax(), emin(), flux(), index(), log(), m_emax, m_emin, m_epivot, m_index, m_mc_cum, m_mc_emax, m_mc_emin, m_mc_exp, m_mc_max, m_mc_min, m_values, GEnergy::MeV(), norm(), gammalib::plaw_photon_flux(), pow(), and GOptimizerPar::value().
Referenced by mc().
|
virtual |
Assignment operator.
[in] | model | Spectral bins model. |
Definition at line 190 of file GModelSpectralBins.cpp.
References copy_members(), free_members(), init_members(), and GModelSpectral::operator=().
Print bin function information.
[in] | chatter | Chattiness. |
Implements GModelSpectral.
Definition at line 1217 of file GModelSpectralBins.cpp.
References bins(), GModelSpectral::m_pars, gammalib::parformat(), SILENT, GModelSpectral::size(), and gammalib::str().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
GException::invalid_value | Lower energy limit larger than upper energy limit. |
Reads the spectral information from an XML element. The format of the XML elements is
<spectrum type="BinFunction"> <parameter name="Index" ../> <bin> <parameter name="LowerLimit" ../> <parameter name="UpperLimit" ../> <parameter name="Intensity" ../> </bin> ... <bin> <parameter name="LowerLimit" ../> <parameter name="UpperLimit" ../> <parameter name="Intensity" ../> </bin> </spectrum>
Check that bins are ordered
Check that energy boundaries are not overlapping
Implements GModelSpectral.
Definition at line 575 of file GModelSpectralBins.cpp.
References bins(), GXmlNode::element(), GXmlNode::elements(), emax(), emin(), G_READ, index(), intensity(), m_emax, m_emin, m_index, m_values, GOptimizerPar::name(), GModelPar::read(), set_cache(), gammalib::str(), update_pars(), GOptimizerPar::value(), and gammalib::xml_get_par().
Referenced by GModelSpectralBins().
void GModelSpectralBins::remove | ( | const int & | index | ) |
Remove bin.
[in] | index | Bin index [0,...,bins()-1]. |
GException::out_of_range | Bin index is out of range. |
Removes bin of specified index
from the bin function.
Definition at line 898 of file GModelSpectralBins.cpp.
References bins(), G_REMOVE, index(), m_emax, m_emin, m_values, set_cache(), and update_pars().
void GModelSpectralBins::reserve | ( | const int & | num | ) |
|
protected |
Set cache.
Sets the computation cache. The method computes for the time being the pivot energies for all bins in MeV.
Definition at line 1415 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, m_epivot, and sqrt().
Referenced by append(), emax(), emin(), extend(), insert(), read(), and remove().
|
inlinevirtual |
Return model type.
Returns the type of the spectral bin function model.
Implements GModelSpectral.
Definition at line 160 of file GModelSpectralBins.hpp.
Referenced by write().
|
protected |
Update parameter mapping.
Sets the parameter pointers in the m_pars array, enabling iterating over all model parameters. This method needs to be called after changing the number of bins in the spectral model. The method needs not to be called after value update.
Definition at line 1366 of file GModelSpectralBins.cpp.
References bins(), m_emax, m_emin, m_index, GModelSpectral::m_pars, m_values, and gammalib::str().
Referenced by append(), copy_members(), extend(), init_members(), insert(), read(), and remove().
|
virtual |
Write model into XML element.
[in] | xml | XML element into which model information is written. |
GException::invalid_value | Existing XML element is not of required type Invalid number of model parameters or bins found in XML element. |
Writes the spectral information into an XML element. The format of the XML element is
<spectrum type="BinFunction"> <parameter name="Index" ../> <bin> <parameter name="LowerLimit" ../> <parameter name="UpperLimit" ../> <parameter name="Intensity" ../> </bin> ... <bin> <parameter name="LowerLimit" ../> <parameter name="UpperLimit" ../> <parameter name="Intensity" ../> </bin> </spectrum>
Implements GModelSpectral.
Definition at line 667 of file GModelSpectralBins.cpp.
References GXmlNode::append(), bins(), GXmlNode::element(), GXmlNode::elements(), emax(), emin(), G_WRITE, index(), intensity(), m_emax, m_emin, m_index, m_values, GOptimizerPar::name(), gammalib::str(), type(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().
|
protected |
Upper energy limits.
Definition at line 124 of file GModelSpectralBins.hpp.
Referenced by append(), bin_index(), copy_members(), eflux(), emax(), extend(), flux(), init_members(), insert(), mc_update(), read(), remove(), reserve(), set_cache(), update_pars(), and write().
|
protected |
Lower energy limits.
Definition at line 123 of file GModelSpectralBins.hpp.
Referenced by append(), bin_index(), copy_members(), eflux(), emin(), extend(), flux(), init_members(), insert(), mc_update(), read(), remove(), reserve(), set_cache(), update_pars(), and write().
|
mutableprotected |
Power-law pivot energies in MeV.
Definition at line 128 of file GModelSpectralBins.hpp.
Referenced by copy_members(), eflux(), eval(), flux(), init_members(), mc_update(), and set_cache().
|
protected |
Spectral index of all bins.
Definition at line 122 of file GModelSpectralBins.hpp.
Referenced by copy_members(), eflux(), eval(), flux(), index(), init_members(), mc_update(), read(), update_pars(), and write().
|
mutableprotected |
Cumulative distribution.
Definition at line 133 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Maximum energy.
Definition at line 132 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), and mc_update().
|
mutableprotected |
Minimum energy.
Definition at line 131 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), and mc_update().
|
mutableprotected |
Exponent for MC.
Definition at line 136 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Upper boundary for MC.
Definition at line 135 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Lower boundary for MC.
Definition at line 134 of file GModelSpectralBins.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
protected |
Bin values.
Definition at line 125 of file GModelSpectralBins.hpp.
Referenced by append(), bins(), copy_members(), eflux(), error(), eval(), extend(), flux(), init_members(), insert(), intensity(), mc_update(), read(), remove(), reserve(), update_pars(), and write().