[pyngl-talk] reading intermediate WPS files

Bill Ladwig ladwig at ucar.edu
Fri Mar 3 23:21:51 MST 2017


Hi Marie,

I threw together a python reader function for the WPS formatted
intermediate files to show how you can read the files using the struct
module.  This only does the read and not the write.  Writing the files is a
little trickier because each fortran record requires the record size at the
beginning and end, but for the most part you can look at this code and do
the reverse operation. I should warn you that this isn't completely tested,
so it might crash on you.

This function will return a list of WPSData objects, and to collect a
common variable type, you'll have to do some searching through the list
since they could be in random order, depending on how the file was
written.  Hopefully you'll find it useful.

Best of luck,

Bill

On Fri, Mar 3, 2017 at 9:44 AM, Bill Ladwig <ladwig at ucar.edu> wrote:

> Hi Marie,
>
> Not currently, but NCL can read the WPS files.  I will make a ticket to
> add this to the wrf-python package, but don't think this will make it in to
> the soon-to-be released 1.0.0 version (beta versions are available now from
> conda using the conda-forge channel if you want the diagnostic and
> interpolation routines in python).
>
> Here is the description of the WPS/intermediate binary files:
>
> http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Basics/IM_files/
>
> You should be able to use the struct, array, or scipy.io.FortranFile
> modules from python to read/write the files, or you can modify the sample
> Fortran code and use f2py to work in Fortran.
>
> Hope this helps,
>
> Bill
>
> On Fri, Mar 3, 2017 at 6:23 AM, Marie Pontoppidan <
> Marie.Pontoppidan at uni.no> wrote:
>
>> Hi.
>> I have been trying for a while to find a way of reading one variable from
>> multiple intermediate files into python for analysis and plotting. However
>> this seems to be more or less impossible. One could read from the met_em
>> files instead, but I would really like to do some analysis on these
>> intermediate files, before the met_em interpolation.
>> Is there a pyngl/pynio function for reading selected variables directly
>> from the intermediatefiles?
>>
>> Cheers,
>> *Marie Pontoppidan*
>> PhD student
>> Uni Research Climate
>> email: marie.pontoppidan at uni.no
>> mobile: +47 975 73 215 <+47%20975%2073%20215>
>> office: +47 555 89 832
>>
>>
>>
>>
>> _______________________________________________
>> pyngl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20170303/c91f3de0/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wps.py
Type: text/x-python-script
Size: 6705 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20170303/c91f3de0/attachment.bin 


More information about the pyngl-talk mailing list