update Fabians review comments

This commit is contained in:
Philipp Glaum 2022-07-29 14:56:00 +02:00
parent 1009e2a0f6
commit ba7a5363e7
3 changed files with 9 additions and 9 deletions

View File

@ -52,7 +52,7 @@ datafiles = ['ch_cantons.csv', 'je-e-21.03.02.xls',
'eez/World_EEZ_v8_2014.shp', 'eez/World_EEZ_v8_2014.shp',
'hydro_capacities.csv', 'naturalearth/ne_10m_admin_0_countries.shp', 'hydro_capacities.csv', 'naturalearth/ne_10m_admin_0_countries.shp',
'NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp', 'nama_10r_3popgdp.tsv.gz', 'NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp', 'nama_10r_3popgdp.tsv.gz',
'nama_10r_3gdp.tsv.gz', 'corine/g250_clc06_V18_5.tif'] 'nama_10r_3gdp.tsv.gz', 'corine/g250_clc06_V18_5.tif', 'shipdensity/shipdensity_global.zip']
if not config.get('tutorial', False): if not config.get('tutorial', False):
@ -197,7 +197,7 @@ if config['enable'].get('build_ship_raster', False):
if config['enable'].get('retrieve_ship_raster', True): if config['enable'].get('retrieve_ship_raster', True):
rule retrieve_ship_raster: rule retrieve_ship_raster:
input: HTTP.remote("path-to-file", keep_local=True, static=True) input: HTTP.remote("https://sandbox.zenodo.org/record/1089563/files/europe_shipdensity_raster.nc", keep_local=True, static=True)
output: "resources/europe_shipdensity_raster.nc" output: "resources/europe_shipdensity_raster.nc"
run: move(input[0], output[0]) run: move(input[0], output[0])

View File

@ -243,8 +243,8 @@ if __name__ == '__main__':
excluder.add_raster(snakemake.input.corine, codes=codes, buffer=buffer, crs=3035) excluder.add_raster(snakemake.input.corine, codes=codes, buffer=buffer, crs=3035)
if "ship_threshold" in config: if "ship_threshold" in config:
shipping_threshold=config["ship_threshold"]*8760*6 # approximation because 6 years of data which is hourly collected shipping_threshold=config["ship_threshold"] * 8760 * 6 # approximation because 6 years of data which is hourly collected
func = functools.partial(np.less,shipping_threshold) func = functools.partial(np.less, shipping_threshold)
excluder.add_raster(snakemake.input.ship_density, codes=func, crs=4326, allow_no_overlap=True) excluder.add_raster(snakemake.input.ship_density, codes=func, crs=4326, allow_no_overlap=True)
if "max_depth" in config: if "max_depth" in config:

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: : 2017-2022 The PyPSA-Eur Authors # SPDX-FileCopyrightText: : 2022 The PyPSA-Eur Authors
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
@ -26,7 +26,7 @@ Inputs
Outputs Outputs
------- -------
- ``resources/natura.tiff``: Reduced version of `Global ship density from <https://datacatalog.worldbank.org/search/dataset/0037580/` to reduce computation times. - ``resources/europe_shipdensity_raster.nc``: Reduced version of `Global ship density from <https://datacatalog.worldbank.org/search/dataset/0037580/` to reduce computation time.
Description Description
----------- -----------
@ -38,7 +38,7 @@ from _helpers import configure_logging
from build_natura_raster import determine_cutout_xXyY from build_natura_raster import determine_cutout_xXyY
import zipfile import zipfile
import xarray import xarray as xr
import os import os
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -54,10 +54,10 @@ if __name__ == "__main__":
with zipfile.ZipFile(snakemake.input.ship_density) as zip_f: with zipfile.ZipFile(snakemake.input.ship_density) as zip_f:
zip_f.extract("shipdensity_global.tif") zip_f.extract("shipdensity_global.tif")
ship_density=xarray.open_rasterio("shipdensity_global.tif") ship_density = xr.open_rasterio("shipdensity_global.tif")
os.remove("shipdensity_global.tif") os.remove("shipdensity_global.tif")
ship_density=ship_density.drop(["band"]).sel(x=slice(min(xs),max(Xs)), y=slice(max(Ys),min(ys))) ship_density = ship_density.drop(["band"]).sel(x=slice(min(xs),max(Xs)), y=slice(max(Ys),min(ys)))
ship_density.to_netcdf(snakemake.output[0]) ship_density.to_netcdf(snakemake.output[0])