def test_dateline_cross(self): from pycoast import ContourWriterPIL dl_img = Image.open( os.path.join(os.path.dirname(__file__), 'dateline_cross.png')) dl_data = np.array(dl_img) img = Image.new('RGB', (640, 480)) proj4_string = '+proj=stere +lon_0=-170.00 +lat_0=60.00 +lat_ts=50.00 +ellps=WGS84' area_extent = (-3363403.31, -2291879.85, 2630596.69, 2203620.1) area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines(img, area_def, resolution='l', level=4) font = ImageFont.truetype( os.path.join(os.path.dirname(__file__), 'test_data', 'DejaVuSerif.ttf'), 16) cw.add_grid(img, area_def, (10.0, 10.0), (2.0, 2.0), font=font, fill='blue', write_text=False, outline='blue', minor_outline='blue', lon_placement='b', lat_placement='lr') res = np.array(img) self.assertTrue(fft_metric(dl_data, res), 'Writing of dateline crossing data failed')
def test_grid_nh(self): from pycoast import ContourWriterPIL grid_img = Image.open(os.path.join(os.path.dirname(__file__), 'grid_nh.png')) grid_data = np.array(grid_img) img = Image.new('RGB', (425, 425)) proj4_string = '+proj=laea +lat_0=90 +lon_0=0 +a=6371228.0 +units=m' area_extent = (-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625) area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines(img, area_def, resolution='l', level=4) font = ImageFont.truetype(os.path.join(os.path.dirname(__file__), 'test_data', 'DejaVuSerif.ttf'), 10) cw.add_grid(img, area_def, (10.0, 10.0), (2.0, 2.0), font=font, fill='blue', outline='blue', minor_outline='blue', write_text=False, lon_placement='tblr', lat_placement='') res = np.array(img) self.assertTrue( fft_metric(grid_data, res), 'Writing of nh grid failed')
def test_grid_germ(self): """Check that issue #26 is fixed.""" from pycoast import ContourWriterPIL result_file = os.path.join(os.path.dirname(__file__), 'grid_germ.png') grid_img = Image.open(result_file) grid_data = np.array(grid_img) img = Image.new('RGB', (1024, 1024)) proj4_string = \ '+proj=stere +ellps=bessel +lat_0=90.0 +lon_0=5.0 +lat_ts=50.0 +a=6378144.0 +b=6356759.0' area_extent = [-155100.436345, -4441495.37946, 868899.563655, -3417495.37946] area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines(img, area_def, resolution='l', level=4) font = ImageFont.truetype(os.path.join(os.path.dirname(__file__), 'test_data', 'DejaVuSerif.ttf'), 16) cw.add_grid(img, area_def, (10.0, 10.0), (2.0, 2.0), font=font, fill='yellow', write_text=True, outline='red', minor_outline='white') res = np.array(img) self.assertTrue(fft_metric(grid_data, res), 'Writing of grid to germ failed')
def test_grid_geos(self): from pycoast import ContourWriterPIL geos_img = Image.open( os.path.join(os.path.dirname(__file__), 'grid_geos.png')) geos_data = np.array(geos_img) img = Image.new('RGB', (425, 425)) proj4_string = \ '+proj=geos +lon_0=0.0 +a=6378169.00 +b=6356583.80 +h=35785831.0' area_extent = (-5570248.4773392612, -5567248.074173444, 5567248.074173444, 5570248.4773392612) area_def = (proj4_string, area_extent) cw = ContourWriterPIL(gshhs_root_dir) cw.add_coastlines(img, area_def, resolution='l') cw.add_grid(img, area_def, (10.0, 10.0), (2.0, 2.0), fill='blue', outline='blue', minor_outline='blue', write_text=False) res = np.array(img) self.assertTrue( fft_metric(geos_data, res), 'Writing of geos contours failed')