-
Notifications
You must be signed in to change notification settings - Fork 42
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
Cubed-sphere Jacobian and wind interpolation #99
Cubed-sphere Jacobian and wind interpolation #99
Conversation
…sphere_interpolation
Please integrate the develop branch as PR #98 is merged in now. |
Done! |
* develop: Quad2D: Added fused multiply-add to discriminant calculation (ecmwf#102) FieldSet::has() to replace FieldSet::has_field() Config::json() function Create Array using ArraySpec only (containing datatype) Add Datatype to ArraySpec Cosmetic changes to UnstructuredBilinearLonLat Change Quad2D's PointXY arguments to Point2 Make GridToolsArray backend work with mixed indexing types
Codecov Report
@@ Coverage Diff @@
## develop #99 +/- ##
===========================================
+ Coverage 77.93% 78.02% +0.08%
===========================================
Files 781 781
Lines 53503 53726 +223
===========================================
+ Hits 41696 41918 +222
- Misses 11807 11808 +1
Continue to review full report at Codecov.
|
@odlomax Again a very good contribution and high quality code! |
@wdeconinck Thank you for your kind words, you've been a great help! Squash and merge away! 😀 |
@@ -82,7 +82,7 @@ class Jacobian : public std::array<std::array<double, 2>, 2> { | |||
return Jacobian{(*this)[1][1], -(*this)[0][1], -(*this)[1][0], (*this)[0][0]} * (1. / determinant()); | |||
} | |||
|
|||
Jacobian transpose() const { return Jacobian{(*this)[1][1], (*this)[0][1], (*this)[1][0], (*this)[0][0]}; } | |||
Jacobian transpose() const { return Jacobian{(*this)[0][0], (*this)[1][0], (*this)[0][1], (*this)[1][1]}; } |
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.
😱
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.
Yes, that was a bit of a head-scratcher! 😂
// wind transform. Then the transform is applied to the entire field, | ||
// *including* the halo. | ||
|
||
sourceFunctionspace.parallel_for(util::Config("include_halo", true), [&](idx_t idx, idx_t t, idx_t i, idx_t j) { |
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.
very nice!
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.
According @MarekWlasak I'm obsessed with std::tie
. I think he's right! 😂
Squash-merged in develop with commit 1b08c23 |
* release/0.29.0: (49 commits) Version 0.29.0 GitHub Actions CI: enable OpenMP for C/C++ ATLAS-355 Workaround macOS OpenMP problems with 'omp task' ATLAS-354 bamboo using proj/8.2.1 ATLAS-354 Introduce FindPROJ.cmake for proj installations based on autotools ATLAS-354 Compatibility with proj >= 8 Add missing include <string> Restore compatibility with eckit < 1.18.5 Support cubed-sphere wind interpolation (#99) Fix Jacobian::transpose() introduced in PR #93 GitHub actions CI: reduce available MPI_SLOTS for macOS builds to 4 Quad2D: Added fused multiply-add to discriminant calculation (#102) FieldSet::has() to replace FieldSet::has_field() Config::json() function Create Array using ArraySpec only (containing datatype) Add Datatype to ArraySpec Cosmetic changes to UnstructuredBilinearLonLat Change Quad2D's PointXY arguments to Point2 Make GridToolsArray backend work with mixed indexing types Apply clang-format ...
This PR implements the
Projection::jacobian
method for the equiangular cubed-sphere. There are three versions of this function:projection::Jacobian Proection::jacobian(const PointXY& xy)
This returns the Jacobian ∂(x, y) / ∂(lon, lat).projection::JacobianProection::jacobian(const PointXY& xy, idx_t t)
This returns the Jacobian ∂(x, y) / ∂(lon, lat) for tile t. This is needed to perform transforms on halo points.projection::Jacobian Proection::alphabetaJacobian(const Point2& alphabeta, idx_t t)
This returns the Jacobian ∂(alpha, beta) / ∂(lon, lat) for tile t. As above, but rotated into the (alpha, beta) coordinate system.Two tests have been added:
tests/projection/test_cubedsphere_projection.cc
This makes sure that xy + J(x, y) * h(lon, lat) converges quadratically as the step size h(lon, lat) tends to zero.
(added to
tests/interpolation/test_interpolation_cubedsphere.cc
). Here, the following operations are performed:alphabetaJacobian
method.The figures below show the output u and v field from the wind interpolation test.
The two figures below show the absolute interpolation error, i.e. the vector distance between (u_interp, v_interp) and (u_analytic, v_analytic). The colour scale is logarithmic.
error_field_0
shows the error when we naively interpolate u and v as if they were scalar fields. Note the excessive errorat the poles (visible near the top of the sphere) where there is a discontinuity in the direction of the (lon, lat) unit vectors.
error_field_1
shows the error when we perform the above wind transform. Note the absence of the polar error in the previous field.