-
Notifications
You must be signed in to change notification settings - Fork 22
Allow the use of CopernicusMetadata to initialize sea ice
#644
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
bad6fb1
fb34727
dee9a17
a8df621
59d3004
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -22,7 +22,8 @@ import ClimaOcean.DataWrangling: | |||
| metadata_filename, | ||||
| inpainted_metadata_path, | ||||
| reversed_vertical_axis, | ||||
| available_variables | ||||
| available_variables, | ||||
| is_three_dimensional | ||||
|
|
||||
| using Scratch | ||||
|
|
||||
|
|
@@ -129,20 +130,33 @@ end | |||
|
|
||||
| inpainted_metadata_path(metadata::CopernicusMetadata) = joinpath(metadata.dir, inpainted_metadata_filename(metadata)) | ||||
|
|
||||
| location(::CopernicusMetadata) = (Center, Center, Center) | ||||
| copernicus_location(metadata::CopernicusMetadata) = is_three_dimensional(metadata) ? (Center, Center, Center) : (Center, Center, Nothing) | ||||
|
|
||||
| location(metadata::CopernicusMetadata) = copernicus_location(metadata) | ||||
| longitude_interfaces(::CopernicusMetadata) = (0, 360) | ||||
| latitude_interfaces(::CopernicusMetadata) = (-80, 90) | ||||
|
|
||||
| is_three_dimensional(metadata::CopernicusMetadata) = | ||||
| metadata.name == :temperature || | ||||
| metadata.name == :salinity || | ||||
| metadata.name == :u_velocity || | ||||
| metadata.name == :v_velocity | ||||
|
Comment on lines
+137
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should blacklist the 2D variables rather than whitelisting 3D variables, since most variables are 3D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I was trying to follow the design pattern here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can achieve this by using a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for example: is_three_dimensional(metadata::CopernicusMetadata) =
!(metadata.name == :ice_concentration ||
metadata.name == :ice_thickness) |
||||
|
|
||||
| function z_interfaces(metadata::CopernicusMetadata) | ||||
| path = metadata_path(metadata) | ||||
| ds = Dataset(path) | ||||
| zc = - reverse(ds["depth"][:]) | ||||
| close(ds) | ||||
| dz = zc[2] - zc[1] | ||||
| zf = zc[1:end-1] .+ zc[2:end] | ||||
| push!(zf, 0) | ||||
| pushfirst!(zf, zf[1] - dz) | ||||
| return zf | ||||
| # Check if this is a 2D surface variable | ||||
| if !is_three_dimensional(metadata) | ||||
| return (0, 1) | ||||
|
Comment on lines
+145
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to build a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line seems to want to take something for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, the size and the halo must be 2-tuples to use |
||||
| else | ||||
| path = metadata_path(metadata) | ||||
| ds = Dataset(path) | ||||
| zc = - reverse(ds["depth"][:]) | ||||
| close(ds) | ||||
| dz = zc[2] - zc[1] | ||||
| zf = zc[1:end-1] .+ zc[2:end] | ||||
| push!(zf, 0) | ||||
| pushfirst!(zf, zf[1] - dz) | ||||
| return zf | ||||
| end | ||||
| end | ||||
|
|
||||
| end # module Copernicus | ||||
| end # module Copernicus | ||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -83,7 +83,8 @@ function Field(metadata::Metadatum, arch=CPU(); | |||
| inpainting = default_inpainting(metadata), | ||||
| mask = nothing, | ||||
| halo = (3, 3, 3), | ||||
| cache_inpainted_data = true) | ||||
| cache_inpainted_data = true, | ||||
| fill_nans = nothing) | ||||
|
||||
| function default_inpainting(metadata) |
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, the purpose of the default_inpainting is to allow dispatch on metadata type
Uh oh!
There was an error while loading. Please reload this page.