Skip to content

Commit

Permalink
Merge pull request #47 from UBC-MDS/review_updates
Browse files Browse the repository at this point in the history
Review updates
  • Loading branch information
chenzhao2020 committed May 2, 2021
2 parents 1f622d5 + e8cdb07 commit df91c5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021, DSCI524 Group23
Copyright (c) 2021, Chen Zhao, Chirag Rank, and Steffen Pentelow

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Buildbadge](https://github.com/UBC-MDS/noaastn/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/UBC-MDS/noaastn/branch/main/graph/badge.svg)](https://codecov.io/gh/UBC-MDS/noaastn) [![Deploy](https://github.com/UBC-MDS/noaastn/actions/workflows/deploy.yml/badge.svg)](https://github.com/UBC-MDS/noaastn/actions/workflows/deploy.yml) [![Documentation Status](https://readthedocs.org/projects/noaastn/badge/?version=latest)](https://noaastn.readthedocs.io/en/latest/?badge=latest)

The US National Oceanic and Atmospheric Administration (NOAA) collects and provides access to weather data from land-based weather stations within the US and around the world ([Land-Based Station Data](https://www.ncdc.noaa.gov/data-access/land-based-station-data)). One method for accessing these data is through a publically accessible FTP site. This package allows users to easily download data from a given station for a given year, extract several key weather parameters from the raw data files, and visualize the variation in these parameters over time. The weather parameters that are extracted with this package are:
The US National Oceanic and Atmospheric Administration (NOAA) collects and provides access to weather data from land-based weather stations within the US and around the world ([Land-Based Station Data](https://www.ncdc.noaa.gov/data-access/land-based-station-data)). One method for accessing these data is through a publicly accessible FTP site. This package allows users to easily download data from a given station for a given year, extract several key weather parameters from the raw data files, and visualize the variation in these parameters over time. The weather parameters that are extracted with this package are:

- Air Temperature (degrees Celsius)
- Atmospheric Pressure (hectopascals)
Expand Down Expand Up @@ -32,27 +32,27 @@ The list of the dependencies for this package can be viewed under

## Related Packages

There are few packages in the python ecosystem like [noaa](https://pypi.org/project/noaa/), [noaa-coops](https://pypi.org/project/noaa-coops/), [noaa-sdk](https://pypi.org/project/noaa-sdk/) that do analysis related to NOAA weather station data. These tools are more focused on using the NOAA's [API service](https://www.ncei.noaa.gov/support/access-data-service-api-user-documentation) to obtain forecast information. They do not provide an interface to obtain historical weather data from the NOAA's FTP site, process and visualize key weather parameters like this package do.
There are few packages in the python ecosystem like [noaa](https://pypi.org/project/noaa/), [noaa-coops](https://pypi.org/project/noaa-coops/), [noaa-sdk](https://pypi.org/project/noaa-sdk/) that do analysis related to NOAA weather station data. These tools are more focused on using the NOAA's [API service](https://www.ncei.noaa.gov/support/access-data-service-api-user-documentation) to obtain forecast information. They do not provide an interface to obtain historical weather data from the NOAA's FTP site, process and visualize key weather parameters like this package does.

## Usage

Typical usage will begin with downloading the list of available weather stations in the country of interest using the `get_stations_info()` function. A dataframe is returned which can be reviewed to find a suitable station in the area of interest. Alternatively, the NOAA provides a [graphical interface](https://gis.ncdc.noaa.gov/maps/ncei/cdo/hourly) for exploring the available weather stations.

```
```python
>>> from noaastn import noaastn
>>> noaastn.get_stations_info(country = "US")
```

![Tabular output from get_stations_info function](https://raw.githubusercontent.com/UBC-MDS/noaastn/main/img/get_stations_info.png)

After selecting a weather station number, the `get_weather_data()` function can be used to download various weather parameters for the station number and year of interest. The following usage example downloads weather data from station number "911650-22536" for the year 2020 and saves the data to a variable called 'weather_data'. 'weather_data' will be a data frame containing a time series of the following parameters for the station and year of interest:
After selecting a weather station number, the `get_weather_data()` function can be used to download various weather parameters for the station number and year of interest. NOAA stations are specified using two ID codes: the USAF station ID and the NCDC WBAN number. The `station_number` argument must have the form '<USAF ID>-<WBAN ID>', both of which can be found in the table returned by `get_stations_info()` (if a WBAN ID does not exist, a value of '99999' should be used in its place). The following usage example downloads weather data from station number "911650-22536" for the year 2020 and saves the data to a variable called 'weather_data'. 'weather_data' will be a data frame containing a time series of the following parameters for the station and year of interest:

- air temperature (degrees Celsius)
- atmospheric pressure (hectopascals)
- wind speed (m/s)
- wind direction (angular degrees)

```
```python
>>> weather_data = noaastn.get_weather_data("911650-22536", 2020)
>>> print(weather_data)
```
Expand All @@ -61,7 +61,7 @@ After selecting a weather station number, the `get_weather_data()` function can

The function `plot_weather_data()` can be used to visualize a time series of any of the available weather parameters either on a mean daily or mean monthly basis. The function returns an Altair chart object which can be saved or displayed in any environment which can render Altair objects.

```
```python
>>> noaastn.plot_weather_data(weather_data, col_name="air_temp", time_basis="monthly")
```

Expand All @@ -73,7 +73,7 @@ Documentation for this package can be found on [Read the Docs](https://noaastn.r

## Contributors

We welcome and recognize all contributions. You can see a list of current contributors in the [contributors tab](https://github.com/UBC-MDS/noaastn/graphs/contributors).
We welcome and recognize all contributions. You can see a list of current contributors in the [contributors tab](https://github.com/UBC-MDS/noaastn/graphs/contributors). The package was originally developed by Chen Zhao, Chirag Rank, and Steffen Pentelow.

## Credits

Expand Down
4 changes: 2 additions & 2 deletions noaastn/noaastn.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_weather_data(station_number, year):
type(station_number) == str
), "Station number must be entered as a string"
assert re.match(
"^[0-9]{6}[-][0-9]{5}$", station_number
"^[A-z|0-9][0-9]{5}[-][0-9]{5}$", station_number
), 'Station number must be entered in form "911650-22536".'

# Generate filename based on selected station number and year and download
Expand All @@ -154,7 +154,7 @@ def get_weather_data(station_number, year):
except error_perm as e_mess:
print("Error generated from NOAA FTP site: \n", e_mess)
noaa_ftp.quit()
return 'FTP Error'
return

noaa_ftp.quit()

Expand Down
6 changes: 3 additions & 3 deletions tests/test_get_weather_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ def test_station_number_coding():

def test_ftp_error_handling():
assert (
noaastn.get_weather_data("999999-99999", 1750) == "FTP Error"
), """Entry of invalid station/year combination should return string
'FTP error'."""
not noaastn.get_weather_data("999999-99999", 1750)
), """Entry of invalid station/year combination should not return
anything."""

0 comments on commit df91c5e

Please sign in to comment.