@@ -691,12 +691,17 @@ def from_netcdf(
691691 if grid is None :
692692 # Concatenate time variable to determine overall dimension
693693 # across multiple files
694- time , time_origin , timeslices , dataFiles = cls ._collect_timeslices (
695- timestamps , data_filenames , _grid_fb_class , dimensions , indices , netcdf_engine
696- )
697- grid = Grid .create_grid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh )
698- grid .timeslices = timeslices
699- kwargs ["dataFiles" ] = dataFiles
694+ if "time" in dimensions or timestamps is not None :
695+ time , time_origin , timeslices , dataFiles = cls ._collect_timeslices (
696+ timestamps , data_filenames , _grid_fb_class , dimensions , indices , netcdf_engine
697+ )
698+ grid = Grid .create_grid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh )
699+ grid .timeslices = timeslices
700+ kwargs ["dataFiles" ] = dataFiles
701+ else : # e.g. for the CROCO CS_w field, see https://github.com/OceanParcels/Parcels/issues/1831
702+ grid = Grid .create_grid (lon , lat , depth , np .array ([0.0 ]), time_origin = TimeConverter (0.0 ), mesh = mesh )
703+ grid .timeslices = [[0 ]]
704+ data_filenames = [data_filenames [0 ]]
700705 elif grid is not None and ("dataFiles" not in kwargs or kwargs ["dataFiles" ] is None ):
701706 # ==== means: the field has a shared grid, but may have different data files, so we need to collect the
702707 # ==== correct file time series again.
0 commit comments