pyart.io.common.add_2d_latlon_axis usage

151 views
Skip to first unread message

Mariana Scott

unread,
Oct 2, 2015, 11:40:56 AM10/2/15
to Py-ART Users
All,
I have been trying to get latitude and longitude points from radar data that was gridded with pyart.map.grid_from_radars. 
I noticed that there is add_2d_latlon_axis [1], which sounds like what I want to do. However, when I run the grid data through this function:

newGrid=pyart.io.common.add_2d_latlon_axis(grid)     #writing to a new variable (newGrid) to test... will hopefully just put this into grid later.

I get:

dir(newGrid)
Out[84]: 
['__class__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__']

...which is not what I expected (I expected the original grid with the addition of latitude and longitude arrays/dictionaries). My grid has the needed dictionaries, namely “x_disp”, “y_disp” and scalar axes ‘lat’, ‘lon’:

grid.axes.keys()

Out[86]: 
['time_end',
 'x_disp',
 'lat',
 'alt',
 'time_start',
 'y_disp',
 'lon',
 'longitude',
 'z_disp',
 'time',
 'latitude']

Did I misunderstand the purpose of add_2d_latlon_axis?

Cheers,
Mariana


Jonathan Helmus

unread,
Oct 5, 2015, 2:19:07 PM10/5/15
to pyart...@googlegroups.com
--
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.
Mariana,

    The description of the return in the documentation of the add_2d_latlon_axis function is incorrect.  Rather than creating a new Grid instance the function adds "latitude" and "longitude" key values pairs to the grid instances passed as the first argument and returns None (the default when nothing is returned from a Python function).  These dictionaries contain 2D arrays which specify the latitude and longitude for Cartesian points in the grid and can be access as follows:

    grid.axes['latitude']['data']
    grid.axes['longitude']['data']

I'll open an issue and fix the documentation for this function shortly. 

Hope this helps,

    - Jonathan Helmus

Mariana Scott

unread,
Oct 6, 2015, 8:16:48 AM10/6/15
to Py-ART Users
Thank you Jonathan!
Has this function been tested? I'm getting some odd results:

From the Radar class (data makes sense):
radar.longitude['data'].max()
Out[110]: 167.73249999999999

radar.longitude['data'].min()
Out[111]: 167.73249999999999

radar.latitude['data'].max()
Out[112]: 8.718055555555555

radar.latitude['data'].min()
Out[113]: 8.718055555555555

From the Grid class, after running pyart.io.common.add_2d_latlon_axis(grid):
grid.axes['longitude']['data'].max()
Out[114]: 1.3477222124638386

grid.axes['longitude']['data'].min()
Out[115]: -1.3477222124638386

grid.axes['latitude']['data'].max()
Out[116]: 1.3565516706141529

grid.axes['latitude']['data'].min()
Out[117]: -1.3565516706141529

Jonathan Helmus

unread,
Oct 6, 2015, 11:44:54 AM10/6/15
to pyart...@googlegroups.com
Mariana,

    Can you provide details on how you constructed the grid you are examining?  I have not used the add_2d_latlon_axis function extensively and it does not appear to be covered by unit test so it is possible that the function has a bug.  I ran the function on a grid used in the examples are the results seemed reasonable. 

The results from the radar class make sense. Typically only has a single latitude and longitude value unless the radar is on a moving platforms (shipborne or airborne radars) so max and min should return the same value.  If the grid is centered at the radar I would expect the latitudes and longitudes to include the this point which in your example they do not.  If you can provide the code that you used to create the grid I should be able to provide some help as to what is happening.

Cheers,

    - Jonathan Helmus

Mariana Scott

unread,
Oct 6, 2015, 3:48:22 PM10/6/15
to Py-ART Users
Jonathan,
Here is the code I used: 

radar = pyart.io.read(thefile)               ;thefile is a string with the path of a UF file

grid = pyart.map.grid_from_radars((radar,), grid_shape=(19, 301, 301),
               grid_limits=((1000.0, 19000.0),(-150000.0, 150000.0),
                            (-150000.0, 150000.0)),
               fields=['corrected_reflectivity','velocity'],
               refl_field='corrected_reflectivity',max_refl=80.,copy_field_data=True,
               grid_origin=(radar.latitude['data'],radar.longitude['data']))

pyart.io.common.add_2d_latlon_axis(grid)

-Mariana

Jonathan Helmus

unread,
Oct 6, 2015, 6:22:04 PM10/6/15
to pyart...@googlegroups.com
Mariana,

    You need to provide grid_order as a tuple of floats, not a tuple of arrays.This can be accomplished by indexing into the arrays as follow:
              
    grid_origin=(radar.latitude['data'][0],radar.longitude['data'][0]))

Alternatively if you want the grid centered at the radar, which is the default setting, you do not need to provide the grid_origin argument at all.   When I use either of these method when calling grid_from_radars I get more sensible latitude and longitudes for the grid.

Cheers,

     - Jonathan Helmus
Message has been deleted

Mariana Scott

unread,
Oct 7, 2015, 10:31:26 AM10/7/15
to Py-ART Users
Jonathan,
I think that took care of the problem and the results look reasonable. Thank you very much for your help!
-Mariana
Reply all
Reply to author
Forward
0 new messages