src/tropycal/recon/dataset.py
def plot_hovmoller(self,recon_select=None,varname='wspd',radlim=None,track_dict=None,plane_p_range=None,\
                       window=6,align='center',ax=None,return_ax=False,**kwargs):
        
        r"""
        Creates a hovmoller plot of azimuthally-averaged recon data.
        
        Parameters
        ----------
        recon_select : Requested recon data
            pandas.DataFrame or dict,
            or datetime or list of start/end datetimes.
        varname : Variable to average and plot (e.g. 'wspd').
            String
        ax : axes
            Instance of axes to plot on. If none, one will be generated. Default is none.
        return_ax : bool
            If True, returns the axes instance on which the plot was generated for the user to further modify. Default is False.
        cartopy_proj : ccrs
            Instance of a cartopy projection to use. If none, one will be generated. Default is none.
            
        Other Parameters
        ----------------
        prop : dict
            Customization properties for recon plot. Please refer to :ref:`options-prop-recon-hovmoller` for available options.
        """
        
        #Pop kwargs
        prop = kwargs.pop('prop',{})
        default_prop = {'cmap':'category','levels':None,'smooth_contourf':False}
        for key in default_prop.keys():
            if key not in prop.keys():
                prop[key]=default_prop[key]
            
        #Get recon data based on recon_select
        if recon_select is None:
            dfRecon = self.recentered
        elif isinstance(recon_select,pd.core.frame.DataFrame):
            dfRecon = recon_select
        elif isinstance(recon_select,dict):
            dfRecon = pd.DataFrame.from_dict(recon_select)
        else:
            dfRecon = self.__getSubTime(recon_select)
        
        #Apply flight level filter
        if plane_p_range is not None:
            dfRecon = dfRecon.loc[(dfRecon['plane_p']>min(plane_p_range)) & (dfRecon['plane_p']<max(plane_p_range))]
        
        #Retrieve track dictionary if none is specified
        if track_dict is None:
            track_dict = self.storm_obj.dict
        
        #Interpolate recon data to a hovmoller
        iRecon = interpRecon(dfRecon,varname,radlim,window=window,align=align)
        Hov_dict = iRecon.interpHovmoller(track_dict)

        #title = get_recon_title(varname) #may not be necessary
        #If no contour levels specified, generate levels based on data min and max
        if prop['levels'] is None:
            prop['levels'] = (np.nanmin(Hov_dict['hovmoller']),np.nanmax(Hov_dict['hovmoller']))
        
        #Retrieve updated contour levels and colormap based on input arguments and variable type
        cmap,clevs = get_cmap_levels(varname,prop['cmap'],prop['levels'])
        
        #Retrieve hovmoller times, radii and data
        time = Hov_dict['time']
        radius = Hov_dict['radius']
        vardata = Hov_dict['hovmoller']
        
        #Error check time
        time = [dt.strptime((i.strftime('%Y%m%d%H%M')),'%Y%m%d%H%M') for i in time]
        
        #------------------------------------------------------------------------------
        
        #Create plot        
        #plt.figure(figsize=(9,11),dpi=150)
        plt.figure(figsize=(9,9),dpi=150) #CHANGE THIS OR ELSE
        ax = plt.subplot()
        
        #Plot surface category colors individually, necessitating normalizing colormap
        if varname in ['vmax','sfmr','fl_to_sfc'] and prop['cmap'] == 'category':
            norm = mcolors.BoundaryNorm(clevs,cmap.N)
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             levels=clevs,cmap=cmap,norm=norm)
        
        #Multiple clevels or without smooth contouring
        elif len(prop['levels']) > 2 or prop['smooth_contourf'] == False:
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             levels=clevs,cmap=cmap)
        
        #Automatically generated levels with smooth contouring
        else:
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             cmap=cmap,levels=np.linspace(min(prop['levels']),max(prop['levels']),256))
        ax.axis([0,max(radius),min(time),max(time)])
        
        #Plot colorbar
        cbar = plt.colorbar(cf,orientation='horizontal',pad=0.1)
        
        #Format y-label ticks and labels as dates
        ax.yaxis.set_major_formatter(mdates.DateFormatter('%m-%d %H'))
        for tick in ax.xaxis.get_major_ticks():
                tick.label.set_fontsize(14)
        for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(14)
        
        #Set axes labels
        ax.set_ylabel('UTC Time (MM-DD HH)',fontsize=15)
        ax.set_xlabel('Radius (km)',fontsize=15)
        
        #--------------------------------------------------------------------------------------
        
        #Generate left and right title strings
        title_left, title_right = hovmoller_plot_title(self.storm_obj,Hov_dict,varname)
        ax.set_title(title_left,loc='left',fontsize=16,fontweight='bold')
        ax.set_title(title_right,loc='right',fontsize=12)
        
        #Return axis
        if return_ax:
            return ax
