Skip to content

Commit

Permalink
bad pull
Browse files Browse the repository at this point in the history
  • Loading branch information
imedan committed Sep 10, 2024
2 parents d92976b + 3ec1074 commit f48b723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 7 additions & 7 deletions bin/create_designid_status_replace_designs.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None):
dtype = np.dtype([('fieldid', '>i4'),
('designid', '>i4'),
('status', 'S20')])
status = np.zeros(n_exp, dtype=dtype)
status_hdu = np.zeros(n_exp, dtype=dtype)

# find if the field already exists and get designids if it does
same_field = targetdb.Field.select().where(hdu[0].header['RACEN'] == targetdb.Field.racen,
Expand All @@ -147,7 +147,7 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None):
targetdb.Field.field_id >= 100000)
if len(same_field) > 0:
field_id = same_field[0].field_id
status['fieldid'] = np.zeros(n_exp, dtype='>i4') + field_id
status_hdu['fieldid'] = np.zeros(n_exp, dtype='>i4') + field_id
# get the design objects if running in parallel
if Ncores > 1 and n_exp > 1:
with Pool(processes=Ncores) as pool:
Expand All @@ -161,15 +161,15 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None):
designid, status = get_designid_status(file, field_id, des_objs=des_objs)
else:
field_id = -1
status['fieldid'] = np.zeros(n_exp, dtype='>i4') + field_id
status_hdu['fieldid'] = np.zeros(n_exp, dtype='>i4') + field_id
designid = np.zeros(n_exp, dtype='>i4') - 1
status = np.zeros(n_exp, dtype='S20')
status[:] = 'not started'

# add the new HDU
status['designid'] = designid
status['status'] = status
status_hdu['designid'] = designid
status_hdu['status'] = status

hdu_status = fits.BinTableHDU(status, name='STATUS')
hdu_status = fits.BinTableHDU(status_hdu, name='STATUS')
hdu.append(hdu_status)
hdu.write(file[:-5] + '_designid_status.fits')
hdu.writeto(file[:-5] + '_designid_status.fits')
7 changes: 5 additions & 2 deletions bin/replace_RS_designs.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
# get status files
files_status = []
for f in files:
files_status.append(f[:-5] + '-status.dat')
if os.path.exists(f[:-5] + '_designid_status.fits'):
files_status.append(f[:-5] + '_designid_status.fits')
else:
raise MugatuError(message='No designid_status file for field')

# get observatory insts
obsDB = targetdb.Observatory()
Expand Down Expand Up @@ -163,7 +166,7 @@
# get number of exposures
n_exp = head['NEXP']
if os.path.exists(status):
design_ids = np.genfromtxt(status, dtype=int)
design_ids = fits.open(status)['STATUS'].data['designid']
else:
design_ids = np.zeros(n_exp, dtype=int) - 1

Expand Down

0 comments on commit f48b723

Please sign in to comment.