-
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
Interpolate to new grid #231
base: master
Are you sure you want to change the base?
Conversation
The new grid file should represent the same equilibrium as the original grid.
When using poloidal_distance for parallel interpolation, calculation was previously very slow due to explicit loop over x. Using apply_ufunc() instead helps.
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! 🍻 Comment last updated at 2021-12-27 18:43:54 UTC |
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 #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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Need to set values in metadata, not directly in da.
MXG and MYG are now set correctly in _open_grid(), so can apply geometry just by passing the argument to open_boutdataset() now.
When zShift is saved by BOUT++ it may have NaN in some corner boundary/guard cells. When doing FFTs of arrays, these NaNs can make the whole output NaN, even in entries that should not depend on the corner cells of zShift. To avoid this, replace the NaNs with 0 - nothing important should depend on the corner cell values, so this should not cause problems.
... in interpolate_to_new_grid().
Avoids circular dependencies when importing these lists into different files.
The attributes "cell_location", "direction_y", "direction_z", "bout_type" are written by BOUT++ for each variable, so should be preserved.
if not isinstance(new_gridfile, xr.Dataset): | ||
new_gridfile = open_boutdataset( | ||
new_gridfile, | ||
keep_xboundaries=da.metadata["keep_xboundaries"], |
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.
Hi @johnomotani. This is throwing an error on my end because da
is not defined. Seems like a simple typo and it should be self.da.metadata
instead of da.metadata
. Is that correct or did I miss something?
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.
That's correct. Maybe cleanest solution is just to move the
da = self.data
from L.724 to the top of the method, and (for consistency) replace all of the self.data
with da
.
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 insideinterpolate_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: boutproject/hypnotoad#116.hypnotoad>=0.4.3.Similar functionality to boutproject/boutdata#56, but interpolates in radial/parallel directions rather than R/Z. Using radial/parallel may be an advantage when interpolating 3d restart files.
Todo:
_update_metadata_increased_x_resolution()
and_update_metadata_increased_y_resolution()
._make_1d_xcoord()
.interpolate_radial()
. These could probably follow the pattern of those already existing for interpolate_parallel.interpolate_to_new_grid()
.