88
99import numpy as np
1010import xarray as xr
11+ from dask .base import is_dask_collection
1112
13+ from parcels ._core ._windowed_array import WindowedArray
1214from parcels ._python import isinstance_noimport
1315
1416if TYPE_CHECKING :
@@ -190,13 +192,15 @@ class _FieldSetDescriptionRow:
190192 model_id : int | None
191193 name : str
192194 interp_method_or_value : str
195+ backend : str | None = None
193196
194197 def to_dict (self ) -> dict [str , str ]:
195198 return {
196199 "Name" : self .name ,
197200 "Type" : self .type_ ,
198201 "Grid number" : str (self .model_id ) if self .model_id is not None else "-" ,
199202 "Interp method / value" : self .interp_method_or_value ,
203+ "Backend" : self .backend if self .backend is not None else "-" ,
200204 }
201205
202206
@@ -213,6 +217,20 @@ def _print_time_interval(time_interval: TimeInterval | None) -> str:
213217 return repr ((time_interval .left , time_interval .right ))
214218
215219
220+ def _field_backend (field : Field | VectorField ) -> str | None :
221+ if hasattr (field , "data" ):
222+ if isinstance (field .data , WindowedArray ):
223+ return "WindowedArray"
224+ elif is_dask_collection (field .data .data ):
225+ return "Dask"
226+ elif isinstance (field .data .data , np .ndarray ):
227+ return "NumPy"
228+ else :
229+ return type (field .data ).__name__
230+ else :
231+ return None
232+
233+
216234def fieldset_describe (fieldset : FieldSet ) -> str :
217235 rows : list [_FieldSetDescriptionRow ] = []
218236 models : dict [int , int ] = {} # mapping of memory ID to a human readable ID
@@ -235,6 +253,7 @@ def fieldset_describe(fieldset: FieldSet) -> str:
235253 model_id = model_id ,
236254 name = field .name ,
237255 interp_method_or_value = repr (field .interp_method ),
256+ backend = _field_backend (field ),
238257 )
239258 )
240259 for k , v in fieldset .context .items ():
@@ -244,6 +263,7 @@ def fieldset_describe(fieldset: FieldSet) -> str:
244263 model_id = None ,
245264 name = k ,
246265 interp_method_or_value = repr (v ),
266+ backend = None ,
247267 )
248268 )
249269 return (
0 commit comments