Skip to content

Commit

Permalink
Further unification of log messages (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion authored Sep 8, 2017
1 parent ea29f4b commit d7e8a60
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions oggm/core/models/flowline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ def random_glacier_evolution(gdir, nyears=1000, y0=None, bias=None,

steps = ['default', 'conservative', 'ultra-conservative']
for step in steps:
log.info('%s: trying %s time stepping scheme.', gdir.rgi_id, step)
log.info('(%s) trying %s time stepping scheme.', gdir.rgi_id, step)
fls = gdir.read_pickle('model_flowlines')
if zero_initial_glacier:
for fl in fls:
Expand All @@ -1604,7 +1604,7 @@ def random_glacier_evolution(gdir, nyears=1000, y0=None, bias=None,
raise
continue
# If we get here we good
log.info('%s: %s time stepping was successful!', gdir.rgi_id, step)
log.info('(%s) %s time stepping was successful!', gdir.rgi_id, step)
break

return model
Expand Down
4 changes: 2 additions & 2 deletions oggm/core/preprocessing/centerlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def compute_centerlines(gdir, div_id=None):

# Final check
if len(cls) == 0:
raise RuntimeError('{} : no centerline found!'.format(gdir.rgi_id))
raise RuntimeError('({}) no centerline found!'.format(gdir.rgi_id))

# Write the data
gdir.write_pickle(cls, 'centerlines', div_id=div_id)
Expand Down Expand Up @@ -971,7 +971,7 @@ def compute_downstream_lines(gdir):

# Final check
if len(cls) == 0:
raise RuntimeError('{} : problem by downstream!'.format(gdir.rgi_id))
raise RuntimeError('({}) problem by downstream!'.format(gdir.rgi_id))

# Write the data
gdir.write_pickle(cls, 'centerlines', div_id=0)
Expand Down
2 changes: 1 addition & 1 deletion oggm/core/preprocessing/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def mu_candidates(gdir, div_id=None, prcp_sf=None):

# Check that we found a least one mustar
if np.sum(np.isfinite(mu_yr_clim)) < 1:
raise RuntimeError('No mustar candidates found for {}'
raise RuntimeError('({}) no mustar candidates found.'
.format(gdir.rgi_id))

# Write
Expand Down
4 changes: 2 additions & 2 deletions oggm/core/preprocessing/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,8 @@ def catchment_width_correction(gdir, div_id=None):
log.warning('(%s) reduced min n per bin to %d', gdir.rgi_id,
nmin)
if nmin == 0:
raise RuntimeError('NO binsize could be chosen for: '
'{}'.format(gdir.rgi_id))
raise RuntimeError('({}) no binsize could be chosen '
.format(gdir.rgi_id))
if bsize > 150:
log.warning('(%s) chosen binsize %d', gdir.rgi_id, bsize)
else:
Expand Down
5 changes: 3 additions & 2 deletions oggm/core/preprocessing/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,12 @@ def glacier_masks(gdir):
# see how many percent of the dem
if np.sum(~isfinite) > (0.2 * nx * ny):
raise RuntimeError('({}) too many NaNs in DEM'.format(gdir.rgi_id))
log.warning(gdir.rgi_id + ': DEM needed zeros somewhere.')
log.warning('({}) DEM needed zeros somewhere.'.format(gdir.rgi_id))
dem[isfinite] = 0

if np.min(dem) == np.max(dem):
raise RuntimeError(gdir.rgi_id + ': min equal max in the DEM.')
raise RuntimeError('({}) min equal max in the DEM.'
.format(gdir.rgi_id))

# Proj
if LooseVersion(rasterio.__version__) >= LooseVersion('1.0'):
Expand Down
8 changes: 4 additions & 4 deletions oggm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ def _entity_task(gdir, reset=None, **kwargs):

# Log what we are doing
if not task_func.__dict__.get('divide_task', False):
self.log.info('%s: %s', gdir.rgi_id, task_func.__name__)
self.log.info('(%s) %s', gdir.rgi_id, task_func.__name__)

# Run the task
try:
Expand All @@ -1989,7 +1989,7 @@ def _entity_task(gdir, reset=None, **kwargs):
out = None
gdir.log(task_func, err=err)
pipe_log(gdir, task_func, err=err)
self.log.error('%s occured during task %s on %s!',
self.log.error('%s occurred during task %s on %s!',
type(err).__name__, task_func.__name__, gdir.rgi_id)
if not cfg.PARAMS['continue_on_error']:
raise
Expand Down Expand Up @@ -2017,7 +2017,7 @@ def __init__(self, log, add_0=False):
self.add_0 = add_0
self._cdoc = """"
div_id : int
the ID of the divide to process. Should be left to the default
the ID of the divide to process. Should be left to the default
``None`` unless you know what you do.
"""

Expand All @@ -2031,7 +2031,7 @@ def _divide_task(gdir, div_id=None, **kwargs):
if self.add_0:
ids = list(ids) + [0]
for i in ids:
self.log.info('%s: %s, divide %d', gdir.rgi_id,
self.log.info('(%s) %s, divide %d', gdir.rgi_id,
task_func.__name__, i)
task_func(gdir, div_id=i, **kwargs)
else:
Expand Down

0 comments on commit d7e8a60

Please sign in to comment.