Skip to content

Commit

Permalink
Merge pull request #262 from openego/features/new-powerd-data-bundle
Browse files Browse the repository at this point in the history
Add download of data bundle for powerd-data
  • Loading branch information
ClaraBuettner authored Sep 3, 2024
2 parents a55b1cf + 5aa309d commit bfef8ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/egon/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,12 @@ data-bundle:
sources:
zenodo:
deposit_id: 10226009
deposit_id_powerd: 11618105
targets:
file:
'data_bundle_egon_data.zip'
file_powerd:
'data_bundle_powerd_data.zip'

pypsa-technology-data:
sources:
Expand Down
19 changes: 18 additions & 1 deletion src/egon/data/datasets/data_bundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,32 @@ def download():
with zipfile.ZipFile(target_file, "r") as zip_ref:
zip_ref.extractall(".")

powerd_data_bundle_path = Path(".") / "data_bundle_powerd_data"
# Delete folder if it already exists
if powerd_data_bundle_path.exists() and powerd_data_bundle_path.is_dir():
shutil.rmtree(powerd_data_bundle_path)

url = f"""https://zenodo.org/record/{sources['deposit_id_powerd']}/files/data_bundle_powerd_data.zip"""
target_file = egon.data.config.datasets()["data-bundle"]["targets"]["file_powerd"]

# Retrieve files
urlretrieve(url, target_file)

with zipfile.ZipFile(target_file, "r") as zip_ref:
zip_ref.extractall(".")


class DataBundle(Dataset):
def __init__(self, dependencies):
deposit_id = egon.data.config.datasets()["data-bundle"]["sources"][
"zenodo"
]["deposit_id"]
deposit_id_powerd = egon.data.config.datasets()["data-bundle"]["sources"][
"zenodo"
]["deposit_id"]
super().__init__(
name="DataBundle",
version=str(deposit_id) + "-0.0.2",
version=str(deposit_id) + str(deposit_id_powerd) + "-0.0.3",
dependencies=dependencies,
tasks=(download),
)

0 comments on commit bfef8ab

Please sign in to comment.