-
Notifications
You must be signed in to change notification settings - Fork 9
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
236 develop pyrealmcoresolar function radiation calc library #237
236 develop pyrealmcoresolar function radiation calc library #237
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #237 +/- ##
===========================================
+ Coverage 95.29% 95.34% +0.05%
===========================================
Files 28 35 +7
Lines 1720 2751 +1031
===========================================
+ Hits 1639 2623 +984
- Misses 81 128 +47 ☔ View full report in Codecov by Sentry. |
@davidorme would it be possible for you to have a quick look over my core.solar functions and the unit tests to make sure they're in line with your code standards. At the moment I've just tested basic maths using representative values as there's no error handling in the functions. I have a spreadsheet with the calcs implemented so it's trivial to add any further tests should they be required. If you would like any basic checks added such as array length equality, just let me know, but for now I presumed data sanitisation would have happened upstream of these calcs. |
@j-emberton That all looks good. In the past, I wouldn't have tended to use One awkward thing in the API are the functions |
Oh - wait... Will post a suggestion. |
@davidorme this library seems to be working now and (at least locally) all tests pass. I incorporated your proposed change to calculate If we compile these functions with cython or number it probably doesn't matter too much unless the arrays are huge. What would you prefer? |
I guess I was thinking that we extend that same structure to the other functions that use I'm not sure how complex that looks - I think my approach here is that users see functions with straightforward inputs and don't have to manual calculate those intermediate inputs, but those functions can then wrap the calculation of the intermediate values and an internal calculation, which we can use more directly inside routines. That does feel a bit around the houses, I admit. |
One way around it would be to put these library functions inside a class and then have self.ru and self.rv generated upon creating a class instance. public methods would then have access to these variables by default. What I'll do for now is go ahead and implement as per your suggestion. We can then profile the code and see if this is an issue or not. If it is, we have a good place to refactor for performance improvements as we have tests ready to go. |
One point I haven't put lots of thought into is whether we want more extensive documentation updates now we've added more functionality to the |
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.
LGTM
If I add some user guidance on how to access the functions in this library, where should I put it. Do we want it to go under core utilities, or create a new solar utilities section? |
moving back to draft while I add a few more bits |
Definitely a new |
On top of what was in there before I've added:
Tests for the above functions Added detail like examples and latex maths to some of the docstrings to function as public facing documentation (where needed) |
Once we get a couple more papers into the bibliography we can add proper citations for the implemented maths |
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. Only minor things:
- Some docstring formatting issues. I've pushed a commit to include the solar docs in the API section, so we can review how they render. I've made some general suggestions on one of the docstrings that apply across the module.
- Using named arguments - I'm not brilliant at practicing this, but with long lists of args, it's much more robust.
- I think the helper wrapper functions could take a packaged
CoreConst
object to make them more usable.
Thankyou for the feedback @davidorme. Much appreciated. I thought we had agreed to make all the variables explicit but I may have got my wires crossed. In any case I'm happy to swap in the core const and adjust as required. I'll do it for all the library functions I create for consistency. It makes sense since those objects will usually be available a priori and don't require any bespoke setup. |
I don't think you got your wires crossed - it's a grey area and we don't have a consistent approach. It's difficult to come up with a hard and fast rule and we're not systematic about this, but I think it's something like "If a function is passing constants on to lower level functions, then passing in constants classes is probably easier for the user and more compact." |
Co-authored-by: David Orme <[email protected]>
Co-authored-by: David Orme <[email protected]>
019f40f
to
ffe91cc
Compare
OK, I think this is all working now and docs basically look ok, although I appreciate there maybe some style tweaks required - lets do these in a followup issue if that's ok. I'd like to just get this work in the bank. |
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 agree that we should bank this functionality and worry about documentation polishing later. The docs are readable and useable now.
One oddity noted in a comment - there are a lot of line endings marked with \
. Those don't appear in the built docs, so aren't a problem, but also aren't required and aren't used elsewhere in the project.
…iation-calc-library
Description
Refactored
pyreal.splash.solar
to move core calculations topyrealm.core.solar
.Functionality of Splash module is unchanged
Change is to facilitate development of two-leaf canopy model
Fixes #236
Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks