Bug #1283

GCTAObservation::Write() don't write irf elements into xml file

Added by Lu Chia-Chun over 10 years ago. Updated over 10 years ago.

Status:ClosedStart date:07/16/2014
Priority:NormalDue date:
Assigned To:Lu Chia-Chun% Done:

100%

Category:-
Target version:00-09-00
Duration:

Description

The attached codes are intended for loading irfs for a given run, and create an observation xml file by the write(GXmlElement) method. write() is supposed to write elements of eventlist, aeff, psf etc. into an xml file.

write() doesn’t work as expected because m_aeffname, m_psfname etc... are not filled except when the irfs are assigned by reading an input xml.

I propose the following:
fill m_aeffname etc. in GCTAObservation::response(rsp) when a rsp is assigned.

  1. set up a cta observation
    cta = GCTAObservation()
    cta.id('{run}'.format(**globals()))
    cta.load(f_event)
    print 'load’, f_event
    rsp = cta.response()
    rsp.load_aeff(f_aeff)
    print 'load’, f_aeff
    rsp.load_psf(f_psf)
    print 'load’, f_psf
    rsp.load_background(f_bg)
    print 'load’, f_bg
    cta.response(rsp)
    xmlelm = GXmlElement('observation_list’)
    cta.write(xmlelm)

Recurrence

No recurrence.

History

#1 Updated by Lu Chia-Chun over 10 years ago

I added a few lines in GCTAObservation::response(). It seems to work.
Please check this branch.
https://github.com/chiachun/gammalib/tree/1278.2-improve-GCTAResponseTable

void GCTAObservation::response(const GResponse& rsp) {
// Get pointer on CTA response
const GCTAResponse* ctarsp = dynamic_cast<const GCTAResponse*>(&rsp);
if (ctarsp == NULL) {
throw GCTAException::bad_response_type(G_RESPONSE);
}

// Copy response function
m_response = *ctarsp;
// Copy filenames of response functions
if (m_response.aeff()){
m_aeffname = m_response.aeff()->filename();
}
if (m_response.psf()){
m_psfname = m_response.psf()->filename();
}
if (m_response.edisp()){
m_edispname = m_response.edisp()->filename();
}
if (m_response.background()){
m_bgdname = m_response.background()->filename();
}
// Return
return;
}

#2 Updated by Knödlseder Jürgen over 10 years ago

  • Status changed from New to Resolved
  • Assigned To set to Lu Chia-Chun
  • Target version set to 00-09-00
  • % Done changed from 0 to 100

Indeed, this looks reasonable. Merging of the code will be done when resolving action #1278.

#3 Updated by Knödlseder Jürgen over 10 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF