Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw data now under NIGHT/EXPID/ not just NIGHT/ #384

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions py/desisim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def findfile(filetype, night, expid, camera=None, outdir=None, mkdir=True):

#- outdir default = $DESI_SPECTRO_SIM/$PIXPROD/{night}/
if outdir is None:
outdir = simdir(night)
outdir = simdir(night, expid)

#- Definition of where files go
location = dict(
Expand Down Expand Up @@ -1000,12 +1000,13 @@ def write_templates(outfile, flux, wave, meta):
#-------------------------------------------------------------------------
#- Utility functions

def simdir(night='', mkdir=False):
def simdir(night='', expid=0, mkdir=False):
"""
Return $DESI_SPECTRO_SIM/$PIXPROD/{night}
If mkdir is True, create directory if needed
"""
dirname = os.path.join(os.getenv('DESI_SPECTRO_SIM'), os.getenv('PIXPROD'), str(night))
dirname = os.path.join(os.getenv('DESI_SPECTRO_SIM'), os.getenv('PIXPROD'),
str(night), '{:08d}'.format(expid))
if mkdir and not os.path.exists(dirname):
os.makedirs(dirname)

Expand Down
4 changes: 2 additions & 2 deletions py/desisim/scripts/pixsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def expand_args(args):
args.rawfile = os.path.join(os.path.dirname(args.simspec), rawfile)

if args.simpixfile is None:
outdir = os.path.dirname(os.path.abspath(args.rawfile))
args.simpixfile = io.findfile(
'simpix', night=args.night, expid=args.expid,
outdir=os.path.dirname(os.path.abspath(args.rawfile)))
'simpix', night=args.night, expid=args.expid, outdir=outdir)


#-------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions py/desisim/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ def test_simdir(self):
x = io.simdir()
self.assertTrue(x is not None)
night = '20150101'
x = io.simdir(night)
self.assertTrue(x.endswith(night))
expid = 123
x = io.simdir(night, expid)
self.assertTrue(x.endswith(str(expid)))
x = io.simdir(int(night), expid)
self.assertTrue(x.endswith(str(expid)))
x = io.simdir(night, mkdir=True)
self.assertTrue(os.path.exists(x))

Expand Down
11 changes: 7 additions & 4 deletions py/desisim/test/test_pixsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ def test_main_override(self):
obs.new_exposure('arc', night=night, expid=expid, nspec=nspec)

#- derive night from simspec input while overriding expid
#- Include wavelengths covering z, but only ask for b and r
simspecfile = io.findfile('simspec', night, expid)
altrawfile = desispec.io.findfile('raw', night, expid) + '.blat'
altexpid = expid+1
altrawfile = desispec.io.findfile('raw', night, altexpid) + '.blat'
opts = [
'--simspec', simspecfile,
'--expid', expid+1,
'--expid', altexpid,
'--rawfile', altrawfile,
'--cameras', 'b0,r0',
'--wavemin', 5000, '--wavemax', 7000.0,
'--wavemin', 5500, '--wavemax', 7000.0,
'--ccd_npix_x', 2000,
]
if ncpu is not None:
Expand All @@ -237,7 +239,8 @@ def test_main_override(self):
log.debug('testing pixsim.main({})'.format(opts))
pixsimargs = desisim.scripts.pixsim.parse(opts)
desisim.scripts.pixsim.main(pixsimargs)
simpixfile = io.findfile('simpix', night, expid+1)
simpixfile = io.findfile('simpix', night, altexpid)

self.assertTrue(os.path.exists(simpixfile))
self.assertTrue(os.path.exists(altrawfile))
fx = fits.open(altrawfile)
Expand Down