[ncl-talk] Adding multiple WRF output files to a script
Mary Haley
haley at ucar.edu
Tue Aug 30 15:39:29 MDT 2016
You have to be careful when you use "addfile" and "addfiles"
interchangeably, because "addfiles" returns a list object, while "addfile"
returns a file pointer.
In your script, you are using "addfiles" to open a series of files, but
then trying to use "f" as if it were a file pointer.
It's telling you where the problem is:
lat1 = f->XLAT(0,ny,mx) ; the is the nearest grid point
You can't use "f->" syntax with something opened with addfiles.
One of these should work:
lat1 = f[0]->XLAT(0,ny,mx)
or
lat1 = wrf_user_getvar(f,"lat",0)
You will need to fix "lon1" too.
--Mary
On Tue, Aug 30, 2016 at 7:28 AM, Muhammad Omer Mughal <
m.mughal1 at postgrad.curtin.edu.au> wrote:
> Hi Mary
>
>
> I tried to use addfiles for just the fourth domain as the wrf output is
> for the fourth domain is split up into multiple files. I put all the
> variables in a single file as it would exceed the limit of my computer.
>
>
> When I used the script you had sent earlier over just the fourth domain I
> get the following error.
>
>
> fatal:(f) not reference to a valid file
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in
> file wrf_script-r2
>
> The script is attached again for convenience.
>
> Muhammad Omer Mughal
> MSc BSc Mechanical Engineering
> PhD Research Scholar
> Remote Sensing and Satellite Research Group
> Department of Imaging and Applied Physics
> Curtin University
>
> Curtin University
> Tel | +61 8 9266 7962
> Fax | +61 8 9266 2377
> Mobile | 0470 237 525
>
> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au>
> Web | http://curtin.edu.au
>
> Curtin University is a trademark of Curtin University of Technology.
> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>
>
> ------------------------------
> *From:* Mary Haley <haley at ucar.edu>
> *Sent:* Tuesday, 30 August 2016 4:21:58 AM
>
> *To:* Muhammad Omer Mughal
> *Cc:* ncl-talk at ucar.edu
> *Subject:* Re: [ncl-talk] Adding multiple WRF output files to a script
>
> It appears that you are using "addfiles" to open a bunch of WRF files that
> are from different domains. I assume these different domain files are of
> different spatial sizes, and hence addfiles shouldn't be used to open all
> of them together.
>
> Addfiles is really mean to be used on similar files, for example, files
> with the same spatial dimensions, but across different times or ensembles.
>
> It's not clear to me what you are trying to accomplish with your original
> script, because you have a couple of calculations, but nothing is really
> done with them.
>
> In any case, I suggest that since you are calling different types of
> files, you will need to call "addfile" inside the loop for each file, and
> do the necessary calculation:
>
> FILES = systemfunc (" ls -1 " + DATADir + "wrfout* ")
> nfiles = dimsizes(FILES)
>
> do nf = 0,nfiles-1 ; # of files loop
> f = addfile(FILES(nf))+".nc","r")
> times = wrf_user_list_times(f)
> ntimes = dimsizes(ntimes)
>
> u = wrf_user_getvar(f,"ua",-1) ; u averaged to mass points
> v = wrf_user_getvar(f,"va",-1) ; v averaged to mass points
> . . .
>
>
>
> On Mon, Aug 29, 2016 at 6:35 AM, Muhammad Omer Mughal <
> m.mughal1 at postgrad.curtin.edu.au> wrote:
>
>> Hi Mary
>>
>>
>> Thanks for the reply. Kindly note intially ntimes was not defined due to
>> error in the line
>>
>>
>> ntimes = dimsizes(ntimes)
>>
>> so I changed it to
>>
>> ntimes = dimsizes(times)
>>
>>
>> After that I get the error the detail of which is listed in the attached
>> file.
>>
>>
>>
>> Muhammad Omer Mughal
>> MSc BSc Mechanical Engineering
>> PhD Research Scholar
>> Remote Sensing and Satellite Research Group
>> Department of Imaging and Applied Physics
>> Curtin University
>>
>> Curtin University
>> Tel | +61 8 9266 7962
>> Fax | +61 8 9266 2377
>> Mobile | 0470 237 525
>>
>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au>
>> Web | http://curtin.edu.au
>>
>> Curtin University is a trademark of Curtin University of Technology.
>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>
>>
>> ------------------------------
>> *From:* Mary Haley <haley at ucar.edu>
>> *Sent:* Saturday, 27 August 2016 3:22:53 AM
>> *To:* Muhammad Omer Mughal
>> *Cc:* ncl-talk at ucar.edu
>> *Subject:* Re: [ncl-talk] Adding multiple WRF output files to a script
>>
>> Dear Muhammad,
>>
>> The script you provided wouldn't run as-is, because you are referencing
>> "times", but never setting it.
>>
>> Also, you are calling "addfiles" inside a do loop across the file names,
>> but addfiles is meant to be used on an array of files.
>>
>> In the future, it would help if you provide the exact error message, and
>> the full script, so we can see what line number the script is failing on.
>>
>> See the attached wrf_script_mod which is a modification of your file.
>> It's likely not going to run, but hopefully it will help you get started in
>> using addfiles correctly.
>>
>> --Mary
>>
>>
>> On Fri, Aug 26, 2016 at 4:08 AM, Muhammad Omer Mughal <
>> m.mughal1 at postgrad.curtin.edu.au> wrote:
>>
>>> Hi
>>>
>>>
>>> I am trying to add multiple wrfoutput files in the attached script but I
>>> get an error of mismatch dimensions. Can some one help please
>>>
>>>
>>>
>>>
>>>
>>> Muhammad Omer Mughal
>>> MSc BSc Mechanical Engineering
>>> PhD Research Scholar
>>> Remote Sensing and Satellite Research Group
>>> Department of Imaging and Applied Physics
>>> Curtin University
>>>
>>> Curtin University
>>> Tel | +61 8 9266 7962
>>> Fax | +61 8 9266 2377
>>> Mobile | 0470 237 525
>>>
>>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au>
>>> Web | http://curtin.edu.au
>>>
>>> Curtin University is a trademark of Curtin University of Technology.
>>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>>
>>>
>>>
>>> _______________________________________________
>>> 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/20160830/25ae0b91/attachment.html
More information about the ncl-talk
mailing list