From 6ac9aa52c0800290970a2290499d1bc3eaa98e13 Mon Sep 17 00:00:00 2001 From: Troy Raen Date: Wed, 11 Dec 2024 16:20:33 -0800 Subject: [PATCH 1/4] Include calibration level 2 for JWST results --- spectroscopy/code_src/mast_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spectroscopy/code_src/mast_functions.py b/spectroscopy/code_src/mast_functions.py index 0ad8defb..2975cd48 100644 --- a/spectroscopy/code_src/mast_functions.py +++ b/spectroscopy/code_src/mast_functions.py @@ -104,7 +104,7 @@ def JWST_get_spec_helper(sample_table, search_radius_arcsec, datadir, verbose, query_results = Observations.query_criteria( coordinates=search_coords, radius=search_radius_arcsec * u.arcsec, dataproduct_type=["spectrum"], obs_collection=["JWST"], intentType="science", - calib_level=[3, 4], instrument_name=['NIRSPEC/MSA', 'NIRSPEC/SLIT'], + calib_level=[2, 3, 4], instrument_name=['NIRSPEC/MSA', 'NIRSPEC/SLIT'], dataRights=['PUBLIC']) print("Number of search results: {}".format(len(query_results))) @@ -118,7 +118,7 @@ def JWST_get_spec_helper(sample_table, search_radius_arcsec, datadir, verbose, # Filter data_products_list_filter = Observations.filter_products( data_products_list, productType=["SCIENCE"], extension="fits", - calib_level=[3, 4], # only fully reduced or contributed + calib_level=[2, 3, 4], # only calibrated data productSubGroupDescription=["X1D"], # only 1D spectra dataRights=['PUBLIC']) # only public data print("Number of files to download: {}".format(len(data_products_list_filter))) From fc2bb996fd757e2a2bd3494483118a852bb1d2d5 Mon Sep 17 00:00:00 2001 From: Troy Raen Date: Mon, 16 Dec 2024 15:46:39 -0800 Subject: [PATCH 2/4] Bugfix: Match query 'obsid' to product 'parent_obsid' --- spectroscopy/code_src/mast_functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spectroscopy/code_src/mast_functions.py b/spectroscopy/code_src/mast_functions.py index 2975cd48..90aed7b0 100644 --- a/spectroscopy/code_src/mast_functions.py +++ b/spectroscopy/code_src/mast_functions.py @@ -140,8 +140,10 @@ def JWST_get_spec_helper(sample_table, search_radius_arcsec, datadir, verbose, tab = Table(names=keys + ["productFilename"], dtype=[str, str, str, int, float, int, int, int, float]+[str]) for jj in range(len(data_products_list_filter)): + # Match query 'obsid' to product 'parent_obsid' (not 'obsID') because products may + # belong to a different group than the observation. idx_cross = np.where(query_results["obsid"] == - data_products_list_filter["obsID"][jj])[0] + data_products_list_filter["parent_obsid"][jj])[0] tmp = query_results[idx_cross][keys] tab.add_row(list(tmp[0]) + [data_products_list_filter["productFilename"][jj]]) From bf4d32023aeed6a563a451e428e9ab6a6e1f744a Mon Sep 17 00:00:00 2001 From: Troy Raen Date: Mon, 16 Dec 2024 22:53:59 -0800 Subject: [PATCH 3/4] Ignore warning about all-NaN slices --- spectroscopy/code_src/mast_functions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spectroscopy/code_src/mast_functions.py b/spectroscopy/code_src/mast_functions.py index 90aed7b0..b1b0993f 100644 --- a/spectroscopy/code_src/mast_functions.py +++ b/spectroscopy/code_src/mast_functions.py @@ -242,6 +242,9 @@ def JWST_group_spectra(df, verbose, quickplot): fluxes_int = np.asarray( [np.interp(wave_grid, tab_sel.iloc[idx]["wave"], tab_sel.iloc[idx]["flux"]) for idx in idx_good]) fluxes_units = [tab_sel.iloc[idx]["flux"].unit for idx in idx_good] + + # Sometimes fluxes are all NaN. We'll leave these in and ignore the RuntimeWarning. + warnings.filterwarnings("ignore", message='All-NaN slice encountered', category=RuntimeWarning) fluxes_stack = np.nanmedian(fluxes_int, axis=0) if verbose: print("Units of fluxes for each spectrum: {}".format( From 0842e8637ee359474e1fe7490a6dac2c63871fd7 Mon Sep 17 00:00:00 2001 From: Troy Raen Date: Mon, 16 Dec 2024 23:17:05 -0800 Subject: [PATCH 4/4] Update runtime --- spectroscopy/spectra_generator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectroscopy/spectra_generator.md b/spectroscopy/spectra_generator.md index 33b2cc79..e79d2222 100644 --- a/spectroscopy/spectra_generator.md +++ b/spectroscopy/spectra_generator.md @@ -81,7 +81,7 @@ The ones with an asterisk (*) are the challenging ones. • ... ## Runtime -As of 2024 August, this notebook takes about 3 minutes to run to completion on Fornax using +As of 2024 December, this notebook takes about 17 minutes to run to completion on Fornax using Server Type: 'Standard - 8GB RAM/4 CPU' and Environment: 'Default Astrophysics' (image). ## Authors: