Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 55 additions & 16 deletions lib/ClimaCorePlots/src/ClimaCorePlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import ClimaCore:
Quadratures,
Topologies,
Spaces,
Utilities
Utilities,
Remapping

using StaticArrays


RecipesBase.@recipe function f(
field::Fields.SpectralElementField1D;
interpolate = 10,
Expand Down Expand Up @@ -492,26 +494,63 @@ end
RecipesBase.@recipe function f(
field::Fields.CubedSphereSpectralElementField2D;
interpolate = 10,
remap_to_latlon = false,
nlat = 180,
nlon = 180,
)
@assert interpolate ≥ 1 "number of element quadrature points for uniform interpolation must be ≥ 1"
FT = eltype(field)

unfolded_panels = _unfolded_pannel_matrix(field, interpolate)
if remap_to_latlon

# construct the title for info about the field space
space = axes(field)
nelem = Topologies.nlocalelems(Spaces.topology(space))
quad_from = Spaces.quadrature_style(space)
dof_in = Quadratures.degrees_of_freedom(quad_from)
quad_from_name = Base.typename(typeof(quad_from)).name
Δh_scale = Spaces.node_horizontal_length_scale(Spaces.axes(field))
planet_radius = FT(6.378e6)
npts = Int(round(2π * planet_radius / Δh_scale))
npts = ifelse(rem(npts, 2) == 0, npts, npts + 1)
npts *= 4
longpts = range(FT(-180), FT(180.0), Int(nlon))
latpts = range(FT(-90), FT(90), Int(nlat))
hcoords = [
Geometry.LatLongPoint(lat, long) for long in longpts, lat in latpts
]

# set the plot attributes
seriestype := :heatmap
title --> "$nelem $quad_from_name{$dof_in} element space"
xguide --> "panel x1"
yguide --> "panel x2"
seriescolor --> :balance
# @Main.infiltrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# @Main.infiltrate


(unfolded_panels)
# hcoords = Remapping.default_target_hcoords(axes(field))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# hcoords = Remapping.default_target_hcoords(axes(field))


remapper = Remapping.Remapper(axes(field), hcoords)
remapped = Array(Remapping.interpolate(remapper, field))

# Set plot attributes
seriestype := :heatmap
xguide --> "Longitude"
yguide --> "Latitude"
seriescolor --> :balance
title --> "Lat-Lon Remapped Field ($nlat × $nlon)"

return (longpts, latpts, transpose(remapped))
Copy link
Member

@akshaysridhar akshaysridhar Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please include an example of the output from your suggested changes and differentiate it from the default "unfolded panel" output in the docs for ClimaCorePlots (I realise the current doc section for Libraries > ClimaCorePlots.jl is empty..) . Thanks @ray-chew, this way we can visually inspect the different options available here. It seems the current tests https://github.com/CliMA/ClimaCore.jl/blob/main/lib/ClimaCorePlots/test/runtests.jl rely heavily on png generation with isfile.


else
# Original panel plotting branch
@assert interpolate ≥ 1 "number of element quadrature points for uniform interpolation must be ≥ 1"

unfolded_panels = _unfolded_pannel_matrix(field, interpolate)

# construct the title for info about the field space
space = axes(field)
nelem = Topologies.nlocalelems(Spaces.topology(space))
quad_from = Spaces.quadrature_style(space)
dof_in = Quadratures.degrees_of_freedom(quad_from)
quad_from_name = Base.typename(typeof(quad_from)).name

# set the plot attributes
seriestype := :heatmap
title --> "$nelem $quad_from_name{$dof_in} element space"
xguide --> "panel x1"
yguide --> "panel x2"
seriescolor --> :balance

(unfolded_panels)
end
end

RecipesBase.@recipe function f(
Expand Down
Loading