viz_utils/eoa_viz.py
def plot_slice_eoa(self, c_img, ax, cmap='gray', mode=PlotMode.RASTER, mincbar=np.nan, maxcbar=np.nan) -> None:
        """
        Plots a 2D img for EOA data.
        :param c_img: 2D array
        :param ax: geoaxes
        :return:
        """
        c_ax = ax
        if self._flip_data:
            origin = 'lower'
        else:
            origin = 'upper'

        if self._background == BackgroundType.CARTO_DEF:
            c_ax.stock_img()
        else:
            if self._background == BackgroundType.BLUE_MARBLE_LR:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bluemarble.png'))
            if self._background == BackgroundType.BLUE_MARBLE_HR:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bluemarble_5400x2700.jpg'))
            if self._background == BackgroundType.TOPO:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/etopo.png'))
            if self._background == BackgroundType.BATHYMETRY:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bathymetry_3600x1800.jpg'))
            c_ax.imshow(img, origin='upper', extent=(-180,180,-90,90), transform=ccrs.PlateCarree())

        if mode == PlotMode.RASTER or mode == PlotMode.MERGED:
            if self._contourf:
                im = c_ax.contourf(self._lons, self._lats, c_img, num_colors=255, cmap='inferno', extent=self._extent)
            else:
                if np.isnan(mincbar):
                    im = c_ax.imshow(c_img, extent=self._extent, origin=origin, cmap=cmap, transform=self._projection, norm=self._norm)
                else:
                    im = c_ax.imshow(c_img, extent=self._extent, origin=origin, cmap=cmap, vmin=mincbar, vmax=maxcbar, transform=self._projection, norm=self._norm)

        if mode == PlotMode.CONTOUR or mode == PlotMode.MERGED:
            c_ax.set_extent(self.getExtent(list(self._lats), list(self._lons)))
            if mode == PlotMode.CONTOUR:
                im = c_ax.contour(c_img, extent=self._extent, transform=self._projection)
            if mode == PlotMode.MERGED:
                if self._contour_labels:
                    c_ax.contour(c_img, self._contour_labels, colors='r', extent=self._extent, transform=self._projection)
                else:
                    c_ax.contour(c_img, extent=self._extent, transform=self._projection)

        if len(self._additional_polygons) > 0:
            pol_lats = []
            pol_lons = []
            for c_polygon in self._additional_polygons:
                if isinstance(c_polygon, shapely.geometry.linestring.LineString):
                    x,y = c_polygon.xy
                elif isinstance(c_polygon, shapely.geometry.polygon.Polygon):
                    x, y = c_polygon.exterior.xy
                pol_lats += y
                pol_lons += x
                c_ax.plot(x,y, transform=self._projection, c='r')

            #  Adds a threshold to the plot to see the polygons
            c_ax.set_extent(self.getExtent(list(self._lats) + pol_lats, list(self._lons) + pol_lons, 0.5))

        if self._vector_field != None:
            try:
                u = self._vector_field['u']
                v = self._vector_field['v']
                x = self._vector_field['x']
                y = self._vector_field['y']
                vec_keys = self._vector_field.keys()
                c = 'r'
                density = 1
                linewidth = 3
                vec_cmap = cmocean.cm.solar
                if 'color' in vec_keys:
                    c = self._vector_field['color']
                if 'density' in vec_keys:
                    density = self._vector_field['density']
                if 'linewidth' in vec_keys:
                    linewidth = self._vector_field['linewidth']
                if 'cmap' in vec_keys:
                    vec_cmap = self._vector_field['cmap']
                c_ax.set_extent(self.getExtent(list(self._lats), list(self._lons)))
                c_ax.streamplot(x, y, u, v, transform=self._projection, density=density, color=c,
                                cmap=vec_cmap, linewidth=linewidth)

            except Exception as e:
                print(F"Couldn't add vector field e:{e}")


        gl = c_ax.gridlines(draw_labels=True, color='grey', alpha=0.5, linestyle='--')
        # gl.xlabel_style = {'size': self._font_size/2, 'color': '#aaaaaa', 'weight':'bold'}
        font_coords = {'size': self._font_size*.6}
        gl.xlabel_style = font_coords
        gl.ylabel_style = font_coords
        gl.top_labels = False
        gl.right_labels = False

        return im

        Plots a 2D img for EOA data.
        :param c_img: 2D array
        :param ax: geoaxes
        :return:
        
