def test_oceans(): f = os.path.join(get_demo_file('wrf_tip_d1.nc')) grid = GeoNetcdf(f).grid m = Map(grid, countries=False) m.set_shapefile(rivers=True, linewidths=2) m.set_shapefile(oceans=True, edgecolor='k', linewidth=3) fig, ax = plt.subplots(1, 1) m.visualize(ax=ax, addcbar=False) plt.tight_layout() return fig
def test_to_cartopy(self): import cartopy.crs as ccrs from salem import GeoNetcdf, GeoTiff grid = gis.mercator_grid(center_ll=(11.38, 47.26), extent=(2000000, 2000000)) p = gis.proj_to_cartopy(grid.proj) assert isinstance(p, ccrs.TransverseMercator) fuzzy_proj_tester(grid.proj, pyproj.Proj(p.proj4_params)) ds = GeoNetcdf(get_demo_file('wrfout_d01.nc')) p = gis.proj_to_cartopy(ds.grid.proj) assert isinstance(p, ccrs.LambertConformal) fuzzy_proj_tester(ds.grid.proj, pyproj.Proj(p.proj4_params)) ds = GeoNetcdf(get_demo_file('wrf_mercator.nc')) p = gis.proj_to_cartopy(ds.grid.proj) assert isinstance(p, ccrs.Mercator) fuzzy_proj_tester(ds.grid.proj, pyproj.Proj(p.proj4_params)) ds = GeoTiff(get_demo_file('himalaya.tif')) p = gis.proj_to_cartopy(ds.grid.proj) assert isinstance(p, ccrs.PlateCarree) ds = GeoTiff(get_demo_file('hef_roi.tif')) p = gis.proj_to_cartopy(ds.grid.proj) assert isinstance(p, ccrs.PlateCarree) fuzzy_proj_tester(ds.grid.proj, pyproj.Proj(p.proj4_params)) p = gis.proj_to_cartopy(wgs84) assert isinstance(p, ccrs.PlateCarree) p = gis.proj_to_cartopy(pyproj.Proj('+proj=utm +zone=15')) assert isinstance(p, ccrs.UTM) # this needs gdal if gis.has_gdal: p = gis.proj_to_cartopy(pyproj.Proj(init='epsg:26915')) assert isinstance(p, ccrs.UTM)