boutproject / xBOUT

Collects BOUT++ data from parallelized simulations into xarray.
https://xbout.readthedocs.io/en/latest/
Apache License 2.0
21 stars 10 forks source link

Better test for re-applying toroidal coordinates; load Bpxy, Brxy, Bzxy if possible #227

Closed johnomotani closed 2 years ago

johnomotani commented 3 years ago

The previous test for re-applying coordinates could send code down wrong branch if, for example, it was applied to a Dataset that had been averaged over the toroidal coordinate, and so had no "toroidal" dimension - then add_toroidal_geometry_coords() would attempt to add coordinates even though they had already been created. Instead, only add the "geometry" attribute to the Dataset after creating coordinates for the first time, so that if ds.attrs["geometry"] == "toroidal" then we know that coordinates were already created.

The variables Bpxy, Brxy, and Bzxy, which are saved into grid files by the Python hypnotoad, can be useful for some plotting/analysis functions, so load them if a grid file is passed and they are present.

Currently draft because this PR includes the changes in #172, because it updates the modified loading-from-grid-file mechanism. Should be merged after #172.

codecov-commenter commented 3 years ago

Codecov Report

Merging #227 (2b785ab) into master (d9fb747) will decrease coverage by 0.48%. The diff coverage is 40.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #227      +/-   ##
==========================================
- Coverage   75.68%   75.20%   -0.49%     
==========================================
  Files          15       15              
  Lines        2682     2710      +28     
  Branches      631      636       +5     
==========================================
+ Hits         2030     2038       +8     
- Misses        420      437      +17     
- Partials      232      235       +3     
Impacted Files Coverage Δ
xbout/utils.py 83.03% <ø> (ø)
xbout/region.py 83.89% <9.09%> (-1.68%) :arrow_down:
xbout/geometries.py 68.33% <53.84%> (-2.84%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d9fb747...2b785ab. Read the comment docs.