<div dir="ltr"><div>Thank you so much, <span name="Griffith Young" class="gmail-gD">Griffith and  </span><span name="Griffith Young" class="gmail-gD"><span style="font-size:11pt;font-family:"Calibri","sans-serif"" lang="EN-US">Guido Cioni for this valuable suggestion.  <br></span></span></div><span name="Griffith Young" class="gmail-gD"><span style="font-size:11pt;font-family:"Calibri","sans-serif"" lang="EN-US">It worked. <br></span></span><div class="gmail_extra"><br></div><div class="gmail_extra">regards<br clear="all"></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Kunal Bali<br></div><br><div><br></div><div><p style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;border-collapse:collapse;font-family:Tahoma,Verdana;font-size:12px"><font color="#1F497D"><br></font></p></div></div></div></div></div></div>
<br><div class="gmail_quote">On Fri, Oct 6, 2017 at 3:16 AM, Griffith Young <span dir="ltr"><<a href="mailto:griffith.young@bom.gov.au" target="_blank">griffith.young@bom.gov.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-AU">
<div class="m_-8224981502855029945WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hello Kunal,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                “</span><span lang="EN-GB">creating wrong date as the files are of December month, but it is generating January month
 date also. I don't know why.</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                Your script was fine.  You just needed to subtract 1 from your Julian date.  So you math was wrong…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                For example …2000001… would become “001 days 2000-01-01”, which is 2000-01-02.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                Guido’s (excellent) script could also be simplified to return the whole date at once.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">               
</span>yyyymmdd=`date -d "${year}-01-01 +${day_of_year} days -1 day" "+%Y%m%d"`<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                If you are using bash, I would recommend using $(command) instead of `command` as it is clearer where the boundaries
 are.  (If that makes sense.  Backticks can lead to strange behaviours that are hard to spot when sharing code.)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                I find this easier to read:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                *             yyyymmdd=$(date -d "${year}-01-01 +${day_of_year} days -1 day" "+%Y%m%d")<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                I hope I have answered your “</span><span lang="EN-GB">I don't know why</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">”
 question.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">                Griff.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"" lang="EN-US"> ncl-talk [mailto:<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.<wbr>edu</a>]
<b>On Behalf Of </b>Guido Cioni<br>
<b>Sent:</b> Friday, 6 October 2017 7:46 AM<br>
<b>To:</b> Marston Johnston<br>
<b>Cc:</b> ncl-talk<br>
<b>Subject:</b> Re: [ncl-talk] set_date_time<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I had to do something similar last week. Converting from hdf to netcdf and then merge into a single file with time information. It was modis data. I don't have time to explain the script so I'm copying here hoping that it could help.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">for f in *.nc; do<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    year=${f:9:4}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    day_of_year=${f:13:3}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    month=`date -d "${year}-01-01 +${day_of_year} days -1 day" "+%m"`<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    day=`date -d "${year}-01-01 +${day_of_year} days -1 day" "+%d"`<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    echo ${year}-${month}-${day}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">    cdo -b F64 setdate,${year}-${month}-${<wbr>day} ${f} ${f%.nc}_<a href="http://2.nc" target="_blank">2.nc</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">done <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Cheers <u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Il 5 ott 2017 9:56 PM, "Marston Johnston" <<a href="mailto:shejo284@gmail.com" target="_blank">shejo284@gmail.com</a>> ha scritto:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span lang="EN-GB">It seems like you choose a fairly complicated way to solve the problem.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">May I suggest reading in the MAIACTAOT.h00v02.<b>*</b>.nc files in chronological order and then writing new netcdf files in ncl where you can create a time array
 with the correct dtg.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">It’s fairly quick and easy in ncl.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">I’ve had such problems before and found it easiest to with the above method.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Hope this helps,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">/M<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">Marston S. Ward, PhD</span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">Department of Earth Sciences</span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">University of Gothenburg, Sweden</span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">Email: <a href="mailto:marston.johnston@gu.se" target="_blank"><span style="color:#0070c0">marston.johnston@gu.se</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">SkypeID: marston.johnston </span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">Phone:
<a href="tel:+46%2031%20786%2049%2001" target="_blank">+46-31-7864901</a> </span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">Only the fruitful thing is true!</span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#0070c0" lang="EN-GB">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span lang="EN-GB"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="color:black" lang="EN-GB">From:
</span></b><span style="color:black" lang="EN-GB">ncl-talk <<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>> on behalf of Kunal Bali <<a href="mailto:kunal.bali9@gmail.com" target="_blank">kunal.bali9@gmail.com</a>><br>
<b>Date: </b>Thursday, 5 October 2017 at 20:40<br>
<b>To: </b>"<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
<b>Subject: </b>[ncl-talk] set_date_time</span><span lang="EN-GB"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Dear NCL users,<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">I have one question regarding date-time setting from filename. This question is not actually related to NCL, sorry in advance. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">I have 4 .nc files named given below. The time is not created in these files during conversion from hdf to netcdf in NCL. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">MAIACTAOT<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>h00v02<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span><b><span style="color:red">2000</span><span style="color:blue">364</span><span style="color:#ff9900">07</span><span style="color:fuchsia">15</span></b><span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.<wbr>nc</span> 
  --> 2000=year, 364=day, 07=<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">hr</span>, 15=min<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">MAIACTAOT<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>h00v02<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>20003650620<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.<wbr>nc</span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">MAIACTAOT<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>h00v02<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>20003660525<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.<wbr>nc</span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">MAIACTAOT<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>h00v02<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.</span>20003660700<span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark">.<wbr>nc</span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">So, I did try to create the date-time with shell scripting (given below)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark"><span lang="EN-GB">but</span></span><span lang="EN-GB"> it is creating wrong date as the files are of December month,
 but it is generating January month date also. I don't know why. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span lang="EN-GB">2000-01-01 05:25:00</span></b><span lang="EN-GB"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span lang="EN-GB">2000-01-01 07:00:00</span></b><span lang="EN-GB"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">2000-12-30 07:15:00<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">2000-12-31 06:20:00<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span class="m_-8224981502855029945m6544476848491288552gmail-gingersoftwaremark"><span lang="EN-GB">the</span></span><span lang="EN-GB"> shell script, which I am using<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-GB">##############################<wbr>#########<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">for n in  MAIACTAOT.h00v02.20*.nc;do<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> ls $n > text<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">export xx=`cut -c18-28 text`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">export YYYY=`cut -c18-21 text`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">export JJJ=`cut -c22-24 text`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">export HH=`cut -c25-26 text`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">export MM=`cut -c27-28 text`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">mm=`date -d "$JJJ days $YYYY-01-01" +"%m"`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">dd=`date -d "$JJJ days $YYYY-01-01" +"%d"`<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">mydate=${YYYY}-${mm}-${dd},${<wbr>HH}:${MM}:00<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">echo $mydate<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">echo "cdo settaxis,$mydate $n re$n"<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">cdo settaxis,$mydate $n re$n<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">done<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">cdo mergetime reMAI*.nc
<a href="http://final.nc" target="_blank">final.nc</a><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">exit<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">##############################<wbr>###<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Any suggestion regarding this issue would be very helpful.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Thank You<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"><br clear="all">
<u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-GB">Kunal Bali<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB"> <u></u><u></u></span></p>
</div>
<div>
<p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:9.0pt;font-family:"Tahoma","sans-serif"" lang="EN-GB"> </span><span lang="EN-GB"><u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span lang="EN-GB">______________________________<wbr>_________________ ncl-talk mailing list
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a> List instructions, subscriber options, unsubscribe:
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a>
<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>

</blockquote></div><br></div></div>