Verified Commit b25ebfe0 authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Better warning handling

parent 18d181b4
Pipeline #25413 passed with stage
in 1 minute and 2 seconds
......@@ -4,6 +4,7 @@ Here are tools to read and write files relating to SWMF.
import datetime as dt
import warnings
import numpy as np
from .tools import _make_line
......@@ -287,7 +288,13 @@ def read_gm_log(filename, colnames=None, dtypes=None, index_time=True):
if dtypes:
data = dtypes[col](data)
data = float(data)
data = float(data)
except ValueError as err:
data = np.nan
warnings.warn('Value error and no manual dtype set'
+ ' changing to NaN',
# datetime index
......@@ -17,6 +17,7 @@ import os.path
import shutil
import urllib
import urllib.request
import warnings
from dateutil import rrule
import numpy as np
from .tools import _nearest, carrington_rotation_number
......@@ -484,7 +485,8 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
for filename in filenames:
# Only try to download if the file does not exist
if os.path.isfile(directory+filename) == True:
raise RuntimeWarning(f'{filename} exists, not downloading')
warnings.warn(f'{filename} exists, not downloading',
# open the file locally
with open(directory + filename, 'wb') as fhandle:
Supports Markdown
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