Plots a 2D img for EOA data.
Plots a 2D img for EOA data .
def plot_slice_eoa(self, c_img, ax, cmap='gray', mode=PlotMode.RASTER, mincbar=np.nan, maxcbar=np.nan) -> None:
        c_ax = ax
        if self._flip_data:
            origin = 'lower'
        else:
            origin = 'upper'
        if self._background == BackgroundType.CARTO_DEF:
            c_ax.stock_img()
        else:
            if self._background == BackgroundType.BLUE_MARBLE_LR:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bluemarble.png'))
            if self._background == BackgroundType.BLUE_MARBLE_HR:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bluemarble_5400x2700.jpg'))
            if self._background == BackgroundType.TOPO:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/etopo.png'))
            if self._background == BackgroundType.BATHYMETRY:
                img = plt.imread(join(self._eoas_pyutils_path,'viz_utils/imgs/bathymetry_3600x1800.jpg'))
            c_ax.imshow(img, origin='upper', extent=(-180,180,-90,90), transform=ccrs.PlateCarree())
        if mode == PlotMode.RASTER or mode == PlotMode.MERGED:
            if self._contourf:
                im = c_ax.contourf(self._lons, self._lats, c_img, num_colors=255, cmap='inferno', extent=self._extent)
            else:
                if np.isnan(mincbar):
                    im = c_ax.imshow(c_img, extent=self._extent, origin=origin, cmap=cmap, transform=self._projection, norm=self._norm)
                else:
                    im = c_ax.imshow(c_img, extent=self._extent, origin=origin, cmap=cmap, vmin=mincbar, vmax=maxcbar, transform=self._projection, norm=self._norm)
        if mode == PlotMode.CONTOUR or mode == PlotMode.MERGED:
            c_ax.set_extent(self.getExtent(list(self._lats), list(self._lons)))
            if mode == PlotMode.CONTOUR:
                im = c_ax.contour(c_img, extent=self._extent, transform=self._projection)
            if mode == PlotMode.MERGED:
                if self._contour_labels:
                    c_ax.contour(c_img, self._contour_labels, colors='r', extent=self._extent, transform=self._projection)
                else:
                    c_ax.contour(c_img, extent=self._extent, transform=self._projection)
        if len(self._additional_polygons) > 0:
            pol_lats = []
            pol_lons = []
            for c_polygon in self._additional_polygons:
                if isinstance(c_polygon, shapely.geometry.linestring.LineString):
                    x,y = c_polygon.xy
                elif isinstance(c_polygon, shapely.geometry.polygon.Polygon):
                    x, y = c_polygon.exterior.xy
                pol_lats += y
                pol_lons += x
                c_ax.plot(x,y, transform=self._projection, c='r')
            c_ax.set_extent(self.getExtent(list(self._lats) + pol_lats, list(self._lons) + pol_lons, 0.5))
        if self._vector_field != None:
            try:
                u = self._vector_field['u']
                v = self._vector_field['v']
                x = self._vector_field['x']
                y = self._vector_field['y']
                vec_keys = self._vector_field.keys()
                c = 'r'
                density = 1
                linewidth = 3
                vec_cmap = cmocean.cm.solar
                if 'color' in vec_keys:
                    c = self._vector_field['color']
                if 'density' in vec_keys:
                    density = self._vector_field['density']
                if 'linewidth' in vec_keys:
                    linewidth = self._vector_field['linewidth']
                if 'cmap' in vec_keys:
                    vec_cmap = self._vector_field['cmap']
                c_ax.set_extent(self.getExtent(list(self._lats), list(self._lons)))
                c_ax.streamplot(x, y, u, v, transform=self._projection, density=density, color=c,
                                cmap=vec_cmap, linewidth=linewidth)
            except Exception as e:
                print(F"Couldn't add vector field e:{e}")
        gl = c_ax.gridlines(draw_labels=True, color='grey', alpha=0.5, linestyle='--')
        font_coords = {'size': self._font_size*.6}
        gl.xlabel_style = font_coords
        gl.ylabel_style = font_coords
        gl.top_labels = False
        gl.right_labels = False
        return im
