예제 #1
0
def goKriging():
    namet = "s00an1"  # trend
    namea = "s10an1"  # NODC gridded
    namem = "s10mn1"  # sample mean
    named = "s10sd1"  # sample std dev
    namee = "s10se1"  # sample std err
    namen = "s10dd1"  # number of samples
    namek = "s10kg1"  # Kriging gridded
    depth = 100
    level = depthLevel(depth)
    ft = readDataFile(namet, level)
    fa = readDataFile(namea, level)
    fm = readDataFile(namem, level)
    fd = readDataFile(named, level)
    fe = readDataFile(namee, level)
    fn = readDataFile(namen, level)
    fd = woa.sdfix(fn, fd)
    fe = woa.sefix(fn, fe)
    print "median of sd =", woa.nmed(1, 10, fn, fd)
    print "median of se =", woa.nmed(1, 10, fn, fe)
    livet = woa.mask(ft, fieldNull(namet))
    livem = woa.mask(fm, fieldNull(namem))
    livea = woa.mask(fa, fieldNull(namea))
    lives = woa.subset(Random(1), 5, livea)
    plotField3(namet, depth, ft, live=livet)
    plotField3(namem, depth, fm, live=livem)
    plotField3(namea, depth, fa, live=lives)
    plotField3(namea, depth, fa, live=livea)
    fr = sub(fa, ft)
    fs, lons, lats = woa.scattered(lives, fr)
    #ds,lons,lats = woa.scattered(lives,fd)
    #ds = add(ds,0.1)
    tensors = woa.makeTensors(livea)
    sc = SmoothCovariance(1.0, 1.0, 5.0, 2)
    nlon, nlat = slon.count, slat.count
    #sc.testSpd(nlon,nlat,tensors)
    #print "sc"
    #kg = KrigingGridder2(tensors,fs,lons,lats)
    kg = KrigingGridder2(fs, lons, lats)
    kg.setModelCovariance(sc)
    #kg.setPaciorek(True)
    #kg.setDataError(ds)
    #kg = BlendedGridder2(tensors,fs,lons,lats)
    print "kg"
    gr = kg.grid(slon, slat)
    ga = add(gr, ft)
    plotField3(namek, depth, ga, live=livea)
    print "gr"
예제 #2
0
파일: woa.py 프로젝트: BKJackson/idh
def goKriging():
  namet = "s00an1" # trend
  namea = "s10an1" # NODC gridded
  namem = "s10mn1" # sample mean
  named = "s10sd1" # sample std dev
  namee = "s10se1" # sample std err
  namen = "s10dd1" # number of samples
  namek = "s10kg1" # Kriging gridded
  depth = 100
  level = depthLevel(depth)
  ft = readDataFile(namet,level)
  fa = readDataFile(namea,level)
  fm = readDataFile(namem,level)
  fd = readDataFile(named,level)
  fe = readDataFile(namee,level)
  fn = readDataFile(namen,level)
  fd = woa.sdfix(fn,fd)
  fe = woa.sefix(fn,fe)
  print "median of sd =",woa.nmed(1,10,fn,fd)
  print "median of se =",woa.nmed(1,10,fn,fe)
  livet = woa.mask(ft,fieldNull(namet))
  livem = woa.mask(fm,fieldNull(namem))
  livea = woa.mask(fa,fieldNull(namea))
  lives = woa.subset(Random(1),5,livea)
  plotField3(namet,depth,ft,live=livet)
  plotField3(namem,depth,fm,live=livem)
  plotField3(namea,depth,fa,live=lives)
  plotField3(namea,depth,fa,live=livea)
  fr = sub(fa,ft)
  fs,lons,lats = woa.scattered(lives,fr)
  #ds,lons,lats = woa.scattered(lives,fd)
  #ds = add(ds,0.1)
  tensors = woa.makeTensors(livea)
  sc = SmoothCovariance(1.0,1.0,5.0,2)
  nlon,nlat = slon.count,slat.count
  #sc.testSpd(nlon,nlat,tensors)
  #print "sc"
  #kg = KrigingGridder2(tensors,fs,lons,lats)
  kg = KrigingGridder2(fs,lons,lats)
  kg.setModelCovariance(sc)
  #kg.setPaciorek(True)
  #kg.setDataError(ds)
  #kg = BlendedGridder2(tensors,fs,lons,lats)
  print "kg"
  gr = kg.grid(slon,slat)
  ga = add(gr,ft)
  plotField3(namek,depth,ga,live=livea)
  print "gr"
