Skip to content

Commit

Permalink
Merge a1c49c2 into 91719ae
Browse files Browse the repository at this point in the history
  • Loading branch information
oberrauch committed May 29, 2019
2 parents 91719ae + a1c49c2 commit 382b076
Show file tree
Hide file tree
Showing 13 changed files with 2,640 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -10,6 +10,9 @@ __pycache__
# coverage stuffs
.coverage

# OS generated files
.DS_Store

# Notebook stuffs
examples/*checkpoints
.ipynb_checkpoints
Expand All @@ -24,6 +27,7 @@ result_images
*.egg
*.egg-info
eggs
*.eggs

# specific
*.cache
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Expand Up @@ -29,6 +29,7 @@ matrix:
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=models MPL=
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=benchmark MPL=
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=utils MPL=
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=vascaling MPL=
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=True
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=False
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=graphics MPL=--mpl
Expand All @@ -43,6 +44,8 @@ matrix:
os: linux
- env: TEST_CONTAINER=20190409 OGGM_TEST_ENV=utils MPL=
os: linux
- env: TEST_CONTAINER=20190409 OGGM_TEST_ENV=vascaling MPL=
os: linux
- env: TEST_CONTAINER=20190409 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=True
os: linux
- env: TEST_CONTAINER=20190409 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=False
Expand All @@ -59,6 +62,8 @@ matrix:
os: linux
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=utils MPL=
os: linux
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=vascaling MPL=
os: linux
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=True
os: linux
- env: TEST_CONTAINER=py37 OGGM_TEST_ENV=workflow MPL=--mpl OGGM_TEST_MULTIPROC=False
Expand Down
5 changes: 5 additions & 0 deletions docs/whats-new.rst
Expand Up @@ -33,6 +33,11 @@ Enhancements
By `Fabien Maussion <https://github.com/fmaussion>`_.
- Added an option to pre-process all DEMs at once (:pull:`771`).
By `Fabien Maussion <https://github.com/fmaussion>`_.
- Added support for another evolution model: the volume-area-scaling based
model of Marzeion et al., 2012 (:pull:`662`). This is a major enhancement
to the code base as it increases the number of choices available to users
and demonstrates the modularity of the model.
By `Moritz Oberrauch <https://github.com/oberrauch>`_.


Bug fixes
Expand Down
25 changes: 16 additions & 9 deletions oggm/cfg.py
Expand Up @@ -210,6 +210,10 @@ def __setitem__(self, key, value):
_doc = 'Calving output (deprecated).'
BASENAMES['calving_output'] = ('calving_output.pkl', _doc)

_doc = "A dict containing the glacier's t*, bias, mu*. Analogous " \
"to 'local_mustar.json', but for the volume/area scaling model."
BASENAMES['vascaling_mustar'] = ('vascaling_mustar.json', _doc)


def set_logging_config(logging_level='INFO'):
"""Set the global logger parameters.
Expand Down Expand Up @@ -385,15 +389,18 @@ def initialize(file=None, logging_level='INFO'):
for k in cp:
PARAMS[k] = cp.as_float(k)

# Read-in the reference t* data - maybe it will be used, maybe not
fns = ['ref_tstars_rgi5_cru4', 'ref_tstars_rgi6_cru4',
'ref_tstars_rgi5_histalp', 'ref_tstars_rgi6_histalp']
for fn in fns:
PARAMS[fn] = pd.read_csv(get_demo_file('oggm_' + fn + '.csv'))
fpath = get_demo_file('oggm_' + fn + '_calib_params.json')
with open(fpath, 'r') as fp:
mbpar = json.load(fp)
PARAMS[fn+'_calib_params'] = mbpar
# Read-in the reference t* data for all available models types (oggm, vas)
model_prefixes = ['oggm_', 'vas_']
for prefix in model_prefixes:
fns = ['ref_tstars_rgi5_cru4', 'ref_tstars_rgi6_cru4',
'ref_tstars_rgi5_histalp', 'ref_tstars_rgi6_histalp']
for fn in fns:
fpath = get_demo_file(prefix + fn + '.csv')
PARAMS[prefix + fn] = pd.read_csv(fpath)
fpath = get_demo_file(prefix + fn + '_calib_params.json')
with open(fpath, 'r') as fp:
mbpar = json.load(fp)
PARAMS[prefix + fn + '_calib_params'] = mbpar

# Empty defaults
set_intersects_db()
Expand Down
6 changes: 3 additions & 3 deletions oggm/core/climate.py
Expand Up @@ -1038,15 +1038,15 @@ def local_t_star(gdir, *, ref_df=None, tstar=None, bias=None):
v = gdir.rgi_version[0] # major version relevant

# Check that the params are fine
str_s = 'cru4' if 'CRU' in source else 'histalp'
vn = 'ref_tstars_rgi{}_{}_calib_params'.format(v, str_s)
s = 'cru4' if 'CRU' in source else 'histalp'
vn = 'oggm_ref_tstars_rgi{}_{}_calib_params'.format(v, s)
for k in params:
if cfg.PARAMS[k] != cfg.PARAMS[vn][k]:
msg = ('The reference t* you are trying to use was '
'calibrated with different MB parameters. You '
'might have to run the calibration manually.')
raise MassBalanceCalibrationError(msg)
ref_df = cfg.PARAMS['ref_tstars_rgi{}_{}'.format(v, str_s)]
ref_df = cfg.PARAMS['oggm_ref_tstars_rgi{}_{}'.format(v, s)]
else:
# Use the the local calibration
fp = os.path.join(cfg.PATHS['working_dir'], 'ref_tstars.csv')
Expand Down
2 changes: 1 addition & 1 deletion oggm/core/flowline.py
Expand Up @@ -399,7 +399,7 @@ def __init__(self, flowlines, mb_model=None, y0=0., glen_a=None,
mb_model : MassBalanceModel
the MB model to use
y0 : int
the starting year of the simultation
the starting year of the simulation
glen_a : float
glen's parameter A
fs: float
Expand Down
2 changes: 1 addition & 1 deletion oggm/core/massbalance.py
Expand Up @@ -856,7 +856,7 @@ def get_annual_mb(self, heights, year=None, fl_id=None):
class MultipleFlowlineMassBalance(MassBalanceModel):
"""Handle mass-balance at the glacier level instead of flowline level.
Convenience class doing not much more than wraping a list of mass-balance
Convenience class doing not much more than wrapping a list of mass-balance
models, one for each flowline.
This is useful for real-case studies, where each flowline might have a
Expand Down

0 comments on commit 382b076

Please sign in to comment.