def plot_slice_eoa ( self , c_img , ax , cmap = 'gray' , mode = PlotMode . RASTER , mincbar = np . nan , maxcbar = np . nan ) -> None : c_ax = ax if self . _flip_data : origin = 'lower' else : origin = 'upper' if self . _background == BackgroundType . CARTO_DEF : c_ax . stock_img ( ) else : if self . _background == BackgroundType . BLUE_MARBLE_LR : img = plt . imread ( join ( self . _eoas_pyutils_path , 'viz_utils/imgs/bluemarble.png' ) ) if self . _background == BackgroundType . BLUE_MARBLE_HR : img = plt . imread ( join ( self . _eoas_pyutils_path , 'viz_utils/imgs/bluemarble_5400x2700.jpg' ) ) if self . _background == BackgroundType . TOPO : img = plt . imread ( join ( self . _eoas_pyutils_path , 'viz_utils/imgs/etopo.png' ) ) if self . _background == BackgroundType . BATHYMETRY : img = plt . imread ( join ( self . _eoas_pyutils_path , 'viz_utils/imgs/bathymetry_3600x1800.jpg' ) ) c_ax . imshow ( img , origin = 'upper' , extent = ( - 180 , 180 , - 90 , 90 ) , transform = ccrs . PlateCarree ( ) ) if mode == PlotMode . RASTER or mode == PlotMode . MERGED : if self . _contourf : im = c_ax . contourf ( self . _lons , self . _lats , c_img , num_colors = 255 , cmap = 'inferno' , extent = self . _extent ) else : if np . isnan ( mincbar ) : im = c_ax . imshow ( c_img , extent = self . _extent , origin = origin , cmap = cmap , transform = self . _projection , norm = self . _norm ) else : im = c_ax . imshow ( c_img , extent = self . _extent , origin = origin , cmap = cmap , vmin = mincbar , vmax = maxcbar , transform = self . _projection , norm = self . _norm ) if mode == PlotMode . CONTOUR or mode == PlotMode . MERGED : c_ax . set_extent ( self . getExtent ( list ( self . _lats ) , list ( self . _lons ) ) ) if mode == PlotMode . CONTOUR : im = c_ax . contour ( c_img , extent = self . _extent , transform = self . _projection ) if mode == PlotMode . MERGED : if self . _contour_labels : c_ax . contour ( c_img , self . _contour_labels , colors = 'r' , extent = self . _extent , transform = self . _projection ) else : c_ax . contour ( c_img , extent = self . _extent , transform = self . _projection ) if len ( self . _additional_polygons ) > 0 : pol_lats = [ ] pol_lons = [ ] for c_polygon in self . _additional_polygons : if isinstance ( c_polygon , shapely . geometry . linestring . LineString ) : x , y = c_polygon . xy elif isinstance ( c_polygon , shapely . geometry . polygon . Polygon ) : x , y = c_polygon . exterior . xy pol_lats += y pol_lons += x c_ax . plot ( x , y , transform = self . _projection , c = 'r' ) c_ax . set_extent ( self . getExtent ( list ( self . _lats ) + pol_lats , list ( self . _lons ) + pol_lons , 0.5 ) ) if self . _vector_field != None : try : u = self . _vector_field [ 'u' ] v = self . _vector_field [ 'v' ] x = self . _vector_field [ 'x' ] y = self . _vector_field [ 'y' ] vec_keys = self . _vector_field . keys ( ) c = 'r' density = 1 linewidth = 3 vec_cmap = cmocean . cm . solar if 'color' in vec_keys : c = self . _vector_field [ 'color' ] if 'density' in vec_keys : density = self . _vector_field [ 'density' ] if 'linewidth' in vec_keys : linewidth = self . _vector_field [ 'linewidth' ] if 'cmap' in vec_keys : vec_cmap = self . _vector_field [ 'cmap' ] c_ax . set_extent ( self . getExtent ( list ( self . _lats ) , list ( self . _lons ) ) ) c_ax . streamplot ( x , y , u , v , transform = self . _projection , density = density , color = c , cmap = vec_cmap , linewidth = linewidth ) except Exception as e : print ( F"Couldn't add vector field e:{e}" ) gl = c_ax . gridlines ( draw_labels = True , color = 'grey' , alpha = 0.5 , linestyle = '--' ) font_coords = { 'size' : self . _font_size * .6 } gl . xlabel_style = font_coords gl . ylabel_style = font_coords gl . top_labels = False gl . right_labels = False return im
Plots a 2D img for EOA data.
Plots a 2D img for EOA data .
"""
        Plots a 2D img for EOA data.
        :param c_img: 2D array
        :param ax: geoaxes
        :return:
        """ #  Adds a threshold to the plot to see the polygons # gl.xlabel_style = {'size': self._font_size/2, 'color': '#aaaaaa', 'weight':'bold'}
None
self
c_img
None
ax
None
cmap
mode
mincbar
maxcbar