Skip to content

Commit

Permalink
Fix ECCO metadata_url and urls that both adding a trailing / (#318
Browse files Browse the repository at this point in the history
)

* don't add / twice

* add missing deps + compats

* temporarily only leave the ECCO2 example on

* GLMakie -> CairoMakie; BuoyancyModels -> BuoyancyFormulations

* update

* code alignment

* add docs/Manifest.toml

* Update Project.toml

trying out to see if scalar operations came with v0.95.7 and changes introduced by CliMA/Oceananigans.jl#4037

* Update Project.toml

* homogenize compats
  • Loading branch information
navidcy authored Jan 20, 2025
1 parent 3b252db commit 25e2881
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/Manifest.toml
docs/Manifest.toml

# Files generated by invoking Julia with --code-coverage
*.jl.cov
Expand Down
6 changes: 4 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Oceananigans = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
OrthogonalSphericalShellGrids = "c2be9673-fb75-4747-82dc-aa2bb9f4aed0"
SeawaterPolynomials = "d496a93d-167e-4197-9f49-d3af4ff8fe40"

[compat]
CairoMakie = "0.10.12, 0.11, 0.12"
DataDeps = "0.7"
Documenter = "1"
Oceananigans = "0.95.2 - 0.99"
OrthogonalSphericalShellGrids = "0.2.0"
Oceananigans = "0.95.7 - 0.99"
OrthogonalSphericalShellGrids = "0.2.1"
SeawaterPolynomials = "0.3.4"
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
const OUTPUT_DIR = joinpath(@__DIR__, "src/literated")

to_be_literated = [
"ecco_inspect_temperature_salinity.jl",
"generate_bathymetry.jl",
"generate_surface_fluxes.jl",
"single_column_os_papa_simulation.jl",
Expand Down Expand Up @@ -40,6 +41,7 @@ pages = [
"Home" => "index.md",

"Examples" => [
"Inspect ECCO2 data" => "literated/ecco_inspect_temperature_salinity.md",
"Generate bathymetry" => "literated/generate_bathymetry.md",
"Surface fluxes" => "literated/generate_surface_fluxes.md",
"Single-column simulation" => "literated/single_column_os_papa_simulation.md",
Expand Down
7 changes: 3 additions & 4 deletions examples/ecco_inspect_temperature_salinity.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Oceananigans
using Oceananigans.ImmersedBoundaries: mask_immersed_field!

using GLMakie
using CairoMakie
using Printf
using ClimaOcean
using ClimaOcean.DataWrangling.ECCO: ECCO_field, ECCOFieldTimeSeries
Expand Down Expand Up @@ -32,7 +32,7 @@ T = CenterField(grid)
S = CenterField(grid)

using SeawaterPolynomials: TEOS10EquationOfState
using Oceananigans.BuoyancyModels: buoyancy
using Oceananigans.BuoyancyFormulations: buoyancy

equation_of_state = TEOS10EquationOfState()
sb = SeawaterBuoyancy(; equation_of_state)
Expand Down Expand Up @@ -83,5 +83,4 @@ Colorbar(fig[1, 2], hmT, label="Temperature (ᵒC)")
Colorbar(fig[2, 2], hmS, label="Salinity (g kg⁻¹)")
Colorbar(fig[3, 2], hmb, label="Buoyancy difference (m s⁻²)")

display(fig)

fig
8 changes: 5 additions & 3 deletions examples/ecco_mixed_layer_depth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using ClimaOcean
using ClimaOcean.Diagnostics: MixedLayerDepthField
using ClimaOcean.DataWrangling.ECCO: ECCO_field, ECCOFieldTimeSeries
using Oceananigans
using GLMakie
using CairoMakie
using Printf
using CFTime
using Dates
Expand All @@ -23,7 +23,7 @@ grid = LatitudeLongitudeGrid(arch; z,
latitude = (-80, 80),
longitude = (0, 360))

bottom_height = regrid_bathymetry(grid;
bottom_height = regrid_bathymetry(grid;
minimum_depth = 10,
interpolation_passes = 5,
major_basins = 1)
Expand Down Expand Up @@ -73,7 +73,9 @@ Label(fig[1, 1], str, tellwidth=false)
hn = @lift ht[$n]
hm = heatmap!(axh, hn, colorrange=(0, 500), colormap=:magma, nan_color=:lightgray)
Colorbar(fig[2, 2], hm, label="Mixed layer depth (m)")
display(fig)
fig

# And record a movie

record(fig, "ecco_mld.mp4", 1:Nt-1, framerate=4) do nn
@info "Drawing frame $nn of $Nt..."
Expand Down
28 changes: 20 additions & 8 deletions src/DataWrangling/ECCO/ECCO_metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,36 @@ ECCO_location = Dict(
)

# URLs for the ECCO datasets specific to each version
urls(::ECCOMetadata{<:Any, <:ECCO2Monthly}) = "https://ecco.jpl.nasa.gov/drive/files/ECCO2/cube92_latlon_quart_90S90N/monthly/"
urls(::ECCOMetadata{<:Any, <:ECCO2Daily}) = "https://ecco.jpl.nasa.gov/drive/files/ECCO2/cube92_latlon_quart_90S90N/daily/"
urls(::ECCOMetadata{<:Any, <:ECCO4Monthly}) = "https://ecco.jpl.nasa.gov/drive/files/Version4/Release4/interp_monthly/"
urls(::ECCOMetadata{<:Any, <:ECCO2Monthly}) = "https://ecco.jpl.nasa.gov/drive/files/ECCO2/cube92_latlon_quart_90S90N/monthly"
urls(::ECCOMetadata{<:Any, <:ECCO2Daily}) = "https://ecco.jpl.nasa.gov/drive/files/ECCO2/cube92_latlon_quart_90S90N/daily"
urls(::ECCOMetadata{<:Any, <:ECCO4Monthly}) = "https://ecco.jpl.nasa.gov/drive/files/Version4/Release4/interp_monthly"

"""
download_dataset(metadata::ECCOMetadata; url = urls(metadata))
Download the dataset specified by `ECCOMetadata`. If `ECCOMetadata.dates` is a single date,
Download the dataset specified by `ECCOMetadata`. If `ECCOMetadata.dates` is a single date,
the dataset is downloaded directly. If `ECCOMetadata.dates` is a vector of dates, each date
is downloaded individually.
The data download requires a username and password to be provided in the `ECCO_USERNAME` and
`ECCO_PASSWORD` environment variables. This can be done by exporting the environment variables
in the shell before running the script, or by launching julia with
in the shell before running the script, or by launching julia with
```
ECCO_USERNAME=myusername ECCO_PASSWORD=mypassword julia
ECCO_USERNAME=myusername ECCO_PASSWORD=mypassword julia
```
or by invoking
```julia
julia> ENV["ECCO_USERNAME"] = "myusername"
julia> ENV["ECCO_PASSWORD"] = "mypassword"
```
within julia.
Arguments
=========
- `metadata::ECCOMetadata`: The metadata specifying the dataset to be downloaded.
Expand All @@ -223,7 +235,7 @@ function download_dataset(metadata::ECCOMetadata; url = urls(metadata))
username = get(ENV, "ECCO_USERNAME", nothing)
password = get(ENV, "ECCO_PASSWORD", nothing)
dir = metadata.dir

# Create a temporary directory to store the .netrc file
# The directory will be deleted after the download is complete
@root mktempdir(dir) do tmp
Expand Down Expand Up @@ -254,6 +266,6 @@ function download_dataset(metadata::ECCOMetadata; url = urls(metadata))
end
end
end

return nothing
end

0 comments on commit 25e2881

Please sign in to comment.