Skip to content

Feature/photometry#120

Merged
capetillo merged 9 commits intomainfrom
feature/photometry
May 1, 2026
Merged

Feature/photometry#120
capetillo merged 9 commits intomainfrom
feature/photometry

Conversation

@capetillo
Copy link
Copy Markdown
Contributor

Refactors flux_to_mag to be a util function and is used to return mag and mag_err in the source_catalog

@capetillo capetillo requested a review from jnation3406 April 29, 2026 22:11
Copy link
Copy Markdown
Contributor

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

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

Looks fine, but I think it would be more efficient to do it with the whole array of flux/fluxerr into mag/magerr using numpys fast array operations, rather than doing it pixel by pixel.

@capetillo capetillo requested a review from jnation3406 April 30, 2026 19:48
Copy link
Copy Markdown
Contributor

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

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

Better, but I think the method is confusing since you are trying to support different input/output types. I think it would be clearer to split it into two methods based on input/outputs

Comment thread datalab/datalab_session/analysis/source_catalog.py Outdated
if flux <= 0:
return None, None
flux_array = np.asarray(flux)
fluxerr_array = np.asarray(fluxerr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these not already numpy arrays when pulled out of the fits file by astropy?


mag = -conversion_factor * np.log10(flux_array)
magerr = flux2mag * (fluxerr_array / flux_array)
return float(mag), float(magerr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume you are doing this to support both single values and numpy arrays of values. I think it might be worth breaking this out into two methods, since it returns different things depending on its input. This will be less confusing, and maybe simplify the logic of each individual method.

Copy link
Copy Markdown
Contributor

@jnation3406 jnation3406 left a comment

Choose a reason for hiding this comment

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

Looks good. Pretty spiffy you have a function that works with both scalars and numpy arrays the same. Can you add a unit test for having negative flux values in a numpy array?

@capetillo capetillo merged commit 2dbdd2c into main May 1, 2026
3 checks passed
@capetillo capetillo deleted the feature/photometry branch May 1, 2026 17:33
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