Skip to content

Commit 16a7ee3

Browse files
taimoorsohailnavidcysimone-silvestri
authored
Moved ECCO downloading to beginning of code in examples/one_degree_simulation.jl (#364)
* Changed the ECCO Password/Username error to have the correct directory for the README * Made a mistake in the file path -- fixed now * Some changes idk * Added the latest version of ClimaOcean * Swapped ECCO download to front of code and added messages to show directory of download * Removed Jupyter Notebooks * Changed the file path for saving outputs back to generic * Removed Jupyter Notebooks * Remove .ipynb files from tracking * Remove .ipynb checkpoint files from tracking * Remove .gitignore from tracking * Added ECCO downloading instructions * Added gitignore and other files back * Added ECCO downloading instructions * Added everything back * code alignment + comment for #363 comment related to #363 * Removed dual conditionals, added missing_files variable * Update ECCO_metadata.jl Co-authored-by: Simone Silvestri <[email protected]> * Update .gitignore * Update .gitignore Co-authored-by: Navid C. Constantinou <[email protected]> * fix bug * fix bug --------- Co-authored-by: Navid C. Constantinou <[email protected]> Co-authored-by: Simone Silvestri <[email protected]>
1 parent 5d89c6b commit 16a7ee3

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ docs/src/literated/
3232
# Password files
3333
*.netrc
3434

35+
# Jupyter notebooks
36+
.ipynb_checkpoints/*
3537
# File generated by Pkg, the package manager, based on a corresponding Project.toml
3638
# It records a fixed state of all packages used by the project. As such, it should not be
3739
# committed for packages, but should be committed for applications that require a static

examples/one_degree_simulation.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@ using OrthogonalSphericalShellGrids
1414
using CFTime
1515
using Dates
1616
using Printf
17+
using ClimaOcean.ECCO: download_dataset
1718

1819
arch = GPU()
1920

21+
# ### Download necessary files to run the code
22+
23+
# ### ECCO files
24+
25+
dates = DateTimeProlepticGregorian(1993, 1, 1) : Month(1) : DateTimeProlepticGregorian(1994, 1, 1)
26+
temperature = ECCOMetadata(:temperature; dates, version=ECCO4Monthly(), dir="./")
27+
salinity = ECCOMetadata(:salinity; dates, version=ECCO4Monthly(), dir="./")
28+
29+
download_dataset(temperature)
30+
download_dataset(salinity)
31+
2032
# ### Grid and Bathymetry
2133

2234
Nx = 360
@@ -35,8 +47,8 @@ underlying_grid = TripolarGrid(arch;
3547

3648
bottom_height = regrid_bathymetry(underlying_grid;
3749
minimum_depth = 10,
38-
interpolation_passes = 75,
39-
major_basins = 2)
50+
interpolation_passes = 75, # 75 interpolation passes smooth the bathymetry near Florida so that the Gulf Stream is able to flow
51+
major_basins = 2)
4052

4153
# For this bathymetry at this horizontal resolution we need to manually open the Gibraltar strait.
4254
view(bottom_height, 102:103, 124, 1) .= -400
@@ -45,16 +57,11 @@ grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height); ac
4557
# ### Restoring
4658
#
4759
# We include temperature and salinity surface restoring to ECCO data.
48-
4960
restoring_rate = 1 / 10days
5061
z_below_surface = r_faces[end-1]
5162

5263
mask = LinearlyTaperedPolarMask(southern=(-80, -70), northern=(70, 90), z=(z_below_surface, 0))
5364

54-
dates = DateTimeProlepticGregorian(1993, 1, 1) : Month(1) : DateTimeProlepticGregorian(1994, 1, 1)
55-
temperature = ECCOMetadata(:temperature; dates, version=ECCO4Monthly(), dir="./")
56-
salinity = ECCOMetadata(:salinity; dates, version=ECCO4Monthly(), dir="./")
57-
5865
FT = ECCORestoring(temperature, grid; mask, rate=restoring_rate)
5966
FS = ECCORestoring(salinity, grid; mask, rate=restoring_rate)
6067
forcing = (T=FT, S=FS)
@@ -163,7 +170,6 @@ ocean.output_writers[:surface] = JLD2OutputWriter(ocean.model, outputs;
163170
with_halos = true,
164171
overwrite_existing = true,
165172
array_type = Array{Float32})
166-
overwrite_existing = true)
167173

168174
# ### Ready to run
169175

src/DataWrangling/ECCO/ECCO_metadata.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,16 @@ function download_dataset(metadata::ECCOMetadata; url = urls(metadata))
235235
# Write down the username and password in a .netrc file
236236
downloader = netrc_downloader(username, password, "ecco.jpl.nasa.gov", tmp)
237237
ntasks = Threads.nthreads()
238-
238+
239+
missing_files = false
240+
239241
asyncmap(metadata; ntasks) do metadatum # Distribute the download among tasks
240242

241243
fileurl = metadata_url(url, metadatum)
242244
filepath = metadata_path(metadatum)
243245

244-
if !isfile(filepath)
246+
if !isfile(filepath)
247+
missing_files = true
245248
instructions_msg = "\n See ClimaOcean.jl/src/DataWrangling/ECCO/README.md for instructions."
246249
if isnothing(username)
247250
msg = "Could not find the ECCO_PASSWORD environment variable. \
@@ -254,10 +257,13 @@ function download_dataset(metadata::ECCOMetadata; url = urls(metadata))
254257
and setting your ECCO_USERNAME and ECCO_PASSWORD." * instructions_msg
255258
throw(ArgumentError(msg))
256259
end
257-
260+
println("Downloading ECCO data: $(metadatum.name)")
258261
Downloads.download(fileurl, filepath; downloader, progress=download_progress)
259-
end
262+
end
260263
end
264+
if !missing_files
265+
@info "Note: ECCO $(metadata.name) data is in $(metadata.dir)."
266+
end
261267
end
262268

263269
return nothing

0 commit comments

Comments
 (0)