Skip to content

Commit

Permalink
Merge branch 'sjb-cleanup-formats'
Browse files Browse the repository at this point in the history
  • Loading branch information
sbailey committed Jan 30, 2015
2 parents 4a9a52e + 446037b commit 76a01c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions py/desisim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def write_simspec(meta, truth, expid, night, header=None):
hdr['AIRORVAC'] = ('vac', 'Vacuum wavelengths')
hdr['LOGLAM'] = (0, 'linear wavelength steps, not log10')
hdr['EXTNAME'] = ('FLUX', 'Object flux [erg/s/cm2/A]')
fits.writeto(outfile, truth['FLUX'], header=hdr, clobber=True)
fits.writeto(outfile, truth['FLUX'].astype(np.float32), header=hdr, clobber=True)

#- Sky flux
hdr['EXTNAME'] = ('SKYFLUX', 'Sky flux [erg/s/cm2/A/arcsec2]')
hdu = fits.ImageHDU(truth['SKYFLUX'], header=hdr)
hdu = fits.ImageHDU(truth['SKYFLUX'].astype(np.float32), header=hdr)
fits.append(outfile, hdu.data, header=hdu.header)

#- Metadata table
Expand Down Expand Up @@ -155,12 +155,12 @@ def write_simspec(meta, truth, expid, night, header=None):

extname = 'PHOT_'+channel
hdr['EXTNAME'] = (extname, channel+' channel object photons per bin')
hdu = fits.ImageHDU(truth[extname], header=hdr)
hdu = fits.ImageHDU(truth[extname].astype(np.float32), header=hdr)
fits.append(outfile, hdu.data, header=hdu.header)

extname = 'SKYPHOT_'+channel
hdr['EXTNAME'] = (extname, channel+' channel sky photons per bin')
hdu = fits.ImageHDU(truth[extname], header=hdr)
hdu = fits.ImageHDU(truth[extname].astype(np.float32), header=hdr)
fits.append(outfile, hdu.data, header=hdu.header)

return outfile
Expand Down
2 changes: 1 addition & 1 deletion py/desisim/obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def new_exposure(nspec=5000, expid=None, tileid=None, airmass=1.0, exptime=None)
#- 2D version
### truth['SKYPHOT_'+channel] = np.tile(skyphot, nspec).reshape((nspec, len(ii)))
#- 1D version
truth['SKYPHOT_'+channel] = skyphot
truth['SKYPHOT_'+channel] = skyphot.astype(np.float32)

#- NOTE: someday skyflux and skyphot may be 2D instead of 1D

Expand Down
20 changes: 15 additions & 5 deletions py/desisim/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import random
import desisim.cosmology
import desisim.interpolation
from desimodel.focalplane import FocalPlane
import astropy.units
import math
import string
Expand Down Expand Up @@ -186,7 +187,16 @@ def get_targets(nspec, tileid=None):
#- Load fiber -> positioner mapping and tile information
#- NOTE: multiple file I/O here; seems clumsy
fiberpos = io.load_fiberpos()


#- Where are these targets? Centered on positioners for now.
x = fiberpos['X'][0:nspec]
y = fiberpos['Y'][0:nspec]
fp = FocalPlane(tile_ra, tile_dec)
ra = np.zeros(nspec)
dec = np.zeros(nspec)
for i in range(nspec):
ra[i], dec[i] = fp.xy2radec(x[i], y[i])

#- Fill in the rest of the fibermap structure
fibermap['FIBER'] = np.arange(nspec, dtype='i4')
fibermap['POSITIONER'] = fiberpos['POSITIONER'][0:nspec]
Expand All @@ -195,10 +205,10 @@ def get_targets(nspec, tileid=None):
fibermap['TARGETCAT'] = np.zeros(nspec, dtype='|S20')
fibermap['LAMBDAREF'] = np.ones(nspec, dtype=np.float32)*5400
fibermap['TARGET_MASK0'] = np.zeros(nspec, dtype='i8')
fibermap['RA_TARGET'] = np.ones(nspec, dtype='f8') * tile_ra #- TODO
fibermap['DEC_TARGET'] = np.ones(nspec, dtype='f8') * tile_dec #- TODO
fibermap['X_TARGET'] = fiberpos['X'][0:nspec]
fibermap['Y_TARGET'] = fiberpos['Y'][0:nspec]
fibermap['RA_TARGET'] = ra
fibermap['DEC_TARGET'] = dec
fibermap['X_TARGET'] = x
fibermap['Y_TARGET'] = y
fibermap['X_FVCOBS'] = fibermap['X_TARGET']
fibermap['Y_FVCOBS'] = fibermap['Y_TARGET']
fibermap['X_FVCERR'] = np.zeros(nspec, dtype=np.float32)
Expand Down

0 comments on commit 76a01c9

Please sign in to comment.