<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;} 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>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> g_in = addfile(gfile,"r")</em><br>
<em> glat = g_in->lat</em><br>
<em> glon = g_in->lon</em><br>
<em></em><br>
<em> nlat = dimsizes(glat)</em><br>
<em> mlon = dimsizes(glon)</em><br>
<em></em><br>
<em> print("New grid = "+mlon+"x"+nlat)</em><br>
<em></em><br>
<em>; Get data</em><br>
<em> z_in = addfile(infile,"r")</em><br>
<em> zlat = z_in->lat</em><br>
<em> zlon = z_in->lon</em><br>
<em> z = z_in->pop</em><br>
<em></em><br>
<em> nlat_in = dimsizes(zlat)</em><br>
<em> nlon_in = dimsizes(zlon)</em><br>
<em></em><br>
<em> print("Original grid = "+nlon_in+"x"+nlat_in)</em><br>
<em> print(" ")</em><br>
<em></em><br>
<em> z_sum = sum(z)</em><br>
<em></em></p>
<p><em> print("Sum z:")</em><br>
<em> print(z_sum)</em><br>
<em> print(" ")</em></p>
<p><br>
</p>
<p><em></em><em>;*****************************************************************</em><br>
<em>; Variables to hold binned quantities</em><br>
<em>;*****************************************************************</em><br>
<em> gbin = new ( (/nlat,mlon/), float )</em><br>
<em> gknt = new ( (/nlat,mlon/), integer)</em><br>
<em></em><br>
<em> gbin = 0.0 ; initialization</em><br>
<em> gknt = 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> bin_sum(gbin,gknt,glon,glat,ndtooned(zlon), ndtooned(zlat),ndtooned(z) )</em><br>
<em></em><br>
<em> z_out_sum = sum(gbin)</em><br>
<em></em><br>
<em> </em><em>print("Sum z_out:")</em><br>
<em> 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 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> ncl-talk-bounces@ucar.edu <ncl-talk-bounces@ucar.edu> on behalf of Dennis Shea <shea@ucar.edu><br>
<b>Sent:</b> Monday, September 29, 2014 7:30 PM<br>
<b>To:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> [ncl-talk] Fwd: Regridding from fine to coarse resolution by aggregating not interpolating</font>
<div> </div>
</div>
<div>
<div dir="ltr">This response was inadvertently not sent to <a href="mailto:ncl-talk@ucar.edu">
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"><<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>></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: "Silva, Raquel" <<a href="mailto:rasilva@live.unc.edu">rasilva@live.unc.edu</a>><br>
Cc: Carl Schreck <<a href="mailto:cjschrec@ncsu.edu">cjschrec@ncsu.edu</a>><br>
<br>
<br>
<div dir="ltr">
<div>
<div>
<div>You should be able to bin. nlat and mlon *can* be different sizes.<br>
<br>
</div>
I just ran: Example 2 (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 class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Sep 29, 2014 at 2:11 PM, Silva, Raquel <span dir="ltr">
<<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</a>></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> zlat = z_in->lat<br>
zlon = z_in->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 <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>><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> </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 "Data Analysis", Click "Binning"<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 (concise but detailed language overview)<br>
<br>
</div>
[2] the DKRZ tutorials. This is a rather large pdf.<br>
The 1st contains a subset of the Mini-Language Manual plu many examples.<br>
</div>
The 2nd has a lot of exercises. Unfortunately, not all the data sets are available<br>
</div>
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">
<<a href="mailto:cjschrec@ncsu.edu" target="_blank">cjschrec@ncsu.edu</a>></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> 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"><<a href="mailto:rasilva@live.unc.edu" target="_blank">rasilva@live.unc.edu</a>></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 regrid global data from a fine (30"x30") to a coarser (0.7x0.5 deg) resolution so that each output 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> <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"> <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> </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> <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: </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: <a href="tel:%2B1%20828%20257%203140" value="+18282573140" target="_blank">+1 828 257 3140</a><br>
</span></span><a href="http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&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>
</body>
</html>