Skip to content

Commit ca17dd2

Browse files
committed
Fix boxes with only one point
It is not possible to construct ranges when there is only one point. This leads to failures in ClimaAtmos "columns". This commit changes the default target coordinates so that we can also handle this case.
1 parent 5efb2cd commit ca17dd2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# NEWS
22

3+
v0.2.14
4+
-------
5+
6+
## Bug fixes
7+
8+
Fixed the default target coordinates for the `NetCDFWriter` for boxes with only
9+
one point in the horizontal space.
10+
311
v0.2.13
412
-------
513

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClimaDiagnostics"
22
uuid = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f"
33
authors = ["Gabriele Bozzola <gbozzola@caltech.edu>"]
4-
version = "0.2.13"
4+
version = "0.2.14"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/netcdf_writer_coordinates.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,17 @@ function target_coordinates(
318318
xmax = Geometry.tofloat(domain.interval1.coord_max)
319319
ymin = Geometry.tofloat(domain.interval2.coord_min)
320320
ymax = Geometry.tofloat(domain.interval2.coord_max)
321-
xpts = collect(range(xmin, xmax, num_points_x))
322-
ypts = collect(range(ymin, ymax, num_points_y))
321+
# Case of box with one single point
322+
if num_points_x == 1
323+
xpts = [(xmax + xmin) / 2]
324+
else
325+
xpts = collect(range(xmin, xmax, num_points_x))
326+
end
327+
if num_points_y == 1
328+
ypts = [(ymax + ymin) / 2]
329+
else
330+
ypts = collect(range(ymin, ymax, num_points_y))
331+
end
323332
return (xpts, ypts)
324333
end
325334

0 commit comments

Comments
 (0)