<div dir="ltr"><div class="gmail_default" style="font-size:small">I believe this code should work on any kind of WRF Times array that looks like "YYYY-MM-DD_mm:SS:SS".</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It parses this string to get the "MM" field, and then uses this to extract the months that are equal to 3, 4 and 5 (for MAM), or 10, 11, and 12 (for OND). It doesn't look at the YYYY, DD, mm, or SS fields at all.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I've attached a dummy NCL script that you should be able to run just as it is. It creates a dummy array of WRF times and then shows how it extracts the MAM and OND times.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You should be able to edit this script to have it read in your WRF files with "addfiles", and then use "wrf_user_list_times" to get the times. You can then see by the "print" statement whether it correct extracted the MAM and OND dates.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 1:35 AM, afwande juliet <span dir="ltr"><<a href="mailto:afwandej965@gmail.com" target="_blank">afwandej965@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>ok Mary </div><div>thanks. Does this code assume the data is daily since my data (wrfoutput) is 3hourly. If that's the case must I convert data to monthly or daily?</div><div>I would appreciate</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 7, 2015 at 8:17 AM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">WRF output files store their "times" array as strings, so you probably need to read these off the files and parse them. You should be able to do this with str_split_csv.</div><div style="font-size:small"><br></div><div style="font-size:small">For example, let's say you open the files and read the "Times" variable with:</div><div style="font-size:small"><br></div><div style="font-size:small">[UNTESTED]:</div><div style="font-size:small"><br></div><div style="font-size:small"><font face="monospace, monospace"> files = systemfunc("ls wrfout_d01*")</font></div><div style="font-size:small"><font face="monospace, monospace"> files = files + ".nc"</font></div><div style="font-size:small"><font face="monospace, monospace"><br></font></div><div style="font-size:small"><font face="monospace, monospace"> f = addfiles(files,"r")</font></div><div style="font-size:small"><span style="font-family:monospace,monospace"> times = wrf_user_list_times(f) ; Read "Times" off the file</span></div><div style="font-size:small"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:small"><font face="arial, helvetica, sans-serif">You can then parse the "times" array using "str_split_csv" to split the fields on the "-" and "_" characters, which is what separates the years, months, and days:</font></div><div style="font-size:small"><span style="font-family:monospace,monospace"><br></span></div><div><div style="font-family:monospace,monospace;font-size:small">;--Parse the WRF times string to get the months as integers. </div><div style="font-family:monospace,monospace;font-size:small"> str1 = str_split_csv(times,"-",0) ; first split on "-"</div><div style="font-family:monospace,monospace;font-size:small"> str2 = str_split_csv(str1(:,2),"_",0) ; now split on "_""<br><br></div><div style="font-family:monospace,monospace;font-size:small"> wrf_months = toint(str1(:,1)) ; should be integers from 1 to 12</div><div style="font-family:monospace,monospace;font-size:small"><br></div><div style="font-size:small"><font face="arial, helvetica, sans-serif">Now that you have "wrf_months", you can use the "ind" function to grab the months you want:</font></div><div style="font-family:monospace,monospace;font-size:small"><br></div><div><div><font face="monospace, monospace">;---Get the index locations for MAM and OND</font></div><div><font face="monospace, monospace"> mam_ind = ind(<a href="http://wrf_months.ge" target="_blank">wrf_months.ge</a>. 3.and.wrf_months.le. 5)</font></div><div><font face="monospace, monospace"> ond_ind = ind(wrf_months.ge.10.and.wrf_months.le.12)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">;</font></div><div><font face="monospace, monospace">; You may not have any need for the wrf_times_mam and</font></div><div><font face="monospace, monospace">; wrf_times_ond arrays, but I'm including them here to</font></div><div><font face="monospace, monospace">; see what they look like.</font></div><div><font face="monospace, monospace">;</font></div><div><font face="monospace, monospace"> wrf_times_mam = times(mam_ind)</font></div><div><font face="monospace, monospace"> wrf_times_ond = times(ond_ind)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> print("MAM: " + wrf_times_mam)</font></div><div><font face="monospace, monospace"> print("OND: " + wrf_times_ond)</font></div></div><div style="font-size:small"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:small"><font face="arial, helvetica, sans-serif">These index values can be used to index any WRF variable that you read with "wrf_user_getvar", or straight off the file:</font></div><div style="font-size:small"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:small">
<p><font face="monospace, monospace">;---Read all sea level pressures off the files<br></font><span style="font-family:monospace,monospace"> slp = wrf_user_getvar(f,"slp",-1) </span><span style="font-family:monospace,monospace">; sea level pressure</span></p><p><font face="monospace, monospace">;---Grab only MAM and OND seasons of slp<br></font><span style="font-family:monospace,monospace"> slp_mam = slp(mam_ind,:,:) ; this assumes "slp" is 3D<br></span><span style="font-family:monospace,monospace"> slp_ond = slp(ond_ind,:,:)</span></p><p><font face="arial, helvetica, sans-serif">Let me know if this is not what you needed.</font></p><p><font face="arial, helvetica, sans-serif">--Mary</font></p><p><span style="font-family:monospace,monospace"><br></span></p></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sun, Dec 6, 2015 at 12:53 AM, afwande juliet <span dir="ltr"><<a href="mailto:afwandej965@gmail.com" target="_blank">afwandej965@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div><div dir="ltr"><div>Dear NCL users</div><div>I have many files from wrf output like this etc..</div><div><br></div><div>wrfout_d01_1982-02-01_00:00:00 <br>wrfout_d01_1982-06-06_00:00:00 <br>wrfout_d01_1982-10-09_00:00:00 <br>wrfout_d01_1997-02-01_00:00:00 <br>wrfout_d01_1997-03-03_03:00:00 <br>wrfout_d01_1997-06-04_03:00:00 <br>wrfout_d01_1997-07-04_03:00:00 <br>wrfout_d01_1997-07-29_03:00:00 <br>wrfout_d01_1997-09-29_15:00:00 </div><div><br></div><div>I want to extract only 6variables for MAM and OND seasons for all the files so that whatever files I will finally have will contain only 6variables for times march-May and October -Dec</div><div><br></div><div>Is there a way I can do this in NCL, I am trying to check the NCL documentations script at <a href="http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/BASIC_SFC/wrf_Surface_multi_input_files.htm" target="_blank">http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/BASIC_SFC/wrf_Surface_multi_input_files.htm</a></div><div>but can get way out</div></div>
<br></div></div>_______________________________________________<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" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>