11import math
2- from datetime import datetime , timedelta
32
43import numpy as np
5- import pandas as pd
64import uxarray as ux
5+ import xarray as xr
76
87__all__ = ["Nx" , "datasets" ]
98
9+ T = 13
1010Nx = 20
1111vmax = 1.0
1212delta = 0.1
13+ TIME = xr .date_range ("2000" , "2001" , T )
1314
1415
1516def _stommel_gyre_delaunay ():
@@ -57,7 +58,7 @@ def _stommel_gyre_delaunay():
5758 uxgrid = uxgrid ,
5859 dims = ["time" , "nz1" , "n_node" ],
5960 coords = dict (
60- time = (["time" ], pd . to_datetime ([ "2000-01-01" ]) ),
61+ time = (["time" ], [ TIME [ 0 ]] ),
6162 nz1 = (["nz1" ], [0 ]),
6263 ),
6364 attrs = dict (
@@ -70,7 +71,7 @@ def _stommel_gyre_delaunay():
7071 uxgrid = uxgrid ,
7172 dims = ["time" , "nz1" , "n_node" ],
7273 coords = dict (
73- time = (["time" ], pd . to_datetime ([ "2000-01-01" ]) ),
74+ time = (["time" ], [ TIME [ 0 ]] ),
7475 nz1 = (["nz1" ], [0 ]),
7576 ),
7677 attrs = dict (
@@ -83,7 +84,7 @@ def _stommel_gyre_delaunay():
8384 uxgrid = uxgrid ,
8485 dims = ["time" , "nz1" , "n_node" ],
8586 coords = dict (
86- time = (["time" ], pd . to_datetime ([ "2000-01-01" ]) ),
87+ time = (["time" ], [ TIME [ 0 ]] ),
8788 nz1 = (["nz1" ], [0 ]),
8889 ),
8990 attrs = dict (description = "pressure" , units = "N/m^2" , location = "node" , mesh = "delaunay" , Conventions = "UGRID-1.0" ),
@@ -108,8 +109,6 @@ def _fesom2_square_delaunay_uniform_z_coordinate():
108109 zc = 0.5 * (zf [:- 1 ] + zf [1 :]) # Vertical element centers
109110 nz = zf .size
110111 nz1 = zc .size
111- num_days = 5
112- date_array = [datetime (2000 , 1 , 1 ) + timedelta (days = i ) for i in range (num_days )]
113112
114113 # mask any point on one of the boundaries
115114 mask = (
@@ -127,25 +126,23 @@ def _fesom2_square_delaunay_uniform_z_coordinate():
127126
128127 # Define arrays U (zonal), V (meridional) and P (sea surface height)
129128 U = np .ones (
130- (num_days , nz1 , uxgrid .n_face ), dtype = np .float64
129+ (T , nz1 , uxgrid .n_face ), dtype = np .float64
131130 ) # Lateral velocity is on the element centers and face centers
132131 V = np .ones (
133- (num_days , nz1 , uxgrid .n_face ), dtype = np .float64
132+ (T , nz1 , uxgrid .n_face ), dtype = np .float64
134133 ) # Lateral velocity is on the element centers and face centers
135134 W = np .zeros (
136- (num_days , nz , uxgrid .n_node ), dtype = np .float64
135+ (T , nz , uxgrid .n_node ), dtype = np .float64
137136 ) # Vertical velocity is on the element faces and face vertices
138- P = np .ones (
139- (num_days , nz1 , uxgrid .n_node ), dtype = np .float64
140- ) # Pressure is on the element centers and face vertices
137+ P = np .ones ((T , nz1 , uxgrid .n_node ), dtype = np .float64 ) # Pressure is on the element centers and face vertices
141138
142139 u = ux .UxDataArray (
143140 data = U ,
144141 name = "U" ,
145142 uxgrid = uxgrid ,
146143 dims = ["time" , "nz1" , "n_face" ],
147144 coords = dict (
148- time = (["time" ], date_array ),
145+ time = (["time" ], TIME ),
149146 nz1 = (["nz1" ], zc ),
150147 ),
151148 attrs = dict (
@@ -158,7 +155,7 @@ def _fesom2_square_delaunay_uniform_z_coordinate():
158155 uxgrid = uxgrid ,
159156 dims = ["time" , "nz1" , "n_face" ],
160157 coords = dict (
161- time = (["time" ], date_array ),
158+ time = (["time" ], TIME ),
162159 nz1 = (["nz1" ], zc ),
163160 ),
164161 attrs = dict (
@@ -171,7 +168,7 @@ def _fesom2_square_delaunay_uniform_z_coordinate():
171168 uxgrid = uxgrid ,
172169 dims = ["time" , "nz" , "n_node" ],
173170 coords = dict (
174- time = (["time" ], date_array ),
171+ time = (["time" ], TIME ),
175172 nz = (["nz" ], zf ),
176173 ),
177174 attrs = dict (
@@ -184,7 +181,7 @@ def _fesom2_square_delaunay_uniform_z_coordinate():
184181 uxgrid = uxgrid ,
185182 dims = ["time" , "nz1" , "n_node" ],
186183 coords = dict (
187- time = (["time" ], date_array ),
184+ time = (["time" ], TIME ),
188185 nz1 = (["nz1" ], zc ),
189186 ),
190187 attrs = dict (description = "pressure" , units = "N/m^2" , location = "node" , mesh = "delaunay" , Conventions = "UGRID-1.0" ),
0 commit comments