-
Notifications
You must be signed in to change notification settings - Fork 14
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
Have Standardizers add obstime to LayeredImage #525
Changes from all commits
aee11a5
0c62513
db14da7
30ced4c
da1a2a8
3af3753
f51d4c6
a3c9abf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,6 +441,7 @@ def toLayeredImage(self): | |
# copy. TODO: fix when/if CPP stuff is fixed. | ||
imgs = [] | ||
for sci, var, mask, psf, t in zip(sciences, variances, masks, psfs, mjds): | ||
imgs.append(LayeredImage(RawImage(sci), RawImage(var), RawImage(mask.astype(np.float32)), psf)) | ||
|
||
# Converts nd array mask from bool to np.float32 | ||
mask = mask.astype(np.float32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What dtype does Rubin butler return for the mask? I have a feeling I assumed something here and then forgot about it. Mostly astropy.io.fits and the butler should already return float32s. I think Butler might be returning an int for mask, but in that case this cast would still be better in the standardizer I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This comment seems to be about the butler standardizer but is on the FITS standardizer file? Sorry if I'm the one confused here, but answering about the FITS standardizers) Yeah I saw that you added it in this "Fix bug in Fits Standardizers." commit but I am also not sure what it was you were specifically trying to fix. But overall the FITS standardizer seems fairly broad/general so it seems like it could be fine to do a default conversion of the dtype Related, we also currently spoof that the mask should be So I guess the overall the question maybe is just what do we want the mask dtype to be since we seem to be a bit inconsistent about it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The array is read into the memory by Astropy based on the header keywords So this is true for both Rubin and any of the FITS standardizers. Then I floated the casts up to Python by banning the implicit conversion and casts in the Python bindings in C++: https://github.com/dirac-institute/kbmod/blob/main/src/kbmod/search/raw_image.cpp#L465 But I seem to have a few unnecessary ones. From the code it seems like I wanted to add a constructor onto LayeredImage that takes a single t and propagates it down, but I seem to have forgot or something. Rubin seems to return int masks, other files seems to return whatever they want. This can be fixed and reduce memory and time requirements, but it's nothing that should be addressed in this PR so it's all ok. Just one more thing for the TODO list. |
||
imgs.append(LayeredImage(RawImage(sci, t), RawImage(var, t), RawImage(mask, t), psf)) | ||
return imgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we explicitly casting the mask to float32? Is Eigen complaining to you? If so then we should address this in the
standardizeMaskImage
method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added this because we were doing it in the FITS standardizer and I thought that it might help to catch some edge case.
In
ButlerStandardizer.standardizeMaskImage()
we do currently explicitly convert to a bool dtype. Do you know if there was any particular reason why we preferred thebool
overfloat32
dtype? Presumably to save on memory but that adds confusion as to why we cast the mask to float32 in other standardizersThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though actually taking another look, in main we do still still get back to a float32, probably in the conversion to Eigen when we create the
RawImage
I'm starting to feel that we should remove all the type conversions both in here and in
standardizeMaskImage