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
DM-14620: Move ap_association DIA schemas their own module #17
Conversation
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.
See review comments. Thanks for explaining why the unittest numbers changed in the commit message.
I know a lot of these methods were copied from elsewhere, but we should clean them up.
"ccdVisitSchema"] | ||
|
||
|
||
"""Defines afw schemas and conversions for use in ap_association tasks. |
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.
module-level docstrings should be just under the copyright:
https://developer.lsst.io/python/numpydoc.html#placement-of-module-docstrings
""" | ||
|
||
|
||
def make_minimal_dia_object_schema(filter_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.
Don't default to an empty list (or any mutable). Use None
instead, if it's optional, and set it to a list at the start of the method.
http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments
|
||
# In the future we would like to store a covariance of the coordinate. | ||
# This functionality is not defined in currently in the stack, so we will | ||
# hold off until it is implemented. This is to be addressed in DM-7101. |
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.
Please mark this with a TODO: so it's easier to spot.
# as well as their errors. | ||
|
||
# In the future we would like to store a covariance of the coordinate. | ||
# This functionality is not defined in currently in the stack, so we will |
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.
"not defined in currently in the stack"
Minimal schema for DIAObjects. | ||
""" | ||
schema = afwTable.SourceTable.makeMinimalSchema() | ||
schema.addField("diaObjectId", type='L') |
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.
Please add `doc=' to document what all these fields are.
Parameters | ||
---------- | ||
source_record : `lsst.afw.table.SourceRecord` | ||
Input source catalog to modify values of if needed. |
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.
"if needed" implies that this is optional. Is it? What is the default value in that case?
overwrite_dict['psFluxErr'] = np.sqrt( | ||
(psFluxErr / exp_dict['fluxZeroPoint']) ** 2 + | ||
(psFlux * exp_dict['fluxZeroPointErr'] / | ||
exp_dict['fluxZeroPoint'] ** 2) ** 2) |
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 don't like that we're coding the error calculation here explicitly. Call something from Calib
or PhotoCalib
instead. For example, PhotoCalib.instFluxToMaggies(flux, fluxErr)
will give you the calibrated flux and fluxErr.
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.
Do calexps or other exposure like objects have a PhotoCalib object? The calib object stored doesn't have an option to convert to maggies. Is there an example of how I can use a PhotoCalib object with an exposure and a catalog?
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.
A more future-proof approach would be to create a PhotoCalib
object when you read in the Exposure and extract the Calib
and pass it around, instead of the zero-point. This should do it:
fluxMag0 = calib.getFluxMag0()
photoCalib = afwImage.PhotoCalib(1.0/fluxMag0[0], fluxMag0[1]/fluxMag0[0]**2, bbox)
That way, once we replace Calib with PhotoCalib (DM-10153), we just have to delete two lines.
Oh, please leave a TODO as well.
@@ -0,0 +1,279 @@ | |||
# |
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 not call the file afwUtils.py
? It's already in ap.association
, so ap.association.assoc_afw_utils
seems redundant. Also, files are camelCase:
ccdVisitSchema, \ | ||
add_dia_source_aliases_to_catalog, \ | ||
get_ccd_visit_info_from_exposure, \ | ||
make_overwrite_dict |
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 not just import .afwUtils
(per my above filename comment), and then they'll all be namespaced. You'll have to expand that file's __all__
.
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'm sort of okay with keeping it this way. It makes it more clear for me when something breaks. Also I'm not sure I want many of these functions exposed for use outside of the context of ap_association.
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.
If you really don't want those things in the namespace, please make a note of that above the __all__
in afwUtils
, so that others don't expose it later.
tests/test_association_db_sqlite.py
Outdated
@@ -29,13 +29,14 @@ | |||
AssociationDBSqliteTask, \ | |||
AssociationDBSqliteConfig, \ | |||
make_minimal_dia_source_schema | |||
from lsst.ap.association.assoc_afw_utils import \ |
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.
Again, probably better to from lsst.ap.association import afwUtils
and then you'll have the whole namespace.
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.
See above, I hope that makes sense.
def convert_dia_source_to_asssoc_schema_and_calibrate(dia_sources, | ||
obj_ids=None, | ||
exposure=None): | ||
"""Create aliases in for the input source catalog schema and overwrite |
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.
typo here.
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.
"and overwrite values if requested": what constitutes a request?
Please rebase squash. |
Add afw_dia_schemas Move exposure and overwrite dicts to afw_dia_schemas.py Rename afw_dia_schemas Move all schemas out of assoc_db_sqlite. Finalize assoc_afw_utils Clean up tests and methods to new call signatures. Debug unittests Found bug from previous testing where flux values were not updated properly due to filter ids not being correct. This has been fixed. Clarify doc strings.
Rename references to afwUtils. Fix import in tests_association_db_sqlite Edit obj_id comment docstring.
Use photoCalib return properly. Fix ccdVisitSchema method name Remove bbox from photoCalib object
Fix linter errors Add TODO refering to DM-10153.
ef3b880
to
cdf86ba
Compare
No description provided.