Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of OCIM2_48L (updated NCDataset syntax) #98

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AIBECS"
uuid = "ace601d6-714c-11e9-04e5-89b7fad23838"
authors = ["Benoit Pasquier <[email protected]>"]
version = "0.13.3"
version = "0.13.4"

[deps]
Bijectors = "76274a88-744f-5084-9051-94815aaf08c4"
Expand Down
6 changes: 3 additions & 3 deletions docs/lit/tutorials/1_ideal_age.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#md # DeVries, T., & Holzer, M. (2019). Radiocarbon and helium isotope constraints on deep ocean ventilation and mantle‐³He sources. Journal of Geophysical Research: Oceans, 124, 3036–3057. doi:[10.1029/2018JC014716](https://doi.org/10.1029/2018JC014716)

using AIBECS
grd, TOCIM2 = OCIM2.load()
grd, TOCIM2_48L = OCIM2_48L.load()

#md # !!! note
#md # If it's your first time, Julia will ask you to download the OCIM2, in which case you should accept (i.e., type `y` and "return").
Expand All @@ -42,7 +42,7 @@ grd, TOCIM2 = OCIM2.load()
#nb # > If it's your first time, Julia will ask you to download the OCIM2, in which case you should accept (i.e., type `y` and "return").
#nb # > Once downloaded, AIBECS will remember where it downloaded the file and it will only load it from your laptop.

# `grd` is an `OceanGrid` object containing information about the 3D grid of the OCIM2 circulation and `TOCIM2` is the transport matrix representing advection and diffusion.
# `grd` is an `OceanGrid` object containing information about the 3D grid of the OCIM2 circulation and `TOCIM2_48L` is the transport matrix representing advection and diffusion.

# The local sources and sinks for the age take the form

Expand Down Expand Up @@ -75,7 +75,7 @@ p = IdealAgeParameters(1.0, 30.0)

# We now use the AIBECS to generate the state function $\boldsymbol{F}$ (and its Jacobian) via

F = AIBECSFunction(TOCIM2, G)
F = AIBECSFunction(TOCIM2_48L, G)

# Now that `F` and `p` are defined, we are going to solve for the steady-state.
# But first, we must create a `SteadyStateProblem` object that contains `F`, `p`, and an initial guess `x_init` for the age.
Expand Down
18 changes: 9 additions & 9 deletions src/OCIM2_48L.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,27 @@ function load()
# Create grid object from NetCDF file variables
# TODO: Add Hyrothermal He fluxes as for the OCIM2 load function
grid = Dataset(joinpath(files_path, "OCIM2_48L_base_data.nc"), "r") do ds
wet3D = ds["ocnmask"][:] .== 1
wet3D = Array(ds["ocnmask"]) .== 1
nlat, nlon, ndepth = size(wet3D)
lat_3D = ds["tlat"][:]°
lon_3D = ds["tlon"][:]°
depth_3D = ds["tz"][:]m
lat_3D = Array(ds["tlat"])°
lon_3D = Array(ds["tlon"])°
depth_3D = Array(ds["tz"])m
lat = unique(lat_3D)
lon = unique(lon_3D)
depth = unique(depth_3D)
ulat = unique(ds["ulon"][:]# ulat↔ulon in OCIM2-48L original files
ulon = unique(ds["ulat"][:]# ulat↔ulon in OCIM2-48L original files
depth_top_3D = ds["wz"][:]m
ulat = unique(Array(ds["ulon"])# ulat↔ulon in OCIM2-48L original files
ulon = unique(Array(ds["ulat"])# ulat↔ulon in OCIM2-48L original files
depth_top_3D = Array(ds["wz"])m
depth_top = unique(depth_top_3D)
δlat = 2(ulat - lat)
δlon = 2(ulon - lon)
δdepth = 2(depth - depth_top)
R = 6371.0km
δy = R * δlat ./ 360°
δy_3D = repeat(reshape(δy, (nlat,1,1)), outer=(1,nlon,ndepth))
A_3D = ds["area"][:]m^2
A_3D = Array(ds["area"])m^2
δx_3D = A_3D ./ δy_3D
volume_3D = ds["vol"]m^3
volume_3D = Array(ds["vol"])m^3
δz_3D = volume_3D ./ A_3D
A_2D = A_3D[:,:,1]
nboxes = count(wet3D)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using Plots
# For CI, make sure the downloads do not hang
ENV["DATADEPS_ALWAYS_ACCEPT"] = true

test_setup_only = [:OCIM1, :OCIM0, :OCCA]
test_setup_only = [:OCIM2_48L, :OCIM1, :OCIM0, :OCCA]
# Using `include` evaluates at global scope,
# so `Circulation` must be changed at the global scope too.
# This is why there is an `eval` in the for loop(s) below
Expand Down
Loading