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

Kevin Hallock hallock at ucar.edu
Thu Oct 12 16:16:40 MDT 2017


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171012/3d73e484/attachment.html>


More information about the ncl-talk mailing list