miranda.eccc package#
- miranda.eccc.aggregate_stations(source_files: str | PathLike | None = None, output_folder: str | PathLike | None = None, time_step: str | None = None, variables: str | int | List[int | str] | 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]#
- Parameters:
source_files (Union[str, Path])
output_folder (Union[str, Path])
variables (Optional[Union[str, int, List[Union[str, int]]]])
time_step ({“hourly”, “daily”})
include_flags (bool)
groupings (int) – The number of files in each group used for converting to multi-file Datasets.
mf_dataset_freq (Optional[str]) – Resampling frequency for creating output multi-file Datasets. E.g. ‘YS’: 1 year per file, ‘5YS’: 5 years per file.
temp_directory (Optional[Union[str, Path]]) – Use another temporary directory location in case default location is not spacious enough.
n_workers (int)
- Returns:
None
- miranda.eccc.convert_ahccd(data_source: str | Path, output_dir: str | Path, variable: str, generation: int | None = None)[source]#
- miranda.eccc.convert_ahccd_fwf_files(ff, metadata, variable, generation: int | None = None, cols_specs: List[Tuple[int, int]] | None = None, attrs: dict | None = None) Dataset [source]#
- miranda.eccc.convert_flat_files(source_files: str | PathLike, output_folder: str | PathLike | List[int | str], variables: str | int | List[int | str], mode: str = 'hourly', n_workers: int = 4) None [source]#
- 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.daily_summaries_to_netcdf(station: dict, path_output: Path | str) None [source]#
- Parameters:
station (dict) – dict created by using find_and_extract_dly
path_output (Union[Path, str])
- Returns:
None
- miranda.eccc.extract_daily_summaries(path_station: Path | str, rm_flags: bool = False, file_suffix: str = '.csv') dict [source]#
- Parameters:
path_station (Union[Path, str]) – PathLike or str to the station’s folder containing the csv files.
rm_flags (bool) – Removes the ‘Flag’ and ‘Quality’ columns of the ECCC files.
file_suffix (str) – File suffixes used by the tabular data. Default: “.csv”.
- Returns:
dict – dict containing the station metadata, as well as the data stored within a pandas Dataframe.
- miranda.eccc.merge_converted_variables(source_files: str | PathLike, output_folder: str | PathLike, variables: str | int | List[int | str] | None = None, station_metadata: str | PathLike | None = None, overwrite: bool = False, n_workers: int = 1) None [source]#
- Parameters:
source_files (Union[str, Path])
output_folder (Union[str, Path])
variables (Optional[Union[str, int, List[Union[str, int]]]])
station_metadata (Optional[Union[str, Path]])
overwrite (bool)
n_workers (int)
- Returns:
None
Submodules#
miranda.eccc._homogenized module#
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[int | str] | 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]#
- Parameters:
source_files (Union[str, Path])
output_folder (Union[str, Path])
variables (Optional[Union[str, int, List[Union[str, int]]]])
time_step ({“hourly”, “daily”})
include_flags (bool)
groupings (int) – The number of files in each group used for converting to multi-file Datasets.
mf_dataset_freq (Optional[str]) – Resampling frequency for creating output multi-file Datasets. E.g. ‘YS’: 1 year per file, ‘5YS’: 5 years per file.
temp_directory (Optional[Union[str, Path]]) – Use another temporary directory location in case default location is not spacious enough.
n_workers (int)
- Returns:
None
- miranda.eccc._raw.convert_flat_files(source_files: str | PathLike, output_folder: str | PathLike | List[int | str], variables: str | int | List[int | str], mode: str = 'hourly', n_workers: int = 4) None [source]#
- 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[int | str] | None = None, station_metadata: str | PathLike | None = None, overwrite: bool = False, n_workers: int = 1) None [source]#
- Parameters:
source_files (Union[str, Path])
output_folder (Union[str, Path])
variables (Optional[Union[str, int, List[Union[str, int]]]])
station_metadata (Optional[Union[str, Path]])
overwrite (bool)
n_workers (int)
- Returns:
None
miranda.eccc._summaries module#
- miranda.eccc._summaries.daily_summaries_to_netcdf(station: dict, path_output: Path | str) None [source]#
- Parameters:
station (dict) – dict created by using find_and_extract_dly
path_output (Union[Path, str])
- Returns:
None
- miranda.eccc._summaries.extract_daily_summaries(path_station: Path | str, rm_flags: bool = False, file_suffix: str = '.csv') dict [source]#
- Parameters:
path_station (Union[Path, str]) – PathLike or str to the station’s folder containing the csv files.
rm_flags (bool) – Removes the ‘Flag’ and ‘Quality’ columns of the ECCC files.
file_suffix (str) – File suffixes used by the tabular data. Default: “.csv”.
- Returns:
dict – dict containing the station metadata, as well as the data stored within a pandas Dataframe.
miranda.eccc._support_rvt module#
- class miranda.eccc._support_rvt.Path(*args, **kwargs)[source]#
Bases:
PurePath
PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
- absolute()[source]#
Return an absolute version of this path. This function works even if the path doesn’t point to anything.
No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.
- classmethod cwd()[source]#
Return a new path pointing to the current working directory (as returned by os.getcwd()).
- expanduser()[source]#
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
- glob(pattern)[source]#
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
- hardlink_to(target)[source]#
Make this path a hard link pointing to the same file as target.
Note the order of arguments (self, target) is the reverse of os.link’s.
- classmethod home()[source]#
Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
- is_file()[source]#
Whether this path is a regular file (also True for symlinks pointing to regular files).
- iterdir()[source]#
Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.
- lchmod(mode)[source]#
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
- link_to(target)[source]#
Make the target path a hard link pointing to this path.
Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.
Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.
- lstat()[source]#
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
- open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]#
Open the file pointed by this path and return a file object, as the built-in open() function does.
- read_text(encoding=None, errors=None)[source]#
Open the file in text mode, read it, and close the file.
- rename(target)[source]#
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- replace(target)[source]#
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- resolve(strict=False)[source]#
Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).
- rglob(pattern)[source]#
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
- samefile(other_path)[source]#
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
- stat(*, follow_symlinks=True)[source]#
Return the result of the stat() system call on this path, like os.stat() does.
- symlink_to(target, target_is_directory=False)[source]#
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- touch(mode=438, exist_ok=True)[source]#
Create this file with the given access mode, if it doesn’t exist.
miranda.eccc._utils module#
- miranda.eccc._utils.cf_ahccd_metadata(code: str, gen: int) -> (typing.Mapping[str, typing.Union[int, float, str]], typing.Dict, typing.List[typing.Tuple[int, int]], <class 'int'>)[source]#
- Parameters:
code ({“dx”, “dn”, “dm”, “dt”, “ds”, “dr”})
gen ({1, 2, 3})
- Returns:
Mapping[str, Union[str, float]], Dict, List[Tuple[int, int]], int