<div dir="ltr"><div><div><div>I am going to add a few more items to a previous response:<br><br></div>The <b>Golden Rules of data processing are:<br><br>(a) Look at your data!<br></b></div><b>(b) Know your data!<br></b></div><b>(c) Make sure *you* know what a function or tool is doing to your data<br></b><div><div><div><b>---<br><br></b></div><div>The source netcDF '2_2_ERAI_Prec_2015_Jan_00_12_<a href="http://12.nc" target="_blank"><wbr>12.nc</a>' was created from a GRIB file:<br><br>history attribute:<br>2018-05-16 09:15:25 GMT by grib_to_netcdf-2.7.3: grib_to_netcdf /data/data05/scratch/3c/71/_ma<wbr>rs-atls00-a562cefde8a29a7288fa<wbr>0b8b7f9413f7-b4mPzK.grib -o /data/data04/scratch/41/14/_gr<wbr>ib2netcdf-atls17-a562cefde8a29<wbr>a7288fa0b8b7f9413f7-PZaKeY.nc -utime" ;<br><br>---<br></div><div>There are <b>62 time steps</b> on the source ERAI file:<br><br></div><div>                  yyyymmddhh     tp value<br></div><div>(0)    ERAI: 2015010112   0.000330344    <b><=== only one value for this calendar day<br><br></b>(1)    ERAI: 2015010200   0.0051588        ......<b> two time steps per calendar day</b> ...<br>(2)    ERAI: 2015010212   0.00401913<br>(3)    ERAI: 2015010300   0<br>(4)    ERAI: 2015010312   0<br>(5)    ERAI: 2015010400   0<br>(6)    ERAI: 2015010412   0.000478998<br>(7)    ERAI: 2015010500   0.00344653<br></div><div>[SNIP]<br>(55)    ERAI: 2015012900   0<br>(56)    ERAI: 2015012912   0<br>(57)    ERAI: 2015013000   9.35942e-05<br>(58)    ERAI: 2015013012   7.15703e-05<br>(59)    ERAI: 2015013100   0.00390901<br>(60)    ERAI: 2015013112   0<br><br>(61)    ERAI: 2015020100   0.00183889<b>      <=== only one value for this calendar day</b></div><div>---<br></div><div>To what 'time' does the source ERAI 'time stamp apply"? <br>That is <b>***USER RESPONSIBILITY*** </b>to know or find the answer.<br><br></div><div>Three possibilities:<br></div><div><br></div><div>[1] beginning<br></div><div>[2] end<br></div><div>[3] 'center-of-mass'  ... mid temporal time?<br><br>---<br></div><div>NCL's '<b>calculate_daily_values</b>' with <b>'ncrit=2</b>' requires two values on the <b>same calendar day</b><br>           <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_daily_values.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/<wbr>Contributed/calculate_daily_<wbr>values.shtml</a><br><br></div><div>With <b>ncrit=2</b> the function returns 30 values ... not 31 or 32. Why?<br></div><div>Because it requires 2 values per calendar date. It ignores the 1st and last times because there is only one time step per calendar day<br><br>tp2_ncl<br>  NCL_tag :     calculate_daily_values: arith=sum<br><br>     ----<br>The function 'tags' it with the <b>1st time step of each *complete*  calendar day</b><br><br>(0)     NCL: 2015010200   0.00917792<br>(1)     NCL: 2015010300   0<br>(2)     NCL: 2015010400   0.000478998<br>(3)     NCL: 2015010500   0.00879252<br></div><div>[SNIP]<br>(28)    NCL: 2015013000   0.000165164<br>(29)    NCL: 2015013100   0.00390901<br></div><div><br></div><div>---<br></div><div>The CDO takes the first two values [0,1], then the next two [2,3], etc. <br>It 'tags' the time as the 2nd time step<br><br>(0)     CDO: 2015010200   0.00548913<br>(1)     CDO: 2015010300   0.00401912<br>(2)     CDO: 2015010400   -1.08611e-10<br></div><div>[SNIP]<br>(29)    CDO: 2015013100   0.00398058<br>(30)    CDO: 2015020100   0.00183889<br><br></div><div>Even though the time 'tags' are the same, they refer to different sums.<br></div><div>---<br></div><div> <br></div><div>NCL can be made to handle the time and data any way the user wants.<b><br><br></b></div><div>I'll let you look at the attached script and output<b><br></b></div><div><b><br></b></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 1, 2018 at 4:03 PM, Ehsan Taghizadeh <span dir="ltr"><<a href="mailto:ehsantaghizadeh@yahoo.com" target="_blank">ehsantaghizadeh@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:bookman old style,new york,times,serif;font-size:16px"><div></div>
            <div>Dears,</div><div>About summation of 12 hours precipitation to obtain daily precipitation, as suggested me I used "cdo" and it seems work correctly:</div><div>"<span>cdo -b F32 -f nc4c -z zip timselsum,2 2_2_ERAI_Prec_2015_Jan_00_12_<wbr><a href="http://12.nc">12.nc</a> 2_2_ERAI_Prec_2015_Jan_24_cdo.<wbr>nc4</span>"</div><div>However I like to know how writing nc files with "Geo2D".</div><div><br></div><div>Sincerely</div><span class="HOEnZb"><font color="#888888"><div>Ehsan<br></div></font></span><div><div class="h5"><div><br></div>
            
            <div id="m_-6783576671254890485yahoo_quoted_8329699892" class="m_-6783576671254890485yahoo_quoted">
                <div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a">
                    
                    <div>
                        On Thursday, May 31, 2018, 7:12:17 PM GMT+4:30, Ehsan Taghizadeh <<a href="mailto:ehsantaghizadeh@yahoo.com" target="_blank">ehsantaghizadeh@yahoo.com</a>> wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                    <div><div id="m_-6783576671254890485yiv7438465636"><div><div style="font-family:bookman old style,new york,times,serif;font-size:16px"><div></div>
            <div>Thank you so much for your nice replies.</div><div>With you comment, it seems work correctly. However I've added some changes to the script to have an output file same as input file, I mean about dimensions, attributes, and so on.</div><div>However I have some difficulties about it and I'll be thankful if I could have your help, again.</div><div>For example about</div><div><span></span><div>fout->tp24_1!1 = tp!1</div><div>fout->tp24_1!2 = tp!2</div><div>I encountered error. It seems they have conflict with following lines:</div><div><span></span><div>fout->latitude = fin->latitude</div><div>fout->longitude = fin->longitude</div><br clear="none"></div><div>Beside that I want to have "<span>tp24_1</span>" with dimension "Geo2D" to plot.</div><div>I attached new version of script, and I'll be thankful if I hear from you.</div><div><br clear="none"></div><div>Sincerley</div><div>Ehsan</div></div>
            
            <div class="m_-6783576671254890485yiv7438465636yahoo_quoted" id="m_-6783576671254890485yiv7438465636yahoo_quoted_8737910354">
                <div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a">
                    
                    <div class="m_-6783576671254890485yiv7438465636yqt5050463565" id="m_-6783576671254890485yiv7438465636yqtfd01829"><div>
                        On Thursday, May 31, 2018, 6:44:48 PM GMT+4:30, Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:
                    </div>
                    <div><br clear="none"></div>
                    <div><br clear="none"></div>
                    <div><div id="m_-6783576671254890485yiv7438465636"><div><div dir="ltr"><div><div><div><div><div><div>The <b>golden rule</b> of  data processing is <b>look at your data</b><br clear="none"><br clear="none"></div>You have:<br clear="none"><br clear="none">tp=f->tp     ; <=== type 'short' [ packed data]<br clear="none"><br clear="none"></div>However, your file has:<br clear="none"><br clear="none">      <b>short</b> tp ( time, latitude, longitude )<br clear="none">        <b> scale_factor </b>: 5.505649013956001e-06<br clear="none">         <b>add_offset </b>:   0.1803980955369768<br clear="none">         _FillValue :   -32767<br clear="none">         missing_value :        -32767<br clear="none">         units :        m<br clear="none">         long_name :    Total precipitation<br clear="none"><br clear="none"></div>You <b>*MUST* </b>unpack the variable before computing the sums.<br clear="none"><br clear="none"></div>tp = <b>short2flt</b>(f->tp)<br clear="none"><br clear="none"></div>printVarSummary(tp)<br clear="none"></div>printMinMax(tp,0)<br clear="none"><br clear="none">===<br clear="none"><a rel="nofollow" shape="rect" href="https://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/<wbr>Contributed/short2flt.shtml</a><br clear="none"><br clear="none"> <br clear="none"><div><div><div><div><br clear="none"><div><br clear="none"><br clear="none"></div></div></div></div></div></div><div class="m_-6783576671254890485yiv7438465636gmail_extra"><br clear="none"><div class="m_-6783576671254890485yiv7438465636gmail_quote">On Thu, May 31, 2018 at 7:19 AM, Ehsan Taghizadeh <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:ehsantaghizadeh@yahoo.com" target="_blank">ehsantaghizadeh@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="m_-6783576671254890485yiv7438465636gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-6783576671254890485yiv7438465636yqt4170128844" id="m_-6783576671254890485yiv7438465636yqt57530"><div><div style="font-family:bookman old style,new york,times,serif;font-size:16px"><div></div>
            <div>Dears,<br clear="none">I've tried sum 12 hour precipitation to obtain 24 hour precipitation using attached script.</div><div>However it seems doesn't work correctly!</div><div>I had to sum tp(0,:,:)+tp(1,:,:), also tp(2,:,;)+tp(3,;,:), and so on.</div><div>I uploaded "<span>2_2_ERAI_Prec_2015_Jan_00_12_<a rel="nofollow" shape="rect" href="http://12.nc" target="_blank"><wbr>12.nc</a></span>" in <span><a rel="nofollow" shape="rect" href="http://ftp.cgd.ucar.edu" target="_blank">ftp.cgd.ucar.edu</a>.</span></div><div><span>I'll be thankful if I hear from you.</span></div><div><span><br clear="none"></span></div><div><span>Sincerely</span></div><div><span>Ehsan</span></div><div><br clear="none"></div>
            
            <div class="m_-6783576671254890485yiv7438465636m_7922525286226352253yahoo_quoted" id="m_-6783576671254890485yiv7438465636m_7922525286226352253yahoo_quoted_8511434241">
                <div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#26282a">
                    
                    <div>
                        On Wednesday, May 16, 2018, 8:23:32 AM GMT+4:30, Dennis Shea <<a rel="nofollow" shape="rect" href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:
                    </div>
                    <div><br clear="none"></div>
                    <div><br clear="none"></div>
                    <div><div id="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380"><div><div dir="ltr"><div><div><div><div><div><div><div><div>This is book keeping. Something like:<br clear="none"><br clear="none"></div>loop  each year<br clear="none"></div>   loop each month<br clear="none"></div>      loop each day<br clear="none">   <br clear="none"></div>        sum all values occurring between 00:00 and 11:59 inclusive ==>PRC(time,lat,lon,0)<br clear="none"></div>        sum all values occurring between 12:00 and 23:59 inclusive ==>PRC(time,lat,lon,1)<br clear="none"><br clear="none"></div>     end day<br clear="none"></div>   end month<br clear="none"></div> end year<br clear="none"><div><div><div><div><div><div><br clear="none"></div></div></div></div></div></div></div><div class="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380gmail_extra"><br clear="none"><div class="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380gmail_quote">On Sun, May 13, 2018 at 9:07 AM, Ehsan Taghizadeh <span dir="ltr"><<a rel="nofollow" shape="rect" href="mailto:ehsantaghizadeh@yahoo.com" target="_blank">ehsantaghizadeh@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380yqt3390863335" id="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380yqt57552"><div><div style="font-family:bookman old style,new york,times,serif;font-size:16px"><div>Hi every body;</div><div>Could I have any help to get daily precipitation from Era-Interim, please?</div><div>I mean, a way to sum "<span><span>accumulated precipitation from 00:00 to 12:00</span></span>" with "<span><span>accumulated precipitation from 12:00 to 24:00</span></span>"?</div><div><br clear="none"></div><div>Sincerely</div><span class="m_-6783576671254890485yiv7438465636m_7922525286226352253yiv0436690380HOEnZb"><font color="#888888"></font></span><div>Ehsan</div></div></div></div><br clear="none">______________________________ _________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/ mailman/listinfo/ncl-talk</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div></div>
                </div>
            </div></div></div></div><br clear="none">______________________________ _________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/ mailman/listinfo/ncl-talk</a><br clear="none">
<br clear="none"></blockquote></div><br clear="none"></div></div></div></div>
                </div></div><div class="m_-6783576671254890485yiv7438465636yqt5050463565" id="m_-6783576671254890485yiv7438465636yqtfd15583">
            </div></div></div></div></div></div>
                </div>
            </div></div></div></div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>