-
Notifications
You must be signed in to change notification settings - Fork 10
v0.3 dev #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
v0.3 dev #226
Changes from 91 commits
Commits
Show all changes
107 commits
Select commit
Hold shift + click to select a range
a4f9deb
Unify config files to expedition.yaml (#217)
j-atkins 2240b89
Update link to website (#215)
VeckoTheGecko 8c08b45
Merge branch 'main' into v1-dev
j-atkins 63cbda5
first refactoring step, parent instrument classes
j-atkins b4fbf2b
ignore refactoring notes in gitignore
j-atkins 2409517
add note to remove upon completing v1 dev
j-atkins cfa7a0f
scratch inputdataset objects integration to _fetch
j-atkins 851dd27
add call to download_data()
j-atkins a417c68
Add new instrument classes and update InputDataset to include depth p…
j-atkins a0c77ab
Refactor instrument handling in _fetch and update imports for consist…
j-atkins 9bcaba2
Refactor instrument classes and re-add (temporary) simulation functio…
j-atkins 8b5954d
improve/clarify comments and notes
j-atkins ff38f4f
Refactor ArgoFloat and XBT classes to include depth parameters and re…
j-atkins c870d1c
avoid circular import issues
j-atkins 49b3bee
make tests for InputDataset base class
j-atkins c4e3196
refactor instrument handling in _fetch.py and update expedition model…
j-atkins 2f40f7d
refactor instrument error handling in Expedition model and remove Sch…
j-atkins 43c855d
add is_underway property to InstrumentType and filter instruments in …
j-atkins 79c81cb
enhance CLI output for fetching
j-atkins efb53ca
general fixes and new error class
j-atkins c4ddea1
refactor test cases to use Expedition object
j-atkins 28e369f
Merge branch 'main' into v1-dev
j-atkins d4e8e8d
Merge branch v1-dev into instrument-refactor
j-atkins 66aa4a5
move instruments base classes out of models/ dir
j-atkins 06ddf37
update base class imports
j-atkins 5887177
make get_instruments_registry more robust with testing
j-atkins cc35538
update mock reanalysis period and refactor tests to use expedition fi…
j-atkins 2fcbbd6
Merge branch 'v1-dev' into instrument-refactor
j-atkins 8f5af04
refactor: reorganize instrument classes and update imports for clarity
j-atkins fdc0e6e
implement instrument registration and input dataset retrieval
j-atkins 95e6cbd
refactor: reorganize imports in instrument test files for consistency
j-atkins 01cee18
further refactoring: instrument classes to use a unified InputDataset…
j-atkins e96aa8a
evaporate simulate_measurements.py; centralise run logic
j-atkins 3efa29b
draft up check land using bathymetry
j-atkins aa2d309
small bug fixes
j-atkins 588cab4
patch copernicus product id search logic to new instrument classes, p…
j-atkins 1081fab
adding U and V to instruments where missing
j-atkins a0d7d2c
enhanced error messaging for XBT in too shallow regions
j-atkins e5c08ce
bug fixes
j-atkins a4f8af0
version U and V downloaded
j-atkins e3c57f6
dummy U and V
j-atkins 813a245
Neaten up logging output
j-atkins b94f4f0
small bug fixes
j-atkins a5d10e7
tidy up
j-atkins 3753032
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b7904e8
Refactor type hints and improve test coverage for instruments and utils
j-atkins 7d1c575
Remove TODO comments and tidy up imports in test files
j-atkins 766dab0
Merge branch 'instrument-refactor' of github.com:OceanParcels/virtual…
j-atkins e74a5ad
Refactor bathymetry error handling, update verification methods and r…
j-atkins 56d8fd5
move product id selection logic to utils
j-atkins eaa124c
Merge branch 'main' into instrument-refactor
j-atkins c447dd8
update
j-atkins 870271b
first draft direct ingestion via copernicusmarine (CTD only)
j-atkins 701e45d
refactor bathymetry data handling and add (temporary) timing for perf…
j-atkins 8194115
update instrument constructors for Copernicus Marine ingestion
j-atkins 446b8d0
move expedition/do_expedition.py to cli/_run.py, rename Instrument.ru…
j-atkins c97d319
move checkpoint class to models, move expedition_cost() to utils.py
j-atkins d1acdef
update imports for expedition_cost
j-atkins d7531ae
working with drifters (bodge), CTD_BGC not yet working
j-atkins 3a12ae8
Merge branch 'instrument-refactor' into ingest
j-atkins 118e685
remove fetch and all associated logic
j-atkins 05686f2
update docstrings/--help info
j-atkins 10e68b3
add buffers to drifters and argos, plus depth limits for drifters
j-atkins 43afe97
remove _creds.py
j-atkins e9a0c54
CTD_BGC fieldset bug fix
j-atkins 995a6e5
fixing bugs associated with BGC data access
j-atkins ec33296
update dependencies
j-atkins c1321ba
logic for handling copernicus credentials
j-atkins f386f42
add support for taking local pre-downloaded data with --from-data opt…
j-atkins 7ba83fc
update drifter to be at -1m depth, to avoid out of bounds at surface
j-atkins f13c836
tidy up
j-atkins 4f533c5
bug fixes for unnecessary copernicusmarine call when using pre-downlo…
j-atkins d288ead
remove redundant tests
j-atkins dc2f4d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2a05ed4
update tests (not yet instrument subclasses)
j-atkins 95a583d
update instrument tests
j-atkins 411c042
test is on land tests in schedule.verify()
j-atkins 10df8f8
Merge branch 'v1-dev' of github.com:OceanParcels/virtualship into v1-dev
j-atkins e364d00
Run pre-commit
j-atkins 56d41e6
update pre-download ingestion methods to take files split by time
j-atkins 845a8f8
fix bug
j-atkins 1418a44
fix bug in ingesting bgc data from disk
j-atkins 5226a02
tidy up
j-atkins 36574b0
add test for data directory structure compliance
j-atkins 4d9f5ed
update docs
j-atkins e9f3b16
edits to docs
j-atkins 554f281
add more checks to docs compliance testing
j-atkins 4893731
TODO in readme
j-atkins 5a61541
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 00c4455
Update docs/user-guide/documentation/pre_download_data.md
j-atkins 3cdfd1a
Apply suggestions from code review
j-atkins a84c8fd
Set t_min to first day of month for monthly resolution
j-atkins 4198406
remove redundant parameters from instrument classes
j-atkins 94d5be2
change variable name
j-atkins 890cd94
make _find_files_in_timerange standalone from Instrument base class
j-atkins c0ba080
Update error docstring
j-atkins 141530a
update plan UI logic to update space-time region dynamically
j-atkins 9cb27a7
fix xbt bug
j-atkins 6b6d395
add warnings to ADCP max depth config if exceeds authentic limits
j-atkins 189f868
Merge branch 'main' of github.com:OceanParcels/virtualship into v1-dev
j-atkins b26636b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ac02bdc
error messaging for case where measurements cause schedule to be missed
j-atkins 89b7084
Merge branch 'v1-dev' of github.com:OceanParcels/virtualship into v1-dev
j-atkins 7b25526
revert to using ScheduleProblem class
j-atkins 28dbe33
add more informative messaging on ScheduleProblem
j-atkins 9bf6446
change test to mock using data from disk to avoid copernicus calls
j-atkins 0d5c5eb
remove accidental breakpoint
j-atkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 193 additions & 0 deletions
193
docs/user-guide/documentation/example_copernicus_download.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "a48322c9", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Example Copernicus data download \n", | ||
| "\n", | ||
| "This notebook provides a rough, non-optimised example of how to download Copernicus Marine data using the `copernicusmarine` Python package.\n", | ||
| "\n", | ||
| "This will download:\n", | ||
| "- Global bathymetry data (static)\n", | ||
| "- Global biogeochemical monthly data (0.25 degree hindcast)\n", | ||
| "- Global physical daily data (0.25 degree reanalysis)\n", | ||
| "\n", | ||
| "For a singular year (2023) and two months (June and July).\n", | ||
| "\n", | ||
| "This notebook is intended as a basic example only. Modifications will be needed to adapt this to your own use case." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "7f5a7cc7", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import copernicusmarine\n", | ||
| "import os\n", | ||
| "from datetime import datetime" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "e7279d5a", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "YEAR = \"2023\"\n", | ||
| "MONTHS = [\"06\", \"07\"]\n", | ||
| "DAYS = [\n", | ||
| " \"01\",\n", | ||
| " \"02\",\n", | ||
| " \"03\",\n", | ||
| " \"04\",\n", | ||
| " \"05\",\n", | ||
| " \"06\",\n", | ||
| " \"07\",\n", | ||
| " \"08\",\n", | ||
| " \"09\",\n", | ||
| " \"10\",\n", | ||
| " \"11\",\n", | ||
| " \"12\",\n", | ||
| " \"13\",\n", | ||
| " \"14\",\n", | ||
| " \"15\",\n", | ||
| " \"16\",\n", | ||
| " \"17\",\n", | ||
| " \"18\",\n", | ||
| " \"19\",\n", | ||
| " \"20\",\n", | ||
| " \"21\",\n", | ||
| " \"22\",\n", | ||
| " \"23\",\n", | ||
| " \"24\",\n", | ||
| " \"25\",\n", | ||
| " \"26\",\n", | ||
| " \"27\",\n", | ||
| " \"28\",\n", | ||
| " \"29\",\n", | ||
| " \"30\",\n", | ||
| " \"31\",\n", | ||
| "]" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "1a583dba", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "### PHYSICAL DAILY FILES\n", | ||
| "\n", | ||
| "os.chdir(\"~/data/phys/\")\n", | ||
| "DATASET_ID = \"cmems_mod_glo_phy-all_my_0.25deg_P1D-m\"\n", | ||
| "\n", | ||
| "for month in MONTHS:\n", | ||
| " for day in DAYS:\n", | ||
| " # check is valid date\n", | ||
| " try:\n", | ||
| " datetime(year=int(YEAR), month=int(month), day=int(day), hour=0)\n", | ||
| " except ValueError:\n", | ||
| " continue\n", | ||
| "\n", | ||
| " filename = f\"{DATASET_ID}_global_fulldepth_{YEAR}_{month}_{day}.nc\"\n", | ||
| "\n", | ||
| " if os.path.exists(filename):\n", | ||
| " print(f\"File {filename} already exists, skipping...\")\n", | ||
| " continue\n", | ||
| "\n", | ||
| " copernicusmarine.subset(\n", | ||
| " dataset_id=DATASET_ID,\n", | ||
| " variables=[\"uo_glor\", \"vo_glor\", \"thetao_glor\", \"so_glor\"],\n", | ||
| " minimum_longitude=-180,\n", | ||
| " maximum_longitude=179.75,\n", | ||
| " minimum_latitude=-80,\n", | ||
| " maximum_latitude=90,\n", | ||
| " start_datetime=f\"{YEAR}-{month}-{day}T00:00:00\",\n", | ||
| " end_datetime=f\"{YEAR}-{month}-{day}T00:00:00\",\n", | ||
| " minimum_depth=0.5057600140571594,\n", | ||
| " maximum_depth=5902.0576171875,\n", | ||
| " output_filename=filename,\n", | ||
| " )" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "89921772", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "### BIOGEOCHEMICAL MONTHLY FILES\n", | ||
| "\n", | ||
| "os.chdir(\"~/data/bgc/\")\n", | ||
| "DATASET_ID = \"cmems_mod_glo_bgc_my_0.25deg_P1M-m\"\n", | ||
| "DAY = \"01\"\n", | ||
| "\n", | ||
| "for month in MONTHS:\n", | ||
| " try:\n", | ||
| " datetime(year=int(YEAR), month=int(month), day=int(DAY), hour=0)\n", | ||
| " except ValueError:\n", | ||
| " continue\n", | ||
| "\n", | ||
| " filename = f\"{DATASET_ID}_global_fulldepth_{YEAR}_{month}_{DAY}.nc\"\n", | ||
| "\n", | ||
| " if os.path.exists(filename):\n", | ||
| " print(f\"File {filename} already exists, skipping...\")\n", | ||
| " continue\n", | ||
| "\n", | ||
| " copernicusmarine.subset(\n", | ||
| " dataset_id=\"cmems_mod_glo_bgc_my_0.25deg_P1M-m\",\n", | ||
| " variables=[\"chl\", \"no3\", \"nppv\", \"o2\", \"ph\", \"phyc\", \"po4\"],\n", | ||
| " minimum_longitude=-180,\n", | ||
| " maximum_longitude=179.75,\n", | ||
| " minimum_latitude=-80,\n", | ||
| " maximum_latitude=90,\n", | ||
| " start_datetime=f\"{YEAR}-{month}-{DAY}T00:00:00\",\n", | ||
| " end_datetime=f\"{YEAR}-{month}-{DAY}T00:00:00\",\n", | ||
| " minimum_depth=0.5057600140571594,\n", | ||
| " maximum_depth=5902.05810546875,\n", | ||
| " output_filename=filename,\n", | ||
| " )" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "8b5495c6", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "### BATHYMETRY FILE\n", | ||
| "os.chdir(\"~/data/bathymetry/\")\n", | ||
| "DATASET_ID = \"cmems_mod_glo_phy_anfc_0.083deg_static\"\n", | ||
| "filename = \"cmems_mod_glo_phy_anfc_0.083deg_static_bathymetry.nc\"\n", | ||
| "\n", | ||
| "copernicusmarine.subset(\n", | ||
| " dataset_id=DATASET_ID,\n", | ||
| " dataset_part=\"bathy\",\n", | ||
| " variables=[\"deptho\"],\n", | ||
| " minimum_longitude=-180,\n", | ||
| " maximum_longitude=179.91668701171875,\n", | ||
| " minimum_latitude=-80,\n", | ||
| " maximum_latitude=90,\n", | ||
| " minimum_depth=0.49402499198913574,\n", | ||
| " maximum_depth=0.49402499198913574,\n", | ||
| " output_filename=filename,\n", | ||
| ")" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "language_info": { | ||
| "name": "python" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Pre-downloading data | ||
|
|
||
| By default, VirtualShip will automatically 'stream' data from the Copernicus Marine Service via the [copernicusmarine toolbox](https://github.com/mercator-ocean/copernicus-marine-toolbox?tab=readme-ov-file). However, for users who wish to manage data locally, it is possible to pre-download the required datasets and feed them into VirtualShip simulations. | ||
|
|
||
| <!-- TODO: quickstart guide needs full update! --> | ||
|
|
||
| As outlined in the [Quickstart Guide](https://virtualship.readthedocs.io/en/latest/user-guide/quickstart.html), the `virtualship run` command supports an optional `--from-data` argument, which allows users to specify a local directory containing the necessary data files. | ||
|
|
||
| ```{tip} | ||
| See the [for example...](#for-example) section for an example data download workflow. | ||
| ``` | ||
|
|
||
| ### Data requirements | ||
|
|
||
| For pre-downloaded data, VirtualShip only supports daily and monthly resolution physical and biogeochemical data, along with a static bathymetry file. | ||
|
|
||
| In addition, all pre-downloaded data must be split into separate files per timestep (i.e. one .nc file per day or month). | ||
|
|
||
| ```{note} | ||
| **Monthly data**: when using monthly data, ensure that your final .nc file download is for the month *after* your expedition schedule end date. This is to ensure that a Parcels FieldSet can be generated under-the-hood which fully covers the expedition period. For example, if your expedition runs from 1st May to 15th May, your final monthly data file should be in June. Daily data files only need to cover the expedition period exactly. | ||
| ``` | ||
|
|
||
| Further, VirtualShip expects pre-downloaded data to be organised in a specific directory & filename structure within the specified local data directory. The expected structure is as outlined in the subsequent sections. | ||
|
|
||
| #### Directory structure | ||
|
|
||
| Assuming the local data directory (as supplied in the `--from-data` argument) is named `data/`, the expected subdirectory structure is: | ||
|
|
||
| ```bash | ||
| . | ||
| └── data | ||
| ├── bathymetry # containing the singular bathymetry .nc file | ||
| ├── bgc # containing biogeochemical .nc files | ||
| └── phys # containing physical .nc files | ||
| ``` | ||
|
|
||
| #### Filename conventions | ||
|
|
||
| Within these subdirectories, the expected filename conventions are: | ||
|
|
||
| - Physical data files (in `data/phys/`) should be named as follows: | ||
| - `<COPERNICUS_DATESET_NOMENCLATURE>_<YYYY_MM_DD>.nc` | ||
| - e.g. `cmems_mod_glo_phy-all_my_0.25deg_P1D-m_1998_05_01.nc` and so on for each timestep. | ||
| - Biogeochemical data files (in `data/bgc/`) should be named as follows: | ||
| - `<COPERNICUS_DATESET_NOMENCLATURE>_<YYYY_MM_DD>.nc` | ||
| - e.g. `cmems_mod_glo_bgc_my_0.25deg_P1M-m_1998_05_01.nc` and so on for each timestep. | ||
| - Bathymetry data file (in `data/bathymetry/`) should be named as follows: | ||
| - `cmems_mod_glo_phy_anfc_0.083deg_static_bathymetry.nc` | ||
|
|
||
| ```{tip} | ||
| Take care to use an underscore (`_`) as the separator between date components in the filenames (i.e. `YYYY_MM_DD`). | ||
| ``` | ||
|
|
||
| ```{note} | ||
| Using the `<COPERNICUS_DATESET_NOMENCLATURE>` in the filenames is vital in order to correctly identify the temporal resolution of the data (daily or monthly). The `P1D` in the example above indicates daily data, whereas `P1M` would indicate monthly data. | ||
|
|
||
| See [here](https://help.marine.copernicus.eu/en/articles/6820094-how-is-the-nomenclature-of-copernicus-marine-data-defined#h_34a5a6f21d) for more information on Copernicus dataset nomenclature. | ||
|
|
||
| See also our own [documentation](https://virtualship.readthedocs.io/en/latest/user-guide/documentation/copernicus_products.html#data-availability) on the Copernicus datasets used natively by VirtualShip when 'streaming' data if you wish to use the same datasets for pre-download. | ||
| ``` | ||
|
|
||
| ```{note} | ||
| **Monthly data**: the `DD` component of the date in the filename for monthly .nc files should always be `01`, representing the first day of the month. This ensures that a Parcels FieldSet can be generated under-the-hood which fully covers the expedition period from the start. | ||
| ``` | ||
|
|
||
| #### Further assumptions | ||
|
|
||
| The following assumptions are also made about the data: | ||
|
|
||
| 1. All pre-downloaded data files must be in NetCDF format (`.nc`). | ||
| 2. Physical data files must contain the following variables: `uo`, `vo`, `so`, `thetao` | ||
| - Or these strings must appear as substrings within the variable names (e.g. `uo_glor` is acceptable for `uo`). | ||
| 3. If using BGC instruments (e.g. `CTD_BGC`), the relevant biogeochemical data files must contain the following variables: `o2`, `chl`, `no3`, `po4`, `nppv`, `ph`, `phyc`. | ||
| - Or these strings must appear as substrings within the variable names (e.g. `o2_glor` is acceptable for `o2`). | ||
| 4. Bathymetry data files must contain a variable named `deptho`. | ||
|
|
||
| #### Also of note | ||
|
|
||
| 1. Whilst not mandatory to use data downloaded only from the Copernicus Marine Service (any existing data you may hold can be re-organised accordingly), the assumptions made by VirtualShip regarding directory structure and filename conventions are motivated by alignment with the Copernicus Marine Service's practices. | ||
| - If you want to use pre-existing data with VirtualShip, which you may have accessed from a different source, it is possible to do so by restructuring and/or renaming your data files as necessary. | ||
| 2. The whole VirtualShip pre-downloaded data workflow should support global data or subsets thereof, provided the data files contain the necessary variables and are structured as outlined above. | ||
|
|
||
| #### For example... | ||
|
|
||
| Example Python code for automating the data download from Copernicus Marine can be found in [Example Copernicus Download](example_copernicus_download.ipynb). | ||
|
|
||
| <!-- TODO: replace with URL? --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the Quickstart guide is a priority after this PR gets merged, as we have students who will be working with VirtualShip on November 27th again