@@ -165,18 +165,42 @@ def get_default_particle(spatial_dtype: np.float32 | np.float64) -> ParticleClas
165165
166166 return ParticleClass (
167167 variables = [
168- Variable ("lon" , dtype = spatial_dtype ),
168+ Variable (
169+ "lon" ,
170+ dtype = spatial_dtype ,
171+ attrs = {"standard_name" : "longitude" , "units" : "degrees_east" , "axis" : "X" },
172+ ),
169173 Variable ("lon_nextloop" , dtype = spatial_dtype , to_write = False ),
170- Variable ("lat" , dtype = spatial_dtype ),
174+ Variable (
175+ "lat" ,
176+ dtype = spatial_dtype ,
177+ attrs = {"standard_name" : "latitude" , "units" : "degrees_north" , "axis" : "Y" },
178+ ),
171179 Variable ("lat_nextloop" , dtype = spatial_dtype , to_write = False ),
172- Variable ("depth" , dtype = spatial_dtype ),
180+ Variable (
181+ "depth" ,
182+ dtype = spatial_dtype ,
183+ attrs = {"standard_name" : "depth" , "units" : "m" , "positive" : "down" },
184+ ),
173185 Variable ("dlon" , dtype = spatial_dtype , to_write = False ),
174186 Variable ("dlat" , dtype = spatial_dtype , to_write = False ),
175187 Variable ("ddepth" , dtype = spatial_dtype , to_write = False ),
176188 Variable ("depth_nextloop" , dtype = spatial_dtype , to_write = False ),
177- Variable ("time" , dtype = _SAME_AS_FIELDSET_TIME_INTERVAL .VALUE ),
189+ Variable (
190+ "time" ,
191+ dtype = _SAME_AS_FIELDSET_TIME_INTERVAL .VALUE ,
192+ attrs = {"standard_name" : "time" , "units" : "seconds" , "axis" : "T" },
193+ ),
178194 Variable ("time_nextloop" , dtype = _SAME_AS_FIELDSET_TIME_INTERVAL .VALUE , to_write = False ),
179- Variable ("trajectory" , dtype = np .int64 , to_write = "once" ),
195+ Variable (
196+ "trajectory" ,
197+ dtype = np .int64 ,
198+ to_write = "once" ,
199+ attrs = {
200+ "long_name" : "Unique identifier for each particle" ,
201+ "cf_role" : "trajectory_id" ,
202+ },
203+ ),
180204 Variable ("obs_written" , dtype = np .int32 , initial = 0 , to_write = False ),
181205 Variable ("dt" , dtype = "timedelta64[s]" , initial = np .timedelta64 (1 , "s" ), to_write = False ),
182206 Variable ("state" , dtype = np .int32 , initial = StatusCode .Evaluate , to_write = False ),
@@ -239,7 +263,7 @@ def _create_array_for_variable(variable: Variable, nparticles: int, time_interva
239263 "This function cannot handle attrgetter initial values."
240264 )
241265 if (dtype := variable .dtype ) is _SAME_AS_FIELDSET_TIME_INTERVAL .VALUE :
242- dtype = type (time_interval . left )
266+ dtype = _get_time_interval_dtype (time_interval )
243267 return np .full (
244268 shape = (nparticles ,),
245269 fill_value = variable .initial ,
@@ -250,4 +274,8 @@ def _create_array_for_variable(variable: Variable, nparticles: int, time_interva
250274def _get_time_interval_dtype (time_interval : TimeInterval | None ) -> np .dtype :
251275 if time_interval is None :
252276 return np .timedelta64 (1 , "ns" )
253- return type (time_interval .left )
277+ time = time_interval .left
278+ if isinstance (time , (np .datetime64 , np .timedelta64 )):
279+ return time .dtype
280+ else :
281+ return object # cftime objects needs to be stored as object dtype
0 commit comments