-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from SpeedyWeather/mk/output
scale_coslat funcs without Geometry, moved to RingGrids
- Loading branch information
Showing
9 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# alias functions to scale the latitude of any gridded map A | ||
scale_coslat!( A::AbstractGrid) = _scale_coslat!(A,power=1) | ||
scale_coslat²!( A::AbstractGrid) = _scale_coslat!(A,power=2) | ||
scale_coslat⁻¹!(A::AbstractGrid) = _scale_coslat!(A,power=-1) | ||
scale_coslat⁻²!(A::AbstractGrid) = _scale_coslat!(A,power=-2) | ||
|
||
function _scale_coslat!(A::Grid;power=1) where {Grid<:AbstractGrid} | ||
coslat = sin.(get_colat(Grid,A.nlat_half)) # sin(colat) = cos(lat) | ||
coslat .^= power | ||
return _scale_lat!(A,coslat) | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Generic latitude scaling applied to `A` in-place with latitude-like vector `v`.""" | ||
function _scale_lat!(A::AbstractGrid{NF},v::AbstractVector) where NF | ||
@boundscheck get_nlat(A) == length(v) || throw(BoundsError) | ||
|
||
rings = eachring(A) | ||
|
||
@inbounds for (j,ring) in enumerate(rings) | ||
vj = convert(NF,v[j]) | ||
for ij in ring | ||
A[ij] *= vj | ||
end | ||
end | ||
|
||
return A | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters