acept.dwd_try_data_handling
Module for handling DWD TRY data.
- Use this module to:
read DWD TRY data as a Xarray Dataset
preprocess DWD TRY data
combine multiple DWD TRY datasets (temperature, direct radiation, and global radiation) into a single Xarray Dataset for use in acept
uncompress DWD TRY data to make file reading faster
check if DWD TRY data is available in the correct subdirectory of
acept.acept_constants.DWD_TRY_PATH
- raises ValueOutsideRangeError:
if years are outside the allowed range (see
acept.dwd_try_data_handling.DWD_MAX_RANGE)- raises ValueError:
if an unknown DWD feature is requested
Note
To set up the DWD TRY data, use the module acept.dwd_try_data_setup
Module Contents
Functions
|
Read a DWD netCDF file and return the data as a Xarray Dataset. |
|
Preprocess the DWD TRY dataset to make it ready for use. |
|
Preprocess the combined DWD TRY dataset to make it ready for use. |
|
Combine the DWD TRY data files (of 'temperature', 'rad_direct', 'rad_global') for Bavaria and save them as netCDF |
|
Combine the DWD TRY data files (of 'temperature', 'rad_direct', 'rad_global') for Bavaria and save them as netCDF |
Whether the combined DWD TRY data is downloaded in the correct directory for the given years. If not, return False. |
|
|
Whether DWD TRY data was downloaded in the correct directory for the given year. If not, return False. |
|
Path to the DWD TRY data file for the given feature, year, and month. |
Attributes
Minimum year of DWD TRY data available to download. |
|
Maximum year of DWD TRY data. |
|
1995-2012. |
- acept.dwd_try_data_handling.DWD_MIN_YEAR = 1995[source]
Minimum year of DWD TRY data available to download.
- acept.dwd_try_data_handling.DWD_MAX_RANGE[source]
1995-2012.
- Type:
Maximum range of years of DWD TRY data available to download as a python range object
- acept.dwd_try_data_handling.read_dwd_netcdf_file(dwd_feature: str, year, month, debug: bool = True) xarray.Dataset[source]
Read a DWD netCDF file and return the data as a Xarray Dataset.
- Parameters:
dwd_feature (str) – The DWD feature to read. Valid options are “temperature”, “rad_direct”, and “rad_global” or “combined_try” for all three features in the same file.
year – The year of the data.
month – The month of the data.
debug (bool) – (optional) Whether to print debug information. Defaults to True.
- Returns:
The data read from the netCDF file.
- Return type:
- acept.dwd_try_data_handling.preprocess_dwd_try_dataset(wd_data: xarray.Dataset, dwd_feature: str, debug: bool = True) xarray.Dataset[source]
Preprocess the DWD TRY dataset to make it ready for use.
Use this function to preprocess the DWD TRY dataset for use in ACEPT. This is the same as
preprocess_combined_dwd_try_datasetbut for the individual DWD TRY datasets. This step is necessary to use to read the individual DWD TRY datasets.- Parameters:
wd_data (xarray.Dataset) – The Xarray Dataset to preprocess.
dwd_feature (str) – The DWD feature to read. Valid options are “temperature”, “rad_direct”, and “rad_global” or “combined_try” for all three features in the same file.
debug (bool) – (optional) Whether to print debug information. Defaults to True.
- Returns:
The preprocessed Xarray Dataset.
- Return type:
- acept.dwd_try_data_handling.preprocess_combined_dwd_try_dataset(wd_data: xarray.Dataset, debug: bool = True) xarray.Dataset[source]
Preprocess the combined DWD TRY dataset to make it ready for use.
Use this function to preprocess the combined DWD TRY dataset for use in ACEPT. This is the same as
preprocess_dwd_try_datasetbut for the combined DWD TRY dataset. This step is necessary to use to read the combined DWD TRY dataset.- Parameters:
wd_data (xarray.Dataset) – The Xarray Dataset to preprocess.
debug (bool) – Whether to print debug information. Defaults to True.
- Returns:
The preprocessed Xarray Dataset.
- Return type:
- acept.dwd_try_data_handling.combine_dwd_try_data_and_save(year_start: int = DWD_MIN_YEAR, year_end: int = DWD_MAX_YEAR, debug: bool = True, uncompressed_years: None | list[int] = None)[source]
Combine the DWD TRY data files (of ‘temperature’, ‘rad_direct’, ‘rad_global’) for Bavaria and save them as netCDF files.
Included features: temperature, direct and global radiation. Combine the data for these features for Bavaria for the given years and the monthly files. This makes using the TRY data easier and more efficient. Store the data in uncompressed netCDF files to speed up reading the data.
- Parameters:
- Raises:
ValueOutsideRangeError – if year_start or year_end is outside the allowed range (see
acept.dwd_try_data_handling.DWD_MAX_RANGE)
- acept.dwd_try_data_handling.combine_dwd_try_data_and_save_single_year(bavaria_shape: geopandas.GeoDataFrame, year_spec: int, debug: bool = True, uncompressed_years: None | list[int] = None)[source]
Combine the DWD TRY data files (of ‘temperature’, ‘rad_direct’, ‘rad_global’) for Bavaria and save them as netCDF files. Included features: temperature, direct and global radiation. Combine the data for these features for Bavaria for the given year and the monthly files.
- Parameters:
bavaria_shape (geopandas.GeoDataFrame) – shape of Bavaria
year_spec (int) – year of the data set to be combined
debug (bool) – if True, print debug information
uncompressed_years (None | list[int]) – optional list of years to be combined and saved without compression. Defaults to None.
- Raises:
ValueOutsideRangeError – if year_spec is outside the allowed range (see
acept.dwd_try_data_handling.DWD_MAX_RANGE)
- acept.dwd_try_data_handling.check_for_un_compressed_dwd_try_data(compressed=True, year_start: int = DWD_MIN_YEAR, year_end: int = DWD_MAX_YEAR) bool[source]
Whether the combined DWD TRY data is downloaded in the correct directory for the given years. If not, return False. If yes, return True.
- Parameters:
- Raises:
ValueOutsideRangeError – if year_start or year_end is outside the allowed range (see
acept.dwd_try_data_handling.DWD_MAX_RANGE)- Returns:
whether the combined DWD TRY data is there
- Return type:
- acept.dwd_try_data_handling.check_for_dwd_try_data_year(year: int, types_to_check: list[str] = ['temperature', 'rad_direct', 'rad_global']) bool[source]
Whether DWD TRY data was downloaded in the correct directory for the given year. If not, return False. If yes, return True.
- Parameters:
- Raises:
ValueOutsideRangeError – if year is outside the allowed range (see
acept.dwd_try_data_handling.DWD_MAX_RANGE)- Returns:
whether the specified DWD TRY data is there
- Return type: