-
Notifications
You must be signed in to change notification settings - Fork 13
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
Read ECCO-Darwin field from NASA Earthdata #328
base: main
Are you sure you want to change the base?
Read ECCO-Darwin field from NASA Earthdata #328
Conversation
Nice. I see there is a lot of code duplication, I think we can avoid it by, instead of writing a new metadata type, writing a new version type that contains the additional information we need to wrangle the data. I would propose therefore to have struct ECCO4DarwinMonthly{T, D}
time_step_size :: T
reference_date :: D
end so that it is possible to define an alias const ECCO4DarwinMetadata = ECCOMetadata{<:Any, <:ECCO4DarwinMonthly} I think it would be nice to have only one |
src/DataWrangling/ECCO/ECCODarwin.jl
Outdated
data = ECCODarwinModelData( | ||
path, | ||
ECCODarwinModelMeta( | ||
replace(path,"data"=>"meta"), | ||
), | ||
ECCODarwinMeshGrid( | ||
metadata.version, | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can define a function read_ECCO_data(metadata, path)
that dispatches on the version of the metadata
and returns
shortname = short_name(metadata)
if variable_is_three_dimensional(metadata)
data = ds[shortname][:, :, :, 1]
data = reverse(data, dims=3)
else
data = ds[shortname][:, :, 1]
end
by default and
model_metadata = ECCODarwinModelMeta(replace(path, "data"=>"meta"))
mesh_grid = ECCODarwinMeshGrid(metadata.version)
data = ECCODarwinModelData(path, model_metadata, mesh_grid)
for ECCODarwin*
versions. In this way you can reuse the current ECCO_field
implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds like a plan.
src/DataWrangling/ECCO/ECCODarwin.jl
Outdated
Base.length(metadata::ECCODarwinMetadata) = length(metadata.dates) | ||
Base.size(data::ECCODarwinMetadata{<:Any, <:Any, <:ECCO270DarwinMonthly}) = (1080, 540, 50, length(data.dates)) | ||
Base.size(data::ECCODarwinMetadata{<:Any, <:Any, <:ECCO4DarwinMonthly}) = (360, 180, 50, length(data.dates)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base.length(metadata::ECCODarwinMetadata) = length(metadata.dates) | |
Base.size(data::ECCODarwinMetadata{<:Any, <:Any, <:ECCO270DarwinMonthly}) = (1080, 540, 50, length(data.dates)) | |
Base.size(data::ECCODarwinMetadata{<:Any, <:Any, <:ECCO4DarwinMonthly}) = (360, 180, 50, length(data.dates)) | |
Base.length(metadata::ECCOMetadata) = length(metadata.dates) | |
Base.size(data::ECCOMetadata{<:Any, <:Any, <:ECCO270DarwinMonthly}) = (1080, 540, 50, length(data.dates)) | |
Base.size(data::ECCOMetadata{<:Any, <:Any, <:ECCO4DarwinMonthly}) = (360, 180, 50, length(data.dates)) |
src/DataWrangling/ECCO/ECCODarwin.jl
Outdated
Read ECCODarwin metadata file and return as a NamedTuple | ||
|
||
""" | ||
function ECCODarwinModelMeta(fileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this function actually read the data or provide a path to the data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It reads a text ("meta") file that contains information about the "data" file - in particular the binary precision of the MITgcm output.
Thanks for the comments @simone-silvestri ! |
src/DataWrangling/ECCO/ECCO.jl
Outdated
@@ -2,6 +2,7 @@ module ECCO | |||
|
|||
export ECCOMetadata, ECCO_field, ECCO_mask, ECCO_immersed_grid, adjusted_ECCO_tracers, initialize! | |||
export ECCO2Monthly, ECCO4Monthly, ECCO2Daily | |||
export ECCODarwinMetadata, ECCO4DarwinMonthly, ECCO270DarwinMonthly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, "ECCO4" refers to ECCO version 4, but certainly "ECCO 270" does not refer to ECCO version 270. Do we have ideas for clearer naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear to me, at least, if LLC270 will be ECCOv5, or if it's a stop-gap for a high res run, that's not CS510 (which is what you're calling ECCO2). Also, FYI there are 5 "releases" of ECCO version 4. ECCODarwin has results on V4r4 and V4r5, but I left that out for now, and just stuck to "ECCO4".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, well the key for the metadata is to define the grid and a way to set the variables. So if the different releases occupy the same pattern, then loading data from different releases can be described through properties of the types rather than the type names; for example ECCO4Monthly(release=5)
or whatever.
We can call ECCO2 CS510 btw. As I understand it, "ECCO v2" refers to the run, whereas CS510 is the name of the grid "cubed sphere 510 points" or whatever. So the name "CS510" is less specific than "ECCO2"; there are many runs with CS510 that are not ECCO, or not on Earth at all. Similarly LLC270 is the name of the grid, right?
…aOceanBiogeochemistry` units.
…lename` function
Please try to proofread the code carefully. There are some formatting inconsistencies, like spacing missing after commas. Reading the code carefully is useful because you may also catch typos. The style is a bit inconsistent with the rest of the code. If a function is not a "constructor" (returning a type of the same name as the function), then it should use some_function(a,
b,
c) rather than some_function(a,
b,
c
) The main point is that the code will have to be proofread carefully anyways, and it's a good idea to write with good style and punctuation, same as writing a paper. |
ClimaOceanBiogeochemistry.jl
Test failing on something external:
|
I am not sure that you have an ECCO_USERNAME and ECCO_PASSWORD set up as environmental variables in your fork of the repository, which would lead to an error like this. Can you try to add them as secrets and see if the tests pass? |
Ah, I see, done! I had no idea that you could do that! |
@@ -200,7 +200,7 @@ function ECCO_field(metadata::ECCOMetadata; | |||
# ECCO4 data is on a -180, 180 longitude grid as opposed to ECCO2 data that | |||
# is on a 0, 360 longitude grid. To make the data consistent, we shift ECCO4 | |||
# data by 180 degrees in longitude | |||
if metadata.version isa ECCO4Monthly | |||
if metadata.version isa ECCO4Monthly || metadata.version isa ECCO4DarwinMonthly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be slightly cleaner to use abstract type or type union to express this. This pattern does not generalize well; this makes it more work to change how we express version
for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in if metadata.version isa Union{ECCO4Monthly, ECCO4DarwinMonthly}
?
Quick note: spotted a few issues that'll need fixing (downloading |
Also, I added my ECCO details as secrets, but the test still fails, so not sure if I did it right? |
Adding functionality and interface to initialize and force BGC
ClimaOcean
simulations using ECCO-Darwin fields