<s> """<STR_LIT>""" <EOL> import sys <EOL> try : <EOL> from StringIO import StringIO <EOL> except ImportError : <EOL> from io import StringIO <EOL> import inspect <EOL> import numpy as np <EOL> from numpy . testing import assert_raises , assert_allclose , assert_almost_equal <EOL> import pyart <EOL> from pyart . lazydict import LazyLoadDict <EOL> def test_gate_longitude_latitude ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert radar . gate_longitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> assert radar . gate_latitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> assert_almost_equal ( radar . gate_longitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT:1> ) <EOL> assert_almost_equal ( radar . gate_latitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> radar . init_gate_longitude_latitude ( ) <EOL> radar . projection . pop ( '<STR_LIT>' ) <EOL> radar . projection [ '<STR_LIT>' ] = <NUM_LIT> <EOL> radar . projection [ '<STR_LIT>' ] = <NUM_LIT> <EOL> assert_almost_equal ( radar . gate_longitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> assert_almost_equal ( radar . gate_latitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> def test_gate_altitude ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert radar . gate_altitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> assert_almost_equal ( radar . gate_altitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> radar . init_gate_altitude ( ) <EOL> radar . altitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] = <NUM_LIT> <EOL> assert_almost_equal ( radar . gate_altitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT:1> ) <EOL> def test_gate_x_y_z ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert radar . gate_x [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:2> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( <EOL> radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:3> ] , [ - <NUM_LIT:5> , - <NUM_LIT:15> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert radar . gate_y [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( <EOL> radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:2> ] , [ - <NUM_LIT:5> , - <NUM_LIT:15> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:3> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert radar . gate_z [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , <NUM_LIT:5> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:2> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:3> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> def test_get_gate_x_y_z ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> gate_x , gate_y , gate_z = radar . get_gate_x_y_z ( <NUM_LIT:0> ) <EOL> assert gate_x . shape == ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:1> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:2> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:3> ] , [ - <NUM_LIT:5> , - <NUM_LIT:15> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert gate_y . shape == ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:0> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:1> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:2> ] , [ - <NUM_LIT:5> , - <NUM_LIT:15> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:3> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert gate_z . shape == ( <NUM_LIT:4> , <NUM_LIT:5> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:1> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:2> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:3> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> def test_get_gate_x_y_z_edges ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> gate_x , gate_y , gate_z = radar . get_gate_x_y_z ( <NUM_LIT:0> , edges = True ) <EOL> zeros = np . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> even = np . array ( [ <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT:50> ] ) <EOL> atol = <NUM_LIT> <EOL> assert gate_x . shape == ( <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:0> ] , - even , atol = atol ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:1> ] , zeros , atol = atol ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:2> ] , even , atol = atol ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:3> ] , zeros , atol = atol ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:4> ] , - even , atol = atol ) <EOL> assert gate_y . shape == ( <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:0> ] , zeros , atol = atol ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:1> ] , even , atol = atol ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:2> ] , zeros , atol = atol ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:3> ] , - even , atol = atol ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:4> ] , zeros , atol = atol ) <EOL> assert gate_z . shape == ( <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:1> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:2> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:3> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:4> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> def test_get_gate_x_y_z_transitions ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . antenna_transition = { '<STR_LIT:data>' : np . array ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) } <EOL> gate_x , gate_y , gate_z = radar . get_gate_x_y_z ( <NUM_LIT:0> , filter_transitions = True ) <EOL> assert gate_x . shape == ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:1> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_x [ <NUM_LIT:2> ] , [ - <NUM_LIT:5> , - <NUM_LIT:15> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert gate_y . shape == ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:0> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:1> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_y [ <NUM_LIT:2> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , atol = <NUM_LIT> ) <EOL> assert gate_z . shape == ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:1> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> assert_allclose ( gate_z [ <NUM_LIT:2> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> def test_init_gate_x_y_z ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> radar . range [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT:5> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> radar . init_gate_x_y_z ( ) <EOL> assert_allclose ( radar . gate_x [ '<STR_LIT:data>' ] [ <NUM_LIT:1> ] , [ <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> assert_allclose ( radar . gate_y [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> ) <EOL> z_sweep0 = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_allclose ( radar . gate_z [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] , z_sweep0 , atol = <NUM_LIT> ) <EOL> def test_rays_per_sweep_attribute ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> rays_per_sweep = radar . rays_per_sweep <EOL> assert isinstance ( rays_per_sweep , LazyLoadDict ) <EOL> assert rays_per_sweep [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:1> , ) <EOL> assert rays_per_sweep [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] == <NUM_LIT> <EOL> def test_iterators ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:5> ) <EOL> radar . fields [ '<STR_LIT>' ] = { <EOL> '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT:100> , <NUM_LIT:30> ) , dtype = np . float32 ) } <EOL> starts = [ <NUM_LIT:0> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ends = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> starts_ends = [ ( s , e ) for s , e in zip ( starts , ends ) ] <EOL> assert inspect . isgenerator ( radar . iter_start ( ) ) <EOL> assert [ s for s in radar . iter_start ( ) ] == starts <EOL> assert inspect . isgenerator ( radar . iter_end ( ) ) <EOL> assert [ s for s in radar . iter_end ( ) ] == ends <EOL> assert inspect . isgenerator ( radar . iter_start_end ( ) ) <EOL> assert [ s for s in radar . iter_start_end ( ) ] == starts_ends <EOL> assert inspect . isgenerator ( radar . iter_slice ( ) ) <EOL> for s , start , end in zip ( radar . iter_slice ( ) , starts , ends ) : <EOL> assert s . start == start <EOL> assert s . stop == end + <NUM_LIT:1> <EOL> assert s . step is None <EOL> assert inspect . isgenerator ( radar . iter_field ( '<STR_LIT>' ) ) <EOL> for d in radar . iter_field ( '<STR_LIT>' ) : <EOL> assert d . shape == ( <NUM_LIT:20> , <NUM_LIT:30> ) <EOL> assert d . dtype == np . float32 <EOL> assert_raises ( KeyError , radar . iter_field , '<STR_LIT>' ) <EOL> assert inspect . isgenerator ( radar . iter_azimuth ( ) ) <EOL> for d in radar . iter_azimuth ( ) : <EOL> assert d . shape == ( <NUM_LIT:20> , ) <EOL> assert inspect . isgenerator ( radar . iter_elevation ( ) ) <EOL> for d in radar . iter_elevation ( ) : <EOL> assert d . shape == ( <NUM_LIT:20> , ) <EOL> def test_get_methods ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:30> , <NUM_LIT:20> , <NUM_LIT:5> ) <EOL> radar . fields [ '<STR_LIT>' ] = { <EOL> '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT:100> , <NUM_LIT:30> ) , dtype = np . float32 ) } <EOL> assert radar . get_start ( <NUM_LIT:0> ) == <NUM_LIT:0> <EOL> assert radar . get_start ( <NUM_LIT:1> ) == <NUM_LIT:20> <EOL> assert_raises ( IndexError , radar . get_start , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_start , <NUM_LIT:20> ) <EOL> assert radar . get_end ( <NUM_LIT:0> ) == <NUM_LIT> <EOL> assert radar . get_end ( <NUM_LIT:1> ) == <NUM_LIT> <EOL> assert_raises ( IndexError , radar . get_end , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_end , <NUM_LIT:20> ) <EOL> assert radar . get_start_end ( <NUM_LIT:0> ) == ( <NUM_LIT:0> , <NUM_LIT> ) <EOL> assert radar . get_start_end ( <NUM_LIT:1> ) == ( <NUM_LIT:20> , <NUM_LIT> ) <EOL> assert_raises ( IndexError , radar . get_start_end , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_start_end , <NUM_LIT:20> ) <EOL> assert radar . get_slice ( <NUM_LIT:0> ) == slice ( <NUM_LIT:0> , <NUM_LIT:20> ) <EOL> assert radar . get_slice ( <NUM_LIT:1> ) == slice ( <NUM_LIT:20> , <NUM_LIT> ) <EOL> assert_raises ( IndexError , radar . get_slice , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_slice , <NUM_LIT:20> ) <EOL> data = radar . get_field ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> assert data . shape == ( <NUM_LIT:20> , <NUM_LIT:30> ) <EOL> assert data . dtype == np . float32 <EOL> data = radar . get_field ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> assert data . shape == ( <NUM_LIT:20> , <NUM_LIT:30> ) <EOL> assert data . dtype == np . float32 <EOL> assert_raises ( KeyError , radar . get_field , <NUM_LIT:0> , '<STR_LIT>' ) <EOL> assert_raises ( IndexError , radar . get_field , - <NUM_LIT:1> , '<STR_LIT>' ) <EOL> assert_raises ( IndexError , radar . get_field , <NUM_LIT:20> , '<STR_LIT>' ) <EOL> assert radar . get_azimuth ( <NUM_LIT:0> ) . shape == ( <NUM_LIT:20> , ) <EOL> assert_raises ( IndexError , radar . get_azimuth , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_azimuth , <NUM_LIT:20> ) <EOL> assert radar . get_elevation ( <NUM_LIT:0> ) . shape == ( <NUM_LIT:20> , ) <EOL> assert_raises ( IndexError , radar . get_elevation , - <NUM_LIT:1> ) <EOL> assert_raises ( IndexError , radar . get_elevation , <NUM_LIT:20> ) <EOL> assert_raises ( LookupError , radar . get_nyquist_vel , <NUM_LIT:0> ) <EOL> radar . instrument_parameters = { <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . ones ( ( <NUM_LIT:100> , ) ) } <EOL> } <EOL> assert round ( radar . get_nyquist_vel ( <NUM_LIT:0> ) ) == <NUM_LIT:1> <EOL> assert_raises ( IndexError , radar . get_nyquist_vel , - <NUM_LIT:1> ) <EOL> radar . instrument_parameters [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] = <NUM_LIT:2> <EOL> assert_raises ( Exception , radar . get_nyquist_vel , <NUM_LIT:0> ) <EOL> def test_extract_sweeps ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT:3> ) <EOL> radar . fields [ '<STR_LIT>' ] = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , <NUM_LIT:100> ) ) } <EOL> radar . fields [ '<STR_LIT>' ] = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , <NUM_LIT:100> ) ) } <EOL> eradar = radar . extract_sweeps ( [ <NUM_LIT:0> , <NUM_LIT:2> ] ) <EOL> assert eradar . time [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , ) <EOL> assert eradar . range [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:100> , ) <EOL> assert eradar . metadata [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert eradar . scan_type == '<STR_LIT>' <EOL> assert eradar . latitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:1> , ) <EOL> assert eradar . longitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:1> , ) <EOL> assert eradar . altitude [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:1> , ) <EOL> assert eradar . altitude_agl is None <EOL> assert eradar . sweep_number [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert eradar . sweep_mode [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert eradar . fixed_angle [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert eradar . sweep_start_ray_index [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert eradar . sweep_end_ray_index [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert eradar . target_scan_rate is None <EOL> assert eradar . azimuth [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , ) <EOL> assert eradar . elevation [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , ) <EOL> assert eradar . scan_rate is None <EOL> assert eradar . antenna_transition is None <EOL> assert eradar . instrument_parameters is None <EOL> assert eradar . radar_calibration is None <EOL> assert eradar . ngates == <NUM_LIT:100> <EOL> assert eradar . nrays == <NUM_LIT> <EOL> assert eradar . nsweeps == <NUM_LIT:2> <EOL> assert eradar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , <NUM_LIT:100> ) <EOL> assert eradar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , <NUM_LIT:100> ) <EOL> def test_extract_sweeps_extra ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:3> ) <EOL> radar . instrument_parameters = { <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , ) ) } , <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . array ( [ '<STR_LIT>' ] * <NUM_LIT:3> ) } , <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . array ( <NUM_LIT:0> ) } , <EOL> } <EOL> radar . radar_calibration = { <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , ) ) } , <EOL> '<STR_LIT>' : { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT:8> , ) ) } <EOL> } <EOL> eradar = radar . extract_sweeps ( [ <NUM_LIT:0> , <NUM_LIT:2> ] ) <EOL> instr = eradar . instrument_parameters <EOL> assert instr [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , ) <EOL> assert instr [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:2> , ) <EOL> assert instr [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( ) <EOL> calib = eradar . radar_calibration <EOL> assert calib [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT> , ) <EOL> assert calib [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . shape == ( <NUM_LIT:8> , ) <EOL> def test_extract_sweeps_errors ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:2> ) <EOL> assert_raises ( ValueError , radar . extract_sweeps , [ <NUM_LIT:0> , <NUM_LIT:2> ] ) <EOL> assert_raises ( ValueError , radar . extract_sweeps , [ - <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> def test_radar_creation ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> assert isinstance ( radar , pyart . core . Radar ) <EOL> def test_add_field ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> dic = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , <NUM_LIT:50> ) ) , '<STR_LIT>' : '<STR_LIT:test>' } <EOL> radar . add_field ( '<STR_LIT:test>' , dic ) <EOL> assert '<STR_LIT:test>' in radar . fields <EOL> assert '<STR_LIT:data>' in radar . fields [ '<STR_LIT:test>' ] <EOL> assert radar . fields [ '<STR_LIT:test>' ] [ '<STR_LIT>' ] == '<STR_LIT:test>' <EOL> def test_add_field_errors ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> assert_raises ( ValueError , radar . add_field , '<STR_LIT>' , { } ) <EOL> dic = { '<STR_LIT>' : np . zeros ( ( <NUM_LIT> , <NUM_LIT:50> ) ) , '<STR_LIT>' : '<STR_LIT:test>' } <EOL> assert_raises ( KeyError , radar . add_field , '<STR_LIT:test>' , dic ) <EOL> dic = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT> , <NUM_LIT> ) ) , '<STR_LIT>' : '<STR_LIT:test>' } <EOL> assert_raises ( ValueError , radar . add_field , '<STR_LIT:test>' , dic ) <EOL> def test_add_field_like ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> data = np . zeros ( ( <NUM_LIT> , <NUM_LIT:50> ) ) <EOL> radar . add_field_like ( '<STR_LIT>' , '<STR_LIT:test>' , data ) <EOL> assert '<STR_LIT:test>' in radar . fields <EOL> assert '<STR_LIT:data>' in radar . fields [ '<STR_LIT:test>' ] <EOL> assert radar . fields [ '<STR_LIT:test>' ] [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_add_field_like_bug ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> data = np . ones ( ( <NUM_LIT> , <NUM_LIT:50> ) ) <EOL> radar . add_field_like ( '<STR_LIT>' , '<STR_LIT:test>' , data ) <EOL> radar . fields [ '<STR_LIT:test>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> assert radar . fields [ '<STR_LIT:test>' ] [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert radar . fields [ '<STR_LIT:test>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] == <NUM_LIT:1> <EOL> assert radar . fields [ '<STR_LIT>' ] [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT:0> , <NUM_LIT:0> ] == <NUM_LIT:0> <EOL> def test_add_field_like_errors ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> assert_raises ( ValueError , radar . add_field_like , '<STR_LIT:foo>' , '<STR_LIT:bar>' , [ ] ) <EOL> def test_info_levels ( ) : <EOL> for level in [ '<STR_LIT>' , '<STR_LIT:s>' , '<STR_LIT>' , '<STR_LIT:c>' , '<STR_LIT>' , '<STR_LIT:f>' ] : <EOL> yield check_info , level <EOL> def test_info_nonstandard ( ) : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> radar . instrument_parameters = { '<STR_LIT>' : { '<STR_LIT:data>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT:bar>' : '<STR_LIT:foo>' } } <EOL> radar . radar_calibration = { '<STR_LIT>' : { '<STR_LIT:data>' : [ <NUM_LIT:1> , <NUM_LIT:2> ] , '<STR_LIT:bar>' : '<STR_LIT:foo>' } } <EOL> check_info ( '<STR_LIT>' , radar ) <EOL> def check_info ( level , radar = None ) : <EOL> out = StringIO ( ) <EOL> get_info ( level , out , radar ) <EOL> assert len ( out . getvalue ( ) ) != <NUM_LIT:0> <EOL> def get_info ( level = '<STR_LIT>' , out = sys . stdout , radar = None ) : <EOL> if radar is None : <EOL> radar = pyart . testing . make_target_radar ( ) <EOL> radar . info ( level , out ) <EOL> def test_info_errors ( ) : <EOL> assert_raises ( ValueError , check_info , '<STR_LIT:foo>' ) </s>
