src/tropycal/tracks/storm.py
def plot_TCtors_rotated(self,dist_thresh=1000,save_path=None):
        
        r"""
        Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
        
        Parameters
        ----------
        dist_thresh : int
            Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Ignored if tornado data was passed into Storm from TrackDataset.
        save_path : str
            Relative or full path of directory to save the image in. If none, image will not be saved.
        
        Returns
        -------
        ax
            Instance of axes containing the plot is returned.
        
        Notes
        -----
        The motion vector is oriented upwards (in the +y direction).
        """
        
        #Checks to see if stormTors exists
        try:
            self.stormTors
            dist_thresh = self.tornado_dist_thresh
        except:
            warn_message = "Reading in tornado data for this storm. If you seek to analyze tornado data for multiple storms, run \"TrackDataset.assign_storm_tornadoes()\" to avoid this warning in the future."
            warnings.warn(warn_message)
            Tors = TornadoDataset()
            stormTors = Tors.get_storm_tornadoes(self,dist_thresh)
            self.stormTors = Tors.rotateToHeading(self,stormTors)
        
        #Create figure for plotting
        plt.figure(figsize=(9,9),dpi=150)
        ax = plt.subplot()
        
        #Default EF color scale
        EFcolors = get_colors_ef('default')
        
        #Plot all tornado tracks in motion relative coords
        for _,row in self.stormTors.iterrows():
            plt.plot([row['rot_xdist_s'],row['rot_xdist_e']+.01],[row['rot_ydist_s'],row['rot_ydist_e']+.01],\
                     lw=2,c=EFcolors[row['mag']])
            
        #Plot dist_thresh radius
        ax.set_facecolor('#F6F6F6')
        circle = plt.Circle((0,0), dist_thresh, color='w')
        ax.add_artist(circle)
        an = np.linspace(0, 2 * np.pi, 100)
        ax.plot(dist_thresh * np.cos(an), dist_thresh * np.sin(an),'k')
        ax.plot([-dist_thresh,dist_thresh],[0,0],'k--',lw=.5)
        ax.plot([0,0],[-dist_thresh,dist_thresh],'k--',lw=.5)
        
        #Plot motion vector
        plt.arrow(0, -dist_thresh*.1, 0, dist_thresh*.2, length_includes_head=True,
          head_width=45, head_length=45,fc='k',lw=2,zorder=100)
        
        #Labels
        ax.set_aspect('equal', 'box')
        ax.set_xlabel('Left/Right of Storm Heading (km)',fontsize=13)
        ax.set_ylabel('Behind/Ahead of Storm Heading (km)',fontsize=13)
        ax.set_title(f'{self.name} {self.year} tornadoes relative to heading',fontsize=17)
        ax.tick_params(axis='both', which='major', labelsize=11.5)
        
        #Add legend
        handles=[]
        for ef,color in enumerate(EFcolors):
            count = len(self.stormTors[self.stormTors['mag']==ef])
            handles.append(mlines.Line2D([], [], linestyle='-',color=color,label=f'EF-{ef} ({count})'))
        ax.legend(handles=handles,loc='lower left',fontsize=11.5)
        
        #Add attribution
        ax.text(0.99,0.01,plot_credit(),fontsize=8,color='k',alpha=0.7,
                transform=ax.transAxes,ha='right',va='bottom',zorder=10)
        
        #Save plot
        if save_path is not None and isinstance(save_path,str):
            plt.savefig(save_path,bbox_inches='tight')
        
        #Return axis or show figure
        return ax
