/***********************************************************************//** * @brief Read sky model from XML element * * @param[in] xml XML element. ***************************************************************************/ void GModelSky::read(const GXmlElement& xml) { // Clear sky model clear(); // Get pointers on spectrum and spatial model GXmlElement* spec = static_cast<GXmlElement*>(xml.element("spectrum", 0)); GXmlElement* spat = static_cast<GXmlElement*>(xml.element("spatialModel", 0)); // Allocate constant GModelTemporalConst temporal; // Clone spatial and spectral models m_spatial = xml_spatial(*spat); m_spectral = xml_spectral(*spec); m_temporal = temporal.clone(); // Set model name name(xml.attribute("name")); // Set instruments instruments(xml.attribute("instrument")); // Set observation identifiers ids(xml.attribute("id")); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Read CTA cube background model from XML element * * @param[in] xml XML element. * * Set up CTA cube background model from the information provided by * an XML element. The XML element is expected to have the following * structure * * <source name="..." type="..." instrument="..."> * <spectrum type="..."> * ... * </spectrum> * </source> * * Optionally, a temporal model may be provided using the following * syntax * * <source name="..." type="..." instrument="..."> * <spectrum type="..."> * ... * </spectrum> * <temporalModel type="..."> * ... * </temporalModel> * </source> * * If no temporal component is found a constant model is assumed. ***************************************************************************/ void GCTAModelCubeBackground::read(const GXmlElement& xml) { // Clear model clear(); // Initialise XML elements const GXmlElement* spectral = NULL; const GXmlElement* temporal = NULL; // Get pointer on spectrum spectral = xml.element("spectrum", 0); // Extract spectral model m_spectral = xml_spectral(*spectral); // Optionally get temporal model if (xml.elements("temporalModel")) { temporal = xml.element("temporalModel", 0); m_temporal = xml_temporal(*temporal); } else { GModelTemporalConst constant; m_temporal = constant.clone(); } // Read model attributes read_attributes(xml); // Set parameter pointers set_pointers(); // Return return; }
// Operators virtual GTestModelData& operator=(const GTestModelData& model) { if (this != &model) { this->GModelData::operator=(model); free_members(); copy_members(model); set_pointers(); } return *this; }
/***********************************************************************//** * @brief Copy class members * * @param[in] model Sky model. ***************************************************************************/ void GModelSky::copy_members(const GModelSky& model) { // Clone spatial and spectral models m_spatial = (model.m_spatial != NULL) ? model.m_spatial->clone() : NULL; m_spectral = (model.m_spectral != NULL) ? model.m_spectral->clone() : NULL; m_temporal = (model.m_temporal != NULL) ? model.m_temporal->clone() : NULL; // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief XML constructor * * @param[in] xml XML element. * * Constructs a CTA cube background model from the information provided by * an XML elements (see GCTAModelCubeBackground::read method). ***************************************************************************/ GCTAModelCubeBackground::GCTAModelCubeBackground(const GXmlElement& xml) : GModelData(xml) { // Initialise members init_members(); // Read XML read(xml); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Copy constructor * * @param[in] model CTA background model. * * Constructs a CTA background model by copying information from an * existing model. Note that the copy is a deep copy, so the original object * can be destroyed after the copy without any loss of information. ***************************************************************************/ GCTAModelBackground::GCTAModelBackground(const GCTAModelBackground& model) : GModelData(model) { // Initialise private members for clean destruction init_members(); // Copy members copy_members(model); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Read CTA instrument background model from XML element * * @param[in] xml XML element. * * Set up CTA instrument background model from the information provided by * an XML element. The XML element is expected to have the following * structure * * <source name="..." type="..." instrument="..."> * <spectrum type="..."> * ... * </spectrum> * </source> * * Optionally, a temporal model may be provided using the following * syntax * * <source name="..." type="..." instrument="..."> * <spectrum type="..."> * ... * </spectrum> * <temporalModel type="..."> * ... * </temporalModel> * </source> * * If no temporal component is found a constant model is assumed. ***************************************************************************/ void GCTAModelIrfBackground::read(const GXmlElement& xml) { // Clear model clear(); // Initialise XML elements const GXmlElement* spectral = NULL; const GXmlElement* temporal = NULL; // Get pointer on spectrum spectral = xml.element("spectrum", 0); // Extract spectral model m_spectral = xml_spectral(*spectral); // Optionally get temporal model if (xml.elements("temporalModel")) { temporal = xml.element("temporalModel", 0); m_temporal = xml_temporal(*temporal); } else { GModelTemporalConst constant; m_temporal = constant.clone(); } // Set model name name(xml.attribute("name")); // Set instruments instruments(xml.attribute("instrument")); // Set observation identifiers ids(xml.attribute("id")); // Check flag if TS value should be computed bool tscalc = (xml.attribute("tscalc") == "1") ? true : false; // Set flag if TS value should be computed this->tscalc(tscalc); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Copy class members * * @param[in] model Model. ***************************************************************************/ void GCOMModelDRBFitting::copy_members(const GCOMModelDRBFitting& model) { // Copy members m_phibars = model.m_phibars; m_values = model.m_values; // Copy cache m_scale = model.m_scale; m_fixed = model.m_fixed; m_old_phibars = model.m_old_phibars; m_nodes = model.m_nodes; // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Copy class members * * @param[in] bgd CTA background model. ***************************************************************************/ void GCTAModelCubeBackground::copy_members(const GCTAModelCubeBackground& bgd) { // Copy cache m_npred_names = bgd.m_npred_names; m_npred_energies = bgd.m_npred_energies; m_npred_times = bgd.m_npred_times; m_npred_values = bgd.m_npred_values; // Clone spectral and temporal model components m_spectral = (bgd.m_spectral != NULL) ? bgd.m_spectral->clone() : NULL; m_temporal = (bgd.m_temporal != NULL) ? bgd.m_temporal->clone() : NULL; // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Construct from spectral component * * @param[in] spectral Spectral model component. * * Constructs a CTA cube background model from a spectral model component. * The temporal component is assumed to be constant. Please refer to the * class GModelSpectral to learn more about the definition of the spectral * components. ***************************************************************************/ GCTAModelCubeBackground::GCTAModelCubeBackground(const GModelSpectral& spectral) : GModelData() { // Initialise members init_members(); // Allocate temporal constant model GModelTemporalConst temporal; // Clone model components m_spectral = spectral.clone(); m_temporal = temporal.clone(); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Copy class members * * @param[in] model Model. * * @todo Document method. ***************************************************************************/ void GCTAModelBackground::copy_members(const GCTAModelBackground& model) { // Copy cache m_npred_names = model.m_npred_names; m_npred_energies = model.m_npred_energies; m_npred_times = model.m_npred_times; m_npred_values = model.m_npred_values; // Clone radial, spectral and temporal model components m_spatial = (model.m_spatial != NULL) ? model.m_spatial->clone() : NULL; m_spectral = (model.m_spectral != NULL) ? model.m_spectral->clone() : NULL; m_temporal = (model.m_temporal != NULL) ? model.m_temporal->clone() : NULL; // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief Read model from XML element * * @param[in] xml XML element. * * The model is composed of a spectrum component ('spectral'), a spatial * component ('spatialModel'), and, optionally, of a temporal component * ('lightcurve'). If no temporal component is found a constant model is * assumed. ***************************************************************************/ void GCTAModelBackground::read(const GXmlElement& xml) { // Clear model clear(); // Initialise XML elements const GXmlElement* spat = NULL; const GXmlElement* spec = NULL; const GXmlElement* temp = NULL; // Get pointers on spectrum and radial model spat = xml.element("spatialModel", 0); spec = xml.element("spectrum", 0); // Clone radial and spectral models m_spatial = xml_spatial(*spat); m_spectral = xml_spectral(*spec); // Optionally get temporal model if (xml.elements("temporalModel")) { temp = xml.element("temporalModel", 0); m_temporal = xml_temporal(*temp); } else { GModelTemporalConst temporal; m_temporal = temporal.clone(); } // Set model name name(xml.attribute("name")); // Set instruments instruments(xml.attribute("instrument")); // Set observation identifiers ids(xml.attribute("id")); // Set parameter pointers set_pointers(); // Return return; }
cir_storage_err_t cir_storage_clear(cir_storage_t * self, uint32_t size) { cir_storage_flash_t *storage = (cir_storage_flash_t *)self; if (size == 0) { /* Put the read pointer at same location as the write pointer */ READ_PTR(storage) = WRITE_PTR(storage); } else { /* Move the read pointer of "size" */ READ_PTR(storage) += size; manage_block_overflow(storage, size, POINTER_READ); } if (set_pointers(storage, &storage->pointers) == 0) return CBUFFER_STORAGE_SUCCESS; else return CBUFFER_STORAGE_ERROR; }
/***********************************************************************//** * @brief Construct sky model from spatial and spectral XML elements * * @param[in] spatial Spatial XML element. * @param[in] spectral Spectral XML element. ***************************************************************************/ GModelSky::GModelSky(const GXmlElement& spatial, const GXmlElement& spectral) : GModel() { // Initialise private members for clean destruction init_members(); // Allocate constant GModelTemporalConst temporal; // Clone spatial and spectral models m_spatial = xml_spatial(spatial); m_spectral = xml_spectral(spectral); m_temporal = temporal.clone(); // Set parameter pointers set_pointers(); // Return return; }
/***********************************************************************//** * @brief XML constructor * * @param[in] xml XML element. ***************************************************************************/ GModelSky::GModelSky(const GXmlElement& xml) : GModel(xml) { // Initialise private members for clean destruction init_members(); // Get pointers on spectrum and spatial model GXmlElement* spec = static_cast<GXmlElement*>(xml.element("spectrum", 0)); GXmlElement* spat = static_cast<GXmlElement*>(xml.element("spatialModel", 0)); // Allocate constant GModelTemporalConst temporal; // Clone spatial and spectral models m_spatial = xml_spatial(*spat); m_spectral = xml_spectral(*spec); m_temporal = temporal.clone(); // Set parameter pointers set_pointers(); // Return return; }
cir_storage_err_t cir_storage_push(cir_storage_t *self, uint8_t *buf, uint32_t len) { cir_storage_flash_t *storage = (cir_storage_flash_t *)self; if ( (len > storage->block_size) || (len <= 0) || (buf == NULL) ) { return CBUFFER_STORAGE_ERROR; } if (manage_block_overflow(storage, len, POINTER_WRITE)) { if (storage->erase(WRITE_PTR(storage)/storage->block_size, 1) !=0) { return CBUFFER_STORAGE_ERROR; } /* If read pointer is in the erased block, we move it on the next one */ if ((WRITE_PTR(storage) / storage->block_size) == (READ_PTR(storage) / storage->block_size)) { READ_PTR(storage) = storage->address_start+storage->block_size+ (WRITE_PTR(storage) - storage->address_start)% (storage->parent.size - storage->block_size); } } if (storage->write(WRITE_PTR(storage), len, buf) != 0) { return CBUFFER_STORAGE_ERROR; } /* We increase data pointer write and copy it in pointers block */ WRITE_PTR(storage) += len; if (set_pointers(storage, &storage->pointers) != 0) { return CBUFFER_STORAGE_ERROR; } return CBUFFER_STORAGE_SUCCESS; }
// Constructors and destructors GTestModelData(void) : GModelData() { init_members(); set_pointers(); return; }
static DEVICE_START(aes_pcb_std) { /* device is aes_cartslot:cartridge:pcb */ // printf("DEVICE_START(aes_pcb_std), tag of device=%s\n", device->tag()); set_pointers(device, get_index_from_tagname(device->owner())-1); }
explicit GTestModelData(const GXmlElement& xml) : GModelData(xml) { init_members(); m_modelTps = new GModelTemporalConst(); set_pointers(); return; }
explicit GTestModelData(const GXmlElement& xml) : GModelData(xml) { init_members(); set_pointers(); return; }
/***********************************************************************//** * @brief Read model from XML element * * @param[in] xml XML element. * * @exception GException::invalid_value * Model definition requires at least one node. * * Read the COMPTEL DRB fitting model from an XML element. * * The model is composed of nodes that define the normalization value as * function of Phibar value. The following XML file syntax is expected: * * <source name="Background" type="DRBFitting" instrument="COM"> * <node> * <parameter name="Phibar" .../> * <parameter name="Normalization" .../> * </node> * ... * <node> * <parameter name="Phibar" .../> * <parameter name="Normalization" .../> * </node> * </source> ***************************************************************************/ void GCOMModelDRBFitting::read(const GXmlElement& xml) { // Free space for nodes m_phibars.clear(); m_values.clear(); // Get number of nodes from XML file int nodes = xml.elements("node"); // Throw an error if there are no nodes if (nodes < 1) { std::string msg = "DRB fitting model requires at least one Phibar " "node. Please correct XML format."; throw GException::invalid_value(G_READ, msg); } // Loop over all nodes for (int i = 0; i < nodes; ++i) { // Allocate node parameters GModelPar phibar; GModelPar normalization; // Get node const GXmlElement* node = xml.element("node", i); // Read Phibar parameter const GXmlElement* par = gammalib::xml_get_par(G_READ, *node, "Phibar"); phibar.read(*par); // Read Normalization parameter par = gammalib::xml_get_par(G_READ, *node, "Normalization"); normalization.read(*par); // Set parameter names std::string phibar_name = "Phibar layer "+gammalib::str(i); std::string normalization_name = "Scale factor "+gammalib::str(i); // Set Phibar attributes phibar.name(phibar_name); phibar.unit("deg"); phibar.has_grad(false); // Set normalization attributes normalization.name(normalization_name); normalization.unit(""); normalization.has_grad(true); // Push node parameters on list m_phibars.push_back(phibar); m_values.push_back(normalization); } // endfor: looped over nodes // Set model name name(xml.attribute("name")); // Set instruments instruments(xml.attribute("instrument")); // Set observation identifiers ids(xml.attribute("id")); // Check flag if TS value should be computed bool tscalc = (xml.attribute("tscalc") == "1") ? true : false; // Set flag if TS value should be computed this->tscalc(tscalc); // Set pointers set_pointers(); // Set evluation cache set_cache(); // Return return; }
void copy_members(const GTestModelData& model){ m_modelTps=model.temporal()->clone(); // Set parameter pointers set_pointers(); }
GTestModelData(const GTestModelData& model) : GModelData(model) { copy_members(model); set_pointers(); return; }