Esempio n. 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'
        })
Esempio n. 2
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'})
Esempio n. 3
0
def buildT1():
  lat = pyg.regularlat(31)
  lon = pyg.regularlon(60)

  T_c = 260. + 40. * pyg.exp(-(lat/45.)**2)
  T_wave = 0.05 * lat * pyg.sind(6*lon)
  T = T_c + T_wave
  T.name = 'Temp'
  T.units = 'K'

  return pyg.Dataset([T], atts={'history':'Synthetic Temperature data generated by pygeode'})
Esempio n. 4
0
import pylab as pyl
import pygeode as pyg, numpy as np

lat = pyg.regularlat(60)
lon = pyg.regularlon(120)

x = pyg.sin(2 * np.pi * lon / 180.) * pyg.exp(-(lat - 30)**2 / (2 * 10**2))
y = pyg.sin(2 * np.pi * lon / 180.) * pyg.exp(-(lat + 40)**2 / (2 * 10**2))

pyl.ioff()
ax = pyg.plot.AxesWrapper()
pyg.vcontour(y,
             clevs=np.linspace(-1, 1, 21),
             clines=None,
             cmap=pyl.cm.PuBuGn,
             axes=ax)
pyg.vcontour(x,
             clevs=None,
             clines=np.linspace(-1, 1, 21),
             linewidths=1.,
             colors='k',
             axes=ax)

ax.setp(title='Filled contours and contour lines')

pyl.ion()
ax.render(1)
Esempio n. 5
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)