[ncl-talk] Question concerning listing files

Dennis Shea shea at ucar.edu
Mon Nov 21 12:25:54 MST 2016


THX.

So .... your directory structure had each 'Date' in a different directory
(diri = DATADir+Date)?
This was not clear (to me) in the original message.

I thought it was embedded in the individual file names: eg

   nam_xxx_20130208_yyyy_zzz.grb

Hence,
    Date = "20130208/"

    files = systemfunc("ls nam_xxx_"+Date+"*grb)

Cheers
D

On Mon, Nov 21, 2016 at 12:11 PM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Dennis, thank you.
>
> Here is the sequence of calls to produce the list, for reference of list
> users.
>
> begin
> ; http://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml
> ; to retrieve a list of files from another directory
>  Date = "20130208/"
>  DATADir = "/data1/wrf/NAM/"
>  diri = DATADir+Date
>  all_files = systemfunc("ls " + diri + "nam*grb") ; notice quotes around
> ls as well.
>  n_files = dimsizes(all_files)
>  print("n_files = " + n_files)
>  do n=0,n_files -1
>    print("all_files(n) = " + all_files(n))
>   filename = all_files(n)
>   print ("filename" + filename)
>   a = addfile(filename,"r")
>   nc_file = a
>   MY_PRES = nc_file->PRMSL_218_MSL
>   print("MY_PRES" + MY_PRES(5,5))
>   end do
> end
>
>
> On Mon, Nov 21, 2016 at 5:51 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> Maybe:
>>
>> Date = "20130208"
>>
>> all_files = systemfunc ("ls nam*"+Date+"*grb"")  ; GRIB file in current
>> directory
>>
>> On Mon, Nov 21, 2016 at 7:28 AM, Barry Lynn <barry.h.lynn at gmail.com>
>> wrote:
>>
>>> Hello:
>>>
>>> On: https://www.ncl.ucar.edu/Applications/addfiles.shtml
>>>
>>> there is the command:
>>>
>>> all_files = *systemfunc* <https://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml> ("ls /fs/cgd/data0/casguest/CLASS/ann*.nc")
>>>
>>> I want to include a variable in the all_files line.
>>>
>>> Date = "20130208"
>>>
>>> all_files = systemfunc ("ls 20130208/nam*grb"")
>>>
>>> Such that it includes the variable "Date."
>>>
>>> --> all_files = systemfunc ("ls Date + "nam*grb"")
>>>
>>> However, the line immediately above gives an syntax error and anything
>>> else I have tried is the same.
>>>
>>> Thank you,
>>>
>>> Barry
>>>
>>>
>>> --
>>> 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
>>>
>>> _______________________________________________
>>> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161121/0fe76a77/attachment.html 


More information about the ncl-talk mailing list