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 various issues related to ImageCollection and Standardizers. #674

Merged
merged 7 commits into from
Aug 5, 2024

Conversation

DinoBektesevic
Copy link
Member

Resolves #665
Resolves #673
Resolves #672

I would also like to close #303.

I tried resolving #410 and resolving #589 but I couldn't really make my way around the work unit code tbh. There's a lot of nesting and some of the duplicated code makes it kind of fuzzy to understand what is the currently used codepath.

The WorkUnit also seems to be broken. It doesn't require a configuration to be given, but it throws an unclear error (None does not have keys) when writing and reading to/from fits without providing one. Not sure if config is intended to be optional (then we need a better error) or we should just make it a required parameter to a work unit?

I added an example of how we can package a flattened image collection into a header unit in the to/from_fits methods, but I'd love some direction from @maxwest-uw or @jeremykubica as to what you would like to see happen here? I think the metadata is serializable into a YAML or dict. WorkUnits have a lot of serialization for that, but is this used?

There's a metadata but the docs aren't clear as to rules of what goes to primary as metadata vs "metadata" HDU? Values are stored in headers for both of them, even when the underlying HDU is BinTable or Table - but I don't think I can do that with image collection tbh. So I don't think that fits with your convention.

More broadly, I don't think this is safe to do. The HIERARCH and CONTINUE keywords are supported by astropy, but I don't think this is part of official standard. Astropy doesn't say much about limitations, but CFITSIO seems to agree and says it will throw an error if the key-value pair is more than 40 chars long and if it's a string it will just forcefully truncate it without error-ing out.

The changes:

Standardizers:
- sync KBMODV1 and ButlerStandardizer; they're not exact, but better.
- rename mjd to mjd_mid, fix tests
- extract obs lon, lat and elevation in ButlerStandardizer
- make MultiExt and SingleExt standardizers not directly instantiabl (this was a complain from Max a while ago but I can't find an issue if there was one)

ImageCollection:
- implement packing and unpacking of shared columns
- implement to and from BinTableHDU cast for ImageCollection
- add it to workunit as a metadata header unit as an example
- add vstack method (have to test in wild) for image collection
- adds a copy method
- add a way to manually reset lazy loading indices after subsetting form a larger collection (useful only for really really large collections)

Flesh out a lot more tests for ImageCollection and Standardizers:
- more explicit testing of more expected values
- more explicit testing of lazy loading and indexing mechanism in IC

src/kbmod/image_collection.py Outdated Show resolved Hide resolved
src/kbmod/image_collection.py Outdated Show resolved Hide resolved
src/kbmod/image_collection.py Outdated Show resolved Hide resolved
src/kbmod/image_collection.py Show resolved Hide resolved
src/kbmod/image_collection.py Show resolved Hide resolved
tests/test_butlerstd.py Show resolved Hide resolved
@maxwest-uw
Copy link
Collaborator

the metadata stuff looks good to me!

@DinoBektesevic
Copy link
Member Author

I've punted adding of the metadata header unit into a different PR so this one doesn't get too long. I've un-done the example addition of the metadata in work-unit here for now.

Standardizers:
    - sync KBMODV1 and ButlerStandardizer; they're not exact, but better.
    - rename mjd to mjd_mid, fix tests
    - extract obs lon, lat and elevation in Butler std
    - make Multi and Single Ext standardizers not directly instantiable.

ImageCollection
    - implement packing and unpacking of shared columns, sadly it's not
      as big of a space-saving as one would really want.
    - implement to and from BinTableHDU cast for ImageCollection
    - add it to workunit as a metadata header unit

Flesh out a lot more tests for ImageCollection and Standardizers:
    - more explicit teting of more expected values
    - more explicit testing of lazy loading and indexing mechanism
      in IC
src/kbmod/image_collection.py Outdated Show resolved Hide resolved
Spelling fix.

Co-authored-by: Jeremy Kubica <[email protected]>
@DinoBektesevic DinoBektesevic merged commit d151b23 into main Aug 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants