-
Notifications
You must be signed in to change notification settings - Fork 20
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
Photon power law #103
Photon power law #103
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #103 +/- ##
==========================================
+ Coverage 55.06% 55.66% +0.60%
==========================================
Files 19 20 +1
Lines 3122 3167 +45
==========================================
+ Hits 1719 1763 +44
- Misses 1403 1404 +1
☔ View full report in Codecov by Sentry. |
The Python 3.7 checks will always fail because I'm using the walrus operator |
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.
Hi @settwi. This looks good. Could you convert the "plot test" into an actual test where you check the output values?
Yes! I'll work on that today. Thank you |
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.
Nice additions @settwi comments below are more of a discussion for us all have rather than you to address/fix
- Would a
power_law_binned_flux
be useful I know it can be achieved using the break energy but that's kinda opaque - Type annotations I'm a fan but we should probably make a decision as package/group
- Is the root folder the correct place for these kind of functions
- There are similar functions but for electrons in the thick target models could they be combined/integrated - less code is better than more code
@samaloney thanks for the feedback! I'll address the style and testing feedback hopefully today and push up the changes. |
I squashed a couple bugs, adjusted the formatting, and tried to address the testing concerns that folks mentioned. Please take a look and let me know if other things need to change. Thanks! PS: i am stuck trying to get Sphinx to properly build. weird indentation errors. ugh |
Co-authored-by: Shane Maloney <maloneys@tcd.ie>
Co-authored-by: Shane Maloney <maloneys@tcd.ie>
Thanks for the fixes @samaloney I am not sure why but I couldn't get my local Sphinx to build the documentation without errors Are we good to merge? |
No worries a fresh install in a clean virtual env e.g. As far as code is concerned I think the PR is good to go but I think there some 'meta' issues that need to be discussed I had suggest at the proposed monthly call? |
@DanRyanIrish and @samaloney can we say your revisions have been satisfied and merge the PR? |
I think this PR might be ready to merge. Should we add it in? |
@samaloney @DanRyanIrish could one of you approve the PR if you think it's good to go? |
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 OK to me. A couple general style points though.
I think it's good practice to have readable variable names. In the tests and main code there are several 2- and 3-letter variable names that are not descriptive, making the code harder to understand.
Similarly, it's good practice name functions with verbs. That way you can tell it's a function/method from its name., e.g. power_law_binned_flux
-> calculate_power_law_binned_flux
import numpy as np | ||
|
||
import astropy.units as u |
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.
import numpy as np | |
import astropy.units as u | |
import astropy.units as u | |
import numpy as np |
See section on ordering imports in PEP 8
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 actually ran autopep8
on this file multiple times :p
It looks like this example given in the PEP8 "Imports" section shows that the foo.bar
package should be imported second?
import myclass
import foo.bar.yourclass
Sure, I can update the variables.
|
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 great @settwi!
sunxspex/photon_power_law.py
Outdated
def compute_broken_power_law( | ||
energy_edges: u.keV, | ||
reference_energy: u.keV, | ||
reference_flux: PHOTON_RATE_UNIT, |
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 there a reason this is called "reference_flux" rather that "normalization"?
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 it's an artifact from when the function had a slightly different implementation. i'll update the name!
reference_energy : `astropy.units.Quantity` | ||
Energy at which the normalization is applied, i.e. :math:`E_0`. | ||
reference_flux : `astropy.units.Quantity` | ||
Normalization flux for the photon power law. |
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 would also add another description here for what this normalisation is
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.
hey @DanRyanIrish @hayesla i will implement Laura's comments. thanks for checking in. |
Co-authored-by: Laura Hayes <hayesla@tcd.ie>
0f10b6f
to
9da8014
Compare
@hayesla and @DanRyanIrish i've implemented Laura's comments and i think things are good to go. i know some tests are failing but i think most of them are out of my hands... |
@samaloney @DanRyanIrish could you mark the pending changes as approved? |
@settwi reminded me of a conversation with @DanRyanIrish at SPD that this was OK to be accepted from his point of view so, before any larger changes are made to the repo, I'm going to merge this PR. Any other changes down the line can be addressed in the refactoring. |
Conversation at SPD with Dan made clear he was happy to accept the PR but physically couldn't at the time.
PR
PR Description
Adds photon space broken power law.
Compare with f_bpow and bknpower.
The broken power law bins flux properly and uses an analytical antiderivative of a power law to do so.
The documentation is (mostly?) in line with other stuff I've seen in sunxspex so far.
Needs more tests!
Fixes #101