-
Notifications
You must be signed in to change notification settings - Fork 10
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
Some changes for FCI #251
base: master
Are you sure you want to change the base?
Some changes for FCI #251
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #251 +/- ##
==========================================
- Coverage 69.01% 67.09% -1.93%
==========================================
Files 15 16 +1
Lines 3208 3300 +92
Branches 790 802 +12
==========================================
Hits 2214 2214
- Misses 732 822 +90
- Partials 262 264 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 @dschwoerer, looks nice!
Is it worth adding a method to BoutDataset
so that if a dataset has FCI geometry it's possible to get a plot from a one-line call, something like ds.bout.poincare_plot()
?
It would be lovely to have a test for the field-line tracing, but I guess that could be pretty complicated to set up.
@@ -0,0 +1,115 @@ | |||
import numpy as np | |||
import eudist |
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.
Should we add eudist
as a dependency? Also would be nice if it could be added to conda-forge, for those of us who use conda 😃
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.
Probably. I thought of maybe an extra [fci] section?
I have no experience with conda. Do you want to do it?
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.
Probably. I thought of maybe an extra [fci] section?
Sounds good!
I have no experience with conda. Do you want to do it?
No prob. I'll set it up and make you a maintainer on the 'feedstock' repo. It's easy to maintain once it's set up, just click 'merge' on auto-generated PRs that're triggered by releases to PyPi and update the dependency list if it changes.
xbout/tracing.py
Outdated
from warnings import warn | ||
|
||
|
||
def rz_to_ab(rz, mesh): |
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.
Some comment about what this function does would be useful. Looks like a Newton iteration? Finds position within a cell in grid-index space? Using some sort of linear algebra on basis vectors(?) describing the cell?
xbout/tracing.py
Outdated
return albe, ij | ||
|
||
|
||
def ab_to_rz(ab, ij, mesh): |
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.
Comment on what this does. Grid-index space -> spatial position? What are a
, b
, c
?
xbout/tracing.py
Outdated
|
||
|
||
def setup_mesh(x, y): | ||
def per(d): |
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.
Could maybe call this function apply_periodicity()
to be slightly easier to read?
xbout/tracing.py
Outdated
return mymesh(x, y) | ||
|
||
|
||
class mymesh(eudist.PolyMesh): |
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.
Maybe PascalCase form - MyMesh
- as it's a class?
Also a brief docstring would be nice.
xbout/tracing.py
Outdated
return A + al * a + be * b + al * be * c | ||
|
||
|
||
def setup_mesh(x, y): |
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.
Add docstring? E.g. something like "Creates a MyMesh
object from R and Z coordinates..." and also explain why the periodicity thing is needed (I guess because the z-dimension of the grid is assumed to be periodic?).
self.shape = tuple([x - 1 for x in x.shape]) | ||
|
||
|
||
class Tracer: |
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.
Docstring would be nice. How does this work? Somehow relies on the field line tracing that was already done by Zoidberg to make the grid file?
) | ||
self.meshes = meshes | ||
|
||
def poincare(self, rz, yind=0, num=100, early_exit="warn"): |
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 a docstring that explains the arguments.
xbout/tracing.py
Outdated
|
||
def rz_to_ab(rz, mesh): | ||
ij = mesh.find_cell(rz) | ||
assert ij >= 0, "We left the domain" |
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 this should be an actual exception - maybe define an OutOfDomainError
or something? If for some reason someone runs Python in 'optimised' mode with -O
, all assert
statements just get ignored (https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement), so they should only be used for debugging, not program logic.
for d, meshes in enumerate(thismeshes): | ||
try: | ||
abij = rz_to_ab(rz, meshes[0]) | ||
except AssertionError as e: |
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.
Note: will need updating if the exception is changed as suggested above.
Do you know how to do that? That certainly would be nice.
Test would be easy if we had an example grid. Can we download one for the tests? At least for CI it should be no issue. We could host it on zenodo or at the mpcdf gitlab or something else? |
For a method, in BoutDataset add something like (?)
Probably need to also set some default arguments so that the plot looks nice. Maybe also have a |
About the grid file for testing: Indeed don't want to add a binary file to the install, so would be a test that only runs from the source repo. We could add another directory like |
Oh sorry, I misread. I thought you wanted to only add the method if it is an fci dataset. Concerning git-lfs, I do not like the github one, they have not only strict size limits, which should be fine, but also limits on traffic, so the fci grid repo is already putting me at the limit ... |
That would be complicated! Probably should add some check that the dataset is an fci one in the method though. If it's not a lot more complicated, I think I'd prefer Zenodo to mpcdf-gitlab, as it's not dependent on having someone with an mpcdf account to keep it going. |
The forward/backward_{R,Z} are needed for field line tracing
* Rename internal stuff with _ * Use OutOfDomainError if we leave the domain * Add doc strings
Currently we only need eudist additionally
Still missing:
|
f08d14d is not FCI related, but I hope to add soon attributes to zoidberg grids, in which case it would be great if that would be preserved ...