r"""
        Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
        
        Parameters
        ----------
        dist_thresh : int
            Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Ignored if tornado data was passed into Storm from TrackDataset.
        save_path : str
            Relative or full path of directory to save the image in. If none, image will not be saved.
        
        Returns
        -------
        ax
            Instance of axes containing the plot is returned.
        
        Notes
        -----
        The motion vector is oriented upwards (in the +y direction).
        
r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.

Parameters

dist_thresh : int
Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Ignored if tornado data was passed into Storm from TrackDataset.
save_path : str
Relative or full path of directory to save the image in. If none, image will not be saved.

Returns

ax
Instance of axes containing the plot is returned.

Notes

The motion vector is oriented upwards (in the +y direction).
r " " " Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone . Parameters dist_thresh : int Distance threshold ( in kilometers ) from the tropical cyclone track over which to attribute tornadoes to the TC . Default is 1000 km . Ignored if tornado data was passed into Storm from TrackDataset . save_path : str Relative or full path of directory to save the image in . If none image will not be saved . Returns ax Instance of axes containing the plot is returned . Notes The motion vector is oriented upwards ( in the + y direction ) .
def plot_TCtors_rotated(self,dist_thresh=1000,save_path=None):
        try:
            self.stormTors
            dist_thresh = self.tornado_dist_thresh
        except:
            warn_message = "Reading in tornado data for this storm. If you seek to analyze tornado data for multiple storms, run \"TrackDataset.assign_storm_tornadoes()\" to avoid this warning in the future."
            warnings.warn(warn_message)
            Tors = TornadoDataset()
            stormTors = Tors.get_storm_tornadoes(self,dist_thresh)
            self.stormTors = Tors.rotateToHeading(self,stormTors)
        plt.figure(figsize=(9,9),dpi=150)
        ax = plt.subplot()
        EFcolors = get_colors_ef('default')
        for _,row in self.stormTors.iterrows():
            plt.plot([row['rot_xdist_s'],row['rot_xdist_e']+.01],[row['rot_ydist_s'],row['rot_ydist_e']+.01],\
                     lw=2,c=EFcolors[row['mag']])
        ax.set_facecolor('#F6F6F6')
        circle = plt.Circle((0,0), dist_thresh, color='w')
        ax.add_artist(circle)
        an = np.linspace(0, 2 * np.pi, 100)
        ax.plot(dist_thresh * np.cos(an), dist_thresh * np.sin(an),'k')
        ax.plot([-dist_thresh,dist_thresh],[0,0],'k--',lw=.5)
        ax.plot([0,0],[-dist_thresh,dist_thresh],'k--',lw=.5)
        plt.arrow(0, -dist_thresh*.1, 0, dist_thresh*.2, length_includes_head=True,
          head_width=45, head_length=45,fc='k',lw=2,zorder=100)
        ax.set_aspect('equal', 'box')
        ax.set_xlabel('Left/Right of Storm Heading (km)',fontsize=13)
        ax.set_ylabel('Behind/Ahead of Storm Heading (km)',fontsize=13)
        ax.set_title(f'{self.name} {self.year} tornadoes relative to heading',fontsize=17)
        ax.tick_params(axis='both', which='major', labelsize=11.5)
        handles=[]
        for ef,color in enumerate(EFcolors):
            count = len(self.stormTors[self.stormTors['mag']==ef])
            handles.append(mlines.Line2D([], [], linestyle='-',color=color,label=f'EF-{ef} ({count})'))
        ax.legend(handles=handles,loc='lower left',fontsize=11.5)
        ax.text(0.99,0.01,plot_credit(),fontsize=8,color='k',alpha=0.7,
                transform=ax.transAxes,ha='right',va='bottom',zorder=10)
        if save_path is not None and isinstance(save_path,str):
            plt.savefig(save_path,bbox_inches='tight')
        return ax
def plot_TCtors_rotated ( self , dist_thresh = 1000 , save_path = None ) : try : self . stormTors dist_thresh = self . tornado_dist_thresh except : warn_message = "Reading in tornado data for this storm. If you seek to analyze tornado data for multiple storms, run \"TrackDataset.assign_storm_tornadoes()\" to avoid this warning in the future." warnings . warn ( warn_message ) Tors = TornadoDataset ( ) stormTors = Tors . get_storm_tornadoes ( self , dist_thresh ) self . stormTors = Tors . rotateToHeading ( self , stormTors ) plt . figure ( figsize = ( 9 , 9 ) , dpi = 150 ) ax = plt . subplot ( ) EFcolors = get_colors_ef ( 'default' ) for _ , row in self . stormTors . iterrows ( ) : plt . plot ( [ row [ 'rot_xdist_s' ] , row [ 'rot_xdist_e' ] + .01 ] , [ row [ 'rot_ydist_s' ] , row [ 'rot_ydist_e' ] + .01 ] , lw = 2 , c = EFcolors [ row [ 'mag' ] ] ) ax . set_facecolor ( '#F6F6F6' ) circle = plt . Circle ( ( 0 , 0 ) , dist_thresh , color = 'w' ) ax . add_artist ( circle ) an = np . linspace ( 0 , 2 * np . pi , 100 ) ax . plot ( dist_thresh * np . cos ( an ) , dist_thresh * np . sin ( an ) , 'k' ) ax . plot ( [ - dist_thresh , dist_thresh ] , [ 0 , 0 ] , 'k--' , lw = .5 ) ax . plot ( [ 0 , 0 ] , [ - dist_thresh , dist_thresh ] , 'k--' , lw = .5 ) plt . arrow ( 0 , - dist_thresh * .1 , 0 , dist_thresh * .2 , length_includes_head = True , head_width = 45 , head_length = 45 , fc = 'k' , lw = 2 , zorder = 100 ) ax . set_aspect ( 'equal' , 'box' ) ax . set_xlabel ( 'Left/Right of Storm Heading (km)' , fontsize = 13 ) ax . set_ylabel ( 'Behind/Ahead of Storm Heading (km)' , fontsize = 13 ) ax . set_title ( f'{self.name} {self.year} tornadoes relative to heading' , fontsize = 17 ) ax . tick_params ( axis = 'both' , which = 'major' , labelsize = 11.5 ) handles = [ ] for ef , color in enumerate ( EFcolors ) : count = len ( self . stormTors [ self . stormTors [ 'mag' ] == ef ] ) handles . append ( mlines . Line2D ( [ ] , [ ] , linestyle = '-' , color = color , label = f'EF-{ef} ({count})' ) ) ax . legend ( handles = handles , loc = 'lower left' , fontsize = 11.5 ) ax . text ( 0.99 , 0.01 , plot_credit ( ) , fontsize = 8 , color = 'k' , alpha = 0.7 , transform = ax . transAxes , ha = 'right' , va = 'bottom' , zorder = 10 ) if save_path is not None and isinstance ( save_path , str ) : plt . savefig ( save_path , bbox_inches = 'tight' ) return ax
r"""
Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
r " " " Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone .
r"""
        Plot tracks of tornadoes relative to the storm motion vector of the tropical cyclone.
        
        Parameters
        ----------
        dist_thresh : int
            Distance threshold (in kilometers) from the tropical cyclone track over which to attribute tornadoes to the TC. Default is 1000 km. Ignored if tornado data was passed into Storm from TrackDataset.
        save_path : str
            Relative or full path of directory to save the image in. If none, image will not be saved.
        
        Returns
        -------
        ax
            Instance of axes containing the plot is returned.
        
        Notes
        -----
        The motion vector is oriented upwards (in the +y direction).
        """ #Checks to see if stormTors exists #Create figure for plotting #Default EF color scale #Plot all tornado tracks in motion relative coords #Plot dist_thresh radius #Plot motion vector #Labels #Add legend #Add attribution #Save plot #Return axis or show figure
self
dist_thresh
save_path