<s> """<STR_LIT>""" <EOL> import warnings <EOL> import pyart <EOL> import numpy as np <EOL> from numpy . testing . decorators import skipif <EOL> from numpy . testing import assert_raises <EOL> def test__get_rgb_values_nan ( ) : <EOL> data = np . arange ( <NUM_LIT:10> , dtype = '<STR_LIT>' ) <EOL> data [ <NUM_LIT:5> ] = np . nan <EOL> with warnings . catch_warnings ( ) : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" , category = RuntimeWarning ) <EOL> rarr , barr , garr = pyart . io . output_to_geotiff . _get_rgb_values ( <EOL> data , <NUM_LIT:0> , <NUM_LIT:10> , None , '<STR_LIT>' ) <EOL> assert np . isnan ( rarr [ <NUM_LIT:5> ] ) <EOL> assert np . isnan ( barr [ <NUM_LIT:5> ] ) <EOL> assert np . isnan ( garr [ <NUM_LIT:5> ] ) <EOL> def test_raise_missingoptionaldepedency ( ) : <EOL> backup = bool ( pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> pyart . io . output_to_geotiff . IMPORT_FLAG = False <EOL> grid = make_tiny_grid ( ) <EOL> assert_raises ( <EOL> pyart . exceptions . MissingOptionalDependency , <EOL> pyart . io . write_grid_geotiff , grid , '<STR_LIT>' , '<STR_LIT>' ) <EOL> pyart . io . output_to_geotiff . IMPORT_FLAG = backup <EOL> def make_tiny_grid ( ) : <EOL> """<STR_LIT>""" <EOL> grid_shape = ( <NUM_LIT:2> , <NUM_LIT:10> , <NUM_LIT:8> ) <EOL> grid_limits = ( ( <NUM_LIT:0> , <NUM_LIT> ) , ( - <NUM_LIT> , <NUM_LIT> ) , ( - <NUM_LIT> , <NUM_LIT> ) ) <EOL> grid = pyart . testing . make_empty_grid ( grid_shape , grid_limits ) <EOL> fdata = np . zeros ( ( <NUM_LIT:2> , <NUM_LIT:10> , <NUM_LIT:8> ) , dtype = '<STR_LIT>' ) <EOL> fdata [ : , <NUM_LIT:2> : - <NUM_LIT:2> , <NUM_LIT:1> : - <NUM_LIT:1> ] = <NUM_LIT> <EOL> fdata [ : , <NUM_LIT:3> : - <NUM_LIT:3> , <NUM_LIT:2> : - <NUM_LIT:2> ] = <NUM_LIT> <EOL> fdata [ : , <NUM_LIT:4> : - <NUM_LIT:4> , <NUM_LIT:3> : - <NUM_LIT:3> ] = <NUM_LIT> <EOL> fdata [ <NUM_LIT:1> ] += <NUM_LIT:5> <EOL> rdic = { <EOL> '<STR_LIT:data>' : fdata , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> grid . fields = { '<STR_LIT>' : rdic } <EOL> return grid <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_tif_single_channel ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( grid , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_tif_rgb_with_missing ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( <EOL> grid , '<STR_LIT>' , '<STR_LIT>' , rgb = True ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_tif_level ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( grid , '<STR_LIT>' , '<STR_LIT>' , level = <NUM_LIT:1> ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_tif_warp ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( <EOL> grid , '<STR_LIT>' , '<STR_LIT>' , warp = True ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_tif_missing_suffix ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( grid , '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_sld ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> with pyart . testing . InTemporaryDirectory ( ) : <EOL> pyart . io . write_grid_geotiff ( <EOL> grid , '<STR_LIT>' , '<STR_LIT>' , sld = True ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:rb>' ) as f : <EOL> assert len ( f . read ( ) ) > <NUM_LIT:0> <EOL> @ skipif ( not pyart . io . output_to_geotiff . IMPORT_FLAG ) <EOL> def test_write_grid_geotiff_missing_field ( ) : <EOL> grid = make_tiny_grid ( ) <EOL> assert_raises ( <EOL> KeyError , pyart . io . write_grid_geotiff , grid , '<STR_LIT>' , '<STR_LIT>' ) </s>
