Skip to content

Commit 902d966

Browse files
author
Jordan Benjamin
committed
bump to new types for isbits ness
1 parent df81272 commit 902d966

File tree

8 files changed

+459
-171
lines changed

8 files changed

+459
-171
lines changed

Manifest.toml

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.10.8"
3+
julia_version = "1.11.5"
44
manifest_format = "2.0"
5-
project_hash = "c9f9a501fdd4adeb40c0abd0ff719a6e7631273d"
5+
project_hash = "7fce62b4bd3751178f467495074d0c47dc23084d"
66

77
[[deps.Adapt]]
88
deps = ["LinearAlgebra", "Requires"]
@@ -17,10 +17,11 @@ weakdeps = ["SparseArrays", "StaticArrays"]
1717

1818
[[deps.ArgTools]]
1919
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
20-
version = "1.1.1"
20+
version = "1.1.2"
2121

2222
[[deps.Artifacts]]
2323
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
24+
version = "1.11.0"
2425

2526
[[deps.Atomix]]
2627
deps = ["UnsafeAtomics"]
@@ -42,6 +43,7 @@ version = "1.1.2"
4243

4344
[[deps.Base64]]
4445
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
46+
version = "1.11.0"
4547

4648
[[deps.Bzip2_jll]]
4749
deps = ["Artifacts", "JLLWrappers", "Libdl"]
@@ -91,6 +93,7 @@ version = "0.18.22"
9193
[[deps.Dates]]
9294
deps = ["Printf"]
9395
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
96+
version = "1.11.0"
9497

9598
[[deps.DelimitedFiles]]
9699
deps = ["Mmap"]
@@ -134,6 +137,7 @@ version = "1.6.0"
134137

135138
[[deps.FileWatching]]
136139
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
140+
version = "1.11.0"
137141

138142
[[deps.ForwardDiff]]
139143
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"]
@@ -160,6 +164,7 @@ version = "2.12.2+0"
160164
[[deps.InteractiveUtils]]
161165
deps = ["Markdown"]
162166
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
167+
version = "1.11.0"
163168

164169
[[deps.IrrationalConstants]]
165170
git-tree-sha1 = "b2d91fe939cae05960e760110b328288867b5758"
@@ -197,6 +202,7 @@ version = "18.1.8+0"
197202
[[deps.LazyArtifacts]]
198203
deps = ["Artifacts", "Pkg"]
199204
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
205+
version = "1.11.0"
200206

201207
[[deps.LibCURL]]
202208
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
@@ -206,16 +212,17 @@ version = "0.6.4"
206212
[[deps.LibCURL_jll]]
207213
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
208214
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
209-
version = "8.4.0+0"
215+
version = "8.6.0+0"
210216

211217
[[deps.LibGit2]]
212218
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
213219
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
220+
version = "1.11.0"
214221

215222
[[deps.LibGit2_jll]]
216223
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
217224
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
218-
version = "1.6.4+0"
225+
version = "1.7.2+0"
219226

220227
[[deps.LibSSH2_jll]]
221228
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
@@ -224,6 +231,7 @@ version = "1.11.0+1"
224231

225232
[[deps.Libdl]]
226233
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
234+
version = "1.11.0"
227235

228236
[[deps.Libiconv_jll]]
229237
deps = ["Artifacts", "JLLWrappers", "Libdl"]
@@ -234,6 +242,7 @@ version = "1.18.0+0"
234242
[[deps.LinearAlgebra]]
235243
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
236244
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
245+
version = "1.11.0"
237246

238247
[[deps.LogExpFunctions]]
239248
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
@@ -253,6 +262,7 @@ version = "0.3.29"
253262

254263
[[deps.Logging]]
255264
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
265+
version = "1.11.0"
256266

257267
[[deps.MPICH_jll]]
258268
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"]
@@ -280,11 +290,12 @@ version = "0.5.16"
280290
[[deps.Markdown]]
281291
deps = ["Base64"]
282292
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
293+
version = "1.11.0"
283294

284295
[[deps.MbedTLS_jll]]
285296
deps = ["Artifacts", "Libdl"]
286297
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
287-
version = "2.28.2+1"
298+
version = "2.28.6+0"
288299

