Commit cd73ba2b authored by Médéric Boquien's avatar Médéric Boquien

Make sure the line fluxes units are correct.

parent 0d52118c
Pipeline #3154 skipped with stage
......@@ -13,6 +13,7 @@
- The `save_chi2` parameter was not correctly acknowledged in `pcigale-plots pdf`, leading to a crash as it tried to build the PDF of parameters for which the corresponding `chi2` files were not saved. (Médéric Boquien, reported by Laia Barrufet de Soto)
- The help of `pcigale-plots sed` incorrectly reported that the values given to the `--xrange` option were in nm, rather than μm. (Médéric Boquien, reported by Guang Yang)
- A run with an already existing `out/` directory led to a crash under Microsoft Windows. This was due to renaming `out/` to add the time with hours, minutes, and second separated by a colon. This is not allowed on this platform. The renamed directory has not been made compact and does not use colons anymore. (Médéric Boquien, reported by Samir Salim)
- The units of line fluxes were not always correct for Bayesian estimates. (Médéric Boquien, reported by Katarzyna Małek)
### Optimised
- The estimation of the physical properties and the related uncertainties has been made up to 50% faster. The final gain in the analysis speed accounting for all the steps depends on the number of properties to be evaluated and the number of models but can be over 25% when estimating many properties over a large parameter space. (Médéric Boquien)
- Invalid models (e.g., when the stellar populations are older than the universe) are now ignored when handling upper limits. The speedup is very variable but can be substantial in case there are many invalid models. (Médéric Boquien)
......
......@@ -366,6 +366,25 @@ class ResultsManager(object):
return merged
@staticmethod
def fluxunit(band):
"""Help function to determine whether the band is a line or a filter
and returns the appropriate unit.
Parameters
----------
band: str
Name of the band. For a line it must start with ".line".
Returns
-------
unit: astropy.unit.Unit
Unit of the band flux.
"""
if band.startswith('line.') or band.startswith('linefilter.'):
return Unit('W/m^2')
return Unit('mJy')
def save(self, filename):
"""Save the estimated values derived from the analysis of the PDF and
the parameters associated with the best fit. A simple text file and a
......@@ -399,11 +418,12 @@ class ResultsManager(object):
table.add_column(Column(self.bayes.exterror[prop],
name="bayes."+prop+"_err", unit=unit))
for band in sorted(self.bayes.fluxmean):
unit = self.fluxunit(band)
table.add_column(Column(self.bayes.fluxmean[band],
name="bayes."+band, unit=Unit('mJy')))
name="bayes."+band, unit=unit))
table.add_column(Column(self.bayes.fluxerror[band],
name="bayes."+band+"_err",
unit=Unit('mJy')))
unit=unit))
table.add_column(Column(self.best.chi2, name="best.chi_square"))
obs = [self.obs.table[obs].data for obs in self.obs.tofit]
......@@ -421,12 +441,9 @@ class ResultsManager(object):
unit=Unit(self.unit[prop])))
for band in self.best.flux:
if band.startswith('line.') or band.startswith('linefilter.'):
unit = 'W/m^2'
else:
unit = 'mJy'
table.add_column(Column(self.best.flux[band],
name="best."+band, unit=unit))
name="best."+band,
unit=self.fluxunit(band)))
table.write(f"out/{filename}.txt", format='ascii.fixed_width',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment