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

DM-23030: Modify Photometry SDM Functor to use stored calibration value. #355

Merged
merged 1 commit into from Mar 11, 2020

Conversation

morriscb
Copy link
Contributor

@morriscb morriscb commented Mar 6, 2020

No description provided.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly documentation fixes, otherwise looks good. Please merge the second commit into the first, as it's clear that the first commit is not self-contained.


@property
def name(self):
return 'mag_{0}'.format(self.instFluxCol)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we use format much in the Stack, consider using f-strings for consistency:

Suggested change
return 'mag_{0}'.format(self.instFluxCol)
return f'mag_{self.instFluxCol}'


Parameters
----------
instFlux : `numpy.ndarray` or `pd.Series`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Sphinx can parse namespace aliases. Does this work when you build the documentation and look at it in a browser? If not, use pandas instead of pd.

calibFlux : `numpy.ndarray` or `pd.Series`
Array of calibrated flux measurements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say what happens if one input is an ndarray and the other is a Series? What do you get back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comes out as Series.

return -2.5 * np.log10(self.instFluxToNanojansky(instFlux, localCalib)) + self.logNJanskyToAB

def instFluxErrToMagnitudeErr(self, instFlux, instFluxErr, localCalib, localCalibErr):
"""Convert instrument flux to nanojanskys.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect description; you're converting the errors.



class LocalNanojansky(LocalPhotometry):
"""Compute calibrated fluxes using the local calibration value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to figure out what's going on here. I suggest:

  • Clarifying in the LocalPhotometry documentation that it's an abstract base class with general calibration code, and not itself a complete Functor.
  • Removing from LocalPhotometry the name and columns properties, which are always overridden in the functors anyway.
  • Clarifying in LocalNanojansky, LocalNanojanskyErr, LocalMagnitude, and LocalMagnitudeErr that these are pieces of a bigger system (e.g., by having a See also section that links between the flux and error versions).

python/lsst/pipe/tasks/functors.py Outdated Show resolved Hide resolved
rtol=0))

# Test functors
func = LocalNanojansky("base_PsfFlux_instFlux",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not have one test case for each class instead of putting everything into a very long method? You'll get more information when you run the tests, it'll be easier to make changes to the test code, and you won't have to worry about weird side effects from shared variables like func and val.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the tests into their own function so the duplicated code is reduced. Considering how closely related the functors are and how they dependent they are the previously tested methods, I'm fine with leaving them here for now.

@morriscb morriscb changed the title DM-23030: Rework functor tests to test specific input/output. DM-23030: Modify Photometry SDM Functor to use stored calibration value. Mar 9, 2020
@morriscb
Copy link
Contributor Author

Hey @kfindeisen, think I've gotten through all of your comments. Take a look and let me know if I missed anything. I'll squash the commits once you have a look.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment. Feel free to merge whenever you're ready.

Comment on lines 1127 to 1132
See also
--------
LocalPhotometry
LocalNanojansky
LocalNanojanskyErr
LocalMagnitude
LocalMagnitudeErr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a bit overkill. You can at least remove LocalPhotometry, because the docs always have an automatic link to the base class.

Add columns definition returns.

Add docstrings.

Add inifial localPhotometry unittest.

Debug localPhotometry functor.

Switch to astropy.

Create unittest for LocalPhotometry.

Debug unittest

Add functor unittests.

Add functor value testing.

Debug unittest

Fixup review requests.

Change to f strings.

Remove extra see also.
@morriscb morriscb merged commit edca71e into master Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants