nautical.io package
Submodules
nautical.io.buoy module
- nautical.io.buoy.create_buoy(buoy)[source]
Provide a full workup for a specific buoy. If the buoy is None or it cannot be found then the data returned will be considered invalid as None
- Parameters
buoy – id of the buoy to do a workup on
- Returns
BuoyWorkup if successful else None
- nautical.io.buoy.fill_buoy(buoy)[source]
Pass in a Buoy object that needs to be filled in with the current data. The buoy object will have the validity set if the results were successful
- Parameters
buoy – nautical.noaa.buoy.Buoy object
- nautical.io.buoy.get_buoy_data(soup: BeautifulSoup, buoy: BuoyData, search: str)
Search the beautiful soup object for a TABLE containing the search string. The function will grab the data from the table and create a NOAAData object and return the data
- Parameters
soup – beautiful soup object generated from the get_url_source()
buoy – BuoyData object that should be filled with data as this function parses the data.
search – text to search for in the soup object.
- Returns
True when data has been found and set
- nautical.io.buoy.get_current_data(soup: BeautifulSoup, buoy: BuoyData, search: str)[source]
Search the beautiful soup object for a TABLE containing the search string. The function will grab the data from the table and create a NOAAData object and return the data
- Parameters
soup – beautiful soup object generated from the get_url_source()
buoy – BuoyData object that should be filled with data as this function parses the data.
search – text to search for in the soup object.
- Returns
True when data has been found and set
nautical.io.cdata module
- nautical.io.cdata.fill_buoy_with_cdata(buoy, cdata)[source]
Parse the CDATA string that contains information about this presumed buoy. The data here will be used as supplemental information as some buoys cannot be scraped online (no valid or useable data).
- Parameters
buoy – nautical.noaa.buoy.Buoy
cdata – String containing the CDATA or description element from kml
- Returns
Buoy object
- nautical.io.cdata.parse_cdata(cdata)[source]
Parse the CDATA string that contains information about this presumed buoy. The data here will be used as supplemental information as some buoys cannot be scraped online (no valid or useable data).
- Parameters
cdata – String containing the CDATA or description element from kml
- Returns
Dictionary containing all parsed fields.
- nautical.io.cdata.parse_location(location_data)[source]
Parse the latitude and longitude values out of the the string that was passed in. The latitude and longitude should contain the NSEW strings describing their sign.
- Parameters
location_data – String data contain latitude and longitude values
- Returns
dictionary containing the location point (when valid)
nautical.io.sources module
- nautical.io.sources.get_buoy_sources(source_type=SourceType.ALL)[source]
NOAA is kind enough to provide all of names, ids, and other information about ALL of their known buoys in a kml document hosted at the link provided (https://www.ndbc.noaa.gov/kml/marineobs_by_pgm.kml). Read through this document and parse the buoy information to determine their id and location. The ID can be used to provide to get_noaa_forecast_url(). Then we can find even more information about the buoys.
- Returns
dictionary all source names mapped to their respective source.
- nautical.io.sources.validate_sources(source_data, remove_invalid=True)[source]
This function is presumed to be executed after get_buoy_sources. The results of the previous function meet the requirements for the formatted parameter here. The function will attempt to parse all buoys found for each source supplied.
- Parameters
source_data – Dictionary in the format of source_name: source
remove_invalid – when True [default] remove the buoys that are invalid
- Returns
New dictionary where the buoys for each source are validated
nautical.io.web module
- nautical.io.web.get_noaa_forecast_url(buoy)[source]
NOAA is kind enough to post all of their data from their buoys at the same url ONLY requiring the id of buoy to change at the end of the link (https://www.ndbc.noaa.gov/station_page.php?station=). This function will simply take in the buoy from the user and append the data to the end of the url, IFF the data exists.
- Parameters
buoy – id of the buoy
- Returns
full url if buoy is not empty, otherwise None
- nautical.io.web.get_url_source(url_name)[source]
If you already know the url_name or if you have run through the get_noaa_forecast_url(), then you can send in the url here. Get the source information for the url and place the information into a BeautifulSoup object, so that we can do any lookups of the data that we need.
- Parameters
url_name – name of the url to search for
- Returns
BeautifulSoup Object on success otherwise none
Module contents
The io module consists of the functions utilized to search for information about buoys and their sources on NOAA’s website.
- nautical.io.create_buoy(buoy)[source]
Provide a full workup for a specific buoy. If the buoy is None or it cannot be found then the data returned will be considered invalid as None
- Parameters
buoy – id of the buoy to do a workup on
- Returns
BuoyWorkup if successful else None
- nautical.io.fill_buoy_with_cdata(buoy, cdata)[source]
Parse the CDATA string that contains information about this presumed buoy. The data here will be used as supplemental information as some buoys cannot be scraped online (no valid or useable data).
- Parameters
buoy – nautical.noaa.buoy.Buoy
cdata – String containing the CDATA or description element from kml
- Returns
Buoy object
- nautical.io.get_buoy_data(soup: BeautifulSoup, buoy: BuoyData, search: str)
Search the beautiful soup object for a TABLE containing the search string. The function will grab the data from the table and create a NOAAData object and return the data
- Parameters
soup – beautiful soup object generated from the get_url_source()
buoy – BuoyData object that should be filled with data as this function parses the data.
search – text to search for in the soup object.
- Returns
True when data has been found and set
- nautical.io.get_buoy_sources(source_type=SourceType.ALL)[source]
NOAA is kind enough to provide all of names, ids, and other information about ALL of their known buoys in a kml document hosted at the link provided (https://www.ndbc.noaa.gov/kml/marineobs_by_pgm.kml). Read through this document and parse the buoy information to determine their id and location. The ID can be used to provide to get_noaa_forecast_url(). Then we can find even more information about the buoys.
- Returns
dictionary all source names mapped to their respective source.
- nautical.io.get_current_data(soup: BeautifulSoup, buoy: BuoyData, search: str)[source]
Search the beautiful soup object for a TABLE containing the search string. The function will grab the data from the table and create a NOAAData object and return the data
- Parameters
soup – beautiful soup object generated from the get_url_source()
buoy – BuoyData object that should be filled with data as this function parses the data.
search – text to search for in the soup object.
- Returns
True when data has been found and set
- nautical.io.get_noaa_forecast_url(buoy)[source]
NOAA is kind enough to post all of their data from their buoys at the same url ONLY requiring the id of buoy to change at the end of the link (https://www.ndbc.noaa.gov/station_page.php?station=). This function will simply take in the buoy from the user and append the data to the end of the url, IFF the data exists.
- Parameters
buoy – id of the buoy
- Returns
full url if buoy is not empty, otherwise None
- nautical.io.get_url_source(url_name)[source]
If you already know the url_name or if you have run through the get_noaa_forecast_url(), then you can send in the url here. Get the source information for the url and place the information into a BeautifulSoup object, so that we can do any lookups of the data that we need.
- Parameters
url_name – name of the url to search for
- Returns
BeautifulSoup Object on success otherwise none
- nautical.io.parse_cdata(cdata)[source]
Parse the CDATA string that contains information about this presumed buoy. The data here will be used as supplemental information as some buoys cannot be scraped online (no valid or useable data).
- Parameters
cdata – String containing the CDATA or description element from kml
- Returns
Dictionary containing all parsed fields.
- nautical.io.parse_location(location_data)[source]
Parse the latitude and longitude values out of the the string that was passed in. The latitude and longitude should contain the NSEW strings describing their sign.
- Parameters
location_data – String data contain latitude and longitude values
- Returns
dictionary containing the location point (when valid)