From 7a3e583bdb0a3fcd3c5e209e8e030c6ef2b5ec20 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 09:26:50 +0100 Subject: [PATCH 1/7] Update environment-doc.yml --- environment-doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 4c13c0e1b5278b2a08e9f46bda523e570cb2685f Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 09:45:09 +0100 Subject: [PATCH 2/7] Update the doc --- docs/usage/preparation.rst | 6 +++--- docs/whats-new.rst | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) 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 `_. From 2927cb0b6eb71bcc3e784aa094d1bc4603f98ef1 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 09:51:21 +0100 Subject: [PATCH 3/7] Update virtualargofleet.py --- virtualargofleet/virtualargofleet.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/virtualargofleet/virtualargofleet.py b/virtualargofleet/virtualargofleet.py index b6fcaa8..3c68c5d 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, List, Tuple log = logging.getLogger("virtualfleet.virtualfleet") @@ -38,7 +38,7 @@ class VirtualFleet: def __init__(self, plan: dict, fieldset: Union[FieldSet, VelocityField], - mission: Union[dict, FloatConfiguration, list, np.ndarray, tuple], + mission: Union[dict, FloatConfiguration, List[dict], List[FloatConfiguration], Tuple[dict], Tuple[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. + + A list/tuple of dictionaries or :class:`FloatConfiguration` can be passed to specified mission parameters for each + virtual floats. In this case, the length of the list/tuple must match the length of the deployment plan. isglobal: bool, optional, default=False A boolean indicating weather the velocity field is global or not From fa7bc1ea7c0d5ce8ddcc0d090b0c30eabd9b904c Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 09:54:37 +0100 Subject: [PATCH 4/7] Update requirements.txt --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f670cbfdfd6da2885774dd9c868e7d03a18ab252 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 10:03:47 +0100 Subject: [PATCH 5/7] Update virtualargofleet.py --- virtualargofleet/virtualargofleet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualargofleet/virtualargofleet.py b/virtualargofleet/virtualargofleet.py index 3c68c5d..f62e5b5 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, List, Tuple +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[dict], List[FloatConfiguration], Tuple[dict], Tuple[FloatConfiguration]], - isglobal: bool=False, + mission: Union[dict, FloatConfiguration, Iterable[dict], Iterable[FloatConfiguration]], + isglobal: bool = False, **kwargs): """Create an Argo Virtual Fleet simulator From b76ed29a2be49bb0e7a99bcd777e9e9ba3e93506 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 10:06:58 +0100 Subject: [PATCH 6/7] Update virtualargofleet.py --- virtualargofleet/virtualargofleet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualargofleet/virtualargofleet.py b/virtualargofleet/virtualargofleet.py index f62e5b5..87ec9e7 100644 --- a/virtualargofleet/virtualargofleet.py +++ b/virtualargofleet/virtualargofleet.py @@ -55,8 +55,8 @@ def __init__(self, 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. - A list/tuple of dictionaries or :class:`FloatConfiguration` can be passed to specified mission parameters for each - virtual floats. In this case, the length of the list/tuple must match the length of the deployment plan. + 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 From f8e451efcfc0ca56187461d217f885fd216b563f Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Wed, 22 Nov 2023 10:07:02 +0100 Subject: [PATCH 7/7] Update utilities.py --- virtualargofleet/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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