<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Assuming from your filedump you do have coordinate variables associated, so the following should easily work.</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">temp_avg=dim_avg_n_Wrap(temp(:,:,{40:50},{-30:-10}),(/2,3/))</font></div><div class=""><br class=""></div><div class="">Otherwise you would have to convert the latitude/longitude variables from 2D to 1D, use the ind function to find all the indices that map into your box, convert again into 2D indices with ind_resolve, subset temp with these indices, do the average.&nbsp;</div><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Guido Cioni</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://guidocioni.altervista" class="">http://guidocioni.altervista</a>.org</div>
</div>
<br class=""><div style=""><blockquote type="cite" class=""><div class="">On 13 Sep 2016, at 09:10, Sourav Chatterjee &lt;<a href="mailto:srvsxc@outlook.com" class="">srvsxc@outlook.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" class="">
<meta content="text/html; charset=utf-8" class="">

<div class="">
<div class="">
<div style="font-family:Calibri,sans-serif; font-size:11pt" class="">Thanks alot Mary for the explanation.<br class="">
<br class="">
Actually I need to do some area averaging for which I have the lat lon information e.g say, surface temperature averaged over 40-50N and -30:-10E. How to perform this spatial averaging with this temperature(time,depth,y,x) variable?<br class="">
<br class="">
Thanks<br class="">
Sourav<br class="">
</div>
</div>
<div dir="ltr" class="">
<hr class="">
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold" class="">From:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt" class=""><a href="mailto:haley@ucar.edu" class="">Mary Haley</a></span><br class="">
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold" class="">Sent:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt" class="">‎12-‎09-‎2016 23:38</span><br class="">
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold" class="">To:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt" class=""><a href="mailto:srvsxc@outlook.com" class="">Sourav Chatterjee</a></span><br class="">
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold" class="">Cc:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt" class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a></span><br class="">
<span style="font-family:Calibri,sans-serif; font-size:11pt; font-weight:bold" class="">Subject:
</span><span style="font-family:Calibri,sans-serif; font-size:11pt" class="">Re: [ncl-talk] Assign lat lon cordinates to polar stereographic coordinate</span><br class="">
<br class="">
</div>
<div class="">
<div dir="ltr" class="">
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class="">Sourav,</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class="">I'm not sure what you mean by "converting my variable".</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class="">Since your latitude and longitude arrays are two-dimensional, you cannot associate them with "temperature" in the same way that "y" and "x" are currently associated with "temperature" as coordinate
 variables. This is a NetCDF limitation that requires that coordinate variables be one-dimensional and the same length as the dimension they represent.</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class="">You already have a "coordinates" *attribute* associated with "temperature", that indicates which variables represent the lat/lon arrays for your data:</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class="gmail_default"><font face="arial, helvetica, sans-serif" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; temperature:coordinates = "longitude latitude" ;</span><br style="" class="">
</font></div>
<div class="gmail_default"><span style="" class=""><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></span></div>
<div class="gmail_default"><span style="" class=""><font face="arial, helvetica, sans-serif" class="">This is how we would normally suggest that you "associate" 2D lat/lon arrays with a variable on a NetCDF file, so really, your "temperature" variable looks pretty
 good as it is.</font></span></div>
<div class="gmail_default"><span style="" class=""><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></span></div>
<div class="gmail_default"><span style="" class=""><font face="arial, helvetica, sans-serif" class="">--Mary</font></span></div>
<div class="gmail_default"><span style="" class=""><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></span></div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Fri, Sep 9, 2016 at 4:19 AM, Sourav Chatterjee <span dir="ltr" class="">
&lt;<a href="mailto:srvsxc@outlook.com" target="_blank" class="">srvsxc@outlook.com</a>&gt;</span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" class="">
<div style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><p class="">Hi all</p><p class=""><br class="">
</p><p class="">I want convert my variable (temperature) to temperature (time,depth,lat,lon) from temperature(time,depth,x,y)
<br class="">
</p><p class=""><br class="">
</p><p class=""><br class="">
</p><p class="">here is how it looks like now.</p><p class=""><br class="">
</p><p class="">Any help!</p><p class=""><br class="">
</p><p class="">Thanks<br class="">
</p><p class=""><br class="">
</p><div class=""><span class=""></span><br class="webkit-block-placeholder"></div>
<div class="">dimensions:<br class="">
&nbsp;&nbsp; &nbsp;depth = 12 ;<br class="">
&nbsp;&nbsp; &nbsp;time = UNLIMITED ; // (288 currently)<br class="">
&nbsp;&nbsp; &nbsp;x = 428 ;<br class="">
&nbsp;&nbsp; &nbsp;y = 403 ;<br class="">
variables:<br class="">
&nbsp;&nbsp; &nbsp;int stereographic ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:grid_mapping_<wbr class="">name = "polar_stereographic" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:latitude_of_<wbr class="">projection_origin = 90. ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:longitude_of_<wbr class="">projection_origin = -45. ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:scale_factor_<wbr class="">at_projection_origin = 1. ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:straight_<wbr class="">vertical_longitude_from_pole = -45. ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:false_easting = 0. ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;stereographic:false_northing = 0. ;<br class="">
&nbsp;&nbsp; &nbsp;float x(x) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x:axis = "X" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x:standard_name = "projection_x_coordinate" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x:units = "100&nbsp; km" ;<br class="">
&nbsp;&nbsp; &nbsp;float y(y) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y:standard_name = "projection_y_coordinate" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y:axis = "Y" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y:units = "100&nbsp; km" ;<br class="">
&nbsp;&nbsp; &nbsp;float depth(depth) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;depth:long_name = "depth" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;depth:units = "m" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;depth:standard_name = "depth" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;depth:positive = "down" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;depth:axis = "Z" ;<br class="">
&nbsp;&nbsp; &nbsp;double time(time) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;time:units = "hour since 1950-1-1T00:00:00Z" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;time:long_name = "forecast time" ;<br class="">
&nbsp;&nbsp; &nbsp;float longitude(y, x) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;longitude:standard_name = "longitude" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;longitude:units = "degrees_east" ;<br class="">
&nbsp;&nbsp; &nbsp;float latitude(y, x) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;latitude:standard_name = "latitude" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;latitude:units = "degrees_north" ;<br class="">
&nbsp;&nbsp; &nbsp;short temperature(time, depth, y, x) ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:_FillValue = -32767s ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:missing_value = -32767s ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:add_offset = 23.5 ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:scale_factor = 0.000808839239385893 ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:units = "Celsius" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:standard_name = "sea_water_potential_<wbr class="">temperature" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:grid_mapping = "stereographic" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:coordinates = "longitude latitude" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temperature:cell_methods = "area: mean" ;<br class="">
<br class="">
// global attributes:<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:title = "Arctic Ocean Physics Reanalysis (1991-2014), 12.5km monthly mean (dataset-ran-arc-myoceanv2-be)<wbr class="">" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:institution = "NERSC, Thormoehlens gate 47, N-5006 Bergen, Norway" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:history = "20160112:Created by program hyc2proj, version V0.3" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:source = "NERSC-HYCOM model fields" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:references = "<a href="http://topaz.nersc.no/" target="_blank" class="">http://topaz.nersc.no</a>" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:field_type = "Files based on file type nersc_weekly" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:Conventions = "CF-1.4" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:field_date = "2014-11-15" ;<br class="">
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;:bulletin_date = "2014-11-15" ;<br class="">
}<br class="">
</div>
<br class=""><div class=""><br class="webkit-block-placeholder"></div>
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class="">
<br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</div>

_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></body></html>