<div dir="ltr">Hi,<div><br></div><div>I am still unable to get the function month_to_annual_weighted.ncl to work. I used the function code that you sent. Here is my script:</div><div><br></div><div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</div><div>load &quot;./month_to_annual_weighted.ncl&quot;</div><div>begin</div><div> </div><div>  diri = &quot;/Users/nmb1441/research/papers/china/monsoons/cru_data/pet/&quot;</div><div>  srcFileName = &quot;<a href="http://cru_ts3.21.1951.1960.pet.dat.nc" target="_blank">cru_ts3.21.1951.1960.pet.dat.nc</a>&quot;   </div><div>  refile= addfile(diri + srcFileName,&quot;r&quot;)</div><div><br></div><div>  pet = refile-&gt;pet</div><div>  lat = refile-&gt;lat</div><div>  lon = refile-&gt;lon</div><div>  time = refile-&gt;time</div><div>  </div><div>  time@calendar = &quot;gregorian&quot;</div><div>  yearfrac = cd_calendar(time,  4)</div><div>  </div><div>  yyyymm = cd_calendar(time, -1)</div><div>  </div><div>  dym      = cd_calendar(time,  -1) </div><div>  </div><div>  print(dym)</div><div><br></div><div>  printVarSummary(pet)</div><div>  printVarSummary(dym)</div><div>  pet_annual_total1= month_to_annual_weighted(yyyymm,pet,0)</div><div>     </div><div>end</div></div><div><br></div><div>The error message I got is : </div><div>







<p><span>fatal:Variable (yrFrac) is undefined, can not assign attribute (calendar)</span></p>
<p><span>fatal:[&quot;Execute.c&quot;:8578]:Execute: Error occurred at or near line 52 in file ./month_to_annual_weighted.ncl</span></p>
<p><span></span><br></p>
<p><span>fatal:[&quot;Execute.c&quot;:8578]:Execute: Error occurred at or near line 28 in file test-temp1.ncl</span></p><p><span><br></span></p><p><span>I am using ncl 6.2.1.</span></p><p><span>Thanks!</span></p><p><span>Lei</span></p><p><span><br></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 28, 2015 at 1:33 PM, Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.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"><div>[1] Please indicate which version of NCL you are using.<br><br></div>[2] I speculate the following will work<br><div><br>     yyyymm = cd_calendar(time, -1)   ; &lt;===<br><div>     pet_annual_total1= month_to_annual_weighted(yyyymm,pet,0)<br><br></div><div>[3] Since, I am not sure what version of NCL you have, please load the attached<br><br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;<br></div><div>load &quot;./month_to_annual_weighted.ncl&quot;<br><br></div><div>... your script ...<br><br></div><div>[4] Note: from 6.2.0 onward,  users do not need to explicitly load the gsn_code/gsn_csm/contributed libraries<br><br></div><div>Goos Luck<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Jan 28, 2015 at 9:54 AM, Lei Meng <span dir="ltr">&lt;<a href="mailto:dream916@gmail.com" target="_blank">dream916@gmail.com</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 class="h5"><div dir="ltr">Hi,<div><br></div><div>I tried to convert monthly values to annual valued weighted by the number of days. Here is my code:</div><div><br></div><div>----</div><div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl&quot;</div><div>begin</div><div> </div><div>  diri = &quot;/Users/nmb1441/research/papers/china/monsoons/cru_data/pet/&quot;</div><div>  srcFileName = &quot;<a href="http://cru_ts3.21.1951.1960.pet.dat.nc" target="_blank">cru_ts3.21.1951.1960.pet.dat.nc</a>&quot;   </div><div>  refile= addfile(diri + srcFileName,&quot;r&quot;)</div><div><br></div><div>  pet = refile-&gt;pet</div><div>  lat = refile-&gt;lat</div><div>  lon = refile-&gt;lon</div><div>  time = refile-&gt;time</div><div>  </div><div>  time@calendar = &quot;gregorian&quot;</div><div>  yearfrac = cd_calendar(time,  4)</div><div>  </div><div>  yyyymm1 = cd_calendar(time, 1)</div><div>  </div><div>  dym      = cd_calendar(time,  1) </div><div>  </div><div>  print(dym)</div><div><br></div><div>  printVarSummary(pet)</div><div>  printVarSummary(dym)</div><div>  pet_annual_total1= month_to_annual_weighted(dym,pet,0)</div><div>     </div><div>end</div></div><div>--</div><div>The summaries of variables pet and dym are as follows:</div><div><br></div><div>







<p><span>Variable: pet</span></p>
<p><span>Type: double</span></p>
<p><span>Total Size: 248832000 bytes</span></p>
<p><span>            31104000 values</span></p>
<p><span>Number of Dimensions: 3</span></p>
<p><span>Dimensions and sizes:<span>        </span>[time | 120] x [lat | 360] x [lon | 720]</span></p>
<p><span>Coordinates: </span></p>
<p><span>            time: [18642..22264]</span></p>
<p><span>            lat: [-89.75..89.75]</span></p>
<p><span>            lon: [-179.75..179.75]</span></p>
<p><span>Number Of Attributes: 5</span></p>
<p><span>  long_name :<span>        </span>potential evapotranspiration</span></p>
<p><span>  units :<span>        </span>mm/day</span></p>
<p><span>  correlation_decay_distance :<span>        </span>-999</span></p>
<p><span>  _FillValue :<span>        </span>9.969209968386869e+36</span></p>
<p><span>  missing_value :<span>        </span>9.969209968386869e+36</span></p><p>Variable: dym</p><p><span></span></p>
<p><span>Type: double</span></p>
<p><span>Total Size: 960 bytes</span></p>
<p><span>            120 values</span></p>
<p><span>Number of Dimensions: 1</span></p>
<p><span>Dimensions and sizes:<span>        </span>[120]</span></p>
<p><span>Coordinates: </span></p>
<p><span>Number Of Attributes: 1</span></p>
<p><span>  calendar :<span>        </span>gregorian</span></p>
<p><span>(0)<span>        </span>month_to_annual_weighted: mm must be 1-to-12 inclusive</span></p><p>The error message is &quot; mm must be 1-to-12 inclusive&quot;. </p><p>dym values are from 195101 to 196012.</p><p>This is a very simple code. I couldn&#39;t figure out what was wrong with my code.</p><p>The data is too big and I will send it if necessary. Thanks for any suggestions. </p><span><font color="#888888"><p>Lei</p><p><br></p><p><span><br></span></p></font></span></div><div><br></div></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></div>
</blockquote></div><br></div>