boutproject / xBOUT

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

Methods to calculate coordinate derivatives #192

Closed johnomotani closed 3 years ago

johnomotani commented 3 years ago

Special method for calculating a derivative in the "bout_zdim" direction (toroidal, z-direction), needed because xarray's differentiate method doesn't have an option to handle a periodic dimension (as of xarray-0.17.0). This method uses a second-order accurate central finite difference method to calculate the derivative.

Edit: Also added methods for a derivative in the "bout_xdim" direction, which needs to account for the fact that dx is a 2d quantity (may be different between core and PFR regions), and for a derivative in the "bout_ydim" direction, which needs to account for branch cuts and shifting to and from the field-aligned grid.

pep8speaks commented 3 years ago

Hello @johnomotani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2021-04-20 17:25:47 UTC
Vandoo commented 3 years ago

Thanks for this PR!

codecov-io commented 3 years ago

Codecov Report

Merging #192 (6b086c0) into master (9295c25) will increase coverage by 0.05%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   75.98%   76.04%   +0.05%     
==========================================
  Files          14       14              
  Lines        2440     2446       +6     
  Branches      563      563              
==========================================
+ Hits         1854     1860       +6     
  Misses        386      386              
  Partials      200      200              
Impacted Files Coverage Δ
xbout/boutdataarray.py 86.42% <100.00%> (+0.29%) :arrow_up:

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 9295c25...6b086c0. Read the comment docs.

johnomotani commented 3 years ago

I've also added ddx() and ddy() methods now.

codecov-commenter commented 3 years ago

Codecov Report

Merging #192 (f4d5001) into master (9295c25) will decrease coverage by 0.93%. The diff coverage is 58.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
- Coverage   75.98%   75.04%   -0.94%     
==========================================
  Files          14       14              
  Lines        2440     2513      +73     
  Branches      563      584      +21     
==========================================
+ Hits         1854     1886      +32     
- Misses        386      411      +25     
- Partials      200      216      +16     
Impacted Files Coverage Δ
xbout/boutdataset.py 76.24% <ø> (-0.35%) :arrow_down:
xbout/boutdataarray.py 76.65% <46.91%> (-9.48%) :arrow_down:
xbout/geometries.py 78.67% <100.00%> (-0.52%) :arrow_down:
xbout/utils.py 82.98% <100.00%> (+0.96%) :arrow_up:

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 9295c25...f4d5001. Read the comment docs.

Vandoo commented 3 years ago

ddy() gives only dict_keys(['lower_inner_PFR']) in the result.regions.keys(), ddx and ddz are fine.