289300
[[deps.MicrosoftMPI_jll]]
290301
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -294,10 +305,11 @@ version = "10.1.4+3"
294305

295306
[[deps.Mmap]]
296307
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
308+
version = "1.11.0"
297309

298310
[[deps.MozillaCACerts_jll]]
299311
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
300-
version = "2023.1.10"
312+
version = "2023.12.12"
301313

302314
[[deps.NCDatasets]]
303315
deps = ["CFTime", "CommonDataModel", "DataStructures", "Dates", "NetCDF_jll", "NetworkOptions", "Printf"]
@@ -330,12 +342,12 @@ version = "0.4.1"
330342
[[deps.OpenBLAS_jll]]
331343
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
332344
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
333-
version = "0.3.23+4"
345+
version = "0.3.27+1"
334346

335347
[[deps.OpenLibm_jll]]
336348
deps = ["Artifacts", "Libdl"]
337349
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
338-
version = "0.8.1+2"
350+
version = "0.8.5+0"
339351

340352
[[deps.OpenMPI_jll]]
341353
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]
@@ -372,9 +384,15 @@ version = "0.2.1"
372384
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
373385

374386
[[deps.Pkg]]
375-
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
387+
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"]
376388
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
377-
version = "1.10.0"
389+
version = "1.11.0"
390+
391+
[deps.Pkg.extensions]
392+
REPLExt = "REPL"
393+
394+
[deps.Pkg.weakdeps]
395+
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
378396

379397
[[deps.PrecompileTools]]
380398
deps = ["Preferences"]
@@ -391,14 +409,12 @@ version = "1.5.0"
391409
[[deps.Printf]]
392410
deps = ["Unicode"]
393411
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
394-
395-
[[deps.REPL]]
396-
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
397-
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
412+
version = "1.11.0"
398413

399414
[[deps.Random]]
400415
deps = ["SHA"]
401416
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
417+
version = "1.11.0"
402418

403419
[[deps.Requires]]
404420
deps = ["UUIDs"]
@@ -418,14 +434,12 @@ version = "0.7.0"
418434

419435
[[deps.Serialization]]
420436
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
421-
422-
[[deps.Sockets]]
423-
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
437+
version = "1.11.0"
424438

425439
[[deps.SparseArrays]]
426440
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
427441
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
428-
version = "1.10.0"
442+
version = "1.11.0"
429443

430444
[[deps.SpecialFunctions]]
431445
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
@@ -459,14 +473,19 @@ uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
459473
version = "1.4.4"
460474

461475
[[deps.Statistics]]
462-
deps = ["LinearAlgebra", "SparseArrays"]
476+
deps = ["LinearAlgebra"]
477+
git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0"
463478
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
464-
version = "1.10.0"
479+
version = "1.11.1"
480+
weakdeps = ["SparseArrays"]
481+
482+
[deps.Statistics.extensions]
483+
SparseArraysExt = ["SparseArrays"]
465484

466485
[[deps.SuiteSparse_jll]]
467486
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
468487
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
469-
version = "7.2.1+1"
488+
version = "7.7.0+0"
470489

471490
[[deps.TOML]]
472491
deps = ["Dates"]
@@ -493,9 +512,11 @@ version = "0.11.7"
493512
[[deps.UUIDs]]
494513
deps = ["Random", "SHA"]
495514
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
515+
version = "1.11.0"
496516

497517
[[deps.Unicode]]
498518
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
519+
version = "1.11.0"
499520

500521
[[deps.UnsafeAtomics]]
501522
git-tree-sha1 = "b13c4edda90890e5b04ba24e20a310fbe6f249ff"
@@ -545,7 +566,7 @@ version = "5.11.0+0"
545566
[[deps.nghttp2_jll]]
546567
deps = ["Artifacts", "Libdl"]
547568
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
548-
version = "1.52.0+1"
569+
version = "1.59.0+0"
549570

