<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 18 Dec 2015, at 11:10, Mark Chan <<a href="mailto:cym263@yahoo.com" class="">cym263@yahoo.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" class=""><div dir="ltr" id="yui_3_16_0_1_1450436634824_24074" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">Dear Dennis,</span></div><div id="yui_3_16_0_1_1450436634824_24197" dir="ltr" class=""><br class=""><span id="yui_3_16_0_1_1450436634824_24096" class=""></span></div><div id="yui_3_16_0_1_1450436634824_24157" dir="ltr" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">I tried to use your suggested script, but got an error message as below (probablly because of, time = cd_convert( time0, "hours since 1987-04-13 18:00:00" )). Would you please kindly give more suggestion?</span></div><div id="yui_3_16_0_1_1450436634824_24312" dir="ltr" class=""><br class=""><span id="yui_3_16_0_1_1450436634824_24096" class=""></span></div><div id="yui_3_16_0_1_1450436634824_24332" dir="ltr" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">Thanks so much!!!</span></div><div dir="ltr" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">Mark<br class=""></span></div><div id="yui_3_16_0_1_1450436634824_24158" dir="ltr" class=""><br class=""><span id="yui_3_16_0_1_1450436634824_24096" class=""></span></div><div id="yui_3_16_0_1_1450436634824_24347" dir="ltr" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">===ncl error message===<br class=""></span></div><div id="yui_3_16_0_1_1450436634824_24102" dir="ltr" class=""><span id="yui_3_16_0_1_1450436634824_24096" class="">Variable: time0<br class="" id="yui_3_16_0_1_1450436634824_24077">Type: character<br class="" id="yui_3_16_0_1_1450436634824_24079">Total Size: 19 bytes<br class="" id="yui_3_16_0_1_1450436634824_24081"> 19 values<br class="" id="yui_3_16_0_1_1450436634824_24083">Number of Dimensions: 2<br class="" id="yui_3_16_0_1_1450436634824_24085">Dimensions and sizes: [Time | 1] x [DateStrLen | 19]<br class="" id="yui_3_16_0_1_1450436634824_24087">Coordinates: <br class="" id="yui_3_16_0_1_1450436634824_24089">Number Of Attributes: 0<br class="" id="yui_3_16_0_1_1450436634824_24091">fatal:Could not coerce values for operation<br class="" id="yui_3_16_0_1_1450436634824_24093">fatal:["Execute.c":8128]:Execute: Error occurred at or near line 15 in file D1_Times.ncl<br class="" id="yui_3_16_0_1_1450436634824_24095"></span></div> <div class="qtdSeparateBR"><br class=""><br class=""></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" class=""> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" class=""> <div dir="ltr" class=""><font face="Arial" size="2" class=""> On Tuesday, December 15, 2015 9:04 PM, Dennis Shea <<a href="mailto:shea@ucar.edu" class="">shea@ucar.edu</a>> wrote:<br class=""></font></div> <br class=""><br class=""> <div class="y_msg_container">Perhaps two approaches....<br clear="none" class=""><br clear="none" class=""><br clear="none" class="">[1] Add 6 to current values<br clear="none" class="">[2] Use a function<br clear="none" class=""><br clear="none" class="">Initially,<br clear="none" class=""> f = addfile("...","r") ; Use "r" for test and "w" to actually<br clear="none" class="">overwrite the values<br clear="none" class=""> time0 = f->time<br clear="none" class=""><br clear="none" class=""> time = time0 ; copy for print<br clear="none" class=""> printVarSummary(time0) ; before<br clear="none" class=""><br clear="none" class="">; method 1<br clear="none" class=""><br clear="none" class=""> time = (/ time+6 /) ; replace values<br clear="none" class=""> <a shape="rect" ymailto="mailto:time@units" href="mailto:time@units" class="">time@units</a> = "hours since 1987-04-13 18:00:00" ; new units<br clear="none" class=""> printVarSummary(time) ; after<br clear="none" class=""><br clear="none" class="">or<br clear="none" class=""><br clear="none" class="">; method 2<br clear="none" class="">; <a shape="rect" href="http://www.ncl.ucar.edu/Document/Functions/Contributed/cd_convert.shtml" target="_blank" class="">http://www.ncl.ucar.edu/Document/Functions/Contributed/cd_convert.shtml</a><br clear="none" class=""><br clear="none" class=""> time = cd_convert( time0, "hours since 1987-04-13 18:00:00" )<br clear="none" class=""><br clear="none" class="">; print to make sure they are as you expect<br clear="none" class=""><br clear="none" class=""> print("-----")<br clear="none" class=""> print(time0+" "+time) ; examine before and after values<br clear="none" class=""><br clear="none" class="">====<br clear="none" class=""> If all is ok the use the "w" on the addfile and then overwrite<br clear="none" class=""><br clear="none" class=""> f->time = time<br clear="none" class=""><br clear="none" class="">=================================<br clear="none" class=""><br clear="none" class="">I'd make a copy of the file before doing anything ... just in case<br clear="none" class="">tehre are errors.<br clear="none" class=""><br clear="none" class="">Good Luck<br clear="none" class=""><div class="yqt5130582994" id="yqtfd42555"><br clear="none" class="">On Fri, Dec 11, 2015 at 4:35 AM, Mark Chan <<a shape="rect" ymailto="mailto:cym263@yahoo.com" href="mailto:cym263@yahoo.com" class="">cym263@yahoo.com</a>> wrote:<br clear="none" class="">> Dear NCL group,<br clear="none" class="">><br clear="none" class="">> I am wondering whether there is any easy method with NCL to modify "internal<br clear="none" class="">> Times" of the netcdf file: (the file name would be changed later)<br clear="none" class="">><br clear="none" class="">> from: met_em_d01_1987-04-13_12:00:00<br clear="none" class="">><br clear="none" class="">> To: met_em_d01_1987-04-13_18:00:00<br clear="none" class="">><br clear="none" class="">> So the time could be shown as (with "ncdump -v Times")<br clear="none" class="">> Times = "1978-04-13_18:00:00" ;<br clear="none" class="">><br clear="none" class="">> Thanks very much in advance!!!<br clear="none" class="">> Mark</div><br clear="none" class="">><br clear="none" class="">> _______________________________________________<br clear="none" class="">> ncl-talk mailing list<br clear="none" class="">> <a shape="rect" ymailto="mailto:ncl-talk@ucar.edu" href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br clear="none" class="">> List instructions, subscriber options, unsubscribe:<br clear="none" class="">> <a shape="rect" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><div class="yqt5130582994" id="yqtfd84390"><br clear="none" class="">><br clear="none" class=""></div><br class=""><br class=""></div> </div> </div> </div></div></div>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>