<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import pyart <EOL> import numpy as np <EOL> from numpy . testing import assert_allclose , assert_raises , assert_almost_equal <EOL> REF_DATA = [ <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> ] <EOL> def test_dealias_unwrap_phase_ray ( ) : <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_unwrap_phase_sweep ( ) : <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_unwrap_phase_volume ( ) : <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_set_limits ( ) : <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' , set_limits = True ) <EOL> assert '<STR_LIT>' in dealias_vel <EOL> assert_almost_equal ( dealias_vel [ '<STR_LIT>' ] , - <NUM_LIT> ) <EOL> assert '<STR_LIT>' in dealias_vel <EOL> assert_almost_equal ( dealias_vel [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' , set_limits = False ) <EOL> assert '<STR_LIT>' not in dealias_vel <EOL> assert '<STR_LIT>' not in dealias_vel <EOL> def test_dealias_unwrap_phase_no_gatefilter ( ) : <EOL> radar , dealias_vel = perform_dealias ( '<STR_LIT>' , gatefilter = False ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_unwrap_phase_explicit_gatefilter ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> gf = pyart . correct . GateFilter ( radar ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( radar , gatefilter = gf ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_unwrap_phase_masked_field_sweep ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> vdata = radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] = np . ma . masked_array ( vdata ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] = np . ma . masked <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , unwrap_unit = '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert not np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_dealias_unwrap_phase_masked_field_volume ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> vdata = radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] = np . ma . masked_array ( vdata ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] = np . ma . masked <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , unwrap_unit = '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert not np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_dealias_unwrap_phase_masked_field_ray ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> vdata = radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] = np . ma . masked_array ( vdata ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] = np . ma . masked <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , unwrap_unit = '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert not np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> def test_dealias_unwrap_phase_rhi_sweep ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_rhi_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( radar ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_unwrap_phase_rhi_volume ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_rhi_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , unwrap_unit = '<STR_LIT>' ) <EOL> assert_allclose ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , : <NUM_LIT> ] , REF_DATA ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) is False <EOL> def test_dealias_keep_original ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT:5> ] = <NUM_LIT> <EOL> gf = pyart . filters . GateFilter ( radar ) <EOL> gf . exclude_above ( '<STR_LIT>' , <NUM_LIT> ) <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , gatefilter = gf , keep_original = False ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT:5> ] ) is True <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , gatefilter = gf , keep_original = True ) <EOL> assert_almost_equal ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT:5> ] , <NUM_LIT> ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT> , <NUM_LIT:5> ] ) is False <EOL> def test_is_radar_sweep_aligned ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . scan_type = '<STR_LIT>' <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> assert pyart . correct . unwrap . _is_radar_sweep_aligned ( radar ) <EOL> radar . elevation [ '<STR_LIT:data>' ] [ : ] = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> assert not pyart . correct . unwrap . _is_radar_sweep_aligned ( radar ) <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . scan_type = '<STR_LIT>' <EOL> assert_raises ( <EOL> ValueError , pyart . correct . unwrap . _is_radar_sweep_aligned , radar ) <EOL> def test_is_sweep_sequential ( ) : <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> radar . scan_type = '<STR_LIT>' <EOL> assert pyart . correct . unwrap . _is_sweep_sequential ( radar , <NUM_LIT:0> ) <EOL> def test_dealias_unwrap_phase_raises ( ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar , <EOL> unwrap_unit = '<STR_LIT>' ) <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . instrument_parameters = None <EOL> assert_raises ( LookupError , pyart . correct . dealias_unwrap_phase , radar ) <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ <NUM_LIT:10> ] = <NUM_LIT> <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar ) <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:2> ) <EOL> radar . fields [ '<STR_LIT>' ] = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT:20> , <NUM_LIT:1> ) ) } <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar , <EOL> nyquist_vel = <NUM_LIT:10> , unwrap_unit = '<STR_LIT>' ) <EOL> radar = pyart . testing . make_empty_ppi_radar ( <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:2> ) <EOL> radar . fields [ '<STR_LIT>' ] = { '<STR_LIT:data>' : np . zeros ( ( <NUM_LIT:20> , <NUM_LIT:1> ) ) } <EOL> radar . azimuth [ '<STR_LIT:data>' ] [ - <NUM_LIT:10> : ] = range ( <NUM_LIT:10> ) <EOL> radar . sweep_end_ray_index [ '<STR_LIT:data>' ] [ - <NUM_LIT:1> ] = <NUM_LIT> <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar , <EOL> nyquist_vel = <NUM_LIT:10> , unwrap_unit = '<STR_LIT>' ) <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . scan_type = '<STR_LIT>' <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar ) <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . scan_type = '<STR_LIT>' <EOL> assert_raises ( ValueError , pyart . correct . dealias_unwrap_phase , radar ) <EOL> def perform_dealias ( unwrap_unit = '<STR_LIT>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> , - <NUM_LIT:4> : ] = [ - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( <EOL> radar , unwrap_unit = unwrap_unit , ** kwargs ) <EOL> return radar , dealias_vel <EOL> def test_fillvalue ( ** kwargs ) : <EOL> radar = pyart . testing . make_velocity_aliased_radar ( ) <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT> <EOL> radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT:100> , <NUM_LIT> ] = <NUM_LIT> <EOL> gf = pyart . filters . GateFilter ( radar ) <EOL> gf . exclude_above ( '<STR_LIT>' , <NUM_LIT> ) <EOL> dealias_vel = pyart . correct . dealias_unwrap_phase ( radar , gatefilter = gf ) <EOL> assert isinstance ( dealias_vel [ '<STR_LIT:data>' ] , np . ma . MaskedArray ) <EOL> assert np . ma . is_masked ( dealias_vel [ '<STR_LIT:data>' ] [ <NUM_LIT:100> , <NUM_LIT> ] ) <EOL> assert '<STR_LIT>' in dealias_vel <EOL> assert dealias_vel [ '<STR_LIT>' ] == <NUM_LIT> <EOL> assert dealias_vel [ '<STR_LIT:data>' ] . fill_value == <NUM_LIT> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> radar , dealias_vel = perform_dealias ( ) <EOL> radar . fields [ '<STR_LIT>' ] = dealias_vel <EOL> print ( "<STR_LIT>" ) <EOL> print ( radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( radar . fields [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ <NUM_LIT> ] ) <EOL> import matplotlib . pyplot as plt <EOL> fig = plt . figure ( figsize = [ <NUM_LIT:5> , <NUM_LIT:10> ] ) <EOL> ax1 = fig . add_subplot ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> ax2 = fig . add_subplot ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> rd = pyart . graph . RadarDisplay ( radar ) <EOL> rd . plot_ppi ( '<STR_LIT>' , <NUM_LIT:0> , ax = ax1 , colorbar_flag = False , <EOL> title = '<STR_LIT>' , vmin = - <NUM_LIT:10> , vmax = <NUM_LIT:10> ) <EOL> rd . plot_ppi ( '<STR_LIT>' , <NUM_LIT:0> , ax = ax2 , colorbar_flag = False , <EOL> title = '<STR_LIT>' , vmin = - <NUM_LIT:10> , vmax = <NUM_LIT:20> ) <EOL> fig . savefig ( '<STR_LIT>' ) </s>
