noaastn package¶
Submodules¶
noaastn.noaastn module¶
-
noaastn.noaastn.get_stations_info(country='all')[source]¶ Downloads and cleans the data of all stations available at ftp://ftp.ncei.noaa.gov/pub/data/noaa/.
- Parameters
country (str, optional) – Filters station information by country location that is represented by two character country code(“US”) or “all” for every country, by default “all”.
- Returns
Data frame containing information of all stations.
- Return type
pandas.DataFrame
Examples
>>> get_stations_info(country="US")
-
noaastn.noaastn.get_weather_data(station_number, year)[source]¶ Loads and cleans weather data for a given NOAA station ID and year. Returns a dataframe containing a time series of air temperature (degrees Celsius), atmospheric pressure (hectopascals), wind speed (m/s), and wind direction (angular degrees). The raw data file is downloaded from the NOAA FTP server at ftp://ftp.ncei.noaa.gov/pub/data/noaa/.
- Parameters
station_number (str) – NOAA station number.
year (int) – Year for which weather data should be returned
Notes
station_number is a combination of the USAF station ID and the NCDC WBAN number in the form ‘<USAF ID>-<WBAN ID>’. If a WBAN ID does not exist, a value of ‘99999’ should be used in its place. Example with WBAN ID - ‘911650-22536’ Example without WBAN ID - ‘010015-99999’ Station numbers can be found in the dataframe returned by get_stations_info() or through the NOAA’s graphical tool at https://gis.ncdc.noaa.gov/maps/ncei/cdo/hourly
- Returns
observations_df – A dataframe that contains a time series of weather station observations.
- Return type
pandas.DataFrame
Examples
>>> get_weather_data('911650-22536', 2020)
-
noaastn.noaastn.plot_weather_data(obs_df, col_name, time_basis)[source]¶ Visualizes the weather station observations including air temperature, atmospheric pressure, wind speed, and wind direction changing over time.
- Parameters
obs_df (pandas.DataFrame) – A dataframe that contains a time series of weather station observations.
col_name (str) – Variables that users would like to plot on a timely basis, including ‘air_temp’, ‘atm_press’, ‘wind_spd’, ‘wind_dir’
time_basis (str) – The users can choose to plot the observations on ‘monthly’ or ‘daily basis’
- Returns
A plot can visualize the changing of observation on the timely basis that user chooses.
- Return type
altair.vegalite.v4.api.Chart
Examples
>>> plot_weather_data(obs_df, col_name="air_temp", time_basis="monthly")