set mem/size=1000 cancel region sp rm calcjet.txt use ACTtransport_insitu.nc use ACT_2010-2013_full_gridded_ts.nc define axis/x/units=meter dist=distance let vcross=v[d=2,gx=dist@asn] let vsouth=if vcross lt 0 then vcross else 0 ! calculation of Tbox: let calcbox=vcross[x=0:219000@din,z=@din] ! calculation of Tjet: ! (1) integrate southward velocities from coast to offshore, then store let vint=vcross[z=@din] let vints=vsouth[z=@din] let vintint=vcross[z=@din,x=@iin] let vintints=vsouth[z=@din,x=@iin] save/file=tmp.nc/clobber calcbox,vint,vints,vintint,vintints cancel var calcbox,vint,vints,vintint,vintints; use tmp.nc !mess ! (2) search for the first northward maximum by building the derivative and find zero crossing ! (2a) derivative let vintddc=vint[x=@ddc] ! (2b) smooth (may not be required) let vintddcs=vintddc ![i=@shn:7] ! (2c) find zero crossing of derivative by searching between positive and negative derivative let xxx=if (vintddcs[i=@shf:-1] gt 0 and vintddcs lt 0) then i ! (3) identify cumulative transport of southward velocities at this point. If not found, take full section repeat/l=1:2078 (list/file=calcjet.txt/nohead/app vintints[i=`missing(xxx[x=110000:300000@min],601)`]) define grid/t=time grd file/grid=grd/var=calcjet calcjet.txt set win 1 plot calcjet,ACTjet[d=1] list calcjet[l=@ave],ACTjet[d=1,l=@ave] set win 2 plot calcjet[l=@shn:11],ACTjet[l=@shn:11,d=1] frame/file=verify_ACTtrans.gif