<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 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" 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 class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For example, let's say you open the files and read the "Times" variable with:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">[UNTESTED]:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> files = systemfunc("ls wrfout_d01*")</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> files = files + ".nc"</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"><br></font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace"> f = addfiles(files,"r")</font></div><div class="gmail_default" style="font-size:small"><span style="font-family:monospace,monospace"> times = wrf_user_list_times(f) ; Read "Times" off the file</span></div><div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default" 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 class="gmail_default" style="font-size:small"><span style="font-family:monospace,monospace"><br></span></div><div class="gmail_default"><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">;--Parse the WRF times string to get the months as integers. </div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"> str1 = str_split_csv(times,"-",0) ; first split on "-"</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"> str2 = str_split_csv(str1(:,2),"_",0) ; now split on "_""<br><br></div><div class="gmail_default" 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 class="h5">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 class="h5"><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" target="_blank" rel="noreferrer">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>