下载3di场景结果的工具
threedi-scenario-downloader的Python项目详细描述
ThreeDI场景下载程序
threedi scenario downloader包包含以下函数: 自动对3di结果执行最常用的下载操作。
示例方法如下:
- 下载原始结果。
- 下载日志记录。
- 下载最大水深(非时间光栅)。
- 下载waterdepth(临时光栅,为快照提供时间戳)。
- 找到所有场景模型slug或场景名称。
示例
开始导入包:
$ from threedi_scenario_downloader import downloader as dl
为蜥蜴API设置身份验证标题:
$ dl.set_headers("your_username","your_password")
根据模型slug(唯一的模型标识符)或方案名称查找方案。返回最后10个匹配结果,除非另有说明:
$ scenarios = dl.find_scenarios_by_model_slug("enter your model_uuid",limit=10)
或:
$ scenarios = dl.find_scenarios_by_name("my_first_scenario",limit=100)
是否要下载特定方案的原始3DI结果(.nc和.h5文件)?使用以下方法:
$ dl.download_raw_results("scenario_uuid") $ dl.download_grid_administration("scenario_uuid")
或:
$ dl.download_raw_results("scenario_uuid",pathname="save_under_different_name.nc") $ dl.download_grid_administration("scenario_uuid",pathname="save_under_different_name.h5")
可以使用以下方法下载特定场景的(临时)光栅:
$ 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)
光栅下载方法为api创建一个任务。根据大小和分辨率,准备光栅需要一些时间。这些方法将继续检查光栅是否可以下载。 当光栅已准备好下载时,也会在蜥蜴门户中创建一条消息。如果要删除这些邮件(例如由于批量下载),请使用以下方法:
$dl.clear_inbox()
安装
我们可以安装:
$ pip install threedi-scenario-downloader
本项目本身的开发安装
我们安装了pipenv,一个方便的包装 围绕着皮普和维图阿列诺夫。首先用pip install pipenv安装它。然后运行:
$ PIPENV_VENV_IN_PROJECT=1 pipenv --three $ pipenv install --dev
为了获得格式良好的python文件,而不必花费手工 处理它,定期运行以下命令:
$ pipenv run black threedi_scenario_downloader
定期进行测试。这也适用于pyflakes,black和它的报告 新闻报道。纯粹的奢华:
$ pipenv run pytest
测试也会自动运行on travis-ci,您将在中看到它 拉取请求。上面还有coverage reporting 工作服。
如果您需要新的依赖项(如请求),请将其添加到 安装需要。然后,再次运行install以实际安装 依赖性:
$ pipenv install --dev
3DI场景下载程序的更改日志
0.11(2019-06-03)
- 更新了查找方案方法。使用“name”参数进行精确搜索,使用“name\u icontains”进行部分搜索
0.10(2019-05-27)
- 增加下载块大小
- 添加边界srs作为可选参数来定义在中提供边界的空间参考系统
0.9(2019-05-22)
- 使用流更新下载方法
- 更新了urllib3依赖项
0.8(2019-03-14)
- 下载总伤害光栅的错误修复
0.7(2019-02-15)
- 添加具有间隔的时间光栅
- 从场景中检索分组(静态、临时)下载链接
0.6(2019-02-13)
- 添加了下载原始3di结果的方法
- 添加了下载gridadmin的方法
- 添加了用于从Lizard API下载文件的身份验证方法
0.5(2019-02-13)
- 清除docstring和使用请求参数
- 使结果限制可更改
- 添加了URL检索方法
- 添加了搜索的可编辑结果限制
0.2(2019-01-24)
0.1(2019-01-23)
- 用cookiecutter和^{a创建的初始项目结构5}
- 初始工作版本。