01_prep_maps
batch_process_all_covariates(output_dir=None, skip_existing=True)
Process all covariates in the COVARIATE_DICT and convert them to netCDF.
Parameters:
output_dir : str or Path, optional Directory to save output files. If None, uses default directory. skip_existing : bool, default=True If True, skip processing covariates that already have output files.
Returns:
dict: Dictionary with covariate names as keys and output paths as values
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
create_multiyear_netcdf(input_path_template, years, output_path, variable_name)
Create a multi-year netCDF file from individual GeoTIFF files.
Parameters:
input_path_template : str Template path with {year} to be replaced for each year years : list of int List of years to process output_path : str Path to save the combined netCDF file variable_name : str Name of the variable in the output file
Returns:
xr.Dataset: The created dataset with time dimension
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
geotiff_to_netcdf(input_path, output_path, variable_name, resolution=None, year=None, encoding=None, global_extent=True, fill_value=0.0)
Convert a GeoTIFF file to netCDF format.
Parameters:
input_path : str Path to the input GeoTIFF file output_path : str Path to save the output netCDF file variable_name : str Name of the variable to use in the netCDF file resolution : float, optional Resolution of the raster in degrees. If None, will be calculated from the transform. year : int, optional Year for the data (for time dimension) encoding : dict, optional Encoding options for xarray.to_netcdf() global_extent : bool, default=False If True, extend the raster to global lat/lon coverage (-180 to 180, -90 to 90) fill_value : float, default=0.0 Value to fill extended areas with
Returns:
xr.Dataset: The created dataset
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
main()
Main function to run when script is executed directly.
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
process_multiyear_variable(covariate_key, output_dir)
Process a multi-year variable and convert to a single netCDF with time dimension.
Parameters:
covariate_key : str Key of the covariate in the COVARIATE_DICT
Returns:
str: Path to the output netCDF file
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
process_synoptic_variable(covariate_key, output_dir)
Process a synoptic (time-invariant) variable and convert to netCDF.
Parameters:
covariate_key : str Key of the covariate in the COVARIATE_DICT
Returns:
str: Path to the output netCDF file
Source code in src/idd_forecast_mbp/map_to_admin_2/01_prep_maps.py
set_file_permissions(file_path)
Set 775 permissions (rwxrwxr-x) on the specified file.