<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Yes! It worked. </p>
<p><br>
</p>
<p>Thanks so much for your help,</p>
<p>Raquel<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Dennis Shea &lt;shea@ucar.edu&gt;<br>
<b>Sent:</b> Tuesday, September 30, 2014 12:25 AM<br>
<b>To:</b> Silva, Raquel<br>
<b>Cc:</b> ncl-talk@ucar.edu; Carl Schreck<br>
<b>Subject:</b> Re: [ncl-talk] Fwd: Regridding from fine to coarse resolution by aggregating not interpolating</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">I see the issue (I think). There must a latitude value and a longitude value for each input 'z' value. I speculate that zlat and zlon are one-dimensional while z is two-dimensional. Thus the zlat/zlon must be replicated (broadcast) to the same
 dimensionality as z.&nbsp; Try<br>
<br>
<br>
; Get data<br>
&nbsp;&nbsp;&nbsp;&nbsp; z_in = addfile(infile,&quot;r&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp; zlat&nbsp; = z_in-&gt;lat<br>
&nbsp;&nbsp;&nbsp;&nbsp; zlon = z_in-&gt;lon<br>
&nbsp;&nbsp;&nbsp;&nbsp; z&nbsp; &nbsp; &nbsp; = z_in-&gt;pop<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; nzlat= dimsizes(zlat)<br>
&nbsp;&nbsp;&nbsp;&nbsp; nzlon= dimsizes(zlon)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; zlat2d = conform_dims( (/nzlat,nzlon/), zlat, 0)<br>
&nbsp;&nbsp;&nbsp;&nbsp; zlon2d = conform_dims( (/nzlat,nzlon/), zlon, 1)<br>
<br>
[snip]<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; bin_sum(gbin,gknt,glon,glat,ndtooned(zlon2d),<br>
ndtooned(zlat2d),ndtooned(z) )<br>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 29, 2014 at 9:31 PM, Silva, Raquel <span dir="ltr">
&lt;<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</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>Dennis,</p>
<p><br>
</p>
<p>Thanks for the references. I was able to run Example 2 and I also looked at Example 1 and compared it to my script.
</p>
<p><br>
</p>
<p>If I understand it correctly, the error I get ('bin_sum: zlat must be the same size as zlon') is related with the dimensions of lon and lat in the original data not nlat and mlon:
</p>
<p><br>
</p>
<p><em>(...)</em></p>
<p><br>
<em></em></p>
<p><em>;*****************************************************************</em><br>
<em>; Get new grid and data to regrid</em><br>
<em>;*****************************************************************</em><br>
<em></em><br>
<em>; Get new grid</em><br>
<em>&nbsp; g_in = addfile(gfile,&quot;r&quot;)</em><br>
<em>&nbsp; glat = g_in-&gt;lat</em><br>
<em>&nbsp; glon = g_in-&gt;lon</em><br>
<em></em><br>
<em>&nbsp; nlat = dimsizes(glat)</em><br>
<em>&nbsp; mlon = dimsizes(glon)</em><br>
<em></em><br>
<em>&nbsp; print(&quot;New grid = &quot;&#43;mlon&#43;&quot;x&quot;&#43;nlat)</em><br>
<em></em><br>
<em>; Get data</em><br>
<em>&nbsp; z_in = addfile(infile,&quot;r&quot;)</em><span class=""><br>
<em>&nbsp; zlat = z_in-&gt;lat</em><br>
<em>&nbsp; zlon = z_in-&gt;lon</em><br>
</span><em>&nbsp; z = z_in-&gt;pop</em><br>
<em></em><br>
<em>&nbsp; nlat_in = dimsizes(zlat)</em><br>
<em>&nbsp; nlon_in = dimsizes(zlon)</em><br>
<em></em><br>
<em>&nbsp; print(&quot;Original grid = &quot;&#43;nlon_in&#43;&quot;x&quot;&#43;nlat_in)</em><br>
<em>&nbsp; print(&quot; &quot;)</em><br>
<em></em><br>
<em>&nbsp; z_sum = sum(z)</em><br>
<em></em></p>
<p><em>&nbsp; print(&quot;Sum z:&quot;)</em><br>
<em>&nbsp; print(z_sum)</em><br>
<em>&nbsp; print(&quot; &quot;)</em></p>
<p><br>
</p>
<p><em></em><em>;*****************************************************************</em><br>
<em>; Variables to hold binned quantities</em><br>
<em>;*****************************************************************</em><br>
<em>&nbsp; gbin&nbsp; = new ( (/nlat,mlon/), float )</em><br>
<em>&nbsp; gknt&nbsp; = new ( (/nlat,mlon/), integer)</em><br>
<em></em><br>
<em>&nbsp; gbin&nbsp; = 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; initialization</em><br>
<em>&nbsp; gknt&nbsp; = 0</em><br>
<em></em><br>
<em>;*****************************************************************</em><br>
<em></em></p>
<p><em>; Regrid data<br>
</em></p>
<p><em></em><em>;*****************************************************************</em><br>
<em>&nbsp; bin_sum(gbin,gknt,glon,glat,ndtooned(zlon), ndtooned(zlat),ndtooned(z) )</em><br>
<em></em><br>
<em>&nbsp; z_out_sum = sum(gbin)</em><br>
<em></em><br>
<em>&nbsp; </em><em>print(&quot;Sum z_out:&quot;)</em><br>
<em>&nbsp; print(z_out_sum)</em><br>
<em></em></p>
<p><br>
</p>
<p><em>(...)</em><br>
</p>
<p><br>
</p>
<p>Is there anything else I should check/change?</p>
<p><br>
</p>
<p>Thanks,<br>
Raquel<br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block; width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b>
<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> &lt;<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>&gt; on behalf of Dennis Shea &lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;<br>
<b>Sent:</b> Monday, September 29, 2014 7:30 PM<br>
<b>To:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> [ncl-talk] Fwd: Regridding from fine to coarse resolution by aggregating not interpolating</font>
<div>&nbsp;</div>
</div>
<div>
<div class="h5">
<div>
<div dir="ltr">This response was inadvertently not sent to <a href="mailto:ncl-talk@ucar.edu" target="_blank">
ncl-talk@ucar.edu</a><br>
<br>
<div>
<div class="gmail_quote">---------- Forwarded message ----------<br>
From: <b class="gmail_sendername">Dennis Shea</b> <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span><br>
Date: Mon, Sep 29, 2014 at 2:40 PM<br>
Subject: Re: [ncl-talk] Regridding from fine to coarse resolution by aggregating not interpolating<br>
To: &quot;Silva, Raquel&quot; &lt;<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</a>&gt;<br>
Cc: Carl Schreck &lt;<a href="mailto:cjschrec@ncsu.edu" target="_blank">cjschrec@ncsu.edu</a>&gt;<br>
<br>
<br>
<div dir="ltr">
<div>
<div>
<div>You should be able to bin.&nbsp; nlat and mlon *can* be different sizes.<br>
<br>
</div>
I just ran: Example 2&nbsp; (random data):<br>
<br>
<b><a href="http://www.ncl.ucar.edu/Applications/binning.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/binning.shtml</a></b><br>
<br>
</div>
You can download the script and run it. Here nlat=36 and mlon=61<br>
<br>
===<br>
<br>
<br>
</div>
<br>
</div>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 29, 2014 at 2:11 PM, Silva, Raquel <span dir="ltr">
&lt;<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</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 Carl and Dennis,</p>
<p><br>
</p>
<p>Thanks for your quick responses.</p>
<p><br>
</p>
<p>I'm getting the following error:</p>
<p>fatal:bin_sum: zlat must be the same size as zlon</p>
<p><br>
</p>
<p>where </p>
<p>&nbsp; zlat = z_in-&gt;lat<br>
&nbsp; zlon = z_in-&gt;lon<br>
<br>
</p>
<p>I thought that I could have different sizes for longitude and latitude.</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Raquel<br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block; width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Dennis Shea &lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;<br>
<b>Sent:</b> Monday, September 29, 2014 4:05 PM<br>
<b>To:</b> Carl Schreck<br>
<b>Cc:</b> Silva, Raquel; <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> Re: [ncl-talk] Regridding from fine to coarse resolution by aggregating not interpolating</font>
<div>&nbsp;</div>
</div>
<div>
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Also, see:<br>
<br>
<a href="http://www.ncl.ucar.edu/Applications/" target="_blank">http://www.ncl.ucar.edu/Applications/</a><br>
<br>
</div>
on the right under &quot;Data Analysis&quot;, Click &quot;Binning&quot;<br>
<br>
</div>
There are a few examples.<br>
<br>
===<br>
</div>
If you are new to NCL, pleasesee<br>
<br>
<a href="http://www.ncl.ucar.edu/Document/Manuals/" target="_blank">http://www.ncl.ucar.edu/Document/Manuals/</a><br>
<br>
</div>
[1] Mini-Language Manual&nbsp;&nbsp;&nbsp; (concise but detailed language overview)<br>
<br>
</div>
[2] the DKRZ tutorials. This is a rather large pdf.<br>
&nbsp; &nbsp;&nbsp; The 1st contains a subset of the Mini-Language Manual plu many examples.<br>
</div>
&nbsp;&nbsp;&nbsp;&nbsp; The 2nd has a lot of exercises. Unfortunately, not all the data sets are available<br>
</div>
&nbsp;&nbsp;&nbsp;&nbsp; for general use.<br>
<br>
</div>
Cheers<br>
<div>
<div>
<div>
<div>
<div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 29, 2014 at 1:00 PM, Carl Schreck <span dir="ltr">
&lt;<a href="mailto:cjschrec@ncsu.edu" target="_blank">cjschrec@ncsu.edu</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">Hi Raquel,
<div><br>
</div>
<div>I believe bin_sum will do what you're looking for:</div>
<div><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/bin_sum.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/bin_sum.shtml</a><br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; Carl</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div>
<div>On Mon, Sep 29, 2014 at 2:25 PM, Silva, Raquel <span dir="ltr">&lt;<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</a>&gt;</span> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div>
<div dir="ltr" style="font-size:12pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi all,</p>
<p><br>
</p>
<p>I need to&nbsp;regrid&nbsp;global data from&nbsp;a&nbsp;fine (30&quot;x30&quot;) to a coarser&nbsp;(0.7x0.5 deg) resolution&nbsp;so that each output&nbsp;cell contains the sum of the input cells that are encompassed by the extent of that cell. Could you please let me know if there is an ncl function
 I could use?</p>
<p><br>
</p>
<p>Thanks,<br>
Raquel<br>
</p>
</div>
<br>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr"><br>
<table style="max-width:100%; border-collapse:collapse; border-spacing:0px; color:rgb(51,51,51); font-size:14px; border:3px solid rgb(170,170,170); font-family:Times; line-height:12px; background-color:transparent" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td align="center" height="71" width="71"><span style="font-size:11px"><span style="font-family:arial,helvetica,sans-serif"><a href="http://www.cicsnc.org/" target="_blank" style="color:rgb(38,58,143); text-decoration:none; font-weight:bold"><img height="93" width="96" src="http://www.cicsnc.org/assets/images/cicsnc-logo.png"></a>&nbsp;&nbsp;<a href="http://www.researcherid.com/rid/B-8711-2011" target="_blank"><br>
</a></span></span><br>
<font size="4"><b style="text-align:start; color:rgb(38,58,143); font-family:arial,helvetica,sans-serif">&nbsp;<a href="http://www.cyclonecenter.org/" target="_blank" style="color:rgb(38,58,143); text-decoration:none">Cyclone</a></b><a href="http://www.cyclonecenter.org/" target="_blank" style="text-align:start; color:rgb(38,58,143); font-family:arial,helvetica,sans-serif; text-decoration:none">Center.org</a>&nbsp;&nbsp;</font></td>
<td valign="top"><span style="font-size:11px"><span style="font-family:arial,helvetica,sans-serif"><b>Carl J. Schreck III, PhD</b><br>
<b>Research Associate</b><br>
<a href="http://www.cicsnc.org/" target="_blank" style="color:rgb(38,58,143); text-decoration:none; font-weight:bold">Cooperative Institute for Climate and Satellites NC</a>&nbsp;<br>
<a href="http://ncsu.edu/" target="_blank" style="color:rgb(38,58,143); text-decoration:none; font-weight:bold">North Carolina State University</a><br>
<a href="http://ncdc.noaa.gov/" target="_blank" style="color:rgb(38,58,143); text-decoration:none; font-weight:bold">NOAA's National Climatic Data Center</a><br>
151 Patton Ave, Asheville, NC 28801<br>
e:&nbsp;</span></span><a href="mailto:cjschrec@ncsu.edu" target="_blank" style="color:rgb(38,58,143); font-family:arial,helvetica,sans-serif; font-size:11px; text-decoration:none; font-weight:bold">cjschrec@ncsu.edu</a><br style="font-family:arial,helvetica,sans-serif; font-size:11px">
<span style="font-size:11px"><span style="font-family:arial,helvetica,sans-serif">o:&nbsp;<a href="tel:%2B1%20828%20257%203140" value="&#43;18282573140" target="_blank">&#43;1 828 257 3140</a><br>
</span></span><a href="http://scholar.google.com/citations?hl=en&amp;user=th8ONEcAAAAJ&amp;view_op=list_works&amp;sortby=pubdate" target="_blank" style="color:rgb(38,58,143); font-family:arial,helvetica,sans-serif; font-size:11px; text-decoration:none; font-weight:bold">Publications</a><br>
<a href="http://monitor.cicsnc.org/mjo/" target="_blank" style="color:rgb(38,58,143); font-family:arial,helvetica,sans-serif; font-size:11px; text-decoration:none; font-weight:bold">monitor.cicsnc.org/mjo</a><br style="font-family:arial,helvetica,sans-serif; font-size:11px">
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>