miranda.eccc package¶
Environment and Climate Change Canada specialized conversion module.
Submodules¶
miranda.eccc._homogenized module¶
Adjusted and Homogenized Canadian Clime Data module.
- miranda.eccc._homogenized.convert_ahccd(data_source: str | Path, output_dir: str | Path, variable: str, generation: int | None = None) None[source]¶
Convert Adjusted and Homogenized Canadian Climate Dataset files.
- Parameters:
data_source (str or Path)
output_dir (str or Path)
variable (str)
generation (int, optional)
- Returns:
None
- miranda.eccc._homogenized.convert_ahccd_fwf_files(ff: Path | str, metadata: DataFrame, variable: str, generation: int | None = None, cols_specs: list[tuple[int, int]] | None = None, attrs: dict | None = None) Dataset[source]¶
Convert AHCCD fixed-width files.
- Parameters:
ff (str or Path)
metadata (pandas.DataFrame)
variable (str)
generation
cols_specs
attrs
- Returns:
xarray.Dataset
- miranda.eccc._homogenized.create_canhomt_xarray(in_files: list, variable_meta: dict, station_meta: DataFrame, project: str) Dataset | None[source]¶
Create a xarray dataset from CanHomT raw .csv files.
- Parameters:
in_files (list) – A list of input files.
variable_meta (dict) – Variable metadata.
station_meta (pd.DataFrame) – Station metadata.
project (str) – Project name.
- Returns:
xr.Dataset, optional – Dataset.
- miranda.eccc._homogenized.download_canhomt(project: str, working_folder: str | PathLike[str] | None = None, update_raw: bool = False, timeout: int | None = None, retry: int = 5, n_workers: int | None = None) None[source]¶
Download CanHomT data.
- Parameters:
project ({“canhomt_dly”}) – Project name.
working_folder (str or os.PathLink[str], optional) – Temporary files folder.
update_raw (bool) – Whether to update the raw files or not.
timeout (int, optional) – Request timeout in seconds.
retry (int) – Number of retries.
n_workers (int, optional) – Number of workers to use. Not implemented.
- Raises:
ValueError – If the project name is unknown.
OSError – If there is an error downloading the data.
miranda.eccc._raw module¶
- miranda.eccc._raw.aggregate_stations(source_files: str | PathLike | None = None, output_folder: str | PathLike | None = None, time_step: str | None = None, variables: str | int | list[str | int] | None = None, include_flags: bool = True, groupings: int | None = None, mf_dataset_freq: str | None = None, temp_directory: str | PathLike | None = None, n_workers: int = 1) None[source]¶
Aggregate stations.
- Parameters:
source_files (str or Path) – Source files to be aggregated.
output_folder (str or Path) – Output folder for the aggregated files.
variables (str or int or list of str or int, optional) – The variable codes to be aggregated.
time_step ({“hourly”, “daily”}) – The time step to be used for aggregation.
include_flags (bool) – Include flags in the output files.
groupings (int) – The number of files in each group used for converting to multi-file Datasets.
mf_dataset_freq (str, optional) – Resampling frequency for creating output multi-file Datasets. E.g. ‘YS’: 1 year per file, ‘5YS’: 5 years per file.
temp_directory (str or Path, optional) – Use another temporary directory location in case default location is not spacious enough.
n_workers (int) – The number of workers to use.
- Returns:
None
- miranda.eccc._raw.convert_flat_files(source_files: str | PathLike, output_folder: str | PathLike | list[str | int], variables: str | int | list[str | int], mode: str = 'hourly', n_workers: int = 4) None[source]¶
Convert flat formatted files.
- Parameters:
source_files (str or Path)
output_folder (str or Path)
variables (str or List[str])
mode ({“hourly”, “daily”})
n_workers (int)
- Returns:
None
- miranda.eccc._raw.merge_converted_variables(source_files: str | PathLike, output_folder: str | PathLike, variables: str | int | list[str | int] | None = None, station_metadata: str | PathLike | None = None, overwrite: bool = False, n_workers: int = 1) None[source]¶
Merge converted variables.
- Parameters:
source_files (str, Path)
output_folder (str, Path)
variables (str or int or list of str or int, optional)
station_metadata (str or Path, optional)
overwrite (bool)
n_workers (int)
- Returns:
None
miranda.eccc._support_rvt module¶
- miranda.eccc._support_rvt.gather_eccc_stations(timestep: str, start_date: datetime | str | None = None, end_date: datetime | str | None = None, climate_id: str | None = None) DataFrame[source]¶
Collect ECCC station data from the Environment and Climate Change Canada API.
- Parameters:
timestep (str)
start_date (datetime.datetime or str, optional)
end_date (datetime.datetime or str, optional)
climate_id (str, optional)
- Returns:
pandas.DataFrame
miranda.eccc._utils module¶
miranda.eccc.geomet module¶
ECCC Geomet Module.