Skip to content

Commit a6ed624

Browse files
authored
Merge pull request #1279 from CliMA/js/spatial-data-pt
Enable reading spatial data to a point/column
2 parents abe6401 + 138d94f commit a6ed624

File tree

6 files changed

+83
-7
lines changed

6 files changed

+83
-7
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,10 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTime
481481
path = ".."
482482
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
483483
version = "0.17.2"
484-
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "DataFrames", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
484+
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "DataFrames", "DelimitedFiles", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
485485

486486
[deps.ClimaLand.extensions]
487+
FluxnetSimulationsExt = ["DelimitedFiles"]
487488
LandSimulationVisualizationExt = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
488489
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
489490

@@ -505,9 +506,9 @@ weakdeps = ["BenchmarkTools", "CUDA", "OrderedCollections", "PrettyTables", "Sta
505506

506507
[[deps.ClimaUtilities]]
507508
deps = ["Artifacts", "ClimaComms", "Dates"]
508-
git-tree-sha1 = "420fe76968208ac2eb2837e9e0f0974456ebec78"
509+
git-tree-sha1 = "4402148693a5096c28cb09e544ce92b049b33e41"
509510
uuid = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
510-
version = "0.1.24"
511+
version = "0.1.25"
511512

512513
[deps.ClimaUtilities.extensions]
513514
ClimaUtilitiesClimaCoreExt = "ClimaCore"

.buildkite/Manifest.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTime
478478
path = ".."
479479
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
480480
version = "0.17.2"
481-
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "DataFrames", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
481+
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "DataFrames", "DelimitedFiles", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
482482

483483
[deps.ClimaLand.extensions]
484+
FluxnetSimulationsExt = ["DelimitedFiles"]
484485
LandSimulationVisualizationExt = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
485486
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
486487

@@ -502,9 +503,9 @@ weakdeps = ["BenchmarkTools", "CUDA", "OrderedCollections", "PrettyTables", "Sta
502503

503504
[[deps.ClimaUtilities]]
504505
deps = ["Artifacts", "ClimaComms", "Dates"]
505-
git-tree-sha1 = "420fe76968208ac2eb2837e9e0f0974456ebec78"
506+
git-tree-sha1 = "4402148693a5096c28cb09e544ce92b049b33e41"
506507
uuid = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
507-
version = "0.1.24"
508+
version = "0.1.25"
508509

509510
[deps.ClimaUtilities.extensions]
510511
ClimaUtilitiesClimaCoreExt = "ClimaCore"

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaLand.jl Release Notes
33

44
main
55
-------
6+
- Use ClimaUtilities v0.1.25 to read in spatial data to a point using lat/lon PR[#1279](https://github.com/CliMA/ClimaLand.jl/pull/1279)
67
- Add data handling tools to FluxnetSimulationsExt and use throughout docs and experiments PR[#1238](https://github.com/CliMA/ClimaLand.jl/pull/1238)
78
- Add convenience constructors for CanopyModel and integrated models PR[#1255](https://github.com/CliMA/ClimaLand.jl/pull/1255)
89
- Rename LandSimulationVisualization to LandSimulationVisualizationExt; add template for FluxnetSimulationsExt PR[#1259](https://github.com/CliMA/ClimaLand.jl/pull/1259)

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ClimaCore = "0.14.23"
5252
ClimaDiagnostics = "0.2.10"
5353
ClimaParams = "0.10.2"
5454
ClimaTimeSteppers = "0.8"
55-
ClimaUtilities = "0.1.24"
55+
ClimaUtilities = "0.1.25"
5656
DataFrames = "1.4"
5757
Dates = "1"
5858
DelimitedFiles = "1.9"

src/shared_utilities/Domains.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,8 @@ If the simulation space is closer to the low resolution CLM data,
13041304
that data will be used, and vice versa. The high resolution data
13051305
takes longer to process and so using lower resolution data when it
13061306
suffices is desirable.
1307+
1308+
If the surface space is a point, `use_lowres_clm` always returns true.
13071309
"""
13081310
function use_lowres_clm(
13091311
surface_space::ClimaCore.Spaces.AbstractSpectralElementSpace,
@@ -1328,6 +1330,7 @@ function use_lowres_clm(
13281330
return abs(lowres_scale - node_scale) < abs(highres_scale - node_scale)
13291331
end
13301332

1333+
use_lowres_clm(surface_space::ClimaCore.Spaces.PointSpace) = true
13311334

13321335

13331336
export AbstractDomain

test/shared_utilities/domains.jl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import ClimaComms
22
ClimaComms.@import_required_backends
33
using ClimaCore
4+
using NCDatasets
45
using Test
6+
import ClimaUtilities.SpaceVaryingInputs: SpaceVaryingInput
57
using ClimaLand
68
using ClimaLand: Domains
79
using ClimaLand.Domains:
@@ -584,5 +586,73 @@ end
584586
)
585587
surface_space = domain.space.surface
586588
@test !ClimaLand.Domains.use_lowres_clm(surface_space)
589+
end
590+
591+
@testset "read in spatial data at a point" begin
592+
# Manually access the rooting depth from the CLM data to compare with
593+
context = ClimaComms.context()
594+
clm_artifact_path =
595+
ClimaLand.Artifacts.clm_data_folder_path(; context, lowres = true)
596+
filepath = joinpath(clm_artifact_path, "vegetation_properties_map.nc")
597+
598+
NCDataset(filepath) do ncd
599+
lats = ncd["lat"][:]
600+
longs = ncd["lon"][:]
601+
lat_ind = 2
602+
long_ind = 10
603+
lat = FT(lats[lat_ind])
604+
long = FT(longs[long_ind])
605+
606+
rooting_depth_nc = ncd["rooting_depth"][long_ind, lat_ind]
607+
608+
# Construct a Point domain at a longlat that appears in the dataset (not testing interpolation)
609+
zmin = FT(0)
610+
nelements = 10
611+
longlat = (long, lat)
612+
zlim = FT.((-1, 0))
613+
column = ClimaLand.Domains.Column(; zlim, nelements, longlat)
614+
surface_space = column.space.surface
615+
616+
# Get the rooting depth at this lat/lon using ClimaUtilities
617+
rooting_depth_pt = ClimaLand.Canopy.clm_rooting_depth(surface_space)
618+
619+
@test all(Array(parent(rooting_depth_pt)) .== FT(rooting_depth_nc))
620+
end
621+
end
587622

623+
@testset "read in spatial data at a column" begin
624+
# Manually access 3D soil parameter data to compare with
625+
context = ClimaComms.context()
626+
627+
soil_params_artifact_path =
628+
ClimaLand.Artifacts.soil_params_artifact_folder_path(; context)
629+
filepath = joinpath(
630+
soil_params_artifact_path,
631+
"residual_map_gupta_etal2020_1.0x1.0x4.nc",
632+
)
633+
634+
NCDataset(filepath) do ncd
635+
lats = ncd["lat"][:]
636+
longs = ncd["lon"][:]
637+
zs = ncd["z"][:]
638+
lat_ind = 90
639+
long_ind = 100
640+
lat = FT(lats[lat_ind])
641+
long = FT(longs[long_ind])
642+
643+
θ_r_nc = ncd["θ_r"][long_ind, lat_ind, :]
644+
645+
# Construct a Column domain at a longlat that appears in the dataset (not testing interpolation)
646+
nelements = length(zs)
647+
longlat = (long, lat)
648+
zlim = FT.((-1, 0))
649+
column = ClimaLand.Domains.Column(; zlim, nelements, longlat)
650+
subsurface_space = column.space.subsurface
651+
652+
# Get the residual water content at this lat/lon using ClimaUtilities
653+
(; θ_r) =
654+
ClimaLand.Soil.soil_vangenuchten_parameters(subsurface_space, FT)
655+
656+
@test all(Array(parent(θ_r)) .== FT.(θ_r_nc[:]))
657+
end
588658
end

0 commit comments

Comments
 (0)