Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def unpatch_utils():
"""Unpatching the utils module.
"""
utils.parse_area_file = utils.old_parse_area_file
delattr(utils, "old_parse_area_file")
utils.generate_quick_linesample_arrays = \
utils.old_generate_quick_linesample_arrays
delattr(utils, "old_generate_quick_linesample_arrays")
def test_easeplot(self):
area_def = pr.utils.parse_area_file(os.path.join(os.path.dirname(__file__),
'test_files', 'areas.cfg'), 'ease_sh')[0]
swath_def = pr.geometry.SwathDefinition(self.lons, self.lats)
result = pr.kd_tree.resample_nearest(swath_def, self.tb37v, area_def,
radius_of_influence=20000,
fill_value=None)
plt = pr.plot._get_quicklook(area_def, result)
def test_area_parser(self):
ease_nh, ease_sh = utils.parse_area_file(os.path.join(os.path.dirname(__file__),
'test_files',
'areas.cfg'), 'ease_nh', 'ease_sh')
nh_found = (ease_nh.__str__() =="""Area ID: ease_nh
Name: Arctic EASE grid
Projection ID: ease_nh
Projection: {'a': '6371228.0', 'lat_0': '90', 'lon_0': '0', 'proj': 'laea', 'units': 'm'}
Number of columns: 425
Number of rows: 425
Area extent: (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625)""")
sh_found = (ease_sh.__str__() =="""Area ID: ease_sh
Name: Antarctic EASE grid
Projection ID: ease_sh
Projection: {'a': '6371228.0', 'lat_0': '-90', 'lon_0': '0', 'proj': 'laea', 'units': 'm'}
Number of columns: 425
def test_plate_carreeplot(self):
area_def = pr.utils.parse_area_file(os.path.join(os.path.dirname(__file__),
'test_files', 'areas.cfg'), 'pc_world')[0]
swath_def = pr.geometry.SwathDefinition(self.lons, self.lats)
result = pr.kd_tree.resample_nearest(swath_def, self.tb37v, area_def,
radius_of_influence=20000,
fill_value=None)
plt = pr.plot._get_quicklook(area_def, result, num_meridians=0,
num_parallels=0)
def test_easeplot(self):
"""Fake function.
"""
del filename
if area == "raise" or not isinstance(area, str):
raise utils.AreaNotFound("This area is not to be found")
else:
return [geometry.AreaDefinition(area)]
def fake_gqla(*args):
"""Fake function.
"""
del args
return (np.random.standard_normal((3, 1)),
np.random.standard_normal((3, 1)))
utils.old_parse_area_file = utils.parse_area_file
utils.parse_area_file = fake_parse_area_file
utils.old_generate_quick_linesample_arrays = \
utils.generate_quick_linesample_arrays
utils.generate_quick_linesample_arrays = \
fake_gqla
def get_area_def(area_name):
"""Get the definition of *area_name* from file. The file is defined to use
is to be placed in the $PPP_CONFIG_DIR directory, and its name is defined
in mpop's configuration file.
"""
return utils.parse_area_file(get_area_file(), area_name)[0]
def get_area_def(area_name):
"""Get the definition of *area_name* from file.
The file is defined to use is to be placed in the $PPP_CONFIG_DIR
directory, and its name is defined in satpy's configuration file.
"""
from pyresample.utils import parse_area_file
return parse_area_file(get_area_file(), area_name)[0]