r"""
        Creates a hovmoller plot of azimuthally-averaged recon data.
        
        Parameters
        ----------
        recon_select : Requested recon data
            pandas.DataFrame or dict,
            or datetime or list of start/end datetimes.
        varname : Variable to average and plot (e.g. 'wspd').
            String
        ax : axes
            Instance of axes to plot on. If none, one will be generated. Default is none.
        return_ax : bool
            If True, returns the axes instance on which the plot was generated for the user to further modify. Default is False.
        cartopy_proj : ccrs
            Instance of a cartopy projection to use. If none, one will be generated. Default is none.
            
        Other Parameters
        ----------------
        prop : dict
            Customization properties for recon plot. Please refer to :ref:`options-prop-recon-hovmoller` for available options.
        
r"""
Creates a hovmoller plot of azimuthally-averaged recon data.

Parameters

recon_select : Requested recon data
pandas.DataFrame or dict,
or datetime or list of start/end datetimes.
varname : Variable to average and plot .
String
ax : axes
Instance of axes to plot on. If none, one will be generated. Default is none.
return_ax : bool
If True, returns the axes instance on which the plot was generated for the user to further modify. Default is False.
cartopy_proj : ccrs
Instance of a cartopy projection to use. If none, one will be generated. Default is none.

Other Parameters

