Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Update pandas version (#21)
Browse files Browse the repository at this point in the history
Update pandas version
  • Loading branch information
ocefpaf authored Oct 17, 2019
2 parents 480356a + 315a80e commit a3ac94c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
14 changes: 6 additions & 8 deletions ioos_tools/ioos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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


Expand Down
13 changes: 11 additions & 2 deletions ioos_tools/skill_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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})
Expand Down
1 change: 0 additions & 1 deletion ioos_tools/tardis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
lxml

0 comments on commit a3ac94c

Please sign in to comment.