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 horizontal spaces and NetCDFWriter #52

Merged
merged 2 commits into from
May 22, 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
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
v0.2.0
-------

- ![][badge-💥breaking]The `NetCDFWriter` now outputs points on the vertical levels by default.
- Fix support for purely horziontal spaces in `NetCDFWriter`.

v0.2.0
-------

- ![][badge-💥breaking] The `NetCDFWriter` now outputs points on the vertical levels by default.
- ![][badge-💥breaking] `disable_vertical_interpolation` is removed in favor of `z_sampling_method`.

[badge-💥breaking]: https://img.shields.io/badge/💥BREAKING-red.svg
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClimaDiagnostics"
uuid = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f"
authors = ["Gabriele Bozzola <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
33 changes: 16 additions & 17 deletions src/netcdf_writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,26 @@ function NetCDFWriter(
horizontal_space = Spaces.horizontal_space(space)
is_horizontal_space = horizontal_space == space

if z_sampling_method isa LevelsMethod
# It is a little tricky to override the number of vertical points because we don't
# know if the vertical direction is the 2nd (as in a plane) or 3rd index (as in a
# box or sphere). To set this value, we check if we are on a plane or not

# TODO: Get the number of dimensions directly from the space
num_horiz_dimensions =
Spaces.horizontal_space(space) isa Spaces.SpectralElementSpace1D ?
1 : 2

num_vpts = Meshes.nelements(Grids.vertical_topology(space).mesh)

@warn "Disabling vertical interpolation, the provided number of points is ignored (using $num_vpts)"
num_points = Tuple([num_points[1:num_horiz_dimensions]..., num_vpts])
end

# Interpolate physical zs
if is_horizontal_space
hpts = target_coordinates(space, num_points)
vpts = []
else
if z_sampling_method isa LevelsMethod
# It is a little tricky to override the number of vertical points because we don't
# know if the vertical direction is the 2nd (as in a plane) or 3rd index (as in a
# box or sphere). To set this value, we check if we are on a plane or not

# TODO: Get the number of dimensions directly from the space
num_horiz_dimensions =
Spaces.horizontal_space(space) isa
Spaces.SpectralElementSpace1D ? 1 : 2

num_vpts = Meshes.nelements(Grids.vertical_topology(space).mesh)

@warn "Disabling vertical interpolation, the provided number of points is ignored (using $num_vpts)"
num_points =
Tuple([num_points[1:num_horiz_dimensions]..., num_vpts])
end
hpts, vpts = target_coordinates(space, num_points, z_sampling_method)
end

Expand Down
Loading