def _test_srtm_retrieve(Source, read_SRTM, max_, min_, pt): # test that the download mechanism for SRTM works with download_to_temp() as tmp_dir: with warnings.catch_warnings(record=True) as w: r = Source().srtm_fname(-4, 50) assert len(w) == 1 assert issubclass(w[0].category, cartopy.io.DownloadWarning) assert r.startswith(tmp_dir), 'File not downloaded to tmp dir' img, _, _ = read_SRTM(r) # check that the data is fairly sensible msg = 'SRTM data has changed. Arbitrary value testing failed. Got {}.' assert img.max() == max_, msg.format(img.max()) assert img.min() == min_, msg.format(img.min()) assert img[-10, 12] == pt, msg.format(img[-10, 12])
def test_srtm3_retrieve(): # test that the download mechanism for srtm3 works with download_to_temp() as tmp_dir: with warnings.catch_warnings(record=True) as w: r = cartopy.io.srtm.SRTM3_retrieve(-4, 50) assert len(w) == 1 assert issubclass(w[0].category, cartopy.io.DownloadWarning) assert r.startswith(tmp_dir), 'File not downloaded to tmp dir' img, _, _ = cartopy.io.srtm.read_SRTM3(r) # check that the data is fairly sensible msg = 'srtm data has changed. arbitrary value testing failed.' assert img.max() == 602, msg assert img.min() == -32768, msg assert img[-10, 12] == 78, msg + 'Got {}'.format(img[-10, 12])