예제 #1
0
def low_pass(series, window_size=193, T=40, dt=360):
    """
    This function applies a lanczos filter on a pandas time-series and
    returns the low pass data series.

    series : Pandas series
    window_size : Size of the filter windows (default is 96+1+96).
    T : Period of the filter. (The default of 40 hours filter should
        get rid of all tides.)
    dt : time_delta in seconds.  Default is 360 (6 minutes).

    """
    from oceans import lanc
    T *= 60 * 60.  # To seconds.
    freq = dt / T

    mask = np.isnan(series)
    avg = series.mean()
    series = series - avg
    series.interpolate(inplace=True)

    wt = lanc(window_size, freq)
    low = np.convolve(wt, series, mode='same')
    low = ma.masked_array(low, mask)
    return low + avg
예제 #2
0
def low_pass(series, window_size=193, T=40, dt=360):
    """
    This function applies a lanczos filter on a pandas time-series and
    returns the low pass data series.

    series : Pandas series
    window_size : Size of the filter windows (default is 96+1+96).
    T : Period of the filter. (The default of 40 hours filter should
        get rid of all tides.)
    dt : time_delta in seconds.  Default is 360 (6 minutes).

    """
    from oceans import lanc
    T *= 60*60.  # To seconds.
    freq = dt/T

    mask = np.isnan(series)
    avg = series.mean()
    series = series - avg
    series.interpolate(inplace=True)

    wt = lanc(window_size, freq)
    low = np.convolve(wt, series, mode='same')
    low = ma.masked_array(low, mask)
    return low+avg
예제 #3
0
shape(ts1h)

# <codecell>

roll_l = pd.rolling_mean(df['u'], window=40, center=True, freq='1H')
df.plot()

# <codecell>

import numpy as np
from oceans import lanc

window_size = 96+1+96
freq = 1./40
wt = lanc(window_size, freq)
df['low'] = np.convolve(wt, df['u'], mode='same')
df['high'] = df['u'] - df['low']

# <codecell>

import pandas as pd

roll_l = pd.rolling_mean(df['u'], window=40, center=True, freq='1H')
roll_h = df['u'] - roll_l

# <codecell>

import iris
from iris.pandas import as_cube