<br>
<p style="font-family:Arial;">
Dear all,
</p>
<p style="font-family:Arial;">
<br>
</p>
<p style="font-family:Arial;">
Thank you so much for reading the email.
</p>
<p style="font-family:Arial;">
<br>
</p>
<p style="font-family:Arial;">
I am trying to calculate the <span style="color:#1C1D1E;font-family:"Open Sans", sans-serif;font-size:12px;white-space:normal;background-color:#FFFFFF;">Sverdrup stream function (using the following equation) </span>
</p>
<p style="font-family:Arial;">
<br>
</p>
<p style="font-family:Arial;">
<img src="cid:58d9b11a$2$17cc2108453$Coremail$chatu$scsio.ac.cn">
</p>
<p style="font-family:Arial;">
<br>
</p>
<p style="font-family:Arial;">
However, My results are not correct. Could you please check the attached script and let me know where I do wrong. That would be a really great help. Please be kind to check this out.
</p>
<p style="font-family:Arial;">
<br>
</p>
<p style="font-family:Arial;">
The script:
</p>
<p style="font-family:Arial;">
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">diri="./"</span><br>
<span style="font-family:Arial;">sfile = "HR_hist_r1i1p1f1.nc" </span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">f = addfile(diri+sfile,"r")</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauuo = f->tauuo(1740:1979,:,:)</span><br>
<span style="font-family:Arial;"> printVarSummary(tauuo)</span><br>
<span style="font-family:Arial;"> printMinMax(tauuo, False)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauvo = f->tauvo(1740:1979,:,:)</span><br>
<span style="font-family:Arial;"> printVarSummary(tauvo)</span><br>
<span style="font-family:Arial;"> printMinMax(tauvo, False)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;***************wind stress curl*********************************</span><br>
<span style="font-family:Arial;">; Miscellaneous</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> lat = tauuo&lat</span><br>
<span style="font-family:Arial;"> lon = tauuo&lon </span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;">; CENTERED FINITE DIFFERENCES:</span><br>
<span style="font-family:Arial;">; Use local function [grad_latlon_cfd]</span><br>
<span style="font-family:Arial;">; to compute zonal (X) and meridional (Y) gradients.</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> gradLatLon = grad_latlon_cfd(tauuo, lat, lon, True, False) </span><br>
<span style="font-family:Arial;"> tauuoY_cfd = gradLatLon[0]</span><br>
<span style="font-family:Arial;"> tauuoX_cfd = gradLatLon[1]</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauuoY_cfd@long_name = "tauuoY: cfd"</span><br>
<span style="font-family:Arial;"> tauuoY_cfd@units = "Nm-3"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauuoX_cfd@long_name = "tauuoX: cfd"</span><br>
<span style="font-family:Arial;"> tauuoX_cfd@units = "Nm-3"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> printVarSummary(tauuoY_cfd)</span><br>
<span style="font-family:Arial;"> printMinMax(tauuoY_cfd, False) ; unscaled = True</span><br>
<span style="font-family:Arial;"> printVarSummary(tauuoX_cfd)</span><br>
<span style="font-family:Arial;"> printMinMax(tauuoX_cfd,False)</span><br>
<span style="font-family:Arial;"> print("")</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">delete([/lat,lon,gradLatLon/])</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;">; Miscellaneous</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> lat = tauvo&lat</span><br>
<span style="font-family:Arial;"> lon = tauvo&lon </span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;">; CENTERED FINITE DIFFERENCES:</span><br>
<span style="font-family:Arial;">; Use local function [grad_latlon_cfd]</span><br>
<span style="font-family:Arial;">; to compute zonal (X) and meridional (Y) gradients.</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> gradLatLon = grad_latlon_cfd(tauvo, lat, lon, True, False) </span><br>
<span style="font-family:Arial;"> tauvoY_cfd = gradLatLon[0]</span><br>
<span style="font-family:Arial;"> tauvoX_cfd = gradLatLon[1]</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauvoY_cfd@long_name = "tauvoY: cfd"</span><br>
<span style="font-family:Arial;"> tauvoY_cfd@units = "Nm-3"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> tauvoX_cfd@long_name = "tauvoX: cfd"</span><br>
<span style="font-family:Arial;"> tauvoX_cfd@units = "Nm-3"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> printVarSummary(tauuoY_cfd)</span><br>
<span style="font-family:Arial;"> printMinMax(tauvoY_cfd, False) ; True=unscaled</span><br>
<span style="font-family:Arial;"> printVarSummary(tauuoX_cfd)</span><br>
<span style="font-family:Arial;"> printMinMax(tauvoX_cfd,False)</span><br>
<span style="font-family:Arial;"> print("")</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">curl = (tauvoX_cfd-tauuoY_cfd)</span>
</p>
<p style="font-family:Arial;">
<span style="font-family:Arial;">copy_VarCoords(tauuo, curl)</span><br>
<span style="font-family:Arial;">curl@long_name = "wind stress curl"</span><br>
<span style="font-family:Arial;">curl@units = "Nm-3"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">printVarSummary(curl)</span><br>
<span style="font-family:Arial;">printMinMax(curl, False)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">curl_av = dim_avg_n_Wrap(curl, 0)</span><br>
<span style="font-family:Arial;">printVarSummary(curl_av)</span><br>
<span style="font-family:Arial;">printMinMax(curl_av, False)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">delete([/gradLatLon,curl/])</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;..........Sv stream function........</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">re = 6371000</span><br>
<span style="font-family:Arial;">density = 1027</span><br>
<span style="font-family:Arial;">omega = 7.292e-05</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">dx = 104492.5 ; in meter</span><br>
<span style="font-family:Arial;">d2rad = 0.017453 ; degrees to radians</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">lat_S = sin(lat*d2rad)</span><br>
<span style="font-family:Arial;">printMinMax(lat_S, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">coriolis = 2*omega*lat_S</span><br>
<span style="font-family:Arial;">printVarSummary(coriolis)</span><br>
<span style="font-family:Arial;">printMinMax(coriolis, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">nlat = dimsizes(curl_av&lat)</span><br>
<span style="font-family:Arial;">print(nlat)</span><br>
<span style="font-family:Arial;">nlon = dimsizes(curl_av&lon)</span><br>
<span style="font-family:Arial;">print(nlon)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> latitude = curl_av&lat</span><br>
<span style="font-family:Arial;"> longitude = curl_av&lon</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;************************************************************** </span><br>
<span style="font-family:Arial;">; calculate intergral </span><br>
<span style="font-family:Arial;">; int[lon1:lon2]curl*re*cos(lat)*dx</span><br>
<br>
<span style="font-family:Arial;">;**************************************************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">zone_int = new((/nlat,nlon/),typeof(curl_av)) ; allocate space</span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;"> do k = 0, nlon-1</span><br>
<span style="font-family:Arial;"> do j = 0, nlat-1</span><br>
<span style="font-family:Arial;"> zone_int(j,k) = dim_sum(curl_av(j,0:k)*re*cos(lat(j)*d2rad)*dx)</span><br>
<span style="font-family:Arial;"> end do</span><br>
<span style="font-family:Arial;"> end do</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">printVarSummary(zone_int)</span><br>
<span style="font-family:Arial;">printMinMax(zone_int, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">cornew = new(dimsizes(curl_av), typeof(coriolis), getFillValue(coriolis))</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">do i = 0,180</span><br>
<span style="font-family:Arial;"> do j = 0,360</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> cornew(i,j) = coriolis(i)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> end do</span><br>
<span style="font-family:Arial;"> end do</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> printVarSummary(cornew)</span><br>
<span style="font-family:Arial;"> printMinMax(cornew, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">dimcornew = dimsizes(cornew)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;">; SPHERICAL HARMONICS:</span><br>
<span style="font-family:Arial;">; Use "highly accurate" spherical harmonics procedure (gradsg)</span><br>
<span style="font-family:Arial;">; to compute zonal (X) and meridional (Y) gradients.</span><br>
<span style="font-family:Arial;">;************************************************</span><br>
<span style="font-family:Arial;"> ; pre-allocate space for return gradients</span><br>
<span style="font-family:Arial;"> cornewX_gradsg = new( dimcornew, typeof(cornew), getFillValue(cornew) ) ; lon=>X</span><br>
<span style="font-family:Arial;"> cornewY_gradsg = new( dimcornew, typeof(cornew), getFillValue(cornew) ) ; lat=>Y</span><br>
<span style="font-family:Arial;"> gradsg(cornew, cornewX_gradsg, cornewY_gradsg) ; procedure for gaussian grids</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> copy_VarCoords(cornew, cornewX_gradsg) ; add meta data</span><br>
<span style="font-family:Arial;"> copy_VarCoords(cornew, cornewY_gradsg) </span><br>
<span style="font-family:Arial;"> cornewX_gradsg@long_name = "cornewX: gradsg"</span><br>
<span style="font-family:Arial;"> cornewX_gradsg@units = "1/s2"</span><br>
<span style="font-family:Arial;"> cornewY_gradsg@long_name = "cornewY: gradsg"</span><br>
<span style="font-family:Arial;"> cornewY_gradsg@units = "1/s2"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> print("")</span><br>
<span style="font-family:Arial;"> printMinMax(cornewY_gradsg,True ) ; unscaled</span><br>
<span style="font-family:Arial;"> printMinMax(cornewX_gradsg,False)</span><br>
<span style="font-family:Arial;"> print("")</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">printVarSummary(cornewY_gradsg)</span><br>
<span style="font-family:Arial;">;print(cornewY_gradsg)</span><br>
<span style="font-family:Arial;">;</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">betarow = (cornewY_gradsg*density)</span><br>
<span style="font-family:Arial;">copy_VarCoords(curl_av, betarow)</span><br>
<span style="font-family:Arial;">printVarSummary(betarow)</span><br>
<span style="font-family:Arial;">printMinMax(betarow, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">stm = (-1/betarow) * zone_int *1e-06</span><br>
<span style="font-family:Arial;">copy_VarCoords(curl_av, stm)</span><br>
<span style="font-family:Arial;">printVarSummary(stm)</span><br>
<span style="font-family:Arial;">printMinMax(stm, True)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;print(stm(80,:))</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;**********************plot**************************</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> wks = gsn_open_wks("png","HR_sv") ; send graphics to PNG file</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> setvalues NhlGetWorkspaceObjectId</span><br>
<span style="font-family:Arial;"> "wsMaximumSize" : 300000000</span><br>
<span style="font-family:Arial;"> end setvalues</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> res = True</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> res@gsnDraw = False ;-- don't draw plot yet</span><br>
<span style="font-family:Arial;"> res@gsnFrame = False ;-- don't advance frame</span><br>
<span style="font-family:Arial;"> res@gsnMaximize = True ;-- maximize plot output</span><br>
<span style="font-family:Arial;"> res@gsnAddCyclic = False ;-- don't add cyclic points</span><br>
<span style="font-family:Arial;"> res@gsnLeftStringFontHeightF = 0.010 ;-- decrease left string font size</span><br>
<span style="font-family:Arial;"> res@gsnRightStringFontHeightF = 0.010 ;-- decrease right string font size</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels</span><br>
<span style="font-family:Arial;"> res@cnMinLevelValF = -80 ; set min contour level</span><br>
<span style="font-family:Arial;"> res@cnMaxLevelValF = 80 ; set max contour level</span><br>
<span style="font-family:Arial;"> res@cnLevelSpacingF = 1 ; set contour spacing</span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;"> res@cnFillOn = True ; turn on contour fill</span><br>
<span style="font-family:Arial;"> res@cnLinesOn = False ; turn off contour lines</span><br>
<span style="font-family:Arial;"> res@cnLineLabelsOn = False ; turn off contour labels</span><br>
<span style="font-family:Arial;"> res@cnFillDrawOrder = "PreDraw"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> res@cnFillPalette = "cmp_flux" ; set color map</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> cmap = read_colormap_file("cmp_flux") ; 16 x 4</span><br>
<span style="font-family:Arial;"> ncolors = dimsizes(cmap(:,1))</span><br>
<span style="font-family:Arial;"> print(dimsizes(cmap))</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> cmap(10,:) = namedcolor2rgba("white")</span><br>
<span style="font-family:Arial;"> cmap(11,:) = namedcolor2rgba("white")</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">res@cnFillPalette := cmap</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> res@mpFillOn = True</span><br>
<span style="font-family:Arial;"> ;res@mpOutlineOn=False</span><br>
<span style="font-family:Arial;"> res@mpGridAndLimbOn = False</span><br>
<span style="font-family:Arial;"> res@mpOutlineBoundarySets = "National"</span><br>
<span style="font-family:Arial;"> res@mpGeophysicalLineThicknessF = 1.5</span><br>
<span style="font-family:Arial;"> res@mpDataBaseVersion = "LowRes"</span><br>
<span style="font-family:Arial;"> res@mpDataSetName = "Earth.4" </span><br>
<span style="font-family:Arial;"> res@lbLabelBarOn = True</span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;"> ;res@sfXArray = lon2d ;-- longitude grid cell center</span><br>
<span style="font-family:Arial;"> ;res@sfYArray = lat2d ;-- latitude grid cell center</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;">;-- create the plot</span><br>
<span style="font-family:Arial;"> </span><br>
<span style="font-family:Arial;"> res@gsnCenterString = "Wind stress curl"</span><br>
<span style="font-family:Arial;"> res@gsnCenterStringFontHeightF = 0.013</span><br>
<span style="font-family:Arial;"> res@gsnLeftStringFontHeightF = 0.013</span><br>
<span style="font-family:Arial;"> res@gsnLeftString = "[2080-2099]-[1995-2014]"</span><br>
<span style="font-family:Arial;"> res@gsnRightStringFontHeightF = 0.013</span><br>
<span style="font-family:Arial;"> res@gsnRightString = "MPI-ESM-HR"</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> plot = gsn_csm_contour_map(wks, stm, res)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
<span style="font-family:Arial;"> ;-- draw the plot and advance the frame </span><br>
<span style="font-family:Arial;"> draw(plot)</span><br>
<span style="font-family:Arial;"> frame(wks)</span><br>
<span style="font-family:Arial;"><br>
</span><br>
Thank you very much and best regards,
</p>
<p style="font-family:Arial;">
Chathu<br>
</p>
<br>
<span style="font-family:Arial;" class="spnEditorSign">
<hr class="signature-separator" align="left" style="margin:0.5em 0;width:10em;height:1px;background-color:#999;border:none;">
<blockquote style="margin:0px 0px 0px 40px;padding:0px;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:small;font-variant-ligatures:normal;orphans:2;widows:2;border:none;">
<span style="font-style:italic;font-size:medium;"><br>
</span>
</blockquote>
<blockquote style="margin:0px 0px 0px 40px;padding:0px;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:small;font-variant-ligatures:normal;orphans:2;widows:2;border:none;">
<span style="font-style:italic;font-size:medium;"><br>
</span>
</blockquote>
<blockquote style="margin:0px 0px 0px 40px;padding:0px;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-variant-ligatures:normal;orphans:2;widows:2;border:none;">
<span style="font-style:italic;"><span style="font-size:x-small;">Wickramage Chathurika Hemamali</span></span>
<div>
<span style="font-style:italic;"><span style="font-size:x-small;">Msc in Physical Oceanography</span></span>
</div>
<div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2251">
<span style="font-style:italic;"><span style="font-size:x-small;">State Key Laboratory of Tropical Oceanography</span></span>
</div>
</div>
<div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2252">
<span style="font-style:italic;"><span style="font-size:x-small;">South China Sea Institute of Oceanology</span></span>
</div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2252">
<span style="font-style:italic;"><span style="font-size:x-small;">University of Chinese Academy of Science</span></span>
</div>
</div>
<div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2264">
<span style="font-style:italic;"><span style="font-size:x-small;">China</span></span>
</div>
</div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2264" style="font-size:small;">
<br>
</div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2264" style="font-size:small;">
<span style="font-style:italic;font-size:medium;"><br>
</span>
</div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2264" style="font-size:small;">
<span style="font-style:italic;font-size:medium;">Email : <a target="_blank">wickramagechathurika@rocketmail.com</a></span>
</div>
<div id="ydpc6aa4ef1yui_3_16_0_ym19_1_1496286059659_2264" style="font-size:small;">
<span style="font-style:italic;font-size:medium;"><a target="_blank">chatu@scsio.ac.cn</a></span>
</div>
</blockquote>
</span>