prop : dict
Customization properties for recon plot. Please refer to :ref:`options-prop-recon-hovmoller` for available options.
r " " " Creates a hovmoller plot of azimuthally - averaged recon data . Parameters recon_select : Requested recon data pandas . DataFrame or dict or datetime or list of start / end datetimes . varname : Variable to average and plot . String ax : axes Instance of axes to plot on . If none one will be generated . Default is none . return_ax : bool If True returns the axes instance on which the plot was generated for the user to further modify . Default is False . cartopy_proj : ccrs Instance of a cartopy projection to use . If none one will be generated . Default is none . Other Parameters prop : dict Customization properties for recon plot . Please refer to : ref : ` options - prop - recon - hovmoller ` for available options .
def plot_hovmoller(self,recon_select=None,varname='wspd',radlim=None,track_dict=None,plane_p_range=None,\
                       window=6,align='center',ax=None,return_ax=False,**kwargs):
        prop = kwargs.pop('prop',{})
        default_prop = {'cmap':'category','levels':None,'smooth_contourf':False}
        for key in default_prop.keys():
            if key not in prop.keys():
                prop[key]=default_prop[key]
        if recon_select is None:
            dfRecon = self.recentered
        elif isinstance(recon_select,pd.core.frame.DataFrame):
            dfRecon = recon_select
        elif isinstance(recon_select,dict):
            dfRecon = pd.DataFrame.from_dict(recon_select)
        else:
            dfRecon = self.__getSubTime(recon_select)
        if plane_p_range is not None:
            dfRecon = dfRecon.loc[(dfRecon['plane_p']>min(plane_p_range)) & (dfRecon['plane_p']<max(plane_p_range))]
        if track_dict is None:
            track_dict = self.storm_obj.dict
        iRecon = interpRecon(dfRecon,varname,radlim,window=window,align=align)
        Hov_dict = iRecon.interpHovmoller(track_dict)
        if prop['levels'] is None:
            prop['levels'] = (np.nanmin(Hov_dict['hovmoller']),np.nanmax(Hov_dict['hovmoller']))
        cmap,clevs = get_cmap_levels(varname,prop['cmap'],prop['levels'])
        time = Hov_dict['time']
        radius = Hov_dict['radius']
        vardata = Hov_dict['hovmoller']
        time = [dt.strptime((i.strftime('%Y%m%d%H%M')),'%Y%m%d%H%M') for i in time]
        plt.figure(figsize=(9,9),dpi=150) 
        ax = plt.subplot()
        if varname in ['vmax','sfmr','fl_to_sfc'] and prop['cmap'] == 'category':
            norm = mcolors.BoundaryNorm(clevs,cmap.N)
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             levels=clevs,cmap=cmap,norm=norm)
        elif len(prop['levels']) > 2 or prop['smooth_contourf'] == False:
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             levels=clevs,cmap=cmap)
        else:
            cf = ax.contourf(radius,time,gfilt1d(vardata,sigma=3,axis=1),
                             cmap=cmap,levels=np.linspace(min(prop['levels']),max(prop['levels']),256))
        ax.axis([0,max(radius),min(time),max(time)])
        cbar = plt.colorbar(cf,orientation='horizontal',pad=0.1)
        ax.yaxis.set_major_formatter(mdates.DateFormatter('%m-%d %H'))
        for tick in ax.xaxis.get_major_ticks():
                tick.label.set_fontsize(14)
        for tick in ax.yaxis.get_major_ticks():
                tick.label.set_fontsize(14)
        ax.set_ylabel('UTC Time (MM-DD HH)',fontsize=15)
        ax.set_xlabel('Radius (km)',fontsize=15)
        --------
        title_left, title_right = hovmoller_plot_title(self.storm_obj,Hov_dict,varname)
        ax.set_title(title_left,loc='left',fontsize=16,fontweight='bold')
        ax.set_title(title_right,loc='right',fontsize=12)
        if return_ax:
            return ax