550571
[[deps.p7zip_jll]]
551572
deps = ["Artifacts", "Libdl"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SOCRATESSingleColumnForcings"
22
uuid = "efca6b66-9b98-11ed-1a32-7b7cdccd517a"
33
authors = ["Jordan Benjamin"]
4-
version = "0.13.9"
4+
version = "0.13.10"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/SOCRATESSingleColumnForcings.jl

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,37 @@ const TDTS = TD.ThermodynamicState
3333
# The other four cases have clouds extending through deeper boundary layers; they are run on a 320-level vertical grid.
3434
const grid_heights = Dict(1 => 320, 9 => 320, 10 => 320, 11 => 320, 12 => 192, 13 => 192)
3535

36+
# Singleton BC types
37+
abstract type AbstractBoundaryCondition end
38+
struct ExtrapolateBoundaryCondition <: AbstractBoundaryCondition end
39+
struct ErrorBoundaryCondition <: AbstractBoundaryCondition end
40+
struct NearestBoundaryCondition <: AbstractBoundaryCondition end
41+
42+
const ValidBoundaryConditions = Union{ExtrapolateBoundaryCondition, ErrorBoundaryCondition, NearestBoundaryCondition}
43+
44+
# string for instances
45+
bc_string(::ExtrapolateBoundaryCondition) = "extrapolate"
46+
bc_string(::ErrorBoundaryCondition) = "error"
47+
bc_string(::NearestBoundaryCondition) = "nearest"
48+
49+
# --- create_bc chain ---
50+
51+
create_bc(x::AbstractBoundaryCondition) = x # pass through
52+
create_bc(s::String) = create_bc(Symbol(lowercase(strip(s))))
53+
create_bc(s::Symbol) = create_bc(Val(s))
54+
55+
# valid BCs
56+
create_bc(::Val{:extrapolate}) = ExtrapolateBoundaryCondition()
57+
create_bc(::Val{:error}) = ErrorBoundaryCondition()
58+
create_bc(::Val{:nearest}) = NearestBoundaryCondition()
59+
60+
# fallback (dynamic, no extra functions)
61+
62+
create_bc(::Val{s}) where {s} = error(
63+
"Invalid boundary condition symbol: $s. Valid options are " *
64+
repr((T -> string(T())).(Base.uniontypes(ValidBoundaryConditions))),
65+
)
66+
3667

3768
abstract type AbstractInterpolationMethod end
3869
abstract type AbstractPCHIPInterpolationMethod <: AbstractInterpolationMethod end
@@ -44,9 +75,11 @@ end
4475
struct DierckxSpline1DInterpolationMethod <: AbstractInterpolationMethod
4576
k::Int
4677
end
47-
struct FastLinear1DInterpolationMethod <: AbstractInterpolationMethod end
78+
struct FastLinear1DInterpolationMethod <: AbstractInterpolationMethod end # Consider repalcing one day with Interpolations.jl - That has Linear() NoInterp() and Throw() BCs... and can hold SVectors and be isbits etc. Notably, however, integration is missing natively so we'd have to implement it, but `Interpolations.gradient()` is provided for the derivative
4879
const FastLinear1DInterpolation = FastLinear1DInterpolationMethod()
4980

81+
# struct InterpolaionsJLMethod <: AbstractInterpolationMethod end # Has so many methods
82+
5083

5184
create_svector(x::AbstractVector) = StaticArrays.SVector{length(x)}(x) # create an SVector from an array, this is the same as SVector(x...) but faster [still slow bc length(x) is looked up at compile time]
5285
create_svector(x::NTuple{N, FT}) where {FT, N} = StaticArrays.SVector{N, FT}(x) # create an SVector from a tuple, this is the same as SVector(x...) but faster [still slow bc length(x) is looked up at compile time]

src/get_LES_reference_profiles.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ function get_LES_reference_profiles(
5959
ps = LES_data["Ps"][1] * 100.0 # surface pressure
6060
ρ = NC.nomissing(LES_data["RHO"][:, 1]) # use t=0 as our reference
6161
# extrapolate to get ρs since that's not given (not calculating from first principles probably is safer too w/ uncertainty in q)
62-
ρs = interpolate_1d(ps, reverse(p), reverse(ρ), FastLinear1DInterpolation, bc = "extrapolate") # switch to increasing for interpolation
62+
ρs = interpolate_1d(ps, reverse(p), reverse(ρ), FastLinear1DInterpolation, bc = ExtrapolateBoundaryCondition()) # switch to increasing for interpolation
6363

6464
# Consider switching to SVector but probably not worth it for now since the high res grids can have 320 levels
6565
p = [ps; p]
6666
ρ = [ρs; ρ]
6767
z = [0; z]
6868

69-
p_c = interpolate_1d(new_zc, z, p, FastLinear1DInterpolation; bc = "nearest")
70-
p_f = interpolate_1d(new_zf, z, p, FastLinear1DInterpolation; bc = "nearest")
71-
ρ_c = interpolate_1d(new_zc, z, ρ, FastLinear1DInterpolation; bc = "nearest")
72-
ρ_f = interpolate_1d(new_zf, z, ρ, FastLinear1DInterpolation; bc = "nearest")
69+
p_c = interpolate_1d(new_zc, z, p, FastLinear1DInterpolation; bc = NearestBoundaryCondition())
70+
p_f = interpolate_1d(new_zf, z, p, FastLinear1DInterpolation; bc = NearestBoundaryCondition())
71+
ρ_c = interpolate_1d(new_zc, z, ρ, FastLinear1DInterpolation; bc = NearestBoundaryCondition())
72+
ρ_f = interpolate_1d(new_zf, z, ρ, FastLinear1DInterpolation; bc = NearestBoundaryCondition())
7373

7474
return NamedTuple{return_values}((p_c, p_f, ρ_c, ρ_f))
7575

src/helper_functions.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function lev_to_z_from_LES_output_column(
128128
# Load pressure from the thermodynamic state
129129
p_in = TD.air_pressure.(thermo_params, tsz)
130130
# Interpolate z from the LES output to the pressure levels of the thermodynamic state
131-
z_out = interpolate_1d(p_in, lesp, lesz, interp_method; bc = "error")
131+
z_out = interpolate_1d(p_in, lesp, lesz, interp_method; bc = ErrorBoundaryCondition())
132132
return z_out
133133
end
134134

@@ -196,8 +196,11 @@ function lev_to_z_from_LES_output(
196196

197197
# interpolate les output data to input times (instead of just choosing the `closest` hour like we did before... (need to apply by row)
198198
# i think you need to map this bc of the splines... but there's probably some way...
199-
p_LES =
200-
mapslices(x -> interpolate_1d(t_in, t_les, x, FastLinear1DInterpolation; bc = "nearest"), p_LES; dims = 2) # apply to each row, use nearest interp but outside les time bounds is bogus
199+
p_LES = mapslices(
200+
x -> interpolate_1d(t_in, t_les, x, FastLinear1DInterpolation; bc = NearestBoundaryCondition()),
201+
p_LES;
202+
dims = 2,
203+
) # apply to each row, use nearest interp but outside les time bounds is bogus
201204

202205
tsz = ts
203206

@@ -643,9 +646,9 @@ function interp_along_dim(
643646
f_enhancement_factor = get(interp_kwargs, :f_enhancement_factor, 1) # default to 1.0
644647
f_p_enhancement_factor = get(interp_kwargs, :f_p_enhancement_factor, 1) # default to 1.0
645648
if conservative_interp
646-
bc = get(interp_kwargs, :bc, "extrapolate") # default to extrapolate
649+
bc::AbstractBoundaryCondition = create_bc(get(interp_kwargs, :bc, ExtrapolateBoundaryCondition())) # default to extrapolate
647650
else
648-
bc = get(interp_kwargs, :bc, "error") # default to error
651+
bc = create_bc(get(interp_kwargs, :bc, ErrorBoundaryCondition())) # default to error
649652
end
650653
k = get(interp_kwargs, :k, 1) # default to 3
651654

@@ -1242,7 +1245,7 @@ function calc_qg_extrapolate_pq(pg, p, q; interp_method = FastLinear1DInterpolat
12421245
# qg = (1 / molmass_ratio) .* pvg ./ (pg .- pvg) #Total water mixing ratio at surface , assuming saturation [ add source ]
12431246

12441247
# not sure if this should be linear in p or logarithmic (linear in z), gonna do linear in p
1245-
qg = interpolate_1d(pg, p, q, interp_method; bc = "extrapolate") # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
1248+
qg = interpolate_1d(pg, p, q, interp_method; bc = ExtrapolateBoundaryCondition()) # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
12461249
# qg = interpolate_1d(log.(pg), log.(p), q, interp_method; bc="extrapolate") # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
12471250

12481251
return qg

0 commit comments

Comments
 (0)