Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9e0c7ce
Reorganising particlefile.py
VeckoTheGecko Aug 5, 2025
9cb867c
Move particle attr metadata to particle class
VeckoTheGecko Aug 5, 2025
caae32c
Reduce dependency on particleset in particlefile
VeckoTheGecko Aug 5, 2025
fca6d57
Remove pset from particlefile.py init
VeckoTheGecko Aug 5, 2025
7d86dd6
Move test_particlefile.py to v4 test suite
VeckoTheGecko Aug 6, 2025
c4d083d
Update test_particlefile.py
VeckoTheGecko Aug 7, 2025
803fe24
Update test_particlefile.py to remote repeatdt tests
VeckoTheGecko Aug 7, 2025
8b1c14e
Update particlefile.py to use updated particle data
VeckoTheGecko Aug 7, 2025
097bf44
Remove test_pfile_set_towrite_False
VeckoTheGecko Aug 7, 2025
b161b16
Update pfile writing to use time of fieldset
VeckoTheGecko Aug 7, 2025
85b9722
Updating particlefile.py to make compatible with v4-dev
VeckoTheGecko Aug 7, 2025
e8d6ada
Fix time metadata
VeckoTheGecko Aug 7, 2025
86f3592
Misc bugfixing while porting particlefile test suite to v4-dev
VeckoTheGecko Aug 7, 2025
00db91a
Update tests
VeckoTheGecko Aug 8, 2025
c9d2270
Add 'new' test marker
VeckoTheGecko Aug 8, 2025
df68621
Split ParticleFile.write into ParticleFile._write_particle_data
VeckoTheGecko Aug 8, 2025
1ba8ac7
Update _get_time_interval_dtype
VeckoTheGecko Aug 8, 2025
0ce4439
Add test_particlefile_write_particle_data test
VeckoTheGecko Sep 1, 2025
cee3082
Add comments
VeckoTheGecko Aug 8, 2025
6864116
Allow chunks to be None
VeckoTheGecko Sep 1, 2025
ac72c56
Restrict outputdt to be datetime or timedelta
VeckoTheGecko Sep 2, 2025
2e5e287
Update outputdt in tests
VeckoTheGecko Sep 3, 2025
3c65501
Remove directorystore from store fixture
VeckoTheGecko Sep 3, 2025
f04aab1
Move zarr store fixture to project level
VeckoTheGecko Sep 3, 2025
28e14b0
Update particleset.py to be compatible with particle writing again
VeckoTheGecko Sep 3, 2025
6db3737
Fix selection of particlefiles for writing
VeckoTheGecko Sep 3, 2025
d09ee25
Move _DATATYPES_TO_FILL_VALUES back to particlefile.py
VeckoTheGecko Sep 4, 2025
66d94a0
Remove np.datetime64 from outputdt
VeckoTheGecko Sep 4, 2025
6bc8284
Update test to remove breakpoint
VeckoTheGecko Sep 4, 2025
68df63c
Self review
VeckoTheGecko Sep 4, 2025
9d0a0a7
Fix selection of next_time in execute
VeckoTheGecko Sep 4, 2025
faec461
Remove Kernel.name in favour of using funcname
VeckoTheGecko Sep 4, 2025
d5f4d1c
Remove empty long_name s
VeckoTheGecko Sep 4, 2025
16032a4
Fix tests in test_particlefile.py
VeckoTheGecko Sep 5, 2025
e3d6a61
Make ParticleFile store and create_new_zarrfile attrs read only
VeckoTheGecko Sep 5, 2025
5393f6f
Remove pset.ParticleFile alias
VeckoTheGecko Sep 5, 2025
67df94e
Update outputdt for test
VeckoTheGecko Sep 5, 2025
1b9f389
Remove outdated TODO
VeckoTheGecko Sep 5, 2025
855ed76
Update pfile metadata to 'parcels_grid_mesh'
VeckoTheGecko Sep 8, 2025
097381f
Add xfailed test_pfile_set_towrite_False back to test_particlefile.py
VeckoTheGecko Sep 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions parcels/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ def funcname(self):
ret += f.__name__
return ret

@property #! Ported from v3. To be removed in v4? (/find another way to name kernels in output file)
def name(self):
return f"{self._ptype.name}{self.funcname}"

@property
def ptype(self):
return self._ptype
Expand Down
42 changes: 35 additions & 7 deletions parcels/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,42 @@ def get_default_particle(spatial_dtype: np.float32 | np.float64) -> ParticleClas

return ParticleClass(
variables=[
Variable("lon", dtype=spatial_dtype),
Variable(
"lon",
dtype=spatial_dtype,
attrs={"standard_name": "longitude", "units": "degrees_east", "axis": "X"},
),
Variable("lon_nextloop", dtype=spatial_dtype, to_write=False),
Variable("lat", dtype=spatial_dtype),
Variable(
"lat",
dtype=spatial_dtype,
attrs={"standard_name": "latitude", "units": "degrees_north", "axis": "Y"},
),
Variable("lat_nextloop", dtype=spatial_dtype, to_write=False),
Variable("depth", dtype=spatial_dtype),
Variable(
"depth",
dtype=spatial_dtype,
attrs={"standard_name": "depth", "units": "m", "positive": "down"},
),
Variable("dlon", dtype=spatial_dtype, to_write=False),
Variable("dlat", dtype=spatial_dtype, to_write=False),
Variable("ddepth", dtype=spatial_dtype, to_write=False),
Variable("depth_nextloop", dtype=spatial_dtype, to_write=False),
Variable("time", dtype=_SAME_AS_FIELDSET_TIME_INTERVAL.VALUE),
Variable(
"time",
dtype=_SAME_AS_FIELDSET_TIME_INTERVAL.VALUE,
attrs={"standard_name": "time", "units": "seconds", "axis": "T"},
),
Variable("time_nextloop", dtype=_SAME_AS_FIELDSET_TIME_INTERVAL.VALUE, to_write=False),
Variable("trajectory", dtype=np.int64, to_write="once"),
Variable(
"trajectory",
dtype=np.int64,
to_write="once",
attrs={
"long_name": "Unique identifier for each particle",
"cf_role": "trajectory_id",
},
),
Variable("obs_written", dtype=np.int32, initial=0, to_write=False),
Variable("dt", dtype="timedelta64[s]", initial=np.timedelta64(1, "s"), to_write=False),
Variable("state", dtype=np.int32, initial=StatusCode.Evaluate, to_write=False),
Expand Down Expand Up @@ -239,7 +263,7 @@ def _create_array_for_variable(variable: Variable, nparticles: int, time_interva
"This function cannot handle attrgetter initial values."
)
if (dtype := variable.dtype) is _SAME_AS_FIELDSET_TIME_INTERVAL.VALUE:
dtype = type(time_interval.left)
dtype = _get_time_interval_dtype(time_interval)
return np.full(
shape=(nparticles,),
fill_value=variable.initial,
Expand All @@ -250,4 +274,8 @@ def _create_array_for_variable(variable: Variable, nparticles: int, time_interva
def _get_time_interval_dtype(time_interval: TimeInterval | None) -> np.dtype:
if time_interval is None:
return np.timedelta64(1, "ns")
return type(time_interval.left)
time = time_interval.left
if isinstance(time, (np.datetime64, np.timedelta64)):
return time.dtype
else:
return object # cftime objects needs to be stored as object dtype
Loading
Loading