From d7597feb590f4e5b94348a85518d6d6b8f899335 Mon Sep 17 00:00:00 2001 From: kmdeck Date: Tue, 19 Nov 2024 10:09:49 -0800 Subject: [PATCH] topmodel artifact --- Artifacts.toml | 7 ++ src/Artifacts.jl | 23 +----- .../preprocess_topographic_index_simple.jl | 82 ------------------- 3 files changed, 11 insertions(+), 101 deletions(-) delete mode 100644 src/standalone/Soil/Runoff/preprocess_topographic_index_simple.jl diff --git a/Artifacts.toml b/Artifacts.toml index ec05491c27..cec3103d71 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -51,3 +51,10 @@ git-tree-sha1 = "2fc70601badf6f83dee2b84ba9c386ad041de8e2" [[fluxnet_sites.download]] sha256 = "f05b4c01b57afe9c0f59095b39cea1c0cf46b20deecd5c7afb44f474d9cd9966" url = "https://caltech.box.com/shared/static/otrr2y0rgjct7hqhmq214nb8qjsvqj5p.gz" + +[topmodel] +git-tree-sha1 = "10855ff977cc948a92c7a83915895d27650649a1" + + [[topmodel.download]] + sha256 = "03de8f42fedf3836c6792571f04b55fbaca321919ecd761b846286dc56bfa2e8" + url = "https://caltech.box.com/shared/static/bfjxp72vre6b5ncm7jqf9w8hyj4ab4yr.gz" diff --git a/src/Artifacts.jl b/src/Artifacts.jl index 285d95d19f..201bb9d1ec 100644 --- a/src/Artifacts.jl +++ b/src/Artifacts.jl @@ -164,33 +164,18 @@ end topmodel_data_path(; context = nothing) Returns the path to the file which contains the necessary information for the TOPMODEL -runoff parameterization at 2.5 degrees resolution. +runoff parameterization at 1.0 degrees resolution. -This file was created with -https://github.com/CliMA/ClimaLand.jl/blob/main/src/standalone/Soil/Runoff/preprocess_topographic_index_simple.jl - -using the data provided by +This file was created using the data provided by Marthews, T.R., Dadson, S.J., Lehner, B., Abele, S., Gedney, N. (2015). High-resolution global topographic index values. NERC Environmental Information Data Centre. (Dataset). https://doi.org/10.5285/6b0c4358-2bf3-4924-aa8f-793d468b92be This resource is available under the Open Government Licence (OGL), and contains data supplied by Natural Environment Research Council. This product, High-resolution global topographic index values, has been created with use of data from the HydroSHEDS database which is © World Wildlife Fund, Inc. (2006-2013) and has been used herein under license. The HydroSHEDS database and more information are available at http://www.hydrosheds.org. - -Eventually, the script processing this data, and this data, will be added to ClimaArtifacts. """ function topmodel_data_path(; context = nothing) - dir = joinpath(@__DIR__, "../") - topmodel_dataset = ArtifactWrapper( - dir, - "processed_topographic_index 2.5 deg", - ArtifactFile[ArtifactFile( - url = "https://caltech.box.com/shared/static/dwa7g0uzhxd50a2z3thbx3a12n0r887s.nc", - filename = "means_2.5_new.nc", - ),], - ) - path = joinpath(get_data_folder(topmodel_dataset), "means_2.5_new.nc") - return path - + dir = @clima_artifact("topmodel", context) + return joinpath(dir, "topographic_index_statistics_1.0x1.0.nc") end """ diff --git a/src/standalone/Soil/Runoff/preprocess_topographic_index_simple.jl b/src/standalone/Soil/Runoff/preprocess_topographic_index_simple.jl deleted file mode 100644 index b947411ace..0000000000 --- a/src/standalone/Soil/Runoff/preprocess_topographic_index_simple.jl +++ /dev/null @@ -1,82 +0,0 @@ -using NCDatasets -using Statistics -function main(; resolution) - - data = NCDataset( - "/Users/katherinedeck/Downloads/6b0c4358-2bf3-4924-aa8f-793d468b92be(1)/ga2.nc", - ) - lat = data["lat"][:] - lon = data["lon"][:] - - (lat_min, lat_max) = extrema(lat) - (lon_min, lon_max) = extrema(lon) - - lat_count = Int(ceil((lat_max - lat_min) / resolution)) + 1 - lon_count = Int(ceil((lon_max - lon_min) / resolution)) + 1 - - parameters = zeros((lon_count, lat_count, 4)) - - for lat_id in 1:1:lat_count - @info lat_id / lat_count - for lon_id in 1:1:lon_count - lat_indices = - Array(1:1:length(lat))[(lat .>= lat_min + resolution * (lat_id - 1)) .& (lat .< lat_min + resolution * lat_id)] - lon_indices = - Array(1:1:length(lon))[(lon .>= lon_min + resolution * (lon_id - 1)) .& (lon .< lon_min + resolution * lon_id)] - ϕ = data["Band1"][lon_indices, lat_indices][:] - present = .~(typeof.(ϕ) .<: Missing) - present_count = sum(present) - zero_count = sum(.~(typeof.(ϕ) .<: Missing) .& (ϕ .== 0)) - #present_nonzero = .~(typeof.(ϕ) .<: Missing) .& (ϕ .> 0) - if present_count / prod(size(ϕ)) > 0.5 - # Land - parameters[lon_id, lat_id, 1] = zero_count ./ present_count - parameters[lon_id, lat_id, 2] = mean(ϕ[present]) - fmax = sum(ϕ[present] .> mean(ϕ[present])) ./ sum(present) - parameters[lon_id, lat_id, 3] = fmax - parameters[lon_id, lat_id, 4] = 1.0 - else - nothing # all set to zero - end - - end - end - ds = NCDataset("means_$(resolution)_new.nc", "c") - defDim(ds, "lon", lon_count) - defDim(ds, "lat", lat_count) - ds.attrib["title"] = "Topographic Index Data" - - la = defVar(ds, "lat", Float32, ("lat",)) - la[:] = - (0.5:1:(lat_count - 0.5)) ./ lat_count .* (lat_max - lat_min) .+ lat_min - - lo = defVar(ds, "lon", Float32, ("lon",)) - lo[:] = - (0.5:1:(lon_count - 0.5)) ./ lon_count .* (lon_max - lon_min) .+ lon_min - - mean_ϕ = defVar(ds, "ϕ_mean", Float32, ("lon", "lat")) - mean_ϕ[:, :] = parameters[:, :, 2] - f0 = defVar(ds, "fraction_zero", Float32, ("lon", "lat")) - f0[:, :] = parameters[:, :, 1] - fmax = defVar(ds, "fmax", Float32, ("lon", "lat")) - fmax[:, :] = parameters[:, :, 3] - mask = defVar(ds, "landsea_mask", Float32, ("lon", "lat")) - mask[:, :] = parameters[:, :, 4] - mean_ϕ.attrib["units"] = "unitless" - f0.attrib["units"] = "unitless" - fmax.attrib["units"] = "unitless" - mask.attrib["units"] = "unitless" - la.attrib["units"] = "degrees_north" - la.attrib["standard_name"] = "latitude" - lo.attrib["standard_name"] = "longitude" - lo.attrib["units"] = "degrees_east" - mean_ϕ.attrib["comments"] = "The mean topographic index" - fmax.attrib["comments"] = "The maximum saturated fraction from TOPMODEL" - f0.attrib["comments"] = "The fraction of zero values in cell" - mask.attrib["comments"] = "1.0 if cell is > 50% land" - close(ds) -end - -if abspath(PROGRAM_FILE) == @__FILE__ - main(resolution = parse(Float64, ARGS[1])) -end