Example #1
0
def buildT2():
    nyrs = 10
    lat = pyg.regularlat(31)
    lon = pyg.regularlon(60)
    time = pyg.ModelTime365(values=np.arange(nyrs*365), \
            units='days', startdate={'year':2011, 'month':1, 'day':1})
    pres = pyg.Pres(np.arange(1000, 0, -50.))
    z = 6.6 * pyg.log(1000. / pres)

    ts1 = 2 * pyg.sin(2 * np.pi * time / 365.) + 4 * pyg.Var(
        (time, ), values=np.random.randn(nyrs * 365))
    ts1 = ts1.smooth('time', 20)
    ts2 = -5 + 0.6 * time / 365. + 5 * pyg.Var(
        (time, ), values=np.random.randn(nyrs * 365))
    ts2 = ts2.smooth('time', 20)

    T_c = 260. + 40. * pyg.exp(-(
        (lat - 10 * np.sin(2 * np.pi * time / 365)) / 45.)**2)
    T_wave = 0.05 * lat * pyg.sind(6 * lon - time)  # * ts1
    T_lapse = -5 * z

    Tf = (T_lapse + T_c + T_wave).transpose('time', 'pres', 'lat', 'lon')
    Tf.name = 'Temp'

    U_c = 40 * pyg.sind(2 * lat)**2 * pyg.sin(2 * np.pi * z / 12)**2
    U_wave = 0.08 * lat * pyg.sind(6 * lon - time)
    U = (U_c + ts2 * U_wave).transpose('time', 'pres', 'lat', 'lon')
    U.name = 'U'
    return pyg.Dataset(
        [Tf, U],
        atts={
            'history':
            'Synthetic Temperature and Wind data generated by pygeode'
        })
Example #2
0
def test_issue044():
    import pygeode as pyg
    import numpy as np
    time = pyg.ModelTime365(values=np.arange(100),
                            units='days',
                            startdate=dict(year=1, month=1))
    ts = time.smooth('time', 20)
    ts[0]
Example #3
0
def test_issue053():
    import pygeode as pyg
    import numpy as np
    l = pyg.regularlat(30)
    t = pyg.ModelTime365(values=np.arange(100),
                         units='days',
                         startdate=dict(year=1, month=1))
    v = pyg.Var((t, l), name='Test', values=np.ones((100, 30)))
    v.plotatts['scalefactor'] = 2.
    v.plotatts['plottitle'] = 'V'

    a = l * v
    b = t + v

    assert a.plotatts == v.plotatts
    assert b.plotatts == v.plotatts
Example #4
0
import pylab as pyl 
import pygeode as pyg, numpy as np

t = pyg.ModelTime365(values = np.arange(100), units='days', startdate=dict(year=1, month=1))
y1 = pyg.exp(-t / 30.) * pyg.cos(2*np.pi * t / 20.)
y2 = pyg.exp(-t / 30.) * pyg.sin(2*np.pi * t / 20.)
y1 = y1.rename('y1')
y2 = y2.rename('y2')

pyl.ioff()
ax = pyg.plot.AxesWrapper()
pyg.vplot(y1, label='y1', c='r', lw=2, axes=ax)
pyg.vplot(y2, label='y2', c='b', lw=2, axes=ax)

ax.setp(title = 'Two lines', ylabel='')
ax.setp_xaxis(major_formatter=pyg.timeticker.TimeFormatter(t, '$b'))

ax.legend(loc='lower right', frameon=False)

pyl.ion()
ax.render(1)