diff --git a/py/desisim/io.py b/py/desisim/io.py index 14ad8307d..710cbdeed 100644 --- a/py/desisim/io.py +++ b/py/desisim/io.py @@ -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 @@ -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 diff --git a/py/desisim/obs.py b/py/desisim/obs.py index e8c89326b..c3700d029 100644 --- a/py/desisim/obs.py +++ b/py/desisim/obs.py @@ -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 diff --git a/py/desisim/targets.py b/py/desisim/targets.py index 6f957cfe9..79653059c 100644 --- a/py/desisim/targets.py +++ b/py/desisim/targets.py @@ -10,6 +10,7 @@ import random import desisim.cosmology import desisim.interpolation +from desimodel.focalplane import FocalPlane import astropy.units import math import string @@ -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] @@ -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)