Skip to content

Commit

Permalink
auto-derive alternate tiles extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed Aug 23, 2024
1 parent 63e0ea4 commit 9ce098b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bin/desi_create_tiletable
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def main():
import argparse
p = argparse.ArgumentParser()
p.add_argument('-o', '--outfile', required=True, help="output filename")
p.add_argument('--outfile2', required=False, help="Additional output filename (e.g. csv instead of fits)")
p.add_argument('--specprod', required=False, help="specprod to use")
p.add_argument('--nproc', type=int, default=32, help="number of processes to use")
p.add_argument('--debug', action="store_true", help="start ipython at the end")
p.epilog = 'Note: in addition to --outfile, also writes .csv or .fits equivalent'
args = p.parse_args()

log = get_logger()
Expand Down Expand Up @@ -145,11 +145,20 @@ def main():
os.rename(tmpfile, args.outfile)
log.info(f'Wrote {args.outfile}')

if args.outfile2 is not None:
tmpfile = get_tempfilename(args.outfile2)
prefix, extension = os.path.splitext(args.outfile)
if extension == '.csv':
altoutfile = prefix+'.fits'
elif extension == '.fits' or extension == '.fits.gz':
altoutfile = prefix+'.csv'
else:
log.info('Unrecognized outfile extension %s; not writing alternate .csv/.fits file')
altoutfile = None

if altoutfile is not None:
tmpfile = get_tempfilename(altoutfile)
results.write(tmpfile)
os.rename(tmpfile, args.outfile2)
log.info(f'Wrote {args.outfile2}')
os.rename(tmpfile, altoutfile)
log.info(f'Wrote {altoutfile}')

if args.debug:
import IPython; IPython.embed()
Expand Down

0 comments on commit 9ce098b

Please sign in to comment.