ghg_forcing_for_cmip.utils#
Module including helper functions
Functions:
| Name | Description |
|---|---|
clean_and_save |
Clean up folder and save final dataset |
unzip_download |
Unzips a given ZIP file into the target directory. |
weighted_average |
Compute area weighted average |
clean_and_save #
clean_and_save(
df: DataFrame,
gas: str,
save_to_path: Path,
measurement_type: str,
remove_original_files: bool,
) -> None
Clean up folder and save final dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
final, post-processed data |
required |
gas
|
str
|
greenhouse gas, either ch4 or co2 |
required |
save_to_path
|
Path
|
path to save the results |
required |
measurement_type
|
str
|
string used to discriminate ground_based and satellite data from each other; either "gb" or "eo" |
required |
remove_original_files
|
bool
|
whether downloaded files should be kept; otherwise they are removed |
required |
Source code in src/ghg_forcing_for_cmip/utils.py
unzip_download #
Unzips a given ZIP file into the target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zip_path
|
Path
|
Path to the zip file (e.g., "data/downloads/noaa_ch4_surface_flask.zip") |
required |
extract_dir
|
Path
|
Path where the files should be extracted. |
required |
Source code in src/ghg_forcing_for_cmip/utils.py
weighted_average #
Compute area weighted average
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
DataFrame
|
raw data frame |
required |
grouping_vars
|
list[str]
|
column names (variables) that should be used to average over |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
data frame with value corresponding to weighted-by-area value |