예제 #3
0
def fieldClips(name, m, f):
    code = fieldCode(name)
    if code == "bn":
        return 1, 58
    elif code == "dl":
        return 2, 40
    else:
        return woa.clips(2, 98, m, f)
예제 #4
0
파일: woa.py 프로젝트: jyzhou/idh
def fieldClips(name,m,f):
  code = fieldCode(name)
  if code=="bn":
    return 1,58
  elif code=="dl":
    return 2,40
  else:
    return woa.clips(2,98,m,f)
예제 #5
0
파일: woa.py 프로젝트: jyzhou/idh
def plotField3(name,depth,f,live=None):
  eimage = readEarthImage()
  #eimage = makeGrayImage(eimage)
  fimage,cmap,cbar,title = None,None,None,None
  if name and f:
    if not live:
      fnull = fieldNull(name)
      live = woa.mask(f,fnull)
    fmin = woa.min(live,f)
    fmax = woa.max(live,f)
    print name,depth,": live =",woa.count(live)," fmin =",fmin," fmax =",fmax
    cmin,cmax = fieldClips(name,live,f)
    cmap = colorMap(name,cmin,cmax)
    fimage = SampledImage.fromFloats(slon,slat,live,f,cmap)
    cbar = valueLabel(name)
    title = makeTitle(name,depth)
  plot3(eimage,fimage,cmap=cmap,cbar=cbar,title=title)
예제 #6
0
def plotField3(name, depth, f, live=None):
    eimage = readEarthImage()
    #eimage = makeGrayImage(eimage)
    fimage, cmap, cbar, title = None, None, None, None
    if name and f:
        if not live:
            fnull = fieldNull(name)
            live = woa.mask(f, fnull)
        fmin = woa.min(live, f)
        fmax = woa.max(live, f)
        print name, depth, ": live =", woa.count(
            live), " fmin =", fmin, " fmax =", fmax
        cmin, cmax = fieldClips(name, live, f)
        cmap = colorMap(name, cmin, cmax)
        fimage = SampledImage.fromFloats(slon, slat, live, f, cmap)
        cbar = valueLabel(name)
        title = makeTitle(name, depth)
    plot3(eimage, fimage, cmap=cmap, cbar=cbar, title=title)
예제 #7
0
"""
Get mask from objectively analyzed data
Construct tensors
Get sample means and standard deviations
Make random subset of sample means (with new mask)
Subtract annual mean from sample means
Fit using tensor-guided kriging
"""

from shared import *
import gph.Woa as woa
from interp import *

pngDir = None
#pngDir = "../../png/woa/"
slon = woa.getLonSampling()
slat = woa.getLatSampling()


def main(args):
    #goShowData()
    goKriging()


def goKriging():
    namet = "s00an1"  # trend
    namea = "s10an1"  # NODC gridded
    namem = "s10mn1"  # sample mean
    named = "s10sd1"  # sample std dev
    namee = "s10se1"  # sample std err
    namen = "s10dd1"  # number of samples
예제 #8
0
파일: woa.py 프로젝트: jyzhou/idh
"""
Get mask from objectively analyzed data
Construct tensors
Get sample means and standard deviations
Make random subset of sample means (with new mask)
Subtract annual mean from sample means
Fit using tensor-guided kriging
"""

from shared import *
import gph.Woa as woa
from interp import *

pngDir = None
#pngDir = "../../png/woa/"
slon = woa.getLonSampling()
slat = woa.getLatSampling()

def main(args):
  #goShowData()
  goKriging()

def goKriging():
  namet = "s00an1" # trend
  namea = "s10an1" # NODC gridded
  namem = "s10mn1" # sample mean
  named = "s10sd1" # sample std dev
  namee = "s10se1" # sample std err
  namen = "s10dd1" # number of samples
  namek = "s10kg1" # Kriging gridded
  depth = 100