Esempio n. 1
0
# Log
logfile = code_file_name(ext='log')
if os.path.exists(logfile): os.remove(logfile)
f = open(logfile, 'w')
print >>f, 'NY=%(ny)i, NX=%(nx)i'%locals()

# Loop on methods
for tool, methods in config.items():
    for method in methods:
#        print tool.upper(), method
        print >>f, tool.upper(), method
        
        # rect...
        t0 = time()
        r = CDATRegridder(vari, gridor, tool=tool, method=method)
        t1 = time()
        dt = t1-t0
        varo = r(vari)
        print >>f,  ' rect: ini=%5.1f s + reg=%5.2f s %s'%(dt, time()-t1, psinfo())
        
        # curved
        t0 = time()
        r = CDATRegridder(vari, gridoc, tool=tool, method=method)
        t1 = time()
        dt = t1-t0
        varo = r(vari)
        print >>f,  ' curv: ini=%5.1f s + reg=%5.2f s %s'%(dt, time()-t1, psinfo())
        
f.close()

    for method in methods:
        if rank==0: 
            t0 = time()
            print >>f, tool.upper(), method, ':' 
            diag = {'dstAreaFractions': None}
        else: diag = None
        try:
            varo = vari.regrid(grido, tool=tool, method=method, diag=diag)
            if rank==0: print >>f, ' ok'
        except:
            if rank==0: 
                print >>f, ' failed'
                print >>f, format_exc()
            continue
        if rank==0: 
            print >>f, tool.upper(), method, ':', '%5.1f'%(time()-t0), 'seconds', psinfo()
            frac = diag['dstAreaFractions']
            if frac is not None:
                mask = frac<=1.e-3
                frac[mask] = 1.
                frac = N.resize(frac, varo.shape)
                mask = N.resize(mask, varo.shape)
                varo[:] /= frac
                varo[:] = MV2.masked_where(mask, varo, copy=0)
#        del r
        gc.collect()
        if rank==0: 
            print >>f, ' plot'
            P.figure(figsize=(12, 6))
            P.subplots_adjust(right=0.9)
            P.subplot(121)
Esempio n. 3
0
            diag = {'dstAreaFractions': None}
        else:
            diag = None
        diag = {}
        try:
            varo = vari.regrid(grido, tool=tool, method=method, diag=diag)
            if rank == 0: print >> f, ' ok'
        except:
            if rank == 0:
                print >> f, ' failed'
                print >> f, format_exc()
            continue
        print 'diag:', diag
        if rank == 0 and False:
            print >> f, tool.upper(), method, ':', '%5.1f' % (
                time() - t0), 'seconds', psinfo()
            frac = diag['dstAreaFractions']
            if frac is not None:
                mask = frac <= 1.e-3
                frac[mask] = 1.
                frac = N.resize(frac, varo.shape)
                mask = N.resize(mask, varo.shape)
                varo[:] /= frac
                varo[:] = MV2.masked_where(mask, varo, copy=0)
#        del r
        gc.collect()
        if rank == 0:
            print >> f, ' plot'
            P.figure(figsize=(12, 6))
            P.subplots_adjust(right=0.9)
            P.subplot(121)