def plot_hovmoller ( self , recon_select = None , varname = 'wspd' , radlim = None , track_dict = None , plane_p_range = None , window = 6 , align = 'center' , ax = None , return_ax = False , ** kwargs ) : prop = kwargs . pop ( 'prop' , { } ) default_prop = { 'cmap' : 'category' , 'levels' : None , 'smooth_contourf' : False } for key in default_prop . keys ( ) : if key not in prop . keys ( ) : prop [ key ] = default_prop [ key ] if recon_select is None : dfRecon = self . recentered elif isinstance ( recon_select , pd . core . frame . DataFrame ) : dfRecon = recon_select elif isinstance ( recon_select , dict ) : dfRecon = pd . DataFrame . from_dict ( recon_select ) else : dfRecon = self . __getSubTime ( recon_select ) if plane_p_range is not None : dfRecon = dfRecon . loc [ ( dfRecon [ 'plane_p' ] > min ( plane_p_range ) ) & ( dfRecon [ 'plane_p' ] < max ( plane_p_range ) ) ] if track_dict is None : track_dict = self . storm_obj . dict iRecon = interpRecon ( dfRecon , varname , radlim , window = window , align = align ) Hov_dict = iRecon . interpHovmoller ( track_dict ) if prop [ 'levels' ] is None : prop [ 'levels' ] = ( np . nanmin ( Hov_dict [ 'hovmoller' ] ) , np . nanmax ( Hov_dict [ 'hovmoller' ] ) ) cmap , clevs = get_cmap_levels ( varname , prop [ 'cmap' ] , prop [ 'levels' ] ) time = Hov_dict [ 'time' ] radius = Hov_dict [ 'radius' ] vardata = Hov_dict [ 'hovmoller' ] time = [ dt . strptime ( ( i . strftime ( '%Y%m%d%H%M' ) ) , '%Y%m%d%H%M' ) for i in time ] plt . figure ( figsize = ( 9 , 9 ) , dpi = 150 ) ax = plt . subplot ( ) if varname in [ 'vmax' , 'sfmr' , 'fl_to_sfc' ] and prop [ 'cmap' ] == 'category' : norm = mcolors . BoundaryNorm ( clevs , cmap . N ) cf = ax . contourf ( radius , time , gfilt1d ( vardata , sigma = 3 , axis = 1 ) , levels = clevs , cmap = cmap , norm = norm ) elif len ( prop [ 'levels' ] ) > 2 or prop [ 'smooth_contourf' ] == False : cf = ax . contourf ( radius , time , gfilt1d ( vardata , sigma = 3 , axis = 1 ) , levels = clevs , cmap = cmap ) else : cf = ax . contourf ( radius , time , gfilt1d ( vardata , sigma = 3 , axis = 1 ) , cmap = cmap , levels = np . linspace ( min ( prop [ 'levels' ] ) , max ( prop [ 'levels' ] ) , 256 ) ) ax . axis ( [ 0 , max ( radius ) , min ( time ) , max ( time ) ] ) cbar = plt . colorbar ( cf , orientation = 'horizontal' , pad = 0.1 ) ax . yaxis . set_major_formatter ( mdates . DateFormatter ( '%m-%d %H' ) ) for tick in ax . xaxis . get_major_ticks ( ) : tick . label . set_fontsize ( 14 ) for tick in ax . yaxis . get_major_ticks ( ) : tick . label . set_fontsize ( 14 ) ax . set_ylabel ( 'UTC Time (MM-DD HH)' , fontsize = 15 ) ax . set_xlabel ( 'Radius (km)' , fontsize = 15 ) title_left , title_right = hovmoller_plot_title ( self . storm_obj , Hov_dict , varname ) ax . set_title ( title_left , loc = 'left' , fontsize = 16 , fontweight = 'bold' ) ax . set_title ( title_right , loc = 'right' , fontsize = 12 ) if return_ax : return ax
r"""
Creates a hovmoller plot of azimuthally-averaged recon data.
r " " " Creates a hovmoller plot of azimuthally - averaged recon data .
r"""
        Creates a hovmoller plot of azimuthally-averaged recon data.
        
        Parameters
        ----------
        recon_select : Requested recon data
            pandas.DataFrame or dict,
            or datetime or list of start/end datetimes.
        varname : Variable to average and plot (e.g. 'wspd').
            String
        ax : axes
            Instance of axes to plot on. If none, one will be generated. Default is none.
        return_ax : bool
            If True, returns the axes instance on which the plot was generated for the user to further modify. Default is False.
        cartopy_proj : ccrs
            Instance of a cartopy projection to use. If none, one will be generated. Default is none.
            
        Other Parameters
        ----------------
        prop : dict
            Customization properties for recon plot. Please refer to :ref:`options-prop-recon-hovmoller` for available options.
        """ #Pop kwargs #Get recon data based on recon_select #Apply flight level filter #Retrieve track dictionary if none is specified #Interpolate recon data to a hovmoller #title = get_recon_title(varname) #may not be necessary #If no contour levels specified, generate levels based on data min and max #Retrieve updated contour levels and colormap based on input arguments and variable type #Retrieve hovmoller times, radii and data #Error check time #------------------------------------------------------------------------------ #Create plot         #plt.figure(figsize=(9,11),dpi=150) #CHANGE THIS OR ELSE #Plot surface category colors individually, necessitating normalizing colormap #Multiple clevels or without smooth contouring #Automatically generated levels with smooth contouring #Plot colorbar #Format y-label ticks and labels as dates #Set axes labels #-------------------------------------------------------------------------------------- #Generate left and right title strings #Return axis
self
recon_select
varname
radlim
track_dict
plane_p_range
window
align
ax
return_ax