Skip to content

Commit

Permalink
Don't write vorticity coordinates to grid file... (#173)
Browse files Browse the repository at this point in the history
* Don't write vorticity coordinates to grid file

* Comment out grid tests with psi coord

* Overwrite grid test data so that it does not contain psi coords

* Take eta_psi, xi_psi dims out of partioning tests

* Linting
  • Loading branch information
NoraLoose authored Oct 21, 2024
1 parent 71ec8de commit 9b75724
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 386 deletions.
156 changes: 64 additions & 92 deletions docs/grid.ipynb

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions roms_tools/setup/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,16 +1128,16 @@ def _create_grid_ds(
dims=["eta_v", "xi_rho"],
attrs={"long_name": "latitude of v-points", "units": "degrees North"},
)
lon_q = xr.Variable(
data=lonq * 180 / np.pi,
dims=["eta_psi", "xi_psi"],
attrs={"long_name": "longitude of psi-points", "units": "degrees East"},
)
lat_q = xr.Variable(
data=latq * 180 / np.pi,
dims=["eta_psi", "xi_psi"],
attrs={"long_name": "latitude of psi-points", "units": "degrees North"},
)
# lon_q = xr.Variable(
# data=lonq * 180 / np.pi,
# dims=["eta_psi", "xi_psi"],
# attrs={"long_name": "longitude of psi-points", "units": "degrees East"},
# )
# lat_q = xr.Variable(
# data=latq * 180 / np.pi,
# dims=["eta_psi", "xi_psi"],
# attrs={"long_name": "latitude of psi-points", "units": "degrees North"},
# )

ds = ds.assign_coords(
{
Expand All @@ -1147,8 +1147,8 @@ def _create_grid_ds(
"lon_u": lon_u,
"lat_v": lat_v,
"lon_v": lon_v,
"lat_psi": lat_q,
"lon_psi": lon_q,
# "lat_psi": lat_q,
# "lon_psi": lon_q,
}
)

Expand Down
4 changes: 2 additions & 2 deletions roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"center_lat": 0,
"center_lon": -20,
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v lat_psi layer_depth_rho layer_depth_u layer_depth_v lon_psi",
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
"hc": 300.0,
"hmin": 5.0,
"roms_tools_version": "0.1.dev138+dirty",
"roms_tools_version": "0.1.dev157+dirty",
"rot": 0,
"size_x": 100,
"size_y": 100,
Expand Down
64 changes: 2 additions & 62 deletions roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
".zattrs": {
"center_lat": 0,
"center_lon": -20,
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v lat_psi layer_depth_rho layer_depth_u layer_depth_v lon_psi",
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
"hc": 300.0,
"hmin": 5.0,
"roms_tools_version": "0.1.dev138+dirty",
"roms_tools_version": "0.1.dev157+dirty",
"rot": 0,
"size_x": 100,
"size_y": 100,
Expand Down Expand Up @@ -325,36 +325,6 @@
"long_name": "latitude of rho-points on coarsened grid",
"units": "degrees North"
},
"lat_psi/.zarray": {
"chunks": [
4,
4
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<f8",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [
4,
4
],
"zarr_format": 2
},
"lat_psi/.zattrs": {
"_ARRAY_DIMENSIONS": [
"eta_psi",
"xi_psi"
],
"long_name": "latitude of psi-points",
"units": "degrees North"
},
"lat_rho/.zarray": {
"chunks": [
3,
Expand Down Expand Up @@ -574,36 +544,6 @@
"long_name": "longitude of rho-points on coarsened grid",
"units": "degrees East"
},
"lon_psi/.zarray": {
"chunks": [
4,
4
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<f8",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [
4,
4
],
"zarr_format": 2
},
"lon_psi/.zattrs": {
"_ARRAY_DIMENSIONS": [
"eta_psi",
"xi_psi"
],
"long_name": "longitude of psi-points",
"units": "degrees East"
},
"lon_rho/.zarray": {
"chunks": [
3,
Expand Down
22 changes: 0 additions & 22 deletions roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zarray

This file was deleted.

This file was deleted.

Binary file not shown.
22 changes: 0 additions & 22 deletions roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zarray

This file was deleted.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"center_lat": 0,
"center_lon": 0,
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v lat_psi layer_depth_rho layer_depth_u layer_depth_v lon_psi",
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
"hc": 300.0,
"hmin": 5.0,
"roms_tools_version": "0.1.dev138+dirty",
"roms_tools_version": "0.1.dev157+dirty",
"rot": 20,
"size_x": 100,
"size_y": 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
".zattrs": {
"center_lat": 0,
"center_lon": 0,
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v lat_psi layer_depth_rho layer_depth_u layer_depth_v lon_psi",
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
"hc": 300.0,
"hmin": 5.0,
"roms_tools_version": "0.1.dev138+dirty",
"roms_tools_version": "0.1.dev157+dirty",
"rot": 20,
"size_x": 100,
"size_y": 100,
Expand Down Expand Up @@ -325,36 +325,6 @@
"long_name": "latitude of rho-points on coarsened grid",
"units": "degrees North"
},
"lat_psi/.zarray": {
"chunks": [
4,
4
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<f8",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [
4,
4
],
"zarr_format": 2
},
"lat_psi/.zattrs": {
"_ARRAY_DIMENSIONS": [
"eta_psi",
"xi_psi"
],
"long_name": "latitude of psi-points",
"units": "degrees North"
},
"lat_rho/.zarray": {
"chunks": [
3,
Expand Down Expand Up @@ -574,36 +544,6 @@
"long_name": "longitude of rho-points on coarsened grid",
"units": "degrees East"
},
"lon_psi/.zarray": {
"chunks": [
4,
4
],
"compressor": {
"blocksize": 0,
"clevel": 5,
"cname": "lz4",
"id": "blosc",
"shuffle": 1
},
"dtype": "<f8",
"fill_value": "NaN",
"filters": null,
"order": "C",
"shape": [
4,
4
],
"zarr_format": 2
},
"lon_psi/.zattrs": {
"_ARRAY_DIMENSIONS": [
"eta_psi",
"xi_psi"
],
"long_name": "longitude of psi-points",
"units": "degrees East"
},
"lon_rho/.zarray": {
"chunks": [
3,
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
8 changes: 4 additions & 4 deletions roms_tools/tests/test_setup/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def test_coords_relation(grid_fixture, request):
grid = request.getfixturevalue(grid_fixture)

# psi versus rho
assert grid.ds.lon_psi.min() < grid.ds.lon_rho.min()
assert grid.ds.lon_psi.max() > grid.ds.lon_rho.max()
assert grid.ds.lat_psi.min() < grid.ds.lat_rho.min()
assert grid.ds.lat_psi.max() > grid.ds.lat_rho.max()
# assert grid.ds.lon_psi.min() < grid.ds.lon_rho.min()
# assert grid.ds.lon_psi.max() > grid.ds.lon_rho.max()
# assert grid.ds.lat_psi.min() < grid.ds.lat_rho.min()
# assert grid.ds.lat_psi.max() > grid.ds.lat_rho.max()

# Assertion with tolerance is necessary for non-rotated grids
def assert_larger_equal_than_with_tolerance(value1, value2, tolerance=1e-5):
Expand Down
Loading

0 comments on commit 9b75724

Please sign in to comment.