From 555c49274c0d509f9b944056a060d407cd61bb11 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Thu, 27 Feb 2020 08:41:37 -0500 Subject: [PATCH 1/3] BUG: list of keys Fixed dimension logic by explicitly creating a list of keys. --- pysatModels/utils/extract.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pysatModels/utils/extract.py b/pysatModels/utils/extract.py index 32a4d3fc..51bcdb65 100644 --- a/pysatModels/utils/extract.py +++ b/pysatModels/utils/extract.py @@ -19,9 +19,9 @@ from __future__ import unicode_literals import numpy as np -import pandas as pds import scipy.interpolate as interpolate +import pandas as pds import pysat.utils as pyutils import pysatModels as ps_mod @@ -743,11 +743,12 @@ def extract_modelled_observations(inst, model, inst_name, mod_name, if i > 0] # Find relevent dimensions for cycling and slicing - ind_dims = [k for k, kk in enumerate(inst_name) - if kk in idim_names] + ind_dims = [k for k, iname in enumerate(inst_name) + if iname in idim_names] imod_dims = [k for k in ind_dims if mod_name[k] in dims] - ind_dims = [inst.data.coords.keys().index(inst_name[k]) + coord_keys = [ckey for ckey in inst.data.coords.keys()] + ind_dims = [coord_keys.index(inst_name[k]) for k in imod_dims] # Set the number of cycles From 63c1ab3370c8b66b2643e8e4be4506ef832a09f1 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Thu, 27 Feb 2020 08:42:18 -0500 Subject: [PATCH 2/3] STY: import order and docstrings Updated docstring to include all routines and fixed import blocks. --- pysatModels/utils/match.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysatModels/utils/match.py b/pysatModels/utils/match.py index e9adcb30..461fc062 100644 --- a/pysatModels/utils/match.py +++ b/pysatModels/utils/match.py @@ -8,6 +8,7 @@ Routines -------- +load_model_xarray collect_inst_model_pairs """ @@ -18,8 +19,8 @@ import datetime as dt import numpy as np from os import path -from pandas import (DateOffset, date_range) +from pandas import (DateOffset, date_range) import pysat from pysatModels.utils import extract From 749beb26ddcf2093cf9573602b96d5f2fb83febb Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Thu, 5 Mar 2020 10:18:27 -0500 Subject: [PATCH 3/3] ENH: added try/except for model file loading Added try/except for model file loading to allow model loading routines to fail informatively using IOError or ValueError, and still allow the rest of the files to load. --- pysatModels/utils/match.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pysatModels/utils/match.py b/pysatModels/utils/match.py index 461fc062..2fe361c6 100644 --- a/pysatModels/utils/match.py +++ b/pysatModels/utils/match.py @@ -17,12 +17,14 @@ from __future__ import unicode_literals import datetime as dt +import logging import numpy as np from os import path from pandas import (DateOffset, date_range) import pysat +import pysatModels from pysatModels.utils import extract @@ -209,7 +211,12 @@ def collect_inst_model_pairs(start, stop, tinc, inst, inst_download_kwargs={}, istart = start while start < stop: # Load the model data for each time - mdata = model_load_rout(start, **model_load_kwargs) + try: + mdata = model_load_rout(start, **model_load_kwargs) + except (IOError, ValueError) as err: + pysatModels.logger.info( + 'unable to load model data at {:}\n{:}'.format(start, err)) + mdata = None if mdata is not None: # Get the range for model longitude