From 20f8ede167d95ab10c880d87d69bf2dd7ccadf97 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Fri, 17 Oct 2025 14:42:24 -0500 Subject: [PATCH 01/22] added function to add text onto cigale sed plots --- frb/galaxies/cigale.py | 71 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/frb/galaxies/cigale.py b/frb/galaxies/cigale.py index 399b0565..7c87deb6 100644 --- a/frb/galaxies/cigale.py +++ b/frb/galaxies/cigale.py @@ -18,6 +18,12 @@ from pcigale.analysis_modules import get_module from pcigale.utils.console import INFO, WARNING, ERROR, console +try: + from pcigale_plots.plot_types.sed import SED +except ImportError: + console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") + pass + from frb.surveys.catalog_utils import _detect_mag_cols, convert_mags_to_flux # Default list of SED modules for CIGALE @@ -370,11 +376,11 @@ def run(photometry_table, zcol, if len(sorted(best_model_files)) == 0: console.print(f"{WARNING} No best model files found for making plots. Please rerun with save_sed=True") else: - try: - from pcigale_plots.plot_types.sed import SED - except ImportError: - console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") - pass + # try: + # from pcigale_plots.plot_types.sed import SED + # except ImportError: + # console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") + # pass # TODO: Let the user customize the plot. series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] @@ -445,3 +451,58 @@ def host_run(host, cut_photom=None, cigale_file=None): sfh_file = cigale_file.replace('CIGALE', 'CIGALE_SFH') os.system('mv {:s}/{:s}_SFH.fits {:s}'.format(host.name, host.name, sfh_file)) return + +def add_text_SED(host, cigale_results, out_name=None): + """ + Add a text file with the SED results + to the host object. + Args + ---- + host (FRBGalaxy): A host galaxy. + """ + config_file = 'pcigale.ini' + cigconf = Configuration(Path(config_file)) + + # TODO: Let the user customize the plot. + series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] + SED(config = cigconf, sed_type = "mJy", nologo = True, + xrange = (False, False), yrange = (False, False), + series = series, format = "png", outdir = Path(f"{host.name}")) ### something wrong with input data file (cigconf) + + # Get unique surveys to put on plot + surveys = set() + for key in host.photom.keys(): + survey = key.split("_")[0] # take everything before the first underscore + if survey == "Pan-STARRS": + survey = "PS1" + surveys.add(survey) + surveys = sorted(list(surveys)) + + from PIL import Image, ImageDraw, ImageFont + + # Open the image + img = Image.open(f"{host.name}/{host.name}_best_model.png") + + # Create a drawing object + draw = ImageDraw.Draw(img) + + # Define font (use a system font or specify a .ttf file) + font = ImageFont.load_default(size=22) + + plot_text = f"{host.name}\n" + plot_text += f"Mstar = {cigale_results['Mstar']:.2e} Msun \n" + plot_text += f"SFR = {cigale_results['SFR_photom']:.2f} Msun/yr\n" + plot_text += "Photometry: \n + " + "\n + ".join(surveys) + + # Add text (x, y coordinates, text, color, font) + draw.text((20, 15), plot_text, fill="black", font=font) + + # Save result + if out_name is not None: + img.save(f"{host.name}/{out_name}") + print(f"Saved {host.name}/{out_name}") + else: + img.save(f"{host.name}/{host.name}_best_model_text.png") + print(f"Saved {host.name}/{host.name}_best_model_text.png") + + return \ No newline at end of file From e892e994c5d564a65b7981d0b6e919f88ebf3009 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Wed, 22 Oct 2025 20:04:23 -0500 Subject: [PATCH 02/22] edited cigale SED plotting, now with a function to add text to the SED and it outputs as a png instead of a pdf --- frb/galaxies/cigale.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/frb/galaxies/cigale.py b/frb/galaxies/cigale.py index 7c87deb6..a4f9e2fb 100644 --- a/frb/galaxies/cigale.py +++ b/frb/galaxies/cigale.py @@ -386,7 +386,7 @@ def run(photometry_table, zcol, series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] SED(config = cigconf, sed_type = "mJy", nologo = True, xrange = (False, False), yrange = (False, False), - series = series, format = "pdf", outdir = Path("out")) + series = series, format = "png", outdir = Path("out")) # Set back to a GUI import matplotlib matplotlib.use('TkAgg') @@ -460,14 +460,16 @@ def add_text_SED(host, cigale_results, out_name=None): ---- host (FRBGalaxy): A host galaxy. """ - config_file = 'pcigale.ini' - cigconf = Configuration(Path(config_file)) + # config_file = 'pcigale.ini' + # cigconf = Configuration(Path(config_file)) + # analysis_module = get_module(cigconf.configuration['analysis_method']) + # analysis_module.process(cigconf.configuration) - # TODO: Let the user customize the plot. - series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] - SED(config = cigconf, sed_type = "mJy", nologo = True, - xrange = (False, False), yrange = (False, False), - series = series, format = "png", outdir = Path(f"{host.name}")) ### something wrong with input data file (cigconf) + # # TODO: Let the user customize the plot. + # series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] + # SED(config = cigconf, sed_type = "mJy", nologo = True, + # xrange = (False, False), yrange = (False, False), + # series = series, format = "png", outdir = Path(f"{host.name}")) # Get unique surveys to put on plot surveys = set() @@ -489,8 +491,7 @@ def add_text_SED(host, cigale_results, out_name=None): # Define font (use a system font or specify a .ttf file) font = ImageFont.load_default(size=22) - plot_text = f"{host.name}\n" - plot_text += f"Mstar = {cigale_results['Mstar']:.2e} Msun \n" + plot_text = f"Mstar = {cigale_results['Mstar']:.2e} Msun \n" plot_text += f"SFR = {cigale_results['SFR_photom']:.2f} Msun/yr\n" plot_text += "Photometry: \n + " + "\n + ".join(surveys) From 766501661d81a499948315cce3401e0f4137dbb8 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 23 Oct 2025 12:58:14 -0500 Subject: [PATCH 03/22] small edits --- frb/galaxies/cigale.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/frb/galaxies/cigale.py b/frb/galaxies/cigale.py index a4f9e2fb..43af5adc 100644 --- a/frb/galaxies/cigale.py +++ b/frb/galaxies/cigale.py @@ -18,12 +18,6 @@ from pcigale.analysis_modules import get_module from pcigale.utils.console import INFO, WARNING, ERROR, console -try: - from pcigale_plots.plot_types.sed import SED -except ImportError: - console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") - pass - from frb.surveys.catalog_utils import _detect_mag_cols, convert_mags_to_flux # Default list of SED modules for CIGALE @@ -376,11 +370,11 @@ def run(photometry_table, zcol, if len(sorted(best_model_files)) == 0: console.print(f"{WARNING} No best model files found for making plots. Please rerun with save_sed=True") else: - # try: - # from pcigale_plots.plot_types.sed import SED - # except ImportError: - # console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") - # pass + try: + from pcigale_plots.plot_types.sed import SED + except ImportError: + console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") + pass # TODO: Let the user customize the plot. series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] @@ -460,16 +454,11 @@ def add_text_SED(host, cigale_results, out_name=None): ---- host (FRBGalaxy): A host galaxy. """ - # config_file = 'pcigale.ini' - # cigconf = Configuration(Path(config_file)) - # analysis_module = get_module(cigconf.configuration['analysis_method']) - # analysis_module.process(cigconf.configuration) - - # # TODO: Let the user customize the plot. - # series = ['stellar_attenuated', 'stellar_unattenuated', 'dust', 'agn', 'model'] - # SED(config = cigconf, sed_type = "mJy", nologo = True, - # xrange = (False, False), yrange = (False, False), - # series = series, format = "png", outdir = Path(f"{host.name}")) + try: + from pcigale_plots.plot_types.sed import SED + except ImportError: + console.print(f"{ERROR} This wrapper is compatible with CIGALE v. 2025. and later. Please update your version.") + pass # Get unique surveys to put on plot surveys = set() From 9d3e4fee78ea69f4dc64e5b3a2b5713a205a07e7 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Mon, 27 Oct 2025 02:04:27 -0500 Subject: [PATCH 04/22] some fixes --- frb/data/analysis/CIGALE/VLT_HAWKI_H.dat | 1 + frb/data/analysis/CIGALE/VLT_HAWKI_J.dat | 1 + frb/data/analysis/CIGALE/VLT_HAWKI_Ks.dat | 1 + frb/surveys/twomass.py | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/frb/data/analysis/CIGALE/VLT_HAWKI_H.dat b/frb/data/analysis/CIGALE/VLT_HAWKI_H.dat index 4c5c6593..c3bac7e2 100644 --- a/frb/data/analysis/CIGALE/VLT_HAWKI_H.dat +++ b/frb/data/analysis/CIGALE/VLT_HAWKI_H.dat @@ -1,4 +1,5 @@ #VLT_HAWKI_H +#photon #VLT HAWKI H band http://www.eso.org/sci/facilities/paranal/instruments/hawki/inst.html 4992.5 0.000316136 5012.47 0.00026036 diff --git a/frb/data/analysis/CIGALE/VLT_HAWKI_J.dat b/frb/data/analysis/CIGALE/VLT_HAWKI_J.dat index be19343c..82b50683 100644 --- a/frb/data/analysis/CIGALE/VLT_HAWKI_J.dat +++ b/frb/data/analysis/CIGALE/VLT_HAWKI_J.dat @@ -1,4 +1,5 @@ #VLT_HAWKI_J +#photon #VLT HAWKI J band http://www.eso.org/sci/facilities/paranal/instruments/hawki/inst.html 5014.98 -0.000258185 5034.96 0.000143311 diff --git a/frb/data/analysis/CIGALE/VLT_HAWKI_Ks.dat b/frb/data/analysis/CIGALE/VLT_HAWKI_Ks.dat index dbc22c18..27865ca0 100644 --- a/frb/data/analysis/CIGALE/VLT_HAWKI_Ks.dat +++ b/frb/data/analysis/CIGALE/VLT_HAWKI_Ks.dat @@ -1,4 +1,5 @@ #VLT_HAWKI_Ks +#photon #VLT HAWKI Ks band http://www.eso.org/sci/facilities/paranal/instruments/hawki/inst.html 4970.0 0.000266825 4989.88 -0.00022829 diff --git a/frb/surveys/twomass.py b/frb/surveys/twomass.py index d5d0e9dd..2da4e755 100644 --- a/frb/surveys/twomass.py +++ b/frb/surveys/twomass.py @@ -85,6 +85,12 @@ def get_catalog(self,query_fields=None): photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m'.format(band.lower()) photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msigcom'.format(band.lower()) + else: # if XSC is not empty, rename columns for mags for XSC + # Instead of _m and _msig, it's _m_fe and _msig_fe for fiducial elliptical Kron + for band in MASS_bands: + photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m_fe'.format(band.lower()) + photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig_fe'.format(band.lower()) + pdict = photom['2MASS'].copy() photom_catalog = catalog_utils.clean_cat(ret,pdict) # rename columns From 9b0e1ae253f273d13a5d58247529b6c274ab9a96 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 30 Oct 2025 18:46:16 -0500 Subject: [PATCH 05/22] small edit to plotting backend to fix issue --- .../Galaxies/20220207C/FRB20220207C_host.json | 74 ------------------- frb/galaxies/cigale.py | 9 ++- 2 files changed, 8 insertions(+), 75 deletions(-) delete mode 100644 frb/data/Galaxies/20220207C/FRB20220207C_host.json diff --git a/frb/data/Galaxies/20220207C/FRB20220207C_host.json b/frb/data/Galaxies/20220207C/FRB20220207C_host.json deleted file mode 100644 index fb455a6d..00000000 --- a/frb/data/Galaxies/20220207C/FRB20220207C_host.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "FRB": "FRB20220207C", - "cosmo": "Planck18", - "dec": 72.88274916666666, - "dec_FRB": 72.882327, - "offsets": { - "ang_avg": 2.6272483853172286, - "ang_avg_err": 0.5904731793305108, - "ang_best": 2.5617577495355914, - "ang_best_err": 0.5940939310275478, - "physical": 2.2606481358231982, - "physical_err": 0.5242639894130404 - }, - "photom": { - "2MASS_H": 15.089434621876995, - "2MASS_H_err": 0.04, - "2MASS_H_flux": 3.3436910716867603, - "2MASS_H_flux_err": 0.12318613147589151, - "2MASS_H_ref": "Sharma2024", - "EBV": 0.6973, - "Pan-STARRS_g": 13.954235698639348, - "Pan-STARRS_g_err": 0.03, - "Pan-STARRS_g_flux": 9.512741926786193, - "Pan-STARRS_g_flux_err": 0.2628467730494081, - "Pan-STARRS_g_ref": "Sharma2024", - "Pan-STARRS_i": 14.581631158613696, - "Pan-STARRS_i_err": 0.01, - "Pan-STARRS_i_flux": 5.33761851198287, - "Pan-STARRS_i_flux_err": 0.04916128327112326, - "Pan-STARRS_i_ref": "Sharma2024", - "Pan-STARRS_r": 14.32004534436542, - "Pan-STARRS_r_err": 0.01, - "Pan-STARRS_r_flux": 6.791752582271093, - "Pan-STARRS_r_flux_err": 0.06255435300496494, - "Pan-STARRS_r_ref": "Sharma2024", - "Pan-STARRS_y": 14.760598934414665, - "Pan-STARRS_y_err": 0.02, - "Pan-STARRS_y_flux": 4.526478068938067, - "Pan-STARRS_y_flux_err": 0.08338080740241013, - "Pan-STARRS_y_ref": "Sharma2024", - "Pan-STARRS_z": 14.67029236026023, - "Pan-STARRS_z_err": 0.01, - "Pan-STARRS_z_flux": 4.919070537243744, - "Pan-STARRS_z_flux_err": 0.04530631396177464, - "Pan-STARRS_z_ref": "Sharma2024", - "WISE_W1": 16.32568193678581, - "WISE_W1_err": 0.01, - "WISE_W1_flux": 1.070846495142043, - "WISE_W1_flux_err": 0.009862860706395958, - "WISE_W1_ref": "Sharma2024", - "WISE_W2": 17.0331515577018, - "WISE_W2_err": 0.03, - "WISE_W2_flux": 0.5581351461714593, - "WISE_W2_flux_err": 0.015421844009405463, - "WISE_W2_ref": "Sharma2024", - "WISE_W3": 15.750148815681989, - "WISE_W3_err": 0.11, - "WISE_W3_flux": 1.819451435758715, - "WISE_W3_flux_err": 0.18433543714980377, - "WISE_W3_ref": "Sharma2024", - "WISE_W4": 15.057680232062475, - "WISE_W4_err": 0.46, - "WISE_W4_flux": 3.442927689424988, - "WISE_W4_flux_err": 1.4586846512024596, - "WISE_W4_ref": "Sharma2024" - }, - "ra": 310.19757875, - "ra_FRB": 310.199525, - "redshift": { - "z": 0.0433, - "z_FRB": 0.0433, - "z_spec": 0.0433 - } -} \ No newline at end of file diff --git a/frb/galaxies/cigale.py b/frb/galaxies/cigale.py index 43af5adc..0956bb03 100644 --- a/frb/galaxies/cigale.py +++ b/frb/galaxies/cigale.py @@ -382,8 +382,15 @@ def run(photometry_table, zcol, xrange = (False, False), yrange = (False, False), series = series, format = "png", outdir = Path("out")) # Set back to a GUI + # import matplotlib + # matplotlib.use('TkAgg') import matplotlib - matplotlib.use('TkAgg') + if matplotlib.get_backend().lower() != 'tkagg': + try: + matplotlib.use('TkAgg') + except ImportError: + pass + # Rename the default output directory? if outdir != 'out': From ed15368ad23e3fd23556597609581f27052f2df4 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Tue, 9 Dec 2025 14:18:26 -0600 Subject: [PATCH 06/22] more edits for modap, mainly changing sdss extinction correction and a fix with twomass querying --- frb/galaxies/cigale.py | 10 ++++++++++ frb/galaxies/photom.py | 15 ++++++++------- frb/surveys/twomass.py | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/frb/galaxies/cigale.py b/frb/galaxies/cigale.py index 0956bb03..85816d6a 100644 --- a/frb/galaxies/cigale.py +++ b/frb/galaxies/cigale.py @@ -175,6 +175,16 @@ def gen_cigale_in(photometry_table, zcol, idcol=None, infile="cigale_in.fits", 'Pan-STARRS_y': 'panstarrs.ps1.y', 'LRISr_I': 'LRIS_I', 'LRISb_V': 'LRIS_V', + 'LRISb_G': 'LRIS_G', + 'LRISr_R': 'LRIS_R', + 'GMOS_N_g': "GMOS_N_g", + 'GMOS_N_r': "GMOS_N_r", + 'GMOS_N_i': "GMOS_N_i", + 'GMOS_N_z': "GMOS_N_z", + 'GMOS_S_g': "GMOS_S_g", + 'GMOS_S_r': "GMOS_S_r", + 'GMOS_S_i': "GMOS_S_i", + 'GMOS_S_z': "GMOS_S_z", 'WFC3_F160W': 'hst.wfc3.ir.F160W', 'WFC3_F300X': 'WFC3_F300X', 'Spitzer_3.6': 'spitzer.irac.l1', diff --git a/frb/galaxies/photom.py b/frb/galaxies/photom.py index 74a5b122..18548144 100644 --- a/frb/galaxies/photom.py +++ b/frb/galaxies/photom.py @@ -240,12 +240,13 @@ def correct_photom_table(photom, EBV, name, max_wave=None, required=True): continue except: embed(header='187 in photom') - # SDSS - if 'SDSS' in filt: - if 'extinction_{}'.format(filt[-1]) in photom.keys(): - print("Appying SDSS-provided extinction correction") - cut_photom[key] -= cut_photom['extinction_{}'.format(filt[-1])] - continue + print('Correcting filter {} for Galactic extinction'.format(filt)) + # SDSS ### removing this because SDSS correction is sometimes different for very dusty sightlines, but TBD + # if 'SDSS' in filt: + # if 'extinction_{}'.format(filt[-1]) in photom.keys(): + # print("Appying SDSS-provided extinction correction") + # cut_photom[key] -= cut_photom['extinction_{}'.format(filt[-1])] + # continue # Hack for LRIS if 'LRIS' in filt: _filter = 'LRIS_{}'.format(filt[-1]) @@ -257,7 +258,7 @@ def correct_photom_table(photom, EBV, name, max_wave=None, required=True): dust_correct = extinction_correction(_filter, EBV, max_wave=max_wave, required=required) mag_dust = 2.5 * np.log10(1. / dust_correct) - cut_photom[key] += mag_dust + # Add it back in photom[idx] = cut_photom diff --git a/frb/surveys/twomass.py b/frb/surveys/twomass.py index 2da4e755..b39c1471 100644 --- a/frb/surveys/twomass.py +++ b/frb/surveys/twomass.py @@ -20,8 +20,8 @@ photom = {} photom['2MASS'] = {} for band in MASS_bands: - photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m'.format(band.lower()) # Many options for apertures, tbd - photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig'.format(band.lower()) + photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m'.format(band) # Many options for apertures, tbd + photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig'.format(band) photom["2MASS"]["2MASS_ID"] = 'designation' photom["2MASS"]['ra'] = 'ra' photom["2MASS"]['dec'] = 'dec' From b9cc862cb91d905c992d9c104b0dfffa3938f1cb Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 22 Jan 2026 16:36:15 -0600 Subject: [PATCH 07/22] minor edits --- frb/galaxies/eazy.py | 3 ++- frb/galaxies/photom.py | 1 + frb/surveys/survey_utils.py | 3 +-- frb/surveys/twomass.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frb/galaxies/eazy.py b/frb/galaxies/eazy.py index 4746872c..a46a798d 100644 --- a/frb/galaxies/eazy.py +++ b/frb/galaxies/eazy.py @@ -21,7 +21,8 @@ try: _eazy_root = os.environ['EAZYDIR'] except KeyError: - warnings.warn('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') + # warnings.warn('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') + print('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') _template_list = ['br07_default','br07_goods','cww+kin','eazy_v1.0','eazy_v1.1_lines','eazy_v1.2_dusty','eazy_v1.3','pegase','pegase13'] _acceptable_priors = ['prior_R_zmax7', 'prior_K_zmax7', 'prior_R_extend', 'prior_K_extend'] # F160W_TAO not included yet. diff --git a/frb/galaxies/photom.py b/frb/galaxies/photom.py index 18548144..61de2825 100644 --- a/frb/galaxies/photom.py +++ b/frb/galaxies/photom.py @@ -258,6 +258,7 @@ def correct_photom_table(photom, EBV, name, max_wave=None, required=True): dust_correct = extinction_correction(_filter, EBV, max_wave=max_wave, required=required) mag_dust = 2.5 * np.log10(1. / dust_correct) + cut_photom[key] += mag_dust # Add it back in photom[idx] = cut_photom diff --git a/frb/surveys/survey_utils.py b/frb/surveys/survey_utils.py index 5418cfdd..79eff4f0 100644 --- a/frb/surveys/survey_utils.py +++ b/frb/surveys/survey_utils.py @@ -28,8 +28,7 @@ import numpy as np import warnings -optical_surveys = ['Pan-STARRS', 'WISE', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'NEDLVS', '2MASS', 'GALEX'] -group_catalogs = ['TullyGroupCat'] +optical_surveys = ['Pan-STARRS', 'WISE', '2MASS', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'NEDLVS', 'GALEX'] radio_surveys = ['NVSS', 'FIRST', 'WENSS', 'PSRCAT'] allowed_surveys = optical_surveys+radio_surveys+group_catalogs diff --git a/frb/surveys/twomass.py b/frb/surveys/twomass.py index b39c1471..4ccbb63a 100644 --- a/frb/surveys/twomass.py +++ b/frb/surveys/twomass.py @@ -20,7 +20,7 @@ photom = {} photom['2MASS'] = {} for band in MASS_bands: - photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m'.format(band) # Many options for apertures, tbd + photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m'.format(band) # default aperture queried like this is k20fe photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig'.format(band) photom["2MASS"]["2MASS_ID"] = 'designation' photom["2MASS"]['ra'] = 'ra' From 4ee4a1b969e0ee53132feb4916e82055756e21cf Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 22 Jan 2026 17:00:31 -0600 Subject: [PATCH 08/22] group catalogs? --- frb/surveys/survey_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frb/surveys/survey_utils.py b/frb/surveys/survey_utils.py index 79eff4f0..3d791d59 100644 --- a/frb/surveys/survey_utils.py +++ b/frb/surveys/survey_utils.py @@ -30,7 +30,7 @@ optical_surveys = ['Pan-STARRS', 'WISE', '2MASS', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'NEDLVS', 'GALEX'] radio_surveys = ['NVSS', 'FIRST', 'WENSS', 'PSRCAT'] -allowed_surveys = optical_surveys+radio_surveys+group_catalogs +allowed_surveys = optical_surveys+radio_surveys #+group_catalogs def load_survey_by_name(name, coord, radius, **kwargs): From 30494c2267be52333df2805e1b659eae5079c3af Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Mon, 26 Jan 2026 20:02:21 -0600 Subject: [PATCH 09/22] try new numpy version isin function otherwise in1d --- frb/surveys/catalog_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frb/surveys/catalog_utils.py b/frb/surveys/catalog_utils.py index de99058d..1f6a99e3 100644 --- a/frb/surveys/catalog_utils.py +++ b/frb/surveys/catalog_utils.py @@ -100,7 +100,11 @@ def match_ids(IDs, match_IDs, require_in_match=True): """ rows = -1 * np.ones_like(IDs).astype(int) # Find which IDs are in match_IDs - in_match = np.in1d(IDs, match_IDs) + try: + in_match = np.isin(IDs, match_IDs) + except AttributeError: + # Older NumPy versions + in_match = np.in1d(IDs, match_IDs) if require_in_match: if np.sum(~in_match) > 0: raise IOError("qcat.match_ids: One or more input IDs not in match_IDs") From c313eecea12a5c11264c4e4b4a7db561ac1d94bc Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Mon, 26 Jan 2026 20:02:42 -0600 Subject: [PATCH 10/22] added new function to catch bad photometry pulls 999 values --- frb/surveys/survey_utils.py | 53 ++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/frb/surveys/survey_utils.py b/frb/surveys/survey_utils.py index 3d791d59..d520098e 100644 --- a/frb/surveys/survey_utils.py +++ b/frb/surveys/survey_utils.py @@ -253,13 +253,64 @@ def search_all_surveys(coord:SkyCoord, radius:u.Quantity, include_radio:bool=Fal # Fill in any empty separations and sort them. combined_cat['separation'] = coord.separation(SkyCoord(combined_cat['ra'], combined_cat['dec'], unit='deg')).to(u.arcmin) combined_cat.sort('separation') - + combined_cat = pick_best_row_by_phot(combined_cat) # Make the ra, dec, separation the first columns colnames = combined_cat.colnames other_cols = np.setdiff1d(colnames, ['ra', 'dec', 'separation']) combined_cat = combined_cat[['ra', 'dec', 'separation']+other_cols.tolist()] return combined_cat + +def pick_best_row_by_phot(cat, mag_cols=None, max_sep=None): + """ + From a catalog sorted by separation, pick the best row + based on having any good photometry in the specified + magnitude columns. + Args: + cat (Table): Astropy table sorted by separation. + mag_cols (list, optional): List of magnitude column names + to consider for "good photometry". If None, + will use all valid filters from frb.galaxies.defs. + max_sep (Quantity, optional): Maximum separation + to consider. If None, no maximum separation + is applied. + + Returns: + best_row (Table): A 1-row table with the best row. + """ + if len(cat) == 0: + return cat + + if mag_cols is None: + from frb.galaxies.defs import valid_filters + mag_cols = valid_filters + + # require separation column already computed in arcmin/arcsec/whatever + sep = cat['separation'] + if max_sep is not None: + inrad = sep <= max_sep + else: + inrad = np.ones(len(cat), dtype=bool) + + # “has any good mag” + has_good = np.zeros(len(cat), dtype=bool) + for c in mag_cols: + if c in cat.colnames: + m = np.array(cat[c]) + good = np.isfinite(m) & (m < 900) & (m > -10) + has_good |= good + + ok = inrad & has_good + if not np.any(ok): + # fall back: just nearest, but you’ll know it’s junk + i = np.argmin(sep) + else: + # nearest among rows with any good photometry + i = np.argmin(sep[ok]) + i = np.where(ok)[0][i] + + return cat[i:i+1] # returns a 1-row table + def PS1_tile(coord:SkyCoord, side:u.Quantity=1*u.deg, **kwargs)->Table: """ From bb490e4dc700b295414ec0fa24de978ffe3b99d4 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Mon, 2 Feb 2026 11:57:55 -0600 Subject: [PATCH 11/22] added lines to query more recent release of delve if desired, and fixed a astropy units Mpc issue with nedlvs that I encountered --- frb/surveys/delve.py | 7 +++++++ frb/surveys/nedlvs.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frb/surveys/delve.py b/frb/surveys/delve.py index 335ed90d..3070c6b3 100644 --- a/frb/surveys/delve.py +++ b/frb/surveys/delve.py @@ -21,14 +21,19 @@ photom = {} photom['DELVE'] = {} photom['DELVE']['DELVE_ID'] = 'quick_object_id' +# photom['DELVE']['DELVE_ID'] = 'coadd_object_id' photom['DELVE']['ra'] = 'ra' photom['DELVE']['dec'] = 'dec' photom['DELVE']['ebv'] = 'ebv' # Schegel, Finkbeiner, Davis (1998) +# photom['DELVE']['ebv'] = '_sfd98' DELVE_bands = ['g', 'r', 'i', 'z'] for band in DELVE_bands: photom['DELVE'][f'DELVE_{band}'] = f'mag_auto_{band}' #mag photom['DELVE'][f'DELVE_{band}_err'] = f'magerr_auto_{band}' #magerr photom['DELVE'][f'class_star_{band}'] = f'class_star_{band}' #morphology class + ## 'bdf_mag_' 'bdf_mag_err_' 'gap_mag_' 'gap_mag_err_' 'mag_detmodel_' 'magerr_detmodel_' + # photom['DELVE'][f'DELVE_{band}'] = 'bdf_mag_'+band + # photom['DELVE'][f'DELVE_{band}_err'] = 'bdf_mag_err_'+band class DELVE_Survey(dlsurvey.DL_Survey): @@ -48,8 +53,10 @@ def __init__(self, coord, radius, **kwargs): self.survey = 'DELVE' self.bands = DELVE_bands self.svc = sia.SIAService("https://datalab.noao.edu/sia/delve_dr2") + # self.svc = sia.SIAService("https://datalab.noao.edu/sia/delve_dr3") self.qc_profile = "default" self.database = "delve_dr2.objects" + # self.database = "delve_dr3.coadd_objects" self.default_query_fields = list(photom['DELVE'].values()) def get_catalog(self, query=None, query_fields=None, print_query=False,**kwargs): diff --git a/frb/surveys/nedlvs.py b/frb/surveys/nedlvs.py index 78c1fa84..4b7ff777 100644 --- a/frb/surveys/nedlvs.py +++ b/frb/surveys/nedlvs.py @@ -36,7 +36,8 @@ def __init__(self, coord, radius=90.*u.deg, cosmo=None, **kwargs): # Set redshift distances using the cosmology of choice redshift_dist_sources = self.datatab['DistMpc_method']=='Redshift' - self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(self.datatab['z'][redshift_dist_sources]).to('Mpc').value + # self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(self.datatab['z'][redshift_dist_sources]).to('Mpc').value + self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(self.datatab['z'][redshift_dist_sources])*u.Mpc self.datatab['phys_sep'] = self.datatab['DistMpc']*u.Mpc*np.sin(self.datatab['ang_sep'].to('rad').value) def get_column_names(self): From 393e0d9337d6ebbcda5170697e9c91a08fbc82ff Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Fri, 6 Mar 2026 16:42:22 -0600 Subject: [PATCH 12/22] added type keyerror fix --- frb/surveys/panstarrs.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frb/surveys/panstarrs.py b/frb/surveys/panstarrs.py index 634f248d..b18c45f6 100644 --- a/frb/surveys/panstarrs.py +++ b/frb/surveys/panstarrs.py @@ -12,6 +12,7 @@ from astropy.coordinates import SkyCoord, match_coordinates_sky from astropy.table import Table, join from ..galaxies.defs import PanSTARRS_bands +import importlib_resources from .images import grab_from_url @@ -319,7 +320,22 @@ def _ps1metadata(table="stack",release="dr2", r = requests.get(url) r.raise_for_status() v = r.json() - # convert to astropy table - tab = Table(rows=[(x['name'],x['type'],x['description']) for x in v], + local_metadata_path = importlib_resources.files('frb').joinpath('data','Public', 'Pan-STARRS','ps1_{}_{}_metadata.csv'.format(release,table)) + try: + tab = Table(rows=[(x['name'],x['type'],x['description']) for x in v], names=('name','type','description')) + # Cache locally + # Create directory if it doesn't exist + if not os.path.isfile(local_metadata_path): + os.makedirs(os.path.dirname(local_metadata_path), exist_ok=True) + tab.write(local_metadata_path, overwrite=True) + + # The following catches the case when there is a server issue + # and we have a local copy of the metadata. + except KeyError: + if not os.path.isfile(local_metadata_path): + raise IOError("PS1 metadata not available from server and no local copy found.") + else: + tab = Table.read(local_metadata_path) + return tab From b413559dc9a74fe0072bd0256f3d36bf82722172 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Wed, 29 Apr 2026 14:54:03 -0500 Subject: [PATCH 13/22] nump trapz --- frb/galaxies/photom.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frb/galaxies/photom.py b/frb/galaxies/photom.py index 61de2825..53c03d6c 100644 --- a/frb/galaxies/photom.py +++ b/frb/galaxies/photom.py @@ -180,9 +180,13 @@ def extinction_correction(filt, EBV, RV=3.1, max_wave=None, required=True): source_flux = 1. #calculate linear correction - delta = np.trapz(throughput * source_flux * - 10 ** (-0.4 * Alambda), wave) / np.trapz( - throughput * source_flux, wave) + if getattr(np, "trapz", None) is not None: + delta = np.trapz(throughput * source_flux * + 10 ** (-0.4 * Alambda), wave) / np.trapz( + throughput * source_flux, wave) + else: + delta = np.trapezoid(throughput * source_flux * 10 ** (-0.4 * Alambda), wave) / np.trapezoid( + throughput * source_flux, wave) correction = 1./delta @@ -203,7 +207,7 @@ def correct_photom_table(photom, EBV, name, max_wave=None, required=True): photom (astropy.table.Table): EBV (float): E(B-V) (can get from frb.galaxies.nebular.get_ebv which uses IRSA Dust extinction query - name (str):\ + name (str): Name of the object to correct required (bool, optional): Crash out if the transmission curve is not present From 93c0a9d2c6f5931cd7ae62d9a2ef147cac1bc627 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Wed, 29 Apr 2026 14:55:59 -0500 Subject: [PATCH 14/22] dfj --- frb/galaxies/defs.py | 1 - frb/scripts/r_vs_dm.py | 4 ++-- frb/tests/test_frbsurveys.py | 14 +++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frb/galaxies/defs.py b/frb/galaxies/defs.py index c650c6d3..47518ab9 100644 --- a/frb/galaxies/defs.py +++ b/frb/galaxies/defs.py @@ -263,7 +263,6 @@ 'Z_photom', # Metallicity from photometry; CIGALE 'Z_spec', # Metallicity from spectra; pPXF 'Z_stellar', # Stellar metallicity; Prospector - 'Z_gas' # Gas-phase metallicity; Prospector ] valid_derived_nebular = [ diff --git a/frb/scripts/r_vs_dm.py b/frb/scripts/r_vs_dm.py index 0f97e1e6..1eea41b9 100644 --- a/frb/scripts/r_vs_dm.py +++ b/frb/scripts/r_vs_dm.py @@ -58,7 +58,7 @@ def grab_zlim(): # Load z-DM distribution - sdict = prob_dmz.grab_repo_grid() + sdict = prob_dmz.grab_repo_grid('PDM_z.npz') PDM_z = sdict['PDM_z'] z = sdict['z'] DM = sdict['DM'] @@ -146,7 +146,7 @@ def r_vs_dm(outfile='fig_r_vs_z.png', # Add P(z|DM) xmnx = (0., 4.) - ymnx = (14, 33.) + ymnx = (14, 27.5) if flipy: ymnx = (ymnx[1], ymnx[0]) diff --git a/frb/tests/test_frbsurveys.py b/frb/tests/test_frbsurveys.py index b75c84c1..ad051f5f 100644 --- a/frb/tests/test_frbsurveys.py +++ b/frb/tests/test_frbsurveys.py @@ -3,17 +3,14 @@ # TEST_UNICODE_LITERALS from calendar import c -import re +import numpy as np import astropy import pytest import os, warnings - -from astropy.table import Table -from astropy.coordinates import SkyCoord -from astropy import units from astropy.io.fits.hdu.image import PrimaryHDU from frb.surveys import survey_utils +from frb.surveys.panstarrs import _ps1metadata from PIL import Image from numpy import setdiff1d @@ -200,6 +197,13 @@ def test_panstarrs(): imghdu = ps_survey.get_image() assert isinstance(imghdu,PrimaryHDU) assert imghdu.data.shape == (120,120) + # Test getting metadata repeatedly to check caching + for index in range(10): + metadata = _ps1metadata() + assert isinstance(metadata,Table) + assert len(metadata) > 0 + assert np.all(np.isin(metadata.colnames, ['name', 'type', 'description'])) + @nedlvs def test_nedlvs(): From cc463769fcf2522810d1adf7bda699b3587789fa Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 30 Apr 2026 11:30:05 -0500 Subject: [PATCH 15/22] fixed thing --- frb/surveys/twomass.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frb/surveys/twomass.py b/frb/surveys/twomass.py index 554fb50f..d399a6d6 100644 --- a/frb/surveys/twomass.py +++ b/frb/surveys/twomass.py @@ -91,12 +91,6 @@ def get_catalog(self,query_fields=None): photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m_fe'.format(band.lower()) photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig_fe'.format(band.lower()) - else: # if XSC is not empty, rename columns for mags for XSC - # Instead of _m and _msig, it's _m_fe and _msig_fe for fiducial elliptical Kron - for band in MASS_bands: - photom["2MASS"]["2MASS"+'_{:s}'.format(band)] = '{:s}_m_fe'.format(band.lower()) - photom["2MASS"]["2MASS"+'_{:s}_err'.format(band)] = '{:s}_msig_fe'.format(band.lower()) - pdict = photom['2MASS'].copy() photom_catalog = catalog_utils.clean_cat(ret,pdict) # rename columns From 542d0e5799c5bf3d731043339f01f087f9aee66b Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 30 Apr 2026 11:38:54 -0500 Subject: [PATCH 16/22] fixing conflict in test_frbsurveys --- frb/tests/test_frbsurveys.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/frb/tests/test_frbsurveys.py b/frb/tests/test_frbsurveys.py index aee0bada..14cb4499 100644 --- a/frb/tests/test_frbsurveys.py +++ b/frb/tests/test_frbsurveys.py @@ -2,11 +2,14 @@ # Most of these are *not* done with Travis yet # TEST_UNICODE_LITERALS -from calendar import c import numpy as np import astropy import pytest import os, warnings + +from astropy.table import Table +from astropy.coordinates import SkyCoord +from astropy import units from astropy.io.fits.hdu.image import PrimaryHDU from frb.surveys import survey_utils @@ -197,13 +200,6 @@ def test_panstarrs(): imghdu = ps_survey.get_image() assert isinstance(imghdu,PrimaryHDU) assert imghdu.data.shape == (120,120) - # Test getting metadata repeatedly to check caching - for index in range(10): - metadata = _ps1metadata() - assert isinstance(metadata,Table) - assert len(metadata) > 0 - assert np.all(np.isin(metadata.colnames, ['name', 'type', 'description'])) - # Test getting metadata repeatedly to check caching for index in range(10): From 835d3b3504f99f35a38aa46299f2557cd541505c Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Thu, 30 Apr 2026 12:39:25 -0500 Subject: [PATCH 17/22] fixed some units issues in coords --- frb/surveys/catalog_utils.py | 4 ++-- frb/surveys/galex.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frb/surveys/catalog_utils.py b/frb/surveys/catalog_utils.py index b48a5b27..59a42529 100644 --- a/frb/surveys/catalog_utils.py +++ b/frb/surveys/catalog_utils.py @@ -217,8 +217,8 @@ def xmatch_catalogs(cat1:Table, cat2:Table, dist:units.Quantity = 5*units.arcsec dist1 = None dist2 = None # Get corodinates - cat1_coord = SkyCoord(cat1[RACol1]*units.deg, cat1[DecCol1]*units.deg, distance=dist1) - cat2_coord = SkyCoord(cat2[RACol2]*units.deg, cat2[DecCol2]*units.deg, distance=dist2) + cat1_coord = SkyCoord(cat1[RACol1], cat1[DecCol1], unit='deg', distance=dist1) + cat2_coord = SkyCoord(cat2[RACol2], cat2[DecCol2], unit='deg', distance=dist2) # Match 2D idx, d2d, d3d = cat1_coord.match_to_catalog_sky(cat2_coord) diff --git a/frb/surveys/galex.py b/frb/surveys/galex.py index f755a885..11021b22 100644 --- a/frb/surveys/galex.py +++ b/frb/surveys/galex.py @@ -63,7 +63,7 @@ def get_catalog(self,query_fields=None, print_query=False): query_fields = _DEFAULT_query_fields else: query_fields = _DEFAULT_query_fields+query_fields - + import astropy.units as u data = {} data['ra'] = self.coord.ra.value data['dec'] = self.coord.dec.value From cb39292658380768d5259f99294bd56698bb8be1 Mon Sep 17 00:00:00 2001 From: Alice Cai Date: Tue, 5 May 2026 17:45:44 -0500 Subject: [PATCH 18/22] fixed some errors and suppressed warning messages about importing stuff into just ImportError --- frb/halos/hmf.py | 4 ++-- frb/halos/models.py | 4 ++-- frb/surveys/nedlvs.py | 3 ++- frb/surveys/psrcat.py | 5 ++++- frb/surveys/survey_utils.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frb/halos/hmf.py b/frb/halos/hmf.py index fa2f4a12..2f2738c3 100644 --- a/frb/halos/hmf.py +++ b/frb/halos/hmf.py @@ -49,8 +49,8 @@ def init_hmf(): # Needs to come after def init_hmf() try: import hmf_emulator -except: - print("If you wish to use the halos modules, you need the Aemulus HMF emulator. Please install it: github.com/AemulusProject/hmf_emulator") +except ImportError: + warnings.warn("If you wish to use the halos modules, you need the Aemulus HMF emulator. Please install it: github.com/AemulusProject/hmf_emulator", ImportWarning, stacklevel=2) else: hmfe = init_hmf() diff --git a/frb/halos/models.py b/frb/halos/models.py index eda663a3..44d8f02d 100644 --- a/frb/halos/models.py +++ b/frb/halos/models.py @@ -55,8 +55,8 @@ def init_hmf(): # Storing for use try: import hmf_emulator -except: - print("If you wish to use the halos modules, you need the Aemulus HMF emulator. Please install it: github.com/AemulusProject/hmf_emulator") +except ImportError: + warnings.warn("If you wish to use the halos modules, you need the Aemulus HMF emulator. Please install it: github.com/AemulusProject/hmf_emulator", ImportWarning, stacklevel=2) else: hmfe = init_hmf() diff --git a/frb/surveys/nedlvs.py b/frb/surveys/nedlvs.py index 658c0d2b..2dbe0b80 100644 --- a/frb/surveys/nedlvs.py +++ b/frb/surveys/nedlvs.py @@ -36,7 +36,8 @@ def __init__(self, coord, radius=90.*u.deg, cosmo=None, **kwargs): # Set redshift distances using the cosmology of choice redshift_dist_sources = self.datatab['DistMpc_method']=='Redshift' # self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(self.datatab['z'][redshift_dist_sources]).to('Mpc').value - self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(self.datatab['z'][redshift_dist_sources])*u.Mpc + z_vals = np.asarray(self.datatab['z'][redshift_dist_sources]) + self.datatab['DistMpc'][redshift_dist_sources] = self.cosmo.luminosity_distance(z_vals).to('Mpc').value self.datatab['phys_sep'] = self.datatab['DistMpc']*u.Mpc*np.sin(self.datatab['ang_sep'].to('rad').value) def get_column_names(self): diff --git a/frb/surveys/psrcat.py b/frb/surveys/psrcat.py index 24b23036..24f61b56 100644 --- a/frb/surveys/psrcat.py +++ b/frb/surveys/psrcat.py @@ -6,8 +6,11 @@ from astropy.coordinates import SkyCoord from astropy import units +import warnings try: - from pulsars import io as pio + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=UserWarning, message="pkg_resources") + from pulsars import io as pio except ImportError: print("Warning: You need FRB/pulsars installed to use PSRCat") diff --git a/frb/surveys/survey_utils.py b/frb/surveys/survey_utils.py index e1ef7fa6..8ed6c3a4 100644 --- a/frb/surveys/survey_utils.py +++ b/frb/surveys/survey_utils.py @@ -28,7 +28,7 @@ import numpy as np import warnings -optical_surveys = ['Pan-STARRS', 'WISE', '2MASS', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'NEDLVS', 'GALEX'] +optical_surveys = ['Pan-STARRS', 'WISE', 'NEDLVS', '2MASS', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'GALEX'] #, radio_surveys = ['NVSS', 'FIRST', 'WENSS', 'PSRCAT'] allowed_surveys = optical_surveys+radio_surveys #+group_catalogs From a058c1d315a6719545be3742426566e540e823af Mon Sep 17 00:00:00 2001 From: Alice Cai <109239008+bizarreboa@users.noreply.github.com> Date: Tue, 5 May 2026 20:23:54 -0500 Subject: [PATCH 19/22] Z_gas was removed but can keep --- frb/galaxies/defs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/frb/galaxies/defs.py b/frb/galaxies/defs.py index 25a22ac6..ff6274fd 100644 --- a/frb/galaxies/defs.py +++ b/frb/galaxies/defs.py @@ -262,6 +262,7 @@ 'Z_photom', # Metallicity from photometry; CIGALE 'Z_spec', # Metallicity from spectra; pPXF 'Z_stellar', # Stellar metallicity; Prospector + 'Z_gas' # Gas-phase metallicity; Prospector ] valid_derived_nebular = [ From 7789b916f2d8c74ccb5aba292aef7f2e63b7004c Mon Sep 17 00:00:00 2001 From: Alice Cai <109239008+bizarreboa@users.noreply.github.com> Date: Tue, 5 May 2026 20:26:33 -0500 Subject: [PATCH 20/22] keep EAZYDIR warning as is --- frb/galaxies/eazy.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frb/galaxies/eazy.py b/frb/galaxies/eazy.py index e08bca13..f36e67de 100644 --- a/frb/galaxies/eazy.py +++ b/frb/galaxies/eazy.py @@ -20,8 +20,7 @@ try: _eazy_root = os.environ['EAZYDIR'] except KeyError: - # warnings.warn('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') - print('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') + warnings.warn('Please define the variable EAZYDIR in your environment pointing to the EAZY folder.') _template_list = ['br07_default','br07_goods','cww+kin','eazy_v1.0','eazy_v1.1_lines','eazy_v1.2_dusty','eazy_v1.3','pegase','pegase13'] _acceptable_priors = ['prior_R_zmax7', 'prior_K_zmax7', 'prior_R_extend', 'prior_K_extend'] # F160W_TAO not included yet. @@ -599,4 +598,4 @@ def getEazyPz(idx, MAIN_OUTPUT_FILE='photz', OUTPUT_DIRECTORY='./OUTPUT', CACHE_ if get_prior: return tempfilt['zgrid'], pzi, prior else: - return tempfilt['zgrid'], pzi \ No newline at end of file + return tempfilt['zgrid'], pzi From 15e7448f8d980d2cef1ac7a1758b983af2b992d9 Mon Sep 17 00:00:00 2001 From: Alice Cai <109239008+bizarreboa@users.noreply.github.com> Date: Tue, 5 May 2026 20:29:33 -0500 Subject: [PATCH 21/22] changed some stuff back from when I was fiddling with stuff --- frb/scripts/r_vs_dm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frb/scripts/r_vs_dm.py b/frb/scripts/r_vs_dm.py index 48342b17..70a73011 100644 --- a/frb/scripts/r_vs_dm.py +++ b/frb/scripts/r_vs_dm.py @@ -39,7 +39,7 @@ def grab_zlim(): # Load z-DM distribution - sdict = prob_dmz.grab_repo_grid('PDM_z.npz') + sdict = prob_dmz.grab_repo_grid() PDM_z = sdict['PDM_z'] z = sdict['z'] DM = sdict['DM'] @@ -127,7 +127,7 @@ def r_vs_dm(outfile='fig_r_vs_z.png', # Add P(z|DM) xmnx = (0., 4.) - ymnx = (14, 27.5) + ymnx = (14, 33.) if flipy: ymnx = (ymnx[1], ymnx[0]) @@ -165,4 +165,4 @@ def r_vs_dm(outfile='fig_r_vs_z.png', ''' Run me ''' # Command line execution if __name__ == '__main__': - r_vs_dm() \ No newline at end of file + r_vs_dm() From 69fa6b6418de4803eeff5dd9c0c3c96dfcccd2e7 Mon Sep 17 00:00:00 2001 From: Alice Cai <109239008+bizarreboa@users.noreply.github.com> Date: Tue, 5 May 2026 20:32:01 -0500 Subject: [PATCH 22/22] reorder surveys back to what it was --- frb/surveys/survey_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frb/surveys/survey_utils.py b/frb/surveys/survey_utils.py index 8ed6c3a4..8c65cd21 100644 --- a/frb/surveys/survey_utils.py +++ b/frb/surveys/survey_utils.py @@ -28,9 +28,10 @@ import numpy as np import warnings -optical_surveys = ['Pan-STARRS', 'WISE', 'NEDLVS', '2MASS', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'GALEX'] #, +optical_surveys = ['Pan-STARRS', 'WISE', 'SDSS', 'DES', 'DESI', 'DELVE', 'DECaL', 'VISTA', 'NSC', 'HSC', 'NEDLVS', '2MASS', 'GALEX'] +group_catalogs = ['TullyGroupCat'] radio_surveys = ['NVSS', 'FIRST', 'WENSS', 'PSRCAT'] -allowed_surveys = optical_surveys+radio_surveys #+group_catalogs +allowed_surveys = optical_surveys+radio_surveys+group_catalogs def load_survey_by_name(name, coord, radius, **kwargs): @@ -381,4 +382,4 @@ def PS1_tile(coord:SkyCoord, side:u.Quantity=1*u.deg, **kwargs)->Table: else: continue combined_table = remove_duplicates(combined_table, 'Pan-STARRS_ID') - return combined_table \ No newline at end of file + return combined_table