Skip to content

Commit 00908ea

Browse files
committed
Remove ParticleSet.from_list()
1 parent ecf27d6 commit 00908ea

File tree

5 files changed

+5
-44
lines changed

5 files changed

+5
-44
lines changed

parcels/particleset.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -341,45 +341,6 @@ def populate_indices(self):
341341

342342
self._data["ei"][:, i] = idx # assumes that we are in the surface layer (zi=0)
343343

344-
@classmethod
345-
def from_list(cls, fieldset, pclass, lon, lat, depth=None, time=None, lonlatdepth_dtype=None, **kwargs):
346-
"""Initialise the ParticleSet from lists of lon and lat.
347-
348-
Parameters
349-
----------
350-
fieldset :
351-
mod:`parcels.fieldset.FieldSet` object from which to sample velocity
352-
pclass :
353-
Particle class. May be a parcels.particle.Particle class as defined in parcels, or a subclass defining a custom particle.
354-
lon :
355-
List of initial longitude values for particles
356-
lat :
357-
List of initial latitude values for particles
358-
depth :
359-
Optional list of initial depth values for particles. Default is 0m
360-
time :
361-
Optional list of start time values for particles. Default is fieldset.U.time[0]
362-
repeatdt :
363-
Optional interval (in seconds) on which to repeat the release of the ParticleSet (Default value = None)
364-
lonlatdepth_dtype :
365-
Floating precision for lon, lat, depth particle coordinates.
366-
It is either np.float32 or np.float64. Default is np.float32 if fieldset.U.interp_method is 'linear'
367-
and np.float64 if the interpolation method is 'cgrid_velocity'
368-
Other Variables can be initialised using further arguments (e.g. v=... for a Variable named 'v')
369-
**kwargs :
370-
Keyword arguments passed to the particleset constructor.
371-
"""
372-
return cls(
373-
fieldset=fieldset,
374-
pclass=pclass,
375-
lon=lon,
376-
lat=lat,
377-
depth=depth,
378-
time=time,
379-
lonlatdepth_dtype=lonlatdepth_dtype,
380-
**kwargs,
381-
)
382-
383344
@classmethod
384345
def from_particlefile(cls, fieldset, pclass, filename, restart=True, restarttime=None, **kwargs):
385346
"""Initialise the ParticleSet from a zarr ParticleFile.

tests/test_fieldset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def sampleTemp(particle, fieldset, time): # pragma: no cover
343343
]
344344
)
345345

346-
pset = ParticleSet.from_list(fieldset, pclass=MyParticle, lon=[0.5], lat=[0.5], depth=[0.5])
346+
pset = ParticleSet(fieldset, pclass=MyParticle, lon=[0.5], lat=[0.5], depth=[0.5])
347347
pset.execute(
348348
AdvectionRK4_3D + pset.Kernel(sampleTemp), runtime=timedelta(hours=51), dt=timedelta(hours=dt_sign * 1)
349349
)

tests/test_particlesets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_pset_create_list_with_customvariable(fieldset):
3232
MyParticle = Particle.add_variable("v")
3333

3434
v_vals = np.arange(npart)
35-
pset = ParticleSet.from_list(fieldset, lon=lon, lat=lat, v=v_vals, pclass=MyParticle)
35+
pset = ParticleSet(fieldset, lon=lon, lat=lat, v=v_vals, pclass=MyParticle)
3636
assert np.allclose([p.lon for p in pset], lon, rtol=1e-12)
3737
assert np.allclose([p.lat for p in pset], lat, rtol=1e-12)
3838
assert np.allclose([p.v for p in pset], v_vals, rtol=1e-12)
@@ -127,7 +127,7 @@ def test_pset_create_with_time(fieldset):
127127
time = 5.0
128128
pset = ParticleSet(fieldset, lon=lon, lat=lat, pclass=Particle, time=time)
129129
assert np.allclose([p.time for p in pset], time, rtol=1e-12)
130-
pset = ParticleSet.from_list(fieldset, lon=lon, lat=lat, pclass=Particle, time=[time] * npart)
130+
pset = ParticleSet(fieldset, lon=lon, lat=lat, pclass=Particle, time=[time] * npart)
131131
assert np.allclose([p.time for p in pset], time, rtol=1e-12)
132132
pset = ParticleSet.from_line(fieldset, size=npart, start=(0, 1), finish=(1, 0), pclass=Particle, time=time)
133133
assert np.allclose([p.time for p in pset], time, rtol=1e-12)

tests/v4/test_structured_gcm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def test_fieldset_frompop():
1212
# dimensions = {"lon": "lon", "lat": "lat", "time": "time"}
1313

1414
# fieldset = FieldSet.from_pop(filenames, variables, dimensions, mesh="flat")
15-
# pset = ParticleSet.from_list(fieldset, Particle, lon=[3, 5, 1], lat=[3, 5, 1])
15+
# pset = ParticleSet(fieldset, Particle, lon=[3, 5, 1], lat=[3, 5, 1])
1616
# pset.execute(AdvectionRK4, runtime=3, dt=1)
1717
pass

v3to4-breaking-changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ ParticleSet
1313

1414
- ParticleSet init had repeatdt removed
1515
- ParticleSet.execute() expects `numpy.datetime64`/`numpy.timedelta.64` for `runtime`, `endtime` and `dt`
16-
- `ParticleSet.from_field()`, `ParticleSet.from_line()` has been removed
16+
- `ParticleSet.from_field()`, `ParticleSet.from_line()`, `ParticleSet.from_list()` has been removed

0 commit comments

Comments
 (0)