ghg_forcing_for_cmip.download_ground_based#
Download ground-based data
The task of this module is data scraping of the GHG concentration data from (A)GAGE and NOAA networks
Functions:
| Name | Description |
|---|---|
add_lat_lon_bnds |
Add latitude and longitude boundaries to d_combined |
compute_bounds |
Compute lower and upper boundary of grid cell |
download_agage |
Download methane concentrations from (A)GAGE database |
download_surface_data |
Download and preprocess surface GHG concentration |
download_zip_from_noaa |
Download NOAA data as NETCDF zip-file |
get_indices |
Compute indices based on CONFIG.LAT/LON_BINS |
merge_netCDFs |
Combine netCDF files into a single dataframe |
postprocess_agage |
Unzip and merge single AGAGE data files |
stats_from_events |
Compute summary statistics from event-data |
validate_surface_data |
Validate column types of dataframe using type schema |
add_lat_lon_bnds #
Add latitude and longitude boundaries to d_combined
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_combined
|
DataFrame
|
combined dataframe |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
combined dataframe with latitude and longitude boundaries |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
compute_bounds #
compute_bounds(
values_idx: NDArray[Union[int_, float32]],
bounds: NDArray[Union[int_, float32]],
boundary_val: Union[int, float],
) -> tuple[
NDArray[Union[int_, float32]],
NDArray[Union[int_, float32]],
]
Compute lower and upper boundary of grid cell
helper function for add_lat_lon_bnds()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values_idx
|
NDArray[Union[int_, float32]]
|
np.array of indices into bounds |
required |
bounds
|
NDArray[Union[int_, float32]]
|
np.array of bin edges |
required |
boundary_val
|
Union[int, float]
|
boundary values for min/max |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray[Union[int_, float32]], NDArray[Union[int_, float32]]]
|
lower boundary, upper boundary |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
download_agage #
download_agage(save_to_path: Path) -> None
Download methane concentrations from (A)GAGE database
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_to_path
|
Path
|
path where data should be stored |
required |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
download_surface_data #
download_surface_data(
gas: str,
remove_original_files: bool,
save_to_path: str = "data/downloads",
) -> None
Download and preprocess surface GHG concentration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas
|
str
|
greenhouse gas, either ch4 or co2 |
required |
save_to_path
|
str
|
path to save the results |
'data/downloads'
|
remove_original_files
|
bool
|
whether downloaded files should be kept; otherwise they are removed |
required |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
download_zip_from_noaa #
Download NOAA data as NETCDF zip-file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gas
|
str
|
target greenhouse gas variable; either 'co2' or 'ch4' |
required |
sampling_strategy
|
str
|
either 'insitu' or 'flask' |
required |
save_to_path
|
Path
|
path to save downloaded data |
required |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
get_indices #
get_indices(
values: Series[Any],
bounds: NDArray[Union[int_, float32]],
) -> NDArray[Union[int_, float32]]
Compute indices based on CONFIG.LAT/LON_BINS
helper function for add_lat_lon_bnds()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Series[Any]
|
latitude/longitude series from data frame |
required |
bounds
|
NDArray[Union[int_, float32]]
|
latitude/longitude bins as set in CONFIG file |
required |
Returns:
| Type | Description |
|---|---|
NDArray[Union[int_, float32]]
|
array with indices |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
merge_netCDFs #
Combine netCDF files into a single dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extract_dir
|
Path
|
path to extracted netCDF files |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
combined dataframe |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
postprocess_agage #
Unzip and merge single AGAGE data files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zip_path
|
Path
|
Path to the zip file (e.g., "data/downloads/") |
required |
extract_dir
|
Path
|
path to extracted netCDF files |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
combined data files from single AGAGE datasets |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
stats_from_events #
Compute summary statistics from event-data
Compute mean, std_dev, and count values across events for insitu data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
insitu data |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
data including mean value, std, and count across events for insitu data |
Source code in src/ghg_forcing_for_cmip/download_ground_based.py
validate_surface_data #
Validate column types of dataframe using type schema
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
postprocessed dataframe |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
final validated dataframe |