<div dir="ltr"><div>I would suggest using the ESMF [ <a href="http://www.ncl.ucar.edu/Applications/ESMF.shtml">http://www.ncl.ucar.edu/Applications/ESMF.shtml</a> ] to separately <br><br>(a) interpolate the zonal-winds on the U-grid to the T-Grid and save the generated weight file: (say)<br><pre><a href="http://wgt.Ugrid_to_Tgrid.nc">wgt.Ugrid_to_Tgrid.nc</a></pre>(b) interpolate the meridional-winds on the V-grid to the T-Grid and save the generated weight file: (say)<br><pre><a href="http://wgt.Vgrid_to_Tgrid.nc">wgt.Vgrid_to_Tgrid.nc</a></pre></div>(c) The following is a sparse matrix multiply. It is *very* fast.<br><pre>U_Tgrid = ESMF_regrid_with_weights(u,&quot;<a href="http://wgt.Ugrid_to_Tgrid.nc">wgt.Ugrid_to_Tgrid.nc</a>&quot;,False)<br>V_Tgrid = ESMF_regrid_with_weights(v,&quot;<a href="http://wgt.Vgrid_to_Tgrid.nc">wgt.Vgrid_to_Tgrid.nc</a>&quot;,False)<br><br>printVarSummary(U_Tgrid)
<br>printVarSummary(V_tgrid)<br><br></pre><pre>The weight files can be reused.<br></pre><pre>Good luck <br></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 3, 2017 at 3:39 PM, Francesco Trotta <span dir="ltr">&lt;<a href="mailto:francesco.trotta4@unibo.it" target="_blank">francesco.trotta4@unibo.it</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi Dennis,</p>
<p>I&#39;m doing this interpolation because my veocity output (U and V datasets) will be use in another code which aspect both U and V on a T-Grid.</p>
<p>Interpolating U and V separatly on a T-grid I think is good.</p>
<p>I tried to do this with the following ncl script but I wonder if there is a way to optimized this script (is a bit time consuming)<br>
</p>
<p><br>
</p>
<p>In order to define the field near the coast I extrapolate the field using the ncl function &quot;poisson_grid_fill&quot; with arguments:<br>
</p>
<p>guess_type=1,nscan=2000,epsx=<wbr>0.001,relc=0.6. Are these values reasonable) </p>
<p>It is possible to extrapolate with this function not in all the Land-points but just near the cost? (this can help to save time)</p>
<p><br>
</p>
<p>thanks</p>
<p>Francesco<br>
</p>
<p><br>
</p>
<p>   ;;;;=========================<wbr>===========================<br>
</p>
<p>   ;;;;=== ZONAL VELOCITY U-GRID FILEs</p>
<p><br>
</p>
<p>   out_T    = addfile(path_exp_outdata_<wbr>ocean+&quot;/&quot;+file_T,&quot;r&quot;)<br>
   out_Mesh = addfile(path_exp_outdata_<wbr>oceanMesh+&quot;/&quot;+file_Mesh,&quot;r&quot;)<br>
     <br>
   nlon  = dimsizes(out_T-&gt;nav_lon(0,:)-<wbr>1)<br>
   nlat  = dimsizes(out_T-&gt;nav_lon(:,0)-<wbr>1)<br>
   nlev  = dimsizes(out_T-&gt;deptht(:)-1)<br>
   ntime = dimsizes(out_T-&gt;time_counter(:<wbr>)-1)<br>
<br>
   lat2dt = out_T-&gt;nav_lat(:,:)<br>
   lon2dt = out_T-&gt;nav_lon(:,:)<br>
   deptht = out_T-&gt;deptht(:)<br>
   time      = out_T-&gt;time_counter(0:ntime-1)<br>
   time_bnds = out_T-&gt;time_counter_bnds(0:<wbr>ntime-1,:)<br>
<br>
   var_name = &quot;vozocrtx&quot;<br>
   out_U  = addfile(path_exp_outdata_<wbr>ocean+&quot;/&quot;+file_U_Ugrid,&quot;r&quot;)<br>
   lon1du = (/ out_U-&gt;nav_lon(0,:) /)<br>
   u_T    = new((/nlev,nlat,nlon/),typeof(<wbr>out_U-&gt;$var_name$))<br>
   ;Define dimensions, coord., attributes<br>
   u_T!0 = &quot;deptht&quot;<br>
   u_T!1 = &quot;y&quot;<br>
   u_T!2 = &quot;x&quot;<br>
   u_T&amp;deptht = (/deptht(0:nlev-1)/)<br>
   u_T&amp;y      = (/lat2dt(0:nlat-1,0)/)<br>
   u_T&amp;x      = (/lon2dt(0,0:nlon-1)/)<br>
   copy_VarAtts(out_U-&gt;$var_name$<wbr>,u_T)<br>
