@@ -684,12 +684,17 @@ def from_netcdf(
684684 if grid is None :
685685 # Concatenate time variable to determine overall dimension
686686 # across multiple files
687- time , time_origin , timeslices , dataFiles = cls ._collect_timeslices (
688- timestamps , data_filenames , _grid_fb_class , dimensions , indices , netcdf_engine
689- )
690- grid = Grid .create_grid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh )
691- grid .timeslices = timeslices
692- kwargs ["dataFiles" ] = dataFiles
687+ if "time" in dimensions :
688+ time , time_origin , timeslices , dataFiles = cls ._collect_timeslices (
689+ timestamps , data_filenames , _grid_fb_class , dimensions , indices , netcdf_engine
690+ )
691+ grid = Grid .create_grid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh )
692+ grid .timeslices = timeslices
693+ kwargs ["dataFiles" ] = dataFiles
694+ else : # e.g. for the CROCO CS_w field, see https://github.com/OceanParcels/Parcels/issues/1831
695+ grid = Grid .create_grid (lon , lat , depth , np .array ([0.0 ]), time_origin = TimeConverter (0.0 ), mesh = mesh )
696+ grid .timeslices = [[0 ]]
697+ data_filenames = [data_filenames [0 ]]
693698 elif grid is not None and ("dataFiles" not in kwargs or kwargs ["dataFiles" ] is None ):
694699 # ==== means: the field has a shared grid, but may have different data files, so we need to collect the
695700 # ==== correct file time series again.
0 commit comments