예제 #1
0
           'sensor_id': 'sensor',
           'station_id': 'station',
           'latitude (degree)': 'lat',
           'longitude (degree)': 'lon',
           'vertical_position (m)': 'height',
           'water_surface_height_above_reference_datum (m)': 'ssh above datum'}

observations.rename(columns=columns, inplace=True)

observations['datum'] = [s.split(':')[-1] for s in observations['datum']]
observations['sensor'] = [s.split(':')[-1] for s in observations['sensor']]
observations['station'] = [s.split(':')[-1] for s in observations['station']]
observations['name'] = [get_coops_longname(s) for s in observations['station']]

observations.set_index('name', inplace=True)
to_html(observations.head(), 'style.css')


# #### Generate a uniform 6-min time base for model/data comparison

# In[ ]:

import iris
from pandas import DataFrame
from owslib.ows import ExceptionReport
from utilities import coops2df, save_timeseries

iris.FUTURE.netcdf_promote = True

log.info(fmt(' Observations (station data) '))
fname = '{:%Y-%m-%d}-OBS_DATA.nc'.format(stop)
# In[4]:

from utilities import mean_bias

dfs = load_ncs(run_name)

df = apply_skill(dfs, mean_bias, remove_mean=False, filter_tides=False)
df = rename_cols(df)
skill_score = dict(mean_bias=df.copy())

# Filter out stations with no valid comparison.
df.dropna(how='all', axis=1, inplace=True)
df = df.applymap('{:.2f}'.format).replace('nan', '--')

html = to_html(df.T)
fname = os.path.join(run_name, 'mean_bias.html'.format(run_name))
save_html(fname, html)
html


# ### Skill 2: Central Root Mean Squared Error
# 
# Root Mean Squared Error of the deviations from the mean.
# 
# $$ \text{CRMS} = \sqrt{\left(\mathbf{m'} - \mathbf{o'}\right)^2}$$
# 
# where: $\mathbf{m'} = \mathbf{m} - \mathbf{\overline{m}}$ and $\mathbf{o'} = \mathbf{o} - \mathbf{\overline{o}}$

# In[5]:
from utilities import collector2table, to_html, get_ndbc_longname

ndbc = collector2table(collector=collector_ndbc)

names = []
for s in ndbc['station']:
    try:
        name = get_ndbc_longname(s)
    except ValueError:
        name = s
    names.append(name)

ndbc['name'] = names

ndbc.set_index('name', inplace=True)
to_html(ndbc.head())


# ### CoopsSoS

# In[9]:

from pyoos.collectors.coops.coops_sos import CoopsSos

collector_coops = CoopsSos()

collector_coops.set_bbox(bbox)
collector_coops.end_time = stop
collector_coops.start_time = start
collector_coops.variables = [sos_name]
    'station_id': 'station',
    'latitude (degree)': 'lat',
    'longitude (degree)': 'lon',
    'vertical_position (m)': 'height',
    'water_surface_height_above_reference_datum (m)': 'ssh above datum'
}

observations.rename(columns=columns, inplace=True)

observations['datum'] = [s.split(':')[-1] for s in observations['datum']]
observations['sensor'] = [s.split(':')[-1] for s in observations['sensor']]
observations['station'] = [s.split(':')[-1] for s in observations['station']]
observations['name'] = [get_coops_longname(s) for s in observations['station']]

observations.set_index('name', inplace=True)
to_html(observations.head(), 'style.css')

# #### Generate a uniform 6-min time base for model/data comparison

# In[ ]:

import iris
from pandas import DataFrame
from owslib.ows import ExceptionReport
from utilities import coops2df, save_timeseries

iris.FUTURE.netcdf_promote = True

log.info(fmt(' Observations (station data) '))
fname = '{:%Y-%m-%d}-OBS_DATA.nc'.format(stop)