Fwd: Re: Creating a radar object from a text file

177 views
Skip to first unread message

Jonathan Helmus

unread,
Jan 9, 2015, 3:22:08 PM1/9/15
to pyart...@googlegroups.com
Sorry I forgot to keep this discussion on the list.  Copied here in case others run into a similar use case.

    - Jonathan


-------- Forwarded Message --------
Subject: Re: Creating a radar object from a text file
Date: Fri, 9 Jan 2015 13:01:36 -0600
From: Michael Muratet <mura...@gmail.com>
To: Jonathan Helmus <jjhe...@gmail.com>


Hi Jonathan

A colleague figured out how to do it.

It looks like this:

 class Radar:
    def __init__(self,sweep):
        self.sweep = sweep
        self.radar = pyart.testing.make_empty_ppi_radar(sweep.N,360,1)
        self.fields = {
            # Modify min and max for display range
            # Eventually these will be settable upon init or by method
            'valid_min' : sweep.min(),
            'valid_max' : sweep.max(),
            'long_name' : 'rain rate',
            'standard_name' : 'drr',
            'units' : 'drr',
            '_FillValue' : 0,
            'coordinates' : None,
            'data' : sweep.data
        }
        self.radar.add_field('drr',self.fields)

sweep.data is a numpy array

and then

 def plotter(radar,filename):
    """ Pull all the commands needed to make a PPI plot in one place"""
    display = pyart.graph.RadarDisplay(radar.radar)
    fig = plt.figure(figsize=(6, 5))
    ax = fig.add_subplot(111)
    display.plot_ppi('drr',ax=ax)
    display.plot_range_ring(radar.radar.range['data'][-1]/1000, ax=ax)
    plt.axes().set_aspect('equal','datalim')
    plt.savefig(filename)
    plt.close()

Everything is cool as long as the dictionary indices match.

Cheers

Mike

On Jan 9, 2015, at 12:01 PM, Jonathan Helmus wrote:

> On 12/19/2014 10:30 AM, Michael Muratet wrote:
>> Greetings
>> I have a text file with radar variables (reflectivity, diff. reflect., etc.,) as rows of numbers with radial coordinates. I'm segmenting the pixels and I'd like to be able to plot the         classes in a ppi plot. I'd also like to be able to plot the radar data. I found the Radar class. I haven't found any examples of creating a Radar object from text files. It seems         like someone must have already done this, so before I go roll my own: does anyone have an example of creating a Radar object from a text file?
>> Cheers
>> Mike 
>> -- 
>> You received this message because you are subscribed to the Google Groups "Py-ART Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to pyart-users...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
> Mike,
> 
>     Sorry for taking so long to get back to you.  Between the holiday break and AMS meeting I've been neglecting responding to anything but time sensitive emails until now.  
> 
>     I've never created a Py-ART Radar object from a text file and have not heard about anyone doing this, until now, so I do not have a readily available example to provide.  That said you might find the following documentation and files in the Py-ART source helpful:
> 
>     To create a radar object you need to provide a number of parameter which specify the layout of the radar volume and fields.  The list of these parameters and the required format are given in the documentation of the Radar object [1].  I would not worry about providing any of the optional parameter (all those after elevation) unless you have a moving platform (ship or airborne radar).  
>     The source code to the various read_* function in the pyart.io name space can be used an example of how read the in data from a file and prepare the parameters for the creation of a Radar object but these are rather complicated.  A more simple example of creating a Radar object can be found in the function in the sample_object.py file in the testing directory [2].  Of special interest would be the make_empty_ppi_radar function [3] which creates an Radar object for a PPI volume with no fields.  This function is used to create the initial Radar object in the other make_*_radar functions [4] in that module which are then filled with additional object specific data.
> 
> If you can provide me with a sample text file that you would like to plot I would be happy to write up a function to read in the data and create a Radar object.
> 
> Cheers,
> 
>     - Jonathan Helmus
> 
> 
> [1] http://arm-doe.github.io/pyart-docs-travis/dev_reference/generated/pyart.core.radar.Radar.html
> [2] https://github.com/ARM-DOE/pyart/blob/master/pyart/testing/sample_objects.py
> [3] https://github.com/ARM-DOE/pyart/blob/master/pyart/testing/sample_objects.py#L27
> [4] http://arm-doe.github.io/pyart-docs-travis/dev_reference/testing.html#pyart-testing-sample-objects



Reply all
Reply to author
Forward
0 new messages