diff --git a/docs/requirements.txt b/docs/requirements.txt index b5f5a56..f6cb86a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -15,7 +15,7 @@ sphinx-rtd-theme sphinx-book-theme # sphinx-bootstrap-theme -parcels<2.3.0 +parcels==2.4.2 cgen pymbolic Pydap diff --git a/docs/usage/preparation.rst b/docs/usage/preparation.rst index cf9795e..12aa571 100644 --- a/docs/usage/preparation.rst +++ b/docs/usage/preparation.rst @@ -149,11 +149,11 @@ Once you created a :class:`FloatConfiguration` instance, you can modify one or m cfg.update('parking_depth', 500) -If you want the same mission configuration for all your virtual floats, you can pass this configuration when instanciate a :class:`VirtualFleet` : +If you want the same mission configuration for all your virtual floats, you can pass this configuration when instantiating a :class:`VirtualFleet` : .. code:: python - VFleet = VirtualFleet(plan=my_plan, fieldset=VELfield.fieldset, mission=cfg.mission) + VFleet = VirtualFleet(plan=my_plan, fieldset=VELfield, mission=cfg) But you can also customized the mission of each float by passing an array of mission configurations to the :class:`VirtualFleet` instance : @@ -166,4 +166,4 @@ But you can also customized the mission of each float by passing an array of mis FloatConfiguration('default').update('parking_depth', 1000), FloatConfiguration('default').update('parking_depth', 1500) ] - VFleet = VirtualFleet(plan=my_plan, fieldset=VELfield.fieldset, mission=mission) \ No newline at end of file + VFleet = VirtualFleet(plan=my_plan, fieldset=VELfield, mission=mission) \ No newline at end of file diff --git a/docs/whats-new.rst b/docs/whats-new.rst index d0c5065..957c2ca 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -7,6 +7,39 @@ What's New |pypi dwn| + +v0.3.1 (22 Nov. 2023) +--------------------- + +.. note:: This is the last version compatible with Parcels versions < 3.0.0 + +**New features** + +- Mission parameters can now be set for each floats of the deployment plan. This is useful to limit the number of simulations to explore a set of configuration parameters. (:pr:`22`) by `K. Balem `_. +For instance: + +.. code-block:: python + + # Number of floats + nfloats = 5 + + # Define space/time locations of deployments: + lat = np.linspace(40, 41, nfloats) + lon = np.full_like(lat, 5) + tim = np.array(['2020-01-16' for i in range(nfloats)], dtype='datetime64') + my_plan = {'lat': lat, 'lon': lon, 'time': tim} + + mission = [ + FloatConfiguration('default').update('parking_depth', 100), + FloatConfiguration('default').update('parking_depth', 200), + FloatConfiguration('default').update('parking_depth', 500), + FloatConfiguration('default').update('parking_depth', 1000), + FloatConfiguration('default').update('parking_depth', 1500) + ] + + VFleet = VirtualFleet(plan=my_plan, fieldset=VELfield, mission=mission) + + v0.3.0 (25 Jan. 2023) --------------------- By `G. Maze `_ and `K. Balem `_. diff --git a/environment-doc.yml b/environment-doc.yml index 823f907..cba4bb6 100644 --- a/environment-doc.yml +++ b/environment-doc.yml @@ -4,7 +4,7 @@ channels: dependencies: - python=3.8 - xarray - - parcels>=2.4.0 + - parcels<3.0.0 - scipy - netcdf4 - dask diff --git a/virtualargofleet/utilities.py b/virtualargofleet/utilities.py index da84d08..43db74f 100644 --- a/virtualargofleet/utilities.py +++ b/virtualargofleet/utilities.py @@ -75,7 +75,7 @@ def meta_to_json(d): class FloatConfiguration: """Float mission configuration manager - Create a default configuration and then possibly update parameter values or add new ones + Create a default configuration and then possibly update parameter values Can be used to create a virtual fleet, to save or load float configurations diff --git a/virtualargofleet/virtualargofleet.py b/virtualargofleet/virtualargofleet.py index b6fcaa8..87ec9e7 100644 --- a/virtualargofleet/virtualargofleet.py +++ b/virtualargofleet/virtualargofleet.py @@ -23,7 +23,7 @@ from .utilities import simu2csv, simu2index, strfdelta, getSystemInfo from packaging import version import time -from typing import Union +from typing import Union, Iterable log = logging.getLogger("virtualfleet.virtualfleet") @@ -38,8 +38,8 @@ class VirtualFleet: def __init__(self, plan: dict, fieldset: Union[FieldSet, VelocityField], - mission: Union[dict, FloatConfiguration, list, np.ndarray, tuple], - isglobal: bool=False, + mission: Union[dict, FloatConfiguration, Iterable[dict], Iterable[FloatConfiguration]], + isglobal: bool = False, **kwargs): """Create an Argo Virtual Fleet simulator @@ -51,8 +51,12 @@ def __init__(self, Depth is optional, if not provided it will be set to 1m. fieldset: :class:`parcels.fieldset.FieldSet` or :class:`VelocityField` A velocity field - mission: dict or :class:`FloatConfiguration` or list/array of those (then it should be the same length as plan arrays) - A dictionary with at least the following Argo float mission parameters: ``parking_depth``, ``profile_depth``, ``vertical_speed`` and ``cycle_duration`` + mission: dict or :class:`FloatConfiguration` or an iterable of those + A dictionary with the following Argo float mission parameters: ``parking_depth``, ``profile_depth``, + ``vertical_speed`` and ``cycle_duration``. A :class:`FloatConfiguration` instance can also be passed. + + An iterable of dictionaries or :class:`FloatConfiguration` can be passed to specified mission parameters for each + virtual floats. In this case, the length of the iterable must match the length of the deployment plan. isglobal: bool, optional, default=False A boolean indicating weather the velocity field is global or not