Skip to content

some small fixes and edits to work with modap - #236

Open
bizarreboa wants to merge 44 commits into
mainfrom
modap_edits
Open

bizarreboa wants to merge 44 commits into
mainfrom
modap_edits

Conversation

@bizarreboa

Copy link
Copy Markdown
Collaborator

mostly added a way to change the cigale SED plot to be a png so that text can be added to it, and then several various fixes for small errors

@bizarreboa
bizarreboa marked this pull request as ready for review May 6, 2026 00:04
@bizarreboa
bizarreboa requested review from SunilSimha and profxj May 6, 2026 00:05

@SunilSimha SunilSimha left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes.

For whatever reason, GitHub is not allowing me to create more comments. So here are the remaining ones:

Line 314 of survey_utils

I'd make the table masked here and add good masks to individual columns. Then, it becomes easy to get the combined mask by getting the "OR" of the individual column masks. Also preserves more info if the user wishes for more granularity later.

e.g.

cat = Table(cat, masked=True)
has_good = np.zeros_like(tab, dtype=bool)

for col in mag_cols:
    tab[col].mask = np.isfinite(tab[col]) & tab[col]< 90 & (tab > 0)
    has_good |= tab[col].mask 

Line 273 of survey_utils

This doesn't make sense here. The combined cat for a large cone search should return several rows. Therefore, picking the best row should be a separate function implemented elsewhere. If MODaP needs this, then MODaP must implement it on whatever this function returns.

Comment thread frb/galaxies/cigale.py
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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a little hacky so are you certain there's no internal CIGALE plot argument that does this already? If not, feel free to just resolve this comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked — pcigale-plots sed has no text-annotation option; the labels are baked
into the matplotlib figure it writes, so there's nothing to hook into. Keeping the
helper.

Comment thread frb/galaxies/photom.py Outdated
delta = np.trapezoid(throughput * source_flux *
10 ** (-0.4 * Alambda), x=wave) / np.trapezoid(
throughput * source_flux, x=wave)
if getattr(np, "trapz", None) is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth adding a deprecation warning here. I believe this is for Numpy < 2.0, and so I don't see a reason to support this long term.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, switching over to the scipy implementation if the naming there is a little more stable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with np.trapezoid

Comment thread frb/galaxies/photom.py Outdated
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would trust SDSS extinction estimates more because I imagine they got their E(B-V) values at the location where they took their spectra as opposed to our method of using the nearest measurement within a few degrees. Worth looking into why they are different.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the SDSS-provided value is preferred again, now behind a
_valid_extinction_value() guard so masked / NaN / -999 entries fall through to the
Gordon 2024 curve instead of silently corrupting the magnitude. Also added an optional
ext_methods dict so callers can record which correction was used per filter.

Comment thread frb/scripts/r_vs_dm.py
# Command line execution
if __name__ == '__main__':
r_vs_dm() No newline at end of file
r_vs_dm()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check that there's a corresponding entry in the new pyproject.toml to make sure this script is installable when pip installing the repo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked — there's no entry, and I don't think it needs one: r_vs_dm.py has no
cli()/main(), and it's one of five scripts (iteration, pz_given_dm,
pzdm_mag_crossmatch, r_vs_dm, random_assoc) run directly rather than installed.

Comment thread frb/surveys/catalog_utils.py Outdated
try:
in_match = np.isin(IDs, match_IDs)
except AttributeError:
# Older NumPy versions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that np.isin has always been available, even in v 1.26. If so, maybe we can get rid of this exception handling?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, dropped the try/except.

Comment thread frb/surveys/delve.py Outdated
photom = {}
photom['DELVE'] = {}
photom['DELVE']['DELVE_ID'] = 'quick_object_id'
# photom['DELVE']['DELVE_ID'] = 'coadd_object_id'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these comments are not changing the original functionality or documenting anything. I suggest getting rid of the comment blocks in this file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all the commented-out blocks I added.

Comment thread frb/surveys/galex.py Outdated
else:
query_fields = _DEFAULT_query_fields+query_fields

import astropy.units as u

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this import being used anywhere in the file? If not, please remove.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used — self.radius.to(u.deg) a few lines down — and the module has no top-level
units import, so removing it outright breaks get_catalog(). Moved it up into the
import block instead.

mag_cols = valid_filters

# require separation column already computed in arcmin/arcsec/whatever
sep = cat['separation']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not guaranteed to be present for some surveys, I think.

I really need to make the survey catalogs and method inputs uniform. 😬

@bizarreboa bizarreboa Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, for now added an early return with a warning when separation isn't present. Also removed the call from search_all_surveys, so this function is now only reached when a caller opts in.

if len(cat) == 0:
return cat

if mag_cols is None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure there's a catalog_utils function called get_mag_cols or some such that just gives you the columns that are present in a table. This is being used for extenction correction I believe. Prevents you from running the if statement in the loop over columns below.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catalog_utils._detect_mag_cols now used instead of iterating
valid_filters with a membership test inside the loop (dfa99dd).

@bizarreboa

Copy link
Copy Markdown
Collaborator Author

On pick_best_row_by_phot being called inside search_all_surveys: test_frbsurveys.test_search_all asserts
len(combined_cat) == 2, so collapsing the result to one row broke it — it just never
ran, being @remote_data. Removed the call in 8f5922f; search_all_surveys returns
every row in the cone again, and pick_best_row_by_phot stays as a public helper.

On the masked-table suggestion: adopted with one change. The provided snippet
assigns the good condition to .mask and then ORs the masks together but that would hide the usable photometry, so I inverted the polarity. The returned table is masked, so callers can see which filters actually carried the row.

Also picked up _detect_mag_cols and the missing-separation guard from the inline
comments. Branch is pushed and ready for another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants