Skip to main content

Tools for downloading results for 3Di scenarios

Project description

threedi-scenario-downloader

The threedi-scenario-downloader package includes functions in order to automate most used download actions on the 3Di results.

Example methods are:

  • Download raw results.

  • Download logging.

  • Download maximum waterdepth (non-temporal raster).

  • Download waterdepth (temporal raster, supply timestamp for snapshot).

  • Find all scenarios model slug or scenario name.

Examples

Start importing the package:

$ from threedi_scenario_downloader import downloader as dl

Set the API key for authentication to the Lizard API (you can get an API key here: <your portal>.lizard.net/management/#/personal_api_keys):

$ dl.set_api_key("INSERT YOUR API KEY HERE")

Find scenarios based on a model slug (unique model identifier) or scenario name. Returns last 10 matching results unless told otherwise:

$ scenarios = dl.find_scenarios_by_model_slug("enter your model_uuid",limit=10)

or:

$ scenarios = dl.find_scenarios_by_name("my_first_scenario",limit=100)

Do you want to download the raw 3Di-results (.nc and .h5 files) of a specific scenario? Use the following methods:

$ dl.download_raw_results("scenario_uuid")
$ dl.download_grid_administration("scenario_uuid")

or:

$ dl.download_raw_results("scenario_uuid",pathname="save_under_different_name.nc")
$ dl.download_grid_administration("scenario_uuid",pathname="save_under_different_name.h5")

Downloading (temporal) rasters of specific scenarios can be done using the following methods:

$ dl.download_maximum_waterdepth_raster("scenario_uuid","EPSG:28992",10)
#download the full extent of the maximum waterdepth of the given scenario_uuid with a 10 meter resolution in the RD New/Amersfoort projection (EPSG:28992)

$ dl.download_waterdepth_raster("scenario_uuid","EPSG:28992",10,"2019-01-01T02:00")
#download the full extend of the waterdepth at the supplied timestamp given scenario_uuid, on 10 meter resolution in the RD New/Amersfoort projection (EPSG:28992)

The raster download methods creates a task for the API. Depending on the size and resolution it takes some time for the raster to be prepared. These methods will keep on checking if the raster is ready to be downloaded. When a raster is ready to be downloaded a message in the Lizard portal is created as well. If you want to delete these messages (due to bulk downloading for example), use the following method:

$dl.clear_inbox()

Installation

We can be installed with:

$ pip install threedi-scenario-downloader

Development installation of this project itself

We’re installed with pipenv, a handy wrapper around pip and virtualenv. Install that first with pip install pipenv. Then run:

$ PIPENV_VENV_IN_PROJECT=1 pipenv --three
$ pipenv install --dev

In order to get nicely formatted python files without having to spend manual work on it, run the following command periodically:

$ pipenv run black threedi_scenario_downloader

Run the tests regularly. This also checks with pyflakes, black and it reports coverage. Pure luxury:

$ pipenv run pytest

The tests are also run automatically on travis-ci, you’ll see it in the pull requests. There’s also coverage reporting on coveralls.io.

If you need a new dependency (like requests), add it in setup.py in install_requires. Afterwards, run install again to actuall install your dependency:

$ pipenv install --dev

Changelog of threedi-scenario-downloader

0.13 (2021-07-22)

  • Added batch functionality to raster download

  • Added resume batch function

0.12 (2020-02-18)

  • Adaptation for improved feedback from Lizard API task endpoint

0.11 (2019-06-03)

  • Updated find_scenarios method. Use ‘name’ argument for exact searches and ‘name__icontains’ for partial searches

0.10 (2019-05-27)

  • Increased download chunk size

  • Added bounds_srs as optional argument to define the spatial reference system the bounds are supplied in

0.9 (2019-05-22)

  • Updated download method using stream

  • Updated urllib3 dependency

0.8 (2019-03-14)

  • Bugfix in downloading total damage rasters

0.7 (2019-02-15)

  • Added temporal rasters with interval

  • Retrieve grouped (static, temporal) download links from scenario

0.6 (2019-02-13)

  • Added method for downloading raw 3Di result

  • Added method for downloading gridadmin

  • Added authentication method for downloading files from Lizard API

0.5 (2019-02-13)

  • Cleanup of docstrings and usage of request parameters

  • Make result-limit changable

  • Added url retrieval methods

  • Added editable result limit on searches

0.2 (2019-01-24)

0.1 (2019-01-23)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

threedi-scenario-downloader-0.13.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

threedi_scenario_downloader-0.13-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file threedi-scenario-downloader-0.13.tar.gz.

File metadata

  • Download URL: threedi-scenario-downloader-0.13.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.7

File hashes

Hashes for threedi-scenario-downloader-0.13.tar.gz
Algorithm Hash digest
SHA256 293dccddd2a92eb41948dfc5523f38d9e6281c260a28e44eefce8ffa1c0d4437
MD5 f1100cbb96c8149bf1c7d466a4ae4f37
BLAKE2b-256 3d3f6589d58ffa9c41bc3a8e9b85c6f45d5495932587820bd78b5bb20fa289cd

See more details on using hashes here.

File details

Details for the file threedi_scenario_downloader-0.13-py3-none-any.whl.

File metadata

  • Download URL: threedi_scenario_downloader-0.13-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.7

File hashes

Hashes for threedi_scenario_downloader-0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 2866d1bce42d94241eb9228c495b7bfab1957717c5403bde8ffc2541cdc664a2
MD5 f22f9b01f1aeaea16f46e58c968084f7
BLAKE2b-256 e4cbbd775ffe966b6393199a2732e64886102d5db0d2a8ca368cc5816e276ddc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page