Пример #1
0
def do(gts):
  """
  Do our 15 minute interval thing
  """
  rain = numpy.zeros( (642, 1020), 'f')
  for m in [-10,-5,0]:
      now = gts + mx.DateTime.RelativeDateTime(minutes=m)
      fp = now.strftime("/mesonet/ARCHIVE/data/%Y/%m/%d/GIS/uscomp/n0r_%Y%m%d%H%M.png")
      if not os.path.isfile(fp):
        continue
      n0r = gdal.Open(fp, 0)
      n0rd = ((n0r.ReadAsArray())[y0:y1,x0:x1] - 6.0) * 5.0
      rain += (0.036 * (10 ** (0.0625 * numpy.where(n0rd > 65, 65, n0rd))) / 12.0)

  # Now we back query, augh
  data = numpy.zeros((134,173), 'f')
  for x in range(173):
    for y in range(134):
      data[y,x] = rain[ n0r_y[y,x], n0r_x[y,x] ]

  fn = gts.strftime("../data/rainfall/product/%Y/%Y%m%d/IA%Y%m%d_%H%M.dat")
  writeArray(data, fn, 'w')
Пример #2
0
    outfilename = sys.argv[2]
except:
    print "Usage:", sys.argv[0], "infile outfile"
    sys.exit(1)

# read (x,y) data from file into a NumPy array data:
from Scientific.IO.ArrayIO import readArray, writeArray
data = readArray(infilename)

# transform y values:


def myfunc(y):
    # y is a NumPy array
    lt0_indices = less(y, 0)  # find all indices where y<0
    r = y**5 * exp(-y)
    # truncate, i.e., insert 0 for all indices where y<0:
    y = where(lt0_indices, 0.0, r)
    return y


y = data[:, 1]
y = myfunc(y)

# create a two-dimensional NumPy array with (x,myfunc(y)):
newdata = transpose(array([data[:, 0], y]))

# dump the new data to file:
writeArray(newdata, outfilename)
# end
Пример #3
0
import sys, math
from numpy import *
"""
As datatrans3a.py, but using Hinsen's Scientific.IO.ArrayIO module.
"""
    
try:
    infilename = sys.argv[1];  outfilename = sys.argv[2]
except:
    print "Usage:",sys.argv[0], "infile outfile"; sys.exit(1)

# read (x,y) data from file into a NumPy array data:
from Scientific.IO.ArrayIO import readArray, writeArray
data = readArray(infilename)

# transform y values:

def myfunc(y):
    # y is a NumPy array
    return where(y < 0, 0.0, y**5*exp(-y))

y = data[:,1]
y = myfunc(y)

# create a two-dimensional NumPy array with (x,myfunc(y)):
newdata = array([data[:,0], y]).transpose()

# dump the new data to file:
writeArray(newdata, outfilename)
# end