-
Notifications
You must be signed in to change notification settings - Fork 28
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
Structured array source detection catalogs #987
Structured array source detection catalogs #987
Conversation
5764aa0
to
6f58a89
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #987 +/- ##
==========================================
+ Coverage 73.53% 73.55% +0.01%
==========================================
Files 103 103
Lines 6704 6711 +7
==========================================
+ Hits 4930 4936 +6
- Misses 1774 1775 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
6569baa
to
32d5af7
Compare
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.
This looks good. I might take it a bit farther and aim to just make 'sources' the catalog (don't bother trimming out columns unless we really think daofind is giving us useless stuff?), and then have the fit_psf branch just ~join the psf_photometry_table onto the sources table + overwrite the x & y so that they get used by tweakreg? Does the psf_photometry_table already include all of the content of the daofind sources table?
It's unclear to me that you actually use or need ndarrays_to_recarrays or recarray_to_ndarrays. I think we can get away without the whole basic_utils.py file, and just rely on Table(ndarray) and Table(ndarray).as_array() to handle all of the conversions between structured arrays and Tables?
romancal/lib/basic_utils.py
Outdated
return Table(data, names=names) | ||
|
||
|
||
def astropy_table_to_recarray(x): |
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 feel like I usually use https://docs.astropy.org/en/stable/api/astropy.table.Table.html#astropy.table.Table.as_array
?
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.
This function converts specifically to a structured array.
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.
Updated!
romancal/lib/basic_utils.py
Outdated
return np.asarray(x.astype(astype).view(to_dtype).reshape((-1, len(names)))) | ||
|
||
|
||
def recarray_to_astropy_table(x): |
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 think you can just do Table(ndarray).
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.
Thanks you're right! Resolved.
That's almost what's done now. I left the DAO trimming in place, as-is. When
Not all of the content, but I'd argue that the parts that are relevant are preserved. |
588e40d
to
95e3bdc
Compare
romancal/lib/basic_utils.py
Outdated
@@ -103,3 +103,45 @@ def __exit__(self, et, ev, tb): | |||
if self.handler and self.close: | |||
self.handler.close() | |||
# implicit return of None => don't swallow exceptions | |||
|
|||
|
|||
def ndarrays_to_recarray(arrays, names): |
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.
Am I missing it, or do we only use this and its inverse in tests? Can we get rid of this module and its tests and just rely on the library conversions?
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.
It's only used in tests at the moment, that's correct. I left this in the PR until chatting with @mairanteodoro to confirm that we won't ever need to read and convert the old catalogs that are 2D ndarrays.
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.
@bmorris3 I think we should be good. Thanks!
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.
Looks good to me!
romancal/lib/basic_utils.py
Outdated
@@ -103,3 +103,45 @@ def __exit__(self, et, ev, tb): | |||
if self.handler and self.close: | |||
self.handler.close() | |||
# implicit return of None => don't swallow exceptions | |||
|
|||
|
|||
def ndarrays_to_recarray(arrays, names): |
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.
@bmorris3 I think we should be good. Thanks!
95e3bdc
to
6b8de32
Compare
6b8de32
to
df1b05e
Compare
Source Detection produces a 2D ndarray of source IDs, centroids, and fluxes, to use as inputs in tweakreg. @schlafly and I discussed in #841 that we could use a self-documenting and more scalable data structure instead if additional Source Detection results are useful for tweakreg or elsewhere.
This PR swaps the unlabeled 2D ndarray for a structured array, and adds some helper functions for converting between ndarrays, structured arrays, and astropy tables.
Resolves RCAL-709
Checklist
CHANGES.rst
under the corresponding subsection