def degrade(): import subprocess as sp import os tr = trm.trm('casco',"decorr") tr.load(intstart=5859329) # 04-15 pl.clf() dslist = [] for t in np.arange(1,9): #proc = sp.Popen(['/Users/bror/git/orm/runtraj', 'degrade', str(t)] ) #proc.wait() os.system('/Users/bror/git/orm/runtraj degrade '+ str(t)) td = trm.trm('casco',"degrade") td.load(intstart=5859329) # 04-15 dist = ([nanmean(tr.dist(td,tr.jd==tr.jdmin+h/24, td.jd==td.jdmin+h/24)) for h in np.arange(48.)]) pl.plot(np.array(dist)*0.2) dslist.append(np.array(dist)) return dslist
def load_tr(filename): tr = trm.trm('casco',"full") trl = stload.load(filename) tr.ints = trl.ints tr.ntrac = trl.ntrac tr.x = trl.x tr.y = trl.y tr.z = trl.z tr.jd = trl.jd tr.jdmin = tr.jd.min() return tr
def rms(field='salt'): """ Make a nrmsd vs dt plot""" tr = trm.trm('casco',"full") cs = casco.GCM() cs.fatten_landmask() cs.fatten_landmask() tr.load(intstart=5858969) #tr.load(intstart=5859217) tr.z[cs.landmask[tr.y.astype(int), tr.x.astype(int)]==0] = np.nan dtvec = hrvec(tr)-tr.jdmin def get_field(jd): field = tr.traj2grid('z',tr.jd==jd) field[cs.landmask==0]=np.nan return np.ravel(field) msk0 = tr.jd==tr.jdmin fld0 = np.ravel(cs.get_field(field,tr.jdmin)) fld0 = get_field(tr.jdmin) lagvec = [] eulvec = [] def eulmsk(diffmat): eulmsk = cs.landmask*np.nan eulmsk[diffmat[:,1].astype(np.int), diffmat[:,0].astype(np.int)] = diffmat[:,3]-diffmat[:,2] return eulmsk*0+1 for dt in dtvec: diffmat = tr.lagr_diff('z',msk0,tr.jd==(tr.jdmin+dt)) rmsd,nrmsd = tr.rmsd(diffmat[:,3],diffmat[:,2],False) lagvec.append(nrmsd) fld1 = np.ravel(cs.get_field(field,tr.jdmin+dt) * eulmsk(diffmat)) fld1 = get_field(tr.jdmin+dt) rmsd,nrmsd = tr.rmsd(fld0,fld1,False) eulvec.append(nrmsd) pl.clf() pl.plot(dtvec*24,np.array(lagvec)*100) pl.plot((dtvec*24)[0:-2:2],(np.array(eulvec)*100)[0:-2:2]) pl.xlabel('Time (hours)') pl.ylabel('NRMSD (%)') pl.xlim(0,48) pl.ylim(0,14) pl.legend(('Lagrangian frame','Eularian frame'),'upper left') pl.title('Temporal decorrelation of %s' % field) pl.savefig('figs/nrmsd_%s.png' % field) pl.xlim(0,12) pl.ylim(0,10) pl.savefig('figs/nrmsd_%s_detail.png' % field)
def eulrms(): pl.clf() cs = casco.GCM() tr = trm.trm('casco',"full") tr.load(intstart=5858969) dtvec = hrvec(tr)-tr.jdmin def get_salt(jd): return np.ravel(tr.traj2grid('z',tr.jd==jd)) fld0 = get_salt(tr.jdmin) rmsvec = [] for dt in dtvec: fld1 = get_salt(tr.jdmin+dt) rmsd,nrmsd = tr.rmsd(fld0,fld1) rmsvec.append(rmsd) pl.clf() pl.plot(dtvec*24,np.array(rmsvec)*100,'*-') pl.xlabel('Time (hours)') pl.ylabel('NRMSD (%)') pl.xlim(0,24)