src/tropycal/tracks/storm.py
def query_nhc_discussions(self,query):
        
        r"""
        Searches for the given word or phrase through all NHC forecast discussions for this storm.
        
        Parameters
        ----------
        query : str or list
            String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions (e.g., "rapid intensification"). Query is case insensitive.
        
        Returns
        -------
        list
            List of dictionaries containing all relevant forecast discussions.
        """
        
        #Check to ensure the data source is HURDAT
        if self.source != "hurdat":
            msg = "Error: NHC data can only be accessed when HURDAT is used as the data source."
            raise RuntimeError(msg)
        
        #Check to ensure storm is not an invest
        if self.invest:
            raise RuntimeError("Error: NHC does not issue advisories for invests that have not been designated as Potential Tropical Cyclones.")
        
        #Get storm ID & corresponding data URL
        storm_id = self.dict['operational_id']
        storm_year = self.dict['year']
        
        #Error check
        if storm_id == '':
            msg = "No NHC operational data is available for this storm."
            raise RuntimeError(msg)
        if isinstance(query,str) == False and isinstance(query,list) == False:
            msg = "'query' must be of type str or list."
            raise TypeError(msg)
        if isinstance(query,list):
            for i in query:
                if isinstance(i,str) == False:
                    msg = "Entries of list 'query' must be of type str."
                    raise TypeError(msg)
        
        #Get list of storm discussions
        disco_dict = self.list_nhc_discussions()
        
        #Iterate over every entry to retrieve its discussion text
        output = []
        for idx,forecast_date in enumerate(disco_dict['utc_date']):
            
            #Get forecast discussion
            forecast = self.get_nhc_discussion(forecast=forecast_date)
            
            #Get forecast text and query for word
            text = forecast['text'].lower()
            
            #If found, add into list
            if isinstance(query,str):
                if text.find(query.lower()) >= 0: output.append(forecast)
            else:
                found = False
                for i_query in query:
                    if text.find(i_query.lower()) >= 0: found = True
                if found: output.append(forecast)
            
        #Return list
        return output
r"""
        Searches for the given word or phrase through all NHC forecast discussions for this storm.
        
        Parameters
        ----------
        query : str or list
            String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions (e.g., "rapid intensification"). Query is case insensitive.
        
        Returns
        -------
        list
            List of dictionaries containing all relevant forecast discussions.
        
r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm.

Parameters

query : str or list
String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions . Query is case insensitive.

Returns

list
List of dictionaries containing all relevant forecast discussions.
r " " " Searches for the given word or phrase through all NHC forecast discussions for this storm . Parameters query : str or list String or list representing a word ( s ) or phrase ( s ) to search for within the NHC forecast discussions . Query is case insensitive . Returns list List of dictionaries containing all relevant forecast discussions .
def query_nhc_discussions(self,query):
        if self.source != "hurdat":
            msg = "Error: NHC data can only be accessed when HURDAT is used as the data source."
            raise RuntimeError(msg)
        if self.invest:
            raise RuntimeError("Error: NHC does not issue advisories for invests that have not been designated as Potential Tropical Cyclones.")
        storm_id = self.dict['operational_id']
        storm_year = self.dict['year']
        if storm_id == '':
            msg = "No NHC operational data is available for this storm."
            raise RuntimeError(msg)
        if isinstance(query,str) == False and isinstance(query,list) == False:
            msg = "'query' must be of type str or list."
            raise TypeError(msg)
        if isinstance(query,list):
            for i in query:
                if isinstance(i,str) == False:
                    msg = "Entries of list 'query' must be of type str."
                    raise TypeError(msg)
        disco_dict = self.list_nhc_discussions()
        output = []
        for idx,forecast_date in enumerate(disco_dict['utc_date']):
            forecast = self.get_nhc_discussion(forecast=forecast_date)
            text = forecast['text'].lower()
            if isinstance(query,str):
                if text.find(query.lower()) >= 0: output.append(forecast)
            else:
                found = False
                for i_query in query:
                    if text.find(i_query.lower()) >= 0: found = True
                if found: output.append(forecast)
        return output
def query_nhc_discussions ( self , query ) : if self . source != "hurdat" : msg = "Error: NHC data can only be accessed when HURDAT is used as the data source." raise RuntimeError ( msg ) if self . invest : raise RuntimeError ( "Error: NHC does not issue advisories for invests that have not been designated as Potential Tropical Cyclones." ) storm_id = self . dict [ 'operational_id' ] storm_year = self . dict [ 'year' ] if storm_id == '' : msg = "No NHC operational data is available for this storm." raise RuntimeError ( msg ) if isinstance ( query , str ) == False and isinstance ( query , list ) == False : msg = "'query' must be of type str or list." raise TypeError ( msg ) if isinstance ( query , list ) : for i in query : if isinstance ( i , str ) == False : msg = "Entries of list 'query' must be of type str." raise TypeError ( msg ) disco_dict = self . list_nhc_discussions ( ) output = [ ] for idx , forecast_date in enumerate ( disco_dict [ 'utc_date' ] ) : forecast = self . get_nhc_discussion ( forecast = forecast_date ) text = forecast [ 'text' ] . lower ( ) if isinstance ( query , str ) : if text . find ( query . lower ( ) ) >= 0 : output . append ( forecast ) else : found = False for i_query in query : if text . find ( i_query . lower ( ) ) >= 0 : found = True if found : output . append ( forecast ) return output
r"""
Searches for the given word or phrase through all NHC forecast discussions for this storm.
r " " " Searches for the given word or phrase through all NHC forecast discussions for this storm .
r"""
        Searches for the given word or phrase through all NHC forecast discussions for this storm.
        
        Parameters
        ----------
        query : str or list
            String or list representing a word(s) or phrase(s) to search for within the NHC forecast discussions (e.g., "rapid intensification"). Query is case insensitive.
        
        Returns
        -------
        list
            List of dictionaries containing all relevant forecast discussions.
        """ #Check to ensure the data source is HURDAT #Check to ensure storm is not an invest #Get storm ID & corresponding data URL #Error check #Get list of storm discussions #Iterate over every entry to retrieve its discussion text #Get forecast discussion #Get forecast text and query for word #If found, add into list #Return list
self
query