Skip to content

Commit 5e7ae7b

Browse files
committed
Add information about oil type names
- add a dict for name to ID mapping - add notes to the `docs/tutorial.md` about the oil types
1 parent 8caa931 commit 5e7ae7b

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

docs/tutorial.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,24 @@ m.o.set_config('environment:constant:x_wind', -1)
220220
m.o.set_config('environment:constant:y_wind', 1)
221221
```
222222

223-
List available oil types from NOAA's ADIOS database (or check the database online):
223+
Note that `oil_type` was input by its oil id, in order to disambiguate the oils in ADIOS.
224+
225+
List of available oil types can be found in the
226+
1. NOAA's ADIOS database https://adios.orr.noaa.gov/oils
227+
2. or in the library's `OIL_ID_TO_NAME` dictionary:
228+
```{code-cell} ipython3
229+
ptm.models.opendrift.enums.oil_types.OIL_ID_TO_NAME
230+
```
231+
232+
You can also find the oil IDs by name in said [database](https://adios.orr.noaa.gov/oils)
233+
or in the library's `NAME_TO_OIL_ID` dictionary. E.g.:
224234
225235
```{code-cell} ipython3
226-
ptm.OpenOilModelConfig.model_json_schema()["$defs"]["OilTypeEnum"]["enum"]
236+
ptm.models.opendrift.enums.oil_types.NAME_TO_OIL_ID["ALASKA NORTH SLOPE"]
227237
```
228238

229-
Note that `oil_type` was input by its oil id, in order to disambiguate the oils in ADIOS.
239+
Keep in mind that some oil types share the same name which is why `NAME_TO_OIL_ID`
240+
contains lists of IDs.
230241

231242
The configuration parameters for this simulation are:
232243

particle_tracking_manager/models/opendrift/enums/oil_types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,14 @@
13011301
}
13021302

13031303

1304+
# A dictionary provided for user's convenience
1305+
NAME_TO_OIL_ID: dict[str, list[str]] = {}
1306+
for oil_id, oil_name in OIL_ID_TO_NAME.items():
1307+
if oil_name not in NAME_TO_OIL_ID:
1308+
NAME_TO_OIL_ID[oil_name] = []
1309+
NAME_TO_OIL_ID[oil_name].append(oil_id)
1310+
1311+
13041312
class OilTypeEnum(Enum):
13051313
"""Representation of oil types
13061314

0 commit comments

Comments
 (0)