Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flux unit #1060

Merged
merged 9 commits into from
Aug 19, 2024
Merged

Fix flux unit #1060

merged 9 commits into from
Aug 19, 2024

Conversation

YicunDuanUMich
Copy link
Collaborator

  • the flux unit defined in catalog.py is problematic; fix it in this PR
  • add some comments to to_tile_catalog
  • consider the cases where corner points in to_tile_catalog have invalid indices

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 87.83784% with 9 lines in your changes missing coverage. Please review.

Project coverage is 81.21%. Comparing base (41d09e1) to head (b917727).
Report is 1 commits behind head on master.

Files Patch % Lines
bliss/encoder/metrics.py 88.63% 5 Missing ⚠️
bliss/catalog.py 86.20% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1060      +/-   ##
==========================================
+ Coverage   80.73%   81.21%   +0.47%     
==========================================
  Files          23       23              
  Lines        3073     3045      -28     
==========================================
- Hits         2481     2473       -8     
+ Misses        592      572      -20     
Flag Coverage Δ
unittests 81.21% <87.83%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


def get_state_for_report(self, state_name):
state = getattr(self, state_name)
match self.report_bin_unit:
case "nmgy":
case "njy":
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't use njy for SDSS, only nmgy

Copy link
Contributor

Choose a reason for hiding this comment

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

I wish there was a generic term that could mean either

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change it to flux

bliss/catalog.py Outdated
"""

return 22.5 - 2.5 * torch.log10(nmgy / 3631)
return 22.5 - 2.5 * torch.log10(flux / c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to subtract log10(c) for stability

Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably the 22.5 can be absorbed by the log10(c) term

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps call c the zero_point. It's more descriptive

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

remove the 22.5 and rename c to zero_point

bliss/catalog.py Outdated
def on_njymag(self) -> Tensor:
return convert_nmgy_to_njymag(self.on_nmgy)
def on_magnitudes(self, c) -> Tensor:
return convert_flux_to_magnitude(self.on_fluxes, c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is c defined? I believe c is survey specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

so we could store these in the Survey subclasses.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to modify the Survey class but find that we also need to change the Encoder and some notebooks. So I move the zero point specification to our metrics by adding one argument mag_zero_point to our metric classes.

@@ -143,17 +143,17 @@ variational_factors:
metrics:
detection_performance:
_target_: bliss.encoder.metrics.DetectionPerformance
base_nmgy_bin_cutoffs: [200, 400, 600, 800, 1000]
report_bin_unit: njymag
base_njy_bin_cutoffs: [200, 400, 600, 800, 1000]
Copy link
Contributor

Choose a reason for hiding this comment

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

For SDSS, it wouldn't make sense to specify anything in terms of nJy. Magnitude is something of a universal system of flux: perhaps we could always specify the cutoffs in terms of magnitude?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we could call these flux_bin_cutoffs, and use the default units for the survey (without specifying what they are). I'm not sure which way is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change it to base_flux_bin_cutoffs

report_bins = torch.flip(report_bins, dims=(-1,))
case "njymag":
report_bins = convert_nmgy_to_njymag(report_bins)
case "ab_mag":
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this "mag" rather than "ab_mag"? Apparently SDSS magnitudes aren't exactly ab magnitudes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

change it to mag

Copy link
Contributor

@jeff-regier jeff-regier 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

@jeff-regier jeff-regier merged commit e9de7ce into master Aug 19, 2024
3 checks passed
@jeff-regier jeff-regier deleted the yd/dc2_cataloging_08-11 branch August 19, 2024 21:47
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