diff --git a/Python/00_get_inventory.py b/Python/00_get_inventory.py new file mode 100644 index 0000000000000000000000000000000000000000..f5ff519bb33777500a704ab0f279e0f63be50481 --- /dev/null +++ b/Python/00_get_inventory.py @@ -0,0 +1,29 @@ +"""Inventory of EuroCordex simuations.""" + +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +# externals +import pandas as pd + +# locals +from pysegcnn.core.utils import search_files + +# parameters defining a Cordex climate simulation +CORDEX_PARAMETERS = ['Variable', 'Domain', 'Gcm', 'Scenario', 'Ensemble', + 'Rcm', 'Version', 'Frequency', 'Years'] + + +def get_inventory(path): + + # find all netcdf files in path + inventory = search_files(path, '(.*).nc$') + + # create dictionary: (filename: [simulation parameters]) + inventory = {k: k.stem.split('_') for k in inventory} + + # create a DataFrame + df = pd.DataFrame(data=inventory.values(), index=inventory.keys(), + columns=CORDEX_PARAMETERS) + + return df