diff --git a/ioos_tools/ioos.py b/ioos_tools/ioos.py index eb24487..f0dd8c3 100644 --- a/ioos_tools/ioos.py +++ b/ioos_tools/ioos.py @@ -535,11 +535,11 @@ def _sanitize(name): """ Examples -------- - >>> _sanitize('ROMS/TOMS') + >>> _sanitize("ROMS/TOMS") 'ROMS_TOMS' - >>> _sanitize('USEAST model') + >>> _sanitize("USEAST model") 'USEAST_model' - >>> _sanitize('GG1SST, SST') + >>> _sanitize("GG1SST, SST") 'GG1SST_SST' """ @@ -576,7 +576,7 @@ def get_model_name(url): return mod_name -@timeout_decorator.timeout(20, use_signals=False) +@timeout_decorator.timeout(40, use_signals=False) def is_station(url): from netCDF4 import Dataset @@ -651,17 +651,15 @@ def load_ncs(config): else: model = os.path.splitext(os.path.split(fname)[-1])[0].split("-")[ -1 - ] # noqa + ] df = nc2df(fname, columns_name="station_code") # FIXME: Horrible work around duplicate times. if len(df.index.values) != len(np.unique(df.index.values)): kw = {"subset": "index", "take_last": True} df = df.reset_index().drop_duplicates(**kw).set_index("index") kw = {"method": "time", "limit": 2} - df = df.reindex(index).interpolate(**kw).ix[index] + df = df.reindex(index).interpolate(**kw).loc[index] dfs.update({model: df}) - kw = {"orient": "items", "intersect": False} - dfs = pd.Panel.from_dict(dfs, **kw).swapaxes(0, 2) return dfs diff --git a/ioos_tools/skill_score.py b/ioos_tools/skill_score.py index e2de83f..33514cf 100644 --- a/ioos_tools/skill_score.py +++ b/ioos_tools/skill_score.py @@ -79,9 +79,17 @@ def r2(x, y): return r2_score(x, y) +def _get_df(dfs, station): + ret = {} + for k, v in dfs.items(): + ret.update({k: v[station]}) + return DataFrame.from_dict(ret) + + def apply_skill(dfs, function, remove_mean=True, filter_tides=False): skills = {} - for station, df in dfs.iteritems(): + for station in dfs["OBS_DATA"].columns: + df = _get_df(dfs, station) if filter_tides: df = df.apply(low_pass) skill = {} @@ -90,7 +98,8 @@ def apply_skill(dfs, function, remove_mean=True, filter_tides=False): # No observations. skills.update({station: np.NaN}) continue - for model, y in df.iteritems(): + for model in df.columns: + y = df[model] # No models. if y.isnull().all(): skills.update({station: np.NaN}) diff --git a/ioos_tools/tardis.py b/ioos_tools/tardis.py index 8dc4d1a..82f4039 100644 --- a/ioos_tools/tardis.py +++ b/ioos_tools/tardis.py @@ -28,7 +28,6 @@ def is_model(cube): Examples -------- >>> import iris - >>> iris.FUTURE.netcdf_promote = True >>> url = "http://thredds.cencoos.org/thredds/dodsC/CENCOOS_CA_ROMS_FCST.nc" >>> cubes = iris.load_raw(url, 'sea_water_potential_temperature') >>> [is_model(cube) for cube in cubes] diff --git a/requirements.txt b/requirements.txt index ebcb79c..982796a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,16 +2,17 @@ beautifulsoup4 cftime folium iris +jupyter matplotlib netcdf4 numpy oceans owslib -pandas>=0.20 +pandas>=0.25.1 pytz requests retrying scikit-learn scipy timeout-decorator -jupyter \ No newline at end of file +lxml