Commit a2153a5a authored by Maximilian Schanner's avatar Maximilian Schanner
Browse files

Fix the warnings (not printing the code anymore) and add a warning if the server is down again.

parent b5bd8044
......@@ -29,14 +29,14 @@ used in the geomagnetism community to evaluate global field models. It can be
applied to all cubic-spline based geomagnetic field models stored in the same
file format as gufm1 or the CALSxk model series.
The package exposes several methods that can be applied to splines representing
a model. To generate such splines, use the `Model` class and its attribute
`Model.splines`. With the `models` dictionary, several built-in models can be
accessed, see also the `list of included models
<index.html#included-models>`__.
The package exposes several methods that can be applied to models or splines
representing a model. To acces the models, use the `Model` class or its
attribute `Model.splines`. With the `models` dictionary, several built-in
models can be accessed, see also the `list of included models
<overview.html#included-models>`__.
'''
# expose only utilities and core modules
# expose only utilities and core members
__all__ = ['local_curve', 'dipole_series', 'file2splines', 'field',
'built_in_models', 'coefficients', 'utils', 'secular_variation',
'power_spectrum', 'Model']
......@@ -46,4 +46,11 @@ from pymagglobal.core import local_curve, dipole_series, file2splines, \
Model
from pymagglobal import utils
import warnings
# Monkey-patch the line away from warnings, as it is rather irritating.
formatwarning_orig = warnings.formatwarning
warnings.formatwarning = lambda msg, cat, fname, lineno, line=None: \
formatwarning_orig(msg, cat, fname, lineno, line='')
__version__ = '1.0.1'
......@@ -27,6 +27,15 @@ from matplotlib import pyplot as plt
from pymagglobal import core
from pymagglobal import utils
from urllib.error import URLError
from warnings import warn
class TimeOutWarning(Warning):
'''Just to give the warning a meaningful name.
'''
pass
def args2times(args):
'''Read the range of the model and create a linear array to evaluate it.
......@@ -576,7 +585,12 @@ def maps(args, fig=None):
cmap=cmaps[it],
levels=levels[it],
extend=extends[it])
axs[it].coastlines(alpha=0.8, lw=0.5)
try:
axs[it].coastlines(alpha=0.8, lw=0.5)
except URLError:
warn('Server connection timed out. Coastlines could not be '
'loaded.',
category=TimeOutWarning)
axs[it].set_global()
axs[it].set_title(f'{utils._names[args.type][it]} [{units[it]}]')
colaxs[it].tick_params(labelsize=12)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment