Commit d8b429b6c0427c01a4208934a611fe23b32aa42d
1 parent
24b82670
Make DRW an optional parameter in XML file
Showing
1 changed file
with
13 additions
and
3 deletions
inst/com/src/GCOMObservation.cpp
... | ... | @@ -518,6 +518,8 @@ double GCOMObservation::npred(const GModel& model) const |
518 | 518 | * <parameter name="DRX" file="m32171_drx.fits"/> |
519 | 519 | * <parameter name="IAQ" value="UNH(1.0-3.0)MeV"/> |
520 | 520 | * </observation> |
521 | + * | |
522 | + * Note that the DRW parameter is optional. | |
521 | 523 | ***************************************************************************/ |
522 | 524 | void GCOMObservation::read(const GXmlElement& xml) |
523 | 525 | { |
... | ... | @@ -568,11 +570,15 @@ void GCOMObservation::read(const GXmlElement& xml) |
568 | 570 | // Get parameters |
569 | 571 | std::string drename = gammalib::xml_get_attr(G_READ, xml, "DRE", "file"); |
570 | 572 | std::string drbname = gammalib::xml_get_attr(G_READ, xml, "DRB", "file"); |
571 | - std::string drwname = gammalib::xml_get_attr(G_READ, xml, "DRW", "file"); | |
572 | 573 | std::string drgname = gammalib::xml_get_attr(G_READ, xml, "DRG", "file"); |
573 | 574 | std::string drxname = gammalib::xml_get_attr(G_READ, xml, "DRX", "file"); |
574 | 575 | std::string iaqname = gammalib::xml_get_attr(G_READ, xml, "IAQ", "value"); |
575 | 576 | |
577 | + // Optionally get DRW | |
578 | + std::string drwname = (gammalib::xml_has_par(xml, "DRW")) ? | |
579 | + gammalib::xml_get_attr(G_READ, xml, "DRW", "file") : | |
580 | + ""; | |
581 | + | |
576 | 582 | // Expand file names |
577 | 583 | drename = gammalib::xml_file_expand(xml, drename); |
578 | 584 | drbname = gammalib::xml_file_expand(xml, drbname); |
... | ... | @@ -659,6 +665,8 @@ void GCOMObservation::read(const GXmlElement& xml) |
659 | 665 | * <parameter name="DRX" file="m32171_drx.fits"/> |
660 | 666 | * <parameter name="IAQ" value="UNH(1.0-3.0)MeV"/> |
661 | 667 | * </observation> |
668 | + * | |
669 | + * Note that the DRW parameter is optional. | |
662 | 670 | ***************************************************************************/ |
663 | 671 | void GCOMObservation::write(GXmlElement& xml) const |
664 | 672 | { |
... | ... | @@ -710,8 +718,10 @@ void GCOMObservation::write(GXmlElement& xml) const |
710 | 718 | par->attribute("file", gammalib::xml_file_reduce(xml, m_drbname)); |
711 | 719 | |
712 | 720 | // Set DRW parameter |
713 | - par = gammalib::xml_need_par(G_WRITE, xml, "DRW"); | |
714 | - par->attribute("file", gammalib::xml_file_reduce(xml, m_drwname)); | |
721 | + if (m_drwname != "") { | |
722 | + par = gammalib::xml_need_par(G_WRITE, xml, "DRW"); | |
723 | + par->attribute("file", gammalib::xml_file_reduce(xml, m_drwname)); | |
724 | + } | |
715 | 725 | |
716 | 726 | // Set DRG parameter |
717 | 727 | par = gammalib::xml_need_par(G_WRITE, xml, "DRG"); | ... | ... |