From b244793445d697a8a634a71376bcc0e6258d3f4e Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Fri, 30 Jan 2015 14:10:14 -0800 Subject: [PATCH] Fixed interpretation of units in input template files --- py/desisim/io.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/py/desisim/io.py b/py/desisim/io.py index d3d1979f4..14ad8307d 100644 --- a/py/desisim/io.py +++ b/py/desisim/io.py @@ -263,8 +263,9 @@ def read_templates(wave, objtype, n, randseed=1): - n : number of templates to return Returns flux[n, len(wave)], meta[n] - - where meta is a metadata table from the input template file + + where flux is in units of 1e-17 erg/s/cm2/A/[arcsec^2] and + meta is a metadata table from the input template file with redshift, mags, etc. Requires $DESI_{objtype}_TEMPLATES to be set, pointing to a file that @@ -283,6 +284,18 @@ def read_templates(wave, objtype, n, randseed=1): meta = fits.getdata(infile, 1).view(np.recarray) ww = 10**(hdr['CRVAL1'] + np.arange(hdr['NAXIS1'])*hdr['CDELT1']) + #- Check flux units + fluxunits = hdr['BUNIT'] + if not fluxunits.startswith('1e-17 erg'): + if fluxunits.startswith('erg'): + flux *= 1e17 + else: + #- check for '1e-16 erg/s/cm2/A' style units + scale, units = fluxunits.split() + assert units.startswith('erg') + scale = float(scale) + flux *= (scale*1e17) + ntemplates = flux.shape[0] randindex = np.arange(ntemplates) np.random.shuffle(randindex)