[ncl-talk] How to combine many nc files from different folders

Dennis Shea shea at ucar.edu
Tue Sep 17 11:44:33 MDT 2019


Given your screen shot, the following will likely work:

fils= *systemfunc*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml>("ls
[1-2][8-9-0-1]*/*nc")
print(fils)

f    = *addfiles*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml>
(fils, "r")
x   = f[:]->X
*printVarSummary*(x)

On Tue, Sep 17, 2019 at 9:57 AM Adam Phillips via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hi Setareh,
> See the examples on the addfiles documentation page:
> https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
>
> Whatever syntax works in your shell, will work for NCL. For instance this
> might work:
> fils = systemfunc ("ls */*.nc") ; file paths
> print(fils)
> f    = addfiles (fils, "r")
> IF the only files in the directories are the ones your want, the ordering
> is what you want, etc. See the output from print(fils). This may take some
> trial and error, but the goal will be to set the correct syntax within
> systemfunc to see only the files you want in the correct order that you
> need them.
> Adam
>
>
> On Tue, Sep 17, 2019 at 4:01 AM Setareh Rahimi via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Dear all,
>>
>> I have daily precipitation data from 1983-2017. Each year has been saved
>> in one separate folder (have a look at attached image). I need to combine
>> all these data to have a climatological average of precipitation. My
>> problem is that, how can I indicate the path of data to NCL, to find all
>> the data set. The script I use is in the same folder that data has been
>> saved. the script attached. Please kindly advice me on this issue.
>> Many thanks in advance,
>> Best wishes,
>> --
>> S.Rahimi
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> --
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
> _______________________________________________
> 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/20190917/d2d67061/attachment.html>


More information about the ncl-talk mailing list