Skip to content

Commit

Permalink
Airnow (#479)
Browse files Browse the repository at this point in the history
* ENH: Updates for airnow

* ENH: Misspelling

* ENH: Adding secret to the workflow config file

* ENH: Adding to build documentation as well

* ENH: Updating for bug catching

* ENH: Bug fixing for PR runs

* ENH: Removign print
  • Loading branch information
AdamTheisen authored Jun 13, 2022
1 parent 2613953 commit 4682b79
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
env:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}
AIRNOW_API: ${{ secrets.AIRNOW_API }}
# Push the book's HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ concurrency:
env:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}
AIRNOW_API: ${{ secrets.AIRNOW_API }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_TOKEN: ${{ secrets.COVERLALLS_REPO_TOKEN }}

Expand Down
14 changes: 7 additions & 7 deletions act/discovery/get_airnow.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ def get_airnow_bounded_obs(token, start_date, end_date, latlon_bnds, parameters=
verbose = 1
inc_raw_con = 1

query_url = ('https://www.airnowapi.org/aq/data/?startDate=' + str(start_date)
+ '&endDate=' + str(end_date) + '&parameters=' + str(parameters)
+ '&BBOX=' + str(latlon_bnds) + '&dataType=' + str(data_type)
+ '&format=text/csv' + '&verbose=' + str(verbose)
+ '&monitorType=' + str(mon_type) + '&includerawconcentrations='
+ str(inc_raw_con) + '&API_KEY=' + str(token))
url = ('https://www.airnowapi.org/aq/data/?startDate=' + str(start_date)
+ '&endDate=' + str(end_date) + '&parameters=' + str(parameters)
+ '&BBOX=' + str(latlon_bnds) + '&dataType=' + str(data_type)
+ '&format=text/csv' + '&verbose=' + str(verbose)
+ '&monitorType=' + str(mon_type) + '&includerawconcentrations='
+ str(inc_raw_con) + '&API_KEY=' + str(token))

# Set Column names
names = ['latitude', 'longitude', 'time', 'parameter', 'concentration', 'unit',
'raw_concentration', 'AQI', 'category', 'site_name', 'site_agency', 'aqs_id', 'full_aqs_id']

# Read data into CSV
df = pd.read_csv(query_url, names=names)
df = pd.read_csv(url, names=names)

# Each line is a different time or site or variable so need to parse out
sites = df['site_name'].unique()
Expand Down
3 changes: 2 additions & 1 deletion act/tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ def test_get_armfile():

def test_airnow():
token = os.getenv('AIRNOW_API')
print(token)
if token is not None:
if len(token) == 0:
return
results = act.discovery.get_airnow_forecast(token, '2022-05-01', zipcode=60108, distance=50)
assert results['CategoryName'].values[0] == 'Good'
assert results['AQI'].values[2] == -1
Expand Down

0 comments on commit 4682b79

Please sign in to comment.