Closed miniufo closed 2 months ago
Yeah I probably didn't think too hard about how to do the meridional integration with Gaussian quadrature, will look into it.
I didn't find the time yet to look into this. Ideally we should do the integration it with Gaussian quadrature, but if it's currently not correctly implemented (my bad!) then that's obviously not very helpful. I'd be happy for you to create a pull request with any integration that yields a more balanced jet. We can just add a # TODO
explaining what's still needed there, but any improvement would be appreciated. A few lines above you can see that the initial conditions are computed on a FullGaussianGrid with some given resolution, you can technically also change that if it leads to better balanced initial conditions, I'd just be reluctant if you wanted to dial up the resolution too much as it's a default that needs to be run frequently for continuous integration etc. But maybe a FullClenshawGrid
with your way is already better? Any help would be awesome!!
For context, this is how we use the quadrature weights in the transforms
the get_quadrature_weights(::Type{<:AbstractGrid}, nlat_half::Integer)
function returns the quadrature weights on one hemisphere, Eq. included, over both hemispheres their sum is 2
julia> using SpeedyWeather
julia> RingGrids.get_quadrature_weights(FullGaussianGrid, 24)
24-element Vector{Float64}:
0.0031533460523056585 # first ring j=1
0.007327553901276272
⋮
0.06446616443595003
0.06473769681268386 # just north of Equator, j = nlat_half
julia> sum(RingGrids.get_quadrature_weights(FullGaussianGrid, 24))
0.9999999999999996
julia> sum(RingGrids.get_quadrature_weights(FullClenshawGrid, 24))
1.0322910836705603 # this includes the Equator that wouldn't be doubled counted for the southern hemisphere
The Gauss-quadrature method seems to be best for definite integral from pole to pole (a reduction in meridional direction). Not so sure if it still make sense for a cumulative integration.
Yes, maybe that's an issue... from Wikipedia
So maybe that's what's missing here when doing cumsum
I can send a PR, in which the weight will be replaced by $\Delta \phi$. This is equivalent to the trapezoidal integration along the meridional direction. But the result looks better.
So far, I cannot figure out whether the cumsum
using Gaussian quadrature is appropriate. My guess is that the "best" weights cannel some error when perform the integration from pole to pole. The intermediate results from cumsum
will not have this kind of cannellation.
Following previous discussion, the initial mass and flow fields for Galewsky Jet are not in balance to each other. The
ZonalJet()
first prescibes au
-field, and then do the meridional integration $h(\phi) = \int_{90}^{\phi} f(u) d\phi'$ to get the mass fieldh
.I read some docs on Gauss-quadrature method, which approximates the integration by:
$$ h(\phi) = \int_{90}^{\phi} f(u) d\phi' \approx \sum_n f(u_i) w_i $$
The corresponding codes are:
It is a bit strange to me that the weight is
2w
rather thanw
. But after some tests (in T170 resolution), both2w
andw
won't give the balanced mass field. I tried the naive way of integration and replace2w
bydlat
as:then I get roughly the balanced mass field
h
. So I am pretty sure there is something wrong with the weight in the integration but cannot go further to check why it is wrong.The Gauss-quadrature method seems to be best for definite integral from pole to pole (a reduction in meridional direction). Not so sure if it still make sense for a cumulative integration.