From ca88109bbcb96a94e26f2e7255dee100fb92ab2f Mon Sep 17 00:00:00 2001 From: imedan Date: Fri, 6 Sep 2024 10:33:11 -0500 Subject: [PATCH 1/5] specify dtype --- bin/create_designid_status_replace_designs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/create_designid_status_replace_designs.py b/bin/create_designid_status_replace_designs.py index a303965..f3f28ee 100644 --- a/bin/create_designid_status_replace_designs.py +++ b/bin/create_designid_status_replace_designs.py @@ -167,8 +167,8 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None): status[:] = 'not started' # add the new HDU - status['designid'] = designid - status['status'] = status + status['designid'] = np.array(designid, dtype='>i4') + status['status'] = np.array(status, dtype='S20') hdu_status = fits.BinTableHDU(status, name='STATUS') hdu.append(hdu_status) From 4756d993d6d1315aef72c1ec9375e7b0029556d1 Mon Sep 17 00:00:00 2001 From: imedan Date: Fri, 6 Sep 2024 10:49:45 -0500 Subject: [PATCH 2/5] print that --- bin/create_designid_status_replace_designs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/create_designid_status_replace_designs.py b/bin/create_designid_status_replace_designs.py index f3f28ee..dcc0b58 100644 --- a/bin/create_designid_status_replace_designs.py +++ b/bin/create_designid_status_replace_designs.py @@ -167,8 +167,9 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None): status[:] = 'not started' # add the new HDU - status['designid'] = np.array(designid, dtype='>i4') - status['status'] = np.array(status, dtype='S20') + print(designid) + status['designid'] = designid + status['status'] = status hdu_status = fits.BinTableHDU(status, name='STATUS') hdu.append(hdu_status) From cec32c9d8f1ac4c02cd3263a65b0a3eace0144cc Mon Sep 17 00:00:00 2001 From: imedan Date: Fri, 6 Sep 2024 11:04:17 -0500 Subject: [PATCH 3/5] dont rename stuff --- bin/create_designid_status_replace_designs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/create_designid_status_replace_designs.py b/bin/create_designid_status_replace_designs.py index dcc0b58..690d4b0 100644 --- a/bin/create_designid_status_replace_designs.py +++ b/bin/create_designid_status_replace_designs.py @@ -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, @@ -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: @@ -161,16 +161,16 @@ 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 print(designid) - 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') From 011e4937f1376f24b6d86a83f179e9f930b75fa3 Mon Sep 17 00:00:00 2001 From: imedan Date: Fri, 6 Sep 2024 11:19:38 -0500 Subject: [PATCH 4/5] change write method --- bin/create_designid_status_replace_designs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/create_designid_status_replace_designs.py b/bin/create_designid_status_replace_designs.py index 690d4b0..561855b 100644 --- a/bin/create_designid_status_replace_designs.py +++ b/bin/create_designid_status_replace_designs.py @@ -167,10 +167,9 @@ def designid_status(design_file, obsTime, exp, fexp, field_id, des_objs=None): status[:] = 'not started' # add the new HDU - print(designid) status_hdu['designid'] = designid status_hdu['status'] = 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') From 3ec10741a4ce1e58f19a9cbf7e11f180f2749643 Mon Sep 17 00:00:00 2001 From: imedan Date: Mon, 9 Sep 2024 16:39:07 -0500 Subject: [PATCH 5/5] point to right status file --- bin/replace_RS_designs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/replace_RS_designs.py b/bin/replace_RS_designs.py index 900f6a4..04ed738 100644 --- a/bin/replace_RS_designs.py +++ b/bin/replace_RS_designs.py @@ -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() @@ -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