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

toy simulator that is 11,000 times faster than galsim #961

Closed
wants to merge 6 commits into from

Conversation

jacksonloper
Copy link
Collaborator

((Also some tiny bug fixes where it was assumed that the reference band should always be 2.))

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 97.34513% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 92.69%. Comparing base (2d883bb) to head (4bd4905).

Files Patch % Lines
bliss/simulator/toy_simulated_dataset.py 98.11% 2 Missing ⚠️
bliss/encoder/encoder.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #961      +/-   ##
==========================================
+ Coverage   92.50%   92.69%   +0.19%     
==========================================
  Files          23       24       +1     
  Lines        2934     3041     +107     
==========================================
+ Hits         2714     2819     +105     
- Misses        220      222       +2     
Flag Coverage Δ
unittests 92.69% <97.34%> (+0.19%) ⬆️

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.


# make predictions/inferences
target_cat1 = target_cat.get_brightest_sources_per_tile(band=2, exclude_num=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this is a helpful fix/generalization



@dataclasses.dataclass
class ToySimulator:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we inherit from pl.LightningDataModule and IterableDataset here, for symmetry with SimulatedDataset? Ideally ToySimulator would be as close to a drop-in replacement for SimulatedDataset as possib.e

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh maybe this is OK, I see now it's ToySimulatedDataset that's intended as the drop-in replacement for SimulatedDataset. It does seem a bit cleaner to me to merge ToySimulator and ToySimulatedDataset, and to inherit from the same classes that SimulatedDataset does.

return torch.stack(band_images, dim=1)


class ToySimulatedDataset(IterableDataset):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe clearer to merge this class with ToySimulator, for symmetry with SimulatedDataset. (The reason we have two classes in simulated_dataset.py is that the second reads from disk.)

return range_tensor < expanded_counts


def draw_trunc_pareto(b, c, loc, scale, size, torch_generator=None):
Copy link
Contributor

@jeff-regier jeff-regier Apr 2, 2024

Choose a reason for hiding this comment

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

We used to have code like this in prior.py but now we use scipy.stats.truncpareto.
Would it be possible to have your simulator take a prior as argument, the way SimulatedDataset does, for greater symmetry? Presumably you'd just ignore some of the fields for now (e.g., source type). That would make this more of a drop-in replacement for SimulatedDataset, which I think is the goal, at least if we're including this code in our main bliss/bliss directory (as opposed to a case study).

* (
(plocs_x - xx) ** 2 / self.psf_radius_h**2
+ (plocs_y - yy) ** 2 / self.psf_radius_w**2
) # noqa: C815
Copy link
Contributor

Choose a reason for hiding this comment

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

black formatter strikes again. it's cleaner to use intermediate variables.

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.

These changes may not all be worth making: it depends how long they would take and what are goals are for the toy simulator. It would be nice to replace SimulatedDataset with it some day.

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