From 8cb6668c2a35755bc13fa8baa8bd99f6ec452ef4 Mon Sep 17 00:00:00 2001 From: imedan Date: Thu, 30 May 2024 16:02:00 -0500 Subject: [PATCH] setup opsdb schema base don obs from file header --- bin/validate_designs_batches.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/validate_designs_batches.py b/bin/validate_designs_batches.py index 021c68b..7c999e7 100644 --- a/bin/validate_designs_batches.py +++ b/bin/validate_designs_batches.py @@ -39,18 +39,13 @@ primary_hdu.header['fps_calibrations_version'] = fps_calib_ver -def valid_field(all_files, offset_min_skybrightness, cache_bs, - observatory): +def valid_field(all_files, offset_min_skybrightness, cache_bs): # need import here for create new connection from mugatu.fpsdesign import FPSDesign from mugatu.designmode import (build_brigh_neigh_query, DesignModeCheck, allDesignModes, designid_status_valid) - # set up correct opsdb schema - from sdssdb.peewee.sdss5db import opsdb - os.environ["OBSERVATORY"] = observatory.upper() - opsdb.database.connect() def validate_design(design_file, exp, obsTime, db_query_results_boss, db_query_results_apogee, @@ -259,8 +254,6 @@ def valid_design_func(file, exp, obsTime, field_desmodes, desmodes[dm]) return valid_arr_des - desmodes = allDesignModes() - file = all_files[0] cache_file = all_files[1] if cache_bs: @@ -277,7 +270,14 @@ def valid_design_func(file, exp, obsTime, field_desmodes, design_ids = fits.open(file)['STATUS'].data['designid'] except KeyError: design_ids = np.zeros(n_exp, dtype=np.int32) - 1 + + # set up correct opsdb schema + from sdssdb.peewee.sdss5db import opsdb + os.environ["OBSERVATORY"] = head['obs'].strip().upper() + opsdb.database.connect() + # do db query results for each desmode in field + desmodes = allDesignModes() db_results_boss = {} db_results_apogee = {} for dm in np.unique(field_desmodes): @@ -574,7 +574,7 @@ def valid_design_func(file, exp, obsTime, field_desmodes, else: all_files = [(f, '') for f in files] res = tqdm(pool.imap(partial(valid_field, offset_min_skybrightness=offset_min_skybrightness, - cache_bs=cache_bs, observatory=observatory), + cache_bs=cache_bs), all_files), total=len(files)) res = [r for r in res]