PyGEM
PyGEM copied to clipboard
Support for PyGEM climate files added in OGGM
Hi, I've added support for the files you provided me in https://github.com/OGGM/oggm/pull/1031
This creates a netdf file in the glacier directory with all the data you need. (I think). The only differences you might see are:
- we correct the original precip and provide monthly sums in mm.
- the time is already cropped to match the hydrological year in both hemispheres.
Here is a code to read and display the data:
rgi_ids = ['RGI60-11.0{}'.format(i) for i in range(3200, 3220)]
# Artesonrau (SH), Hintereisferner (NH)
rgi_ids = ['RGI60-16.02444', 'RGI60-11.00897']
# Locals
import oggm.cfg as cfg
from oggm import utils, workflow
# Initialize OGGM and set up the default run parameters
cfg.initialize(logging_level='WORKFLOW')
cfg.PARAMS['border'] = 10
# Usually we recommend to set dl_verify to True - here it is quite slow
# because of the huge files so we just turn it off.
# Switch it on for real cases!
cfg.PARAMS['dl_verify'] = False
cfg.PATHS['working_dir'] = utils.get_temp_dir('PyGEM_ex')
# Get the pre-processed topography data
from oggm.shop import rgitopo
gdirs = rgitopo.init_glacier_directories_from_rgitopo(rgi_ids)
# Process the ECMWF climate data from David
from oggm.shop import ecmwf
workflow.execute_entity_task(ecmwf.process_ecmwf_data, gdirs, dataset='ERA5dr')
# This creates a "climate_historical.nc" file in each glacier directory with
# the data in it:
fpath = gdirs[0].get_filepath('climate_historical')
print(fpath)
# plots
import xarray as xr
import matplotlib.pyplot as plt
for gdir, name in zip(gdirs, ['Artesonraju', 'Hintereisferner']):
ds = xr.open_dataset(gdir.get_filepath('climate_historical'))
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 7))
ds.temp.plot(ax=ax1)
ds.temp_std.plot(ax=ax2)
ds.gradient.plot(ax=ax3)
ds.prcp.plot(ax=ax4)
plt.suptitle(name + ' - Ref height: {}m'.format(int(ds.ref_hgt)))