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)) livea = woa.mask(fa, fieldNull(namea)) livem = woa.mask(fm, fieldNull(namem)) lives = woa.subset(Random(1), 10, livem) #plotField3(namet,depth,ft,live=livet) plotField3(namen, depth, fn, live=livem) plotField3(namem, depth, fm, live=livem) plotField3(namet, depth, ft, live=livet) plotField3(namem, depth, sub(fm, ft), live=livem) plotField3(namea, depth, sub(fa, ft), live=livea) #plotField3(named,depth,fd,live=livem) #plotField3(namee,depth,fe,live=livem) #plotField3(named,depth,fd,live=lives) plotField3(namem, depth, sub(fm, ft), live=lives) return fr = sub(fm, ft) fs, lons, lats = woa.scattered(lives, fr) ds, lons, lats = woa.scattered(lives, fd) #ds = add(ds,???) 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.setModelCovariance(sc) #kg.setPaciorek(True) kg.setDataError(ds) #kg = BlendedGridder2(tensors,fs,lons,lats) print "kg" gr = kg.grid(slon, slat) plotField3(namek, depth, gr, live=livea) gm = add(gr, ft) print "gr"
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)) livea = woa.mask(fa,fieldNull(namea)) livem = woa.mask(fm,fieldNull(namem)) lives = woa.subset(Random(1),10,livem) #plotField3(namet,depth,ft,live=livet) plotField3(namen,depth,fn,live=livem) plotField3(namem,depth,fm,live=livem) plotField3(namet,depth,ft,live=livet) plotField3(namem,depth,sub(fm,ft),live=livem) plotField3(namea,depth,sub(fa,ft),live=livea) #plotField3(named,depth,fd,live=livem) #plotField3(namee,depth,fe,live=livem) #plotField3(named,depth,fd,live=lives) plotField3(namem,depth,sub(fm,ft),live=lives) return fr = sub(fm,ft) fs,lons,lats = woa.scattered(lives,fr) ds,lons,lats = woa.scattered(lives,fd) #ds = add(ds,???) 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.setModelCovariance(sc) #kg.setPaciorek(True) kg.setDataError(ds) #kg = BlendedGridder2(tensors,fs,lons,lats) print "kg" gr = kg.grid(slon,slat) plotField3(namek,depth,gr,live=livea) gm = add(gr,ft) print "gr"
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)
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)