some small fixes and edits to work with modap - #236
bizarreboa wants to merge 44 commits into
Conversation
…D and it outputs as a png instead of a pdf
…a fix with twomass querying
…ed a astropy units Mpc issue with nedlvs that I encountered
…ff into just ImportError
There was a problem hiding this comment.
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.
| 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Alternatively, switching over to the scipy implementation if the naming there is a little more stable.
There was a problem hiding this comment.
Went with np.trapezoid
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| # Command line execution | ||
| if __name__ == '__main__': | ||
| r_vs_dm() No newline at end of file | ||
| r_vs_dm() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| try: | ||
| in_match = np.isin(IDs, match_IDs) | ||
| except AttributeError: | ||
| # Older NumPy versions |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Gotcha, dropped the try/except.
| photom = {} | ||
| photom['DELVE'] = {} | ||
| photom['DELVE']['DELVE_ID'] = 'quick_object_id' | ||
| # photom['DELVE']['DELVE_ID'] = 'coadd_object_id' |
There was a problem hiding this comment.
Seems like these comments are not changing the original functionality or documenting anything. I suggest getting rid of the comment blocks in this file.
There was a problem hiding this comment.
Removed all the commented-out blocks I added.
| else: | ||
| query_fields = _DEFAULT_query_fields+query_fields | ||
|
|
||
| import astropy.units as u |
There was a problem hiding this comment.
Is this import being used anywhere in the file? If not, please remove.
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
This is not guaranteed to be present for some surveys, I think.
I really need to make the survey catalogs and method inputs uniform. 😬
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
catalog_utils._detect_mag_cols now used instead of iterating
valid_filters with a membership test inside the loop (dfa99dd).
|
On On the masked-table suggestion: adopted with one change. The provided snippet Also picked up |
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