xBOUT icon indicating copy to clipboard operation
xBOUT copied to clipboard

Interpolate to new grid

Open johnomotani opened this issue 3 years ago • 2 comments

Add methods BoutDataset.interpolate_to_new_grid()/BoutDataArray.interpolate_to_new_grid() to interpolate a Dataset or DataArray to a new grid. The new grid should be defined by a new grid file created using the same equilibrium as the original grid. Interpolation is done first radially (using psi as the coordinate) and then in the parallel direction (using poloidal distance along a psi-contour as the coordinate).

Also includes a new method BoutData*.interpolate_radial(), for radial interpolation, which is used inside interpolate_to_new_grid().

Requires grid files generated using ~~a version of hypnotoad including the changes in this PR, which saves poloidal distances to the grid files: https://github.com/boutproject/hypnotoad/pull/116.~~ hypnotoad>=0.4.3.

Similar functionality to https://github.com/boutproject/boutdata/pull/56, but interpolates in radial/parallel directions rather than R/Z. Using radial/parallel may be an advantage when interpolating 3d restart files.

Todo:

  • [ ] Unit test all functionality of utility functions _update_metadata_increased_x_resolution() and _update_metadata_increased_y_resolution().
  • [ ] Unit test _make_1d_xcoord().
  • [ ] Tests for interpolate_radial(). These could probably follow the pattern of those already existing for interpolate_parallel.
  • [ ] Tests for interpolate_to_new_grid().
  • [x] Option to do radial interpolation in field-aligned coordinates. Probably only suitable if most of the turbulence is around the outboard midplane, but may result in a smaller initial transient when restarting on the new grid due to better field-alignment of the perturbations.
  • [ ] Interpolation in the toroidal direction.

johnomotani avatar Dec 24 '21 23:12 johnomotani

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-12-27 18:43:54 UTC

pep8speaks avatar Dec 24 '21 23:12 pep8speaks

Codecov Report

Merging #231 (7beece4) into master (212b407) will decrease coverage by 4.20%. The diff coverage is 23.67%.

:mega: 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     #231      +/-   ##
==========================================
- Coverage   68.94%   64.75%   -4.20%     
==========================================
  Files          15       16       +1     
  Lines        3214     3447     +233     
  Branches      792      856      +64     
==========================================
+ Hits         2216     2232      +16     
- Misses        734      944     +210     
- Partials      264      271       +7     
Impacted Files Coverage Δ
xbout/boutdataset.py 66.66% <3.79%> (-10.07%) :arrow_down:
xbout/boutdataarray.py 59.79% <25.00%> (-18.57%) :arrow_down:
xbout/utils.py 77.54% <43.47%> (-4.66%) :arrow_down:
xbout/bout_info.py 100.00% <100.00%> (ø)
xbout/geometries.py 69.63% <100.00%> (-0.32%) :arrow_down:
xbout/region.py 83.59% <100.00%> (+0.03%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Dec 25 '21 00:12 codecov-commenter