dirac-institute / kbmod

KBMOD (Kernel-Based Moving Object Detection)
BSD 2-Clause "Simplified" License
46 stars 14 forks source link

Fix various issues related to ImageCollection and Standardizers. #674

Closed DinoBektesevic closed 3 months ago

DinoBektesevic commented 3 months ago

Resolves https://github.com/dirac-institute/kbmod/issues/665 Resolves https://github.com/dirac-institute/kbmod/issues/673 Resolves https://github.com/dirac-institute/kbmod/issues/672

I would also like to close https://github.com/dirac-institute/kbmod/issues/303.

I tried resolving https://github.com/dirac-institute/kbmod/issues/410 and resolving https://github.com/dirac-institute/kbmod/issues/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:

ImageCollection:

Flesh out a lot more tests for ImageCollection and Standardizers:

maxwest-uw commented 3 months ago

the metadata stuff looks good to me!

DinoBektesevic commented 3 months ago

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.