<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 "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"</div><div>begin</div><div> </div><div> diri = "/Users/nmb1441/research/papers/china/monsoons/cru_data/pet/"</div><div> srcFileName = "<a href="http://cru_ts3.21.1951.1960.pet.dat.nc">cru_ts3.21.1951.1960.pet.dat.nc</a>" </div><div> refile= addfile(diri + srcFileName,"r")</div><div><br></div><div> pet = refile->pet</div><div> lat = refile->lat</div><div> lon = refile->lon</div><div> time = refile->time</div><div> </div><div> time@calendar = "gregorian"</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 class=""><span class="">Variable: pet</span></p>
<p class=""><span class="">Type: double</span></p>
<p class=""><span class="">Total Size: 248832000 bytes</span></p>
<p class=""><span class=""> 31104000 values</span></p>
<p class=""><span class="">Number of Dimensions: 3</span></p>
<p class=""><span class="">Dimensions and sizes:<span class="">        </span>[time | 120] x [lat | 360] x [lon | 720]</span></p>
<p class=""><span class="">Coordinates: </span></p>
<p class=""><span class=""> time: [18642..22264]</span></p>
<p class=""><span class=""> lat: [-89.75..89.75]</span></p>
<p class=""><span class=""> lon: [-179.75..179.75]</span></p>
<p class=""><span class="">Number Of Attributes: 5</span></p>
<p class=""><span class=""> long_name :<span class="">        </span>potential evapotranspiration</span></p>
<p class=""><span class=""> units :<span class="">        </span>mm/day</span></p>
<p class=""><span class=""> correlation_decay_distance :<span class="">        </span>-999</span></p>
<p class=""><span class=""> _FillValue :<span class="">        </span>9.969209968386869e+36</span></p>
<p class=""><span class=""> missing_value :<span class="">        </span>9.969209968386869e+36</span></p><p class="">Variable: dym</p><p class=""><span class=""></span></p>
<p class=""><span class="">Type: double</span></p>
<p class=""><span class="">Total Size: 960 bytes</span></p>
<p class=""><span class=""> 120 values</span></p>
<p class=""><span class="">Number of Dimensions: 1</span></p>
<p class=""><span class="">Dimensions and sizes:<span class="">        </span>[120]</span></p>
<p class=""><span class="">Coordinates: </span></p>
<p class=""><span class="">Number Of Attributes: 1</span></p>
<p class=""><span class=""> calendar :<span class="">        </span>gregorian</span></p>
<p class=""><span class="">(0)<span class="">        </span>month_to_annual_weighted: mm must be 1-to-12 inclusive</span></p><p class="">The error message is " mm must be 1-to-12 inclusive". </p><p class="">dym values are from 195101 to 196012.</p><p class="">This is a very simple code. I couldn't figure out what was wrong with my code.</p><p class="">The data is too big and I will send it if necessary. Thanks for any suggestions. </p><p class="">Lei</p><p class=""><br></p><p class=""><span class=""><br></span></p></div><div><br></div></div>