@@ -19,10 +19,12 @@ import ClimaCore:
19
19
Quadratures,
20
20
Topologies,
21
21
Spaces,
22
- Utilities
22
+ Utilities,
23
+ Remapping
23
24
24
25
using StaticArrays
25
26
27
+
26
28
RecipesBase. @recipe function f (
27
29
field:: Fields.SpectralElementField1D ;
28
30
interpolate = 10 ,
@@ -492,26 +494,63 @@ end
492
494
RecipesBase. @recipe function f (
493
495
field:: Fields.CubedSphereSpectralElementField2D ;
494
496
interpolate = 10 ,
497
+ remap_to_latlon = false ,
498
+ nlat = 180 ,
499
+ nlon = 180 ,
495
500
)
496
- @assert interpolate ≥ 1 " number of element quadrature points for uniform interpolation must be ≥ 1 "
501
+ FT = eltype (field)
497
502
498
- unfolded_panels = _unfolded_pannel_matrix (field, interpolate)
503
+ if remap_to_latlon
499
504
500
- # construct the title for info about the field space
501
- space = axes (field)
502
- nelem = Topologies. nlocalelems (Spaces. topology (space))
503
- quad_from = Spaces. quadrature_style (space)
504
- dof_in = Quadratures. degrees_of_freedom (quad_from)
505
- quad_from_name = Base. typename (typeof (quad_from)). name
505
+ Δh_scale = Spaces. node_horizontal_length_scale (Spaces. axes (field))
506
+ planet_radius = FT (6.378e6 )
507
+ npts = Int (round (2 π * planet_radius / Δh_scale))
508
+ npts = ifelse (rem (npts, 2 ) == 0 , npts, npts + 1 )
509
+ npts *= 4
510
+ longpts = range (FT (- 180 ), FT (180.0 ), Int (nlon))
511
+ latpts = range (FT (- 90 ), FT (90 ), Int (nlat))
512
+ hcoords = [
513
+ Geometry. LatLongPoint (lat, long) for long in longpts, lat in latpts
514
+ ]
506
515
507
- # set the plot attributes
508
- seriestype := :heatmap
509
- title --> " $nelem $quad_from_name {$dof_in } element space"
510
- xguide --> " panel x1"
511
- yguide --> " panel x2"
512
- seriescolor --> :balance
516
+ # @Main.infiltrate
513
517
514
- (unfolded_panels)
518
+ # hcoords = Remapping.default_target_hcoords(axes(field))
519
+
520
+ remapper = Remapping. Remapper (axes (field), hcoords)
521
+ remapped = Array (Remapping. interpolate (remapper, field))
522
+
523
+ # Set plot attributes
524
+ seriestype := :heatmap
525
+ xguide --> " Longitude"
526
+ yguide --> " Latitude"
527
+ seriescolor --> :balance
528
+ title --> " Lat-Lon Remapped Field ($nlat × $nlon )"
529
+
530
+ return (longpts, latpts, transpose (remapped))
531
+
532
+ else
533
+ # Original panel plotting branch
534
+ @assert interpolate ≥ 1 " number of element quadrature points for uniform interpolation must be ≥ 1"
535
+
536
+ unfolded_panels = _unfolded_pannel_matrix (field, interpolate)
537
+
538
+ # construct the title for info about the field space
539
+ space = axes (field)
540
+ nelem = Topologies. nlocalelems (Spaces. topology (space))
541
+ quad_from = Spaces. quadrature_style (space)
542
+ dof_in = Quadratures. degrees_of_freedom (quad_from)
543
+ quad_from_name = Base. typename (typeof (quad_from)). name
544
+
545
+ # set the plot attributes
546
+ seriestype := :heatmap
547
+ title --> " $nelem $quad_from_name {$dof_in } element space"
548
+ xguide --> " panel x1"
549
+ yguide --> " panel x2"
550
+ seriescolor --> :balance
551
+
552
+ (unfolded_panels)
553
+ end
515
554
end
516
555
517
556
RecipesBase. @recipe function f (
0 commit comments