CORDEX-be2 / ValEnsPy

A Python package to Validate Ensembles of gridded model data
GNU General Public License v3.0
1 stars 0 forks source link

Bug: Inpumanager put in single year for period does not work #91

Closed Ivanderkelen closed 3 months ago

Ivanderkelen commented 4 months ago

Describe the bug I a single year is used as input into the input manager, an error occurs.

ds = manager.load_data("ERA5",["tas"], period=[1995],freq="daily",region=region)

--> [207](https://vscode-remote+tunnel-002bvsc-002dvsc31332-002ddodrio.vscode-resource.vscode-cdn.net/dodrio/scratch/projects/2022_200/project_output/RMIB-UGent/vsc31332_inne/ValEnsPy/src/valenspy/input_manager.py:207)     year_regex = f"({'|'.join([str(year) for year in range(period[0], period[1]+1)])})"
    [208](https://vscode-remote+tunnel-002bvsc-002dvsc31332-002ddodrio.vscode-resource.vscode-cdn.net/dodrio/scratch/projects/2022_200/project_output/RMIB-UGent/vsc31332_inne/ValEnsPy/src/valenspy/input_manager.py:208)     components.append(year_regex)
    [209](https://vscode-remote+tunnel-002bvsc-002dvsc31332-002ddodrio.vscode-resource.vscode-cdn.net/dodrio/scratch/projects/2022_200/project_output/RMIB-UGent/vsc31332_inne/ValEnsPy/src/valenspy/input_manager.py:209) if freq:

IndexError: list index out of range

Expected behavior Allow for the input manager to handle a single year

Environment (super) computer - hortense Branch - dev Conda environment - valenspy_dev Other relevant environment information:

Minimal Reproducible Example

import valenspy as vp
manager = vp.InputManager(machine='hortense')
ds = manager.load_data("ERA5",["tas"], period=[1995],freq="daily",region='europe')"""

Additional context Current workaround: using two times the same year works:

ds = manager.load_data("ERA5",["tas"], period=[1995, 1995],freq="daily",region='europe')

Ivanderkelen commented 4 months ago

@kobebryant432 maybe something for you to take a look at? (not urgent as workaround is present)

kobebryant432 commented 3 months ago

This is a quick fix - would you prefer the solution work for:

period=2009 #or 
period=[2009]

or both?

Ivanderkelen commented 3 months ago

both would allow the user optimal flexibility. Thanks!