<br>
   mask3dt = (/ out_Mesh-&gt;tmask(0,:,:,:) /)<br>
   mask3du = (/ out_Mesh-&gt;umask(0,:,:,:) /)<br>
<br>
   do itime=0,ntime-1<br>
      u_U = out_U-&gt;$var_name$(itime,:,:,:)<br>
      ;printVarSummary(u_U)<br>
<br>
      ;--- Assign Missing Values at Land Points (grid-U)<br>
      u_U(0:nlev-1,0:nlat-1,0:nlon-<wbr>1) = \<br>
                where(mask3du(0:nlev-1,0:nlat-<wbr>1,0:nlon-1).eq.0., \<br>
                      u_U@_FillValue, \<br>
                      u_U(0:nlev-1,0:nlat-1,0:nlon-<wbr>1))<br>
<br>
      ;--- Interpolates linearly along the longitude dimension<br>
      u_T(0:nlev-1,0:nlat-1,0:nlon-<wbr>1) = \<br>
                 linint1_n(lon1du(0:nlon-1), \<br>
                           u_U(0:nlev-1,0:nlat-1,0:nlon-<wbr>1),False, \<br>
                           lon2dt(0,0:nlon-1),0,2)<br>
<br>
      ;--- Assign an extrapol Value to Missing Values points<br>
      ;Replaces all Missing(_FillValue) values with values derived from solving Poisson&#39;s equation via relaxation.<br>
      poisson_grid_fill(u_T(0:nlev-<wbr>1,0:nlat-1,0:nlat-1), False, 1, 2000, 0.001, 0.6, 0)<br>
      ;printVarSummary(u_T)<br>
<br>
      ;--- Assign Missing Values at Land Points (grid-T)<br>
      u_T(0:nlev-1,0:nlat-1,0:nlon-<wbr>1) = \<br>
                where(mask3dt(0:nlev-1,0:nlat-<wbr>1,0:nlon-1).eq.0., \<br>
                      u_T@_FillValue, \<br>
                      u_T(0:nlev-1,0:nlat-1,0:nlon-<wbr>1))<br>
<br>
      write_regridVel(path_exp_<wbr>outdata_ocean,file_U_Tgrid,<wbr>itime,ntime,nlev,nlat,nlon, \<br>
                      lon2dt(0:nlat-1,0:nlon-1),<wbr>lat2dt(0:nlat-1,0:nlon-1),<wbr>deptht(0:nlev-1), \<br>
                      time(0:ntime-1),time_bnds(0:<wbr>ntime-1,0:1), \<br>
                      u_T(0:nlev-1,0:nlat-1,0:nlon-<wbr>1),var_name)<br>
<br>
   end do<br>
</p>
<p><br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block;width:98%">
<div id="m_4803675359014953430divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Da:</b> Dennis Shea &lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;<br>
<b>Inviato:</b> venerdì 30 giugno 2017 16:11<br>
<b>A:</b> Francesco Trotta<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Oggetto:</b> Re: [ncl-talk] from staggered grid field to interpolated unique grid field</font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>The Arakawa C-grid has the U, V and scalar (?T?) variables on separate grids.
<br>
<br>
</div>
To *my* knowledge, the ESMF regrid package does not interpolate vector wind components. Wind components should be interpolated together on the sphere. The wind speed is conserved but the magnitudes of the wind components will vary. For u and v on the same grid<br>
<br>
  uNew = u*cos(rot) - v*sin(rot)    ; rot - <span class="m_4803675359014953430gmail-il">rotation</span> angle<br>
  vNew = u*sin(rot) + v*cos(rot)<br>
<br>
</div>
Actually, on the Arakawa C-grid, since u and v are on separate grids the appropriate rotation angles would be different also.<br>
<br>
---<br>
</div>
What is the objective of the interpolation? <br>
<br>
If it is &#39;just&#39; graphics, then, maybe, interpolating the the V-grid and  U-grid separately to the T-grid would be acceptable.
<br>
<br>
</div>
---<br>
<div>
<div>
<div><br>
<br>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Jun 29, 2017 at 3:31 AM, Francesco Trotta <span dir="ltr">
&lt;<a href="mailto:francesco.trotta4@unibo.it" target="_blank">francesco.trotta4@unibo.it</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<div>Dear ncl team,</div>
<div>  I using ncl and I’m producing 2 netcdf files of meridional e zonal velocity definite on the stagarate grid (C_arakawa U e V grids) and I need to pass this datasets to a collage on a unique T grid.</div>
<div><br>
</div>
<div>   Is there in ncl some build-in-function which from 2 netcdf file with u e v defined in a staggered U e V grid produce a file with u and v field interpolate on T grid?</div>
<div><br>
</div>
<div>thanks</div>
<span class="m_4803675359014953430HOEnZb"><font color="#888888">
<div>Francesco​<br>
</div>
<p><br>
</p>
</font></span></div>
<br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>