[ncl-talk] addfiles: selecting files with datestamp in filename

Dennis Shea shea at ucar.edu
Fri Oct 13 08:00:04 MDT 2017


An additional method based on Kevin's reply:

files = *systemfunc*("ls wrfout_d01_2*")   ; *all* 'd01' files for the 2000s

*sqsort*(files)   ; sort into ascending order

name_start = "wrfout_d01_2016-12-01_00:00:00"

*ii* = *ind*(files.ge.name_start)
f  = *addfiles*(files(*ii*), "r") ; all file from 'name_start' onward

======
If you want a stop date then

name_last = "wrfout_d01_2016-25-01_23:59:59"

*kk* = *ind*(files.ge.name_start .and. files.le.name_last)
f  = *addfiles*(files(*kk*), "r")

On Fri, Oct 13, 2017 at 1:00 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Kevin:
>
> Thank you for this very clear explanation for how to read multiple files
> with systemfunc "ls."
>
> Barry
>
> On Fri, Oct 13, 2017 at 1:16 AM, Kevin Hallock <hallock at ucar.edu> wrote:
>
>> Hi Sujit,
>>
>> The simplest way to open multiple wrfout files would be something like
>> this:
>> files = systemfunc("ls wrfout_d01_2016-12*")
>> f = addfiles(files, "r")
>>
>> This will load all files that begin with “wrfout_d01_2016-12” (in other
>> words any file from December 2016).
>>
>> If you want to include files from 2017 as well, you could run:
>> files = systemfunc("ls wrfout_d01_2016-12* wrfout_d01_2017*")
>> f = addfiles(files, "r")
>>
>> This will load all files that begin with “wrfout_d01_2016-12” or “
>> wrfout_d01_2017” (in other words any file from December 2016 or all of
>> 2017).
>>
>> Alternatively, if you need more control over which files are selected,
>> you could try something like this instead:
>> files = systemfunc("ls wrfout_d01_2016-12-0[123]*")
>> f = addfiles(files, "r")
>>
>> This loads all files that begin with “wrfout_d01_2016-12-0” and where
>> the following character is 1, 2, or 3 (so just December 1 through 3).
>>
>> Finally, you can also include time with the date in your “ls” command.
>> For example, if you wanted all files from December 1 through 9 at 12:00:
>> files = systemfunc("ls wrfout_d01_2016-12-0[0-9]_12:00:00")
>> f = addfiles(files, "r")
>>
>> I hope this helps,
>>
>> Kevin
>>
>> On Oct 12, 2017, at 12:05 AM, Sujit Maji <sujit.cat at tropmet.res.in>
>> wrote:
>>
>> Hi all,
>>
>> Have anyone tried to select wrfout*(WRF model output) files (as input to
>> addfiles function in ncl) based on the date stamp on filename ?
>>
>> e.g. suppose filename is  wrfout_d01_2016-12-01_00:00:00
>>
>> and
>>
>> I want to select files with dates later than 2016_12_01 (1st December
>> 2016) in filename i.e. wrfout_d01_2016-12-02_00:00:00 or
>> wrfout_d01_2016-12-03_00:00:00.
>>
>>
>> I don't have expertise in sed,awk or find utilities of GNU. That's why I
>> asked.
>>
>> If anyone have tried please share any experience.
>>
>> Thanks and regards,
>> Sujit Maji
>> IITM Pune
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108 <(914)%20432-3108>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171013/70f1b1f9/attachment.html>


More information about the ncl-talk mailing list