Updated for ONA 2024 in Atlanta ... Using Data to Help Tell Weather Stories
Join me ...
- Sign into Github (or quickly make an account if you haven't already): github.com
- Go to my Github page github.com/jkeefe/
- Click on the pinned repository at the top: weather-newsrooms-ona24
- Heat Risk
- Excessive Rain
- Winter Storm Severity Index
- Severe storm risks
- Records
- The forecast for free!
- Your Places: Extreme Weather
- Weather forecast office = WFO
- Google "Atlanta WFO"
- Click on "Cllimate and Past Weather"
- Click on "Observed Weather"
- "Daily Climate Report"
- NOW Data tab
- "Daily Data for a month"
Method 1: NECI climate data
- Go to https://www.ncei.noaa.gov/access/search/data-search/daily-summaries (or bit.ly/weather-records-1)
- Type in Atlanta
- Choose "Preview" on the Atlanta Hartsfield Airport line
- Pick a year month
- View the PDF
- Now download all the data
- But what are these columns?
- See the descriptions here: https://www.ncei.noaa.gov/metadata/geoportal/rest/metadata/item/gov.noaa.ncdc:C00861/html
Method 2: Thredex data
- Go to https://builder.rcc-acis.org/ (or bit.ly/weather-records-2)
- Enter ATL
- por (period of record)
- por
- mint (minimum temperature)
- can convert to csv: https://www.convertcsv.com/json-to-csv.htm
- can throw into datawrapper
- Can see trends!
Record highs and lows
- Same as the Method 2 above, but ethe lements are:
- Record lows:
[{"name":"mint","interval":[0,0,1],"duration":1,"smry":{"add":"date","reduce":"min"},"smry_only":"1","groupby":"year"}]
- Record highs:
[{"name":"maxt","interval":[0,0,1],"duration":1,"smry":{"add":"date","reduce":"max"},"smry_only":"1","groupby":"year"}]
- Documentation: https://www.rcc-acis.org/docs_webservices.html#title8
- Documentation: https://www.weather.gov/documentation/services-web-api
- Click on "Specification"
- Building a URL:
- Base endpoint:
https://api.weather.gov/alerts/active
- We want actual warnings, not tests:
?status=actual
- Area? Let's say Georgia. You can get fancier here, but states are easy:
&area=GA
- Code. This is the warning type. Tornado warning, tornado watch, etc. List is here. Could do
&code=TOR
, but let's just leave this off.
- Base endpoint:
- But what about monitoring it?
- Sign into Github (or quickly make an account if you haven't already): github.com
- Return to this page or scroll to the top of this page!
- Chose the "Fork" button
- Note that the owner is now you. Click "Create fork"
- After a minute, you will have a new screen. Note that your name is up at the top! This is your copy. You can use this now or just watch and return to it later. (If you see jkeefe instead of your name, you're on the wrong screen. Go find your copy in your github account.)
- Now click the green "<> Code" button and, after you do, the "Codespaces" tab under it.
- Click "Create Codespace on Main"
- File list on the left side
- Editing happens in the big window
- There's a terminal window at the bottom to run things
- Look at the Makefile in that folder
- Open the Terminal, if it's not open already
- Type
npm install
- Type
make download
Don't do make warnings
yet. Let's look at what this does!
- okay, when John says so, do
make warnings
It'd be great to get notified when there are new warnings! One way to pull that off is to send new warnings to Slack. Here's how to do that ...
Slack is a messaging platform used by a lot of newsrooms, and it's surprisingly good at showing messages from robots. Also? This will work in a free Slack workspace. So even if you don't have full access to your organization's Slack system, you can do this all on your own if you want; just make a new workspace at slack.com
.
You'll need to make a Slack app (it's easier than that sounds) and get a "bot token."
The only catch is that depending on your existing Slack setup, you may need to get an administrator to approve the creation of an app. The good thing is that you are only requesting the ability to chat:write
, which is simply posting into a channel.
OK, here's what to do:
- Do steps 1, 2 and 3 in this Slack app quickstart
- In step 2, "Requesting Scopes" you just need the
chat:write
scope and it will only work in channels where the bot is invited. - The thing you want is the "Bot User OAuth Token" which always starts
oxob-
. That's the token. - Locally, you can enter the following to test it directly into your Slack:
export SLACK_TOKEN=[your_token]
For example:
export SLACK_TOKEN=xoxb-123-456-abc-zyz
Next we need the Slack Channel id.
-
Go to your Slack workspace and pick (or make) a channel where you want your warnings to appear (I called mine #alerts.)
-
In that channel, invite the bot to the channel! For example, type:
/invite @warnings_bot
(using whatever you called your bot) -
Next, get the channel ID, which you can find by clicking on the channel name at the very top of the screen.
-
The ID is at the very bottom of the pop-up window, and you can click the little copy icon to copy it.
-
In the terminal type:
export SLACK_CHANNEL=[channel ID]
For example:
export SLACK_CHANNEL=C123ABC45
- Now type
make slack
!
You should see something like this appear:
If you click on the "reply" link, you'll see that the bot has included the details as a thread!
Github actions allow you to run your code in the cloud.
The driver of any github action is a yaml file in the .github/workflows
directory of a repo, like this one.
In short, here's what our warnings
Github Action does:
- It starts running according to a cron statement ([here every 10 minutes(https://github.com/jkeefe/nicar2024-weather/blob/39ae476058f19021be90a70dbc59b60cef120fd5/.github/workflows/warnings.yml#L5C1-L5C103)])
- Spins up a computer running ubuntu.
- Checks out this repo
- Loads node.js and installs packages (or pulls them from a cache if nothing has changed).
- Reads a SLACK_TOKEN secret
- Runs make all just like we did in the terminal
- Commits the new data to the repo (saving our
seen.json
for next run)
To get this working, you need to do a few key things:
Let the Action write back to the repo
- Settings > Actions > General > Workflow Permissions > Read and Write permissions > SAVE
- Don't forget to click "Save!"
Let the Action know your Slack Token
- Settings > Secrets and varialbes > Actions > Repository Secrets > New Repository Secret
- Enter
SLACK_TOKEN
in the top box - Paste your "Bot User OAuth Token" which always starts
oxob-
into the larger box - Click the "Add Secret" button
Let the Action know your Slack Channel
- Again, you want a New Repository Secret
- This time, enter
SLACK_CHANNEL
in the top box - Paste your channel ID in the bottom box.
Then ... run your action:
-
Actions > warnings > Run workflow dropdown > Run workflow button
-
Click the "warnings" label next to the yellow dot to watch it in action.
To make the bot run automatically, find the warnings.yml
file in the .github/workflows
folder.
Then uncomment (so remove the #
and a single space) from lines 4 and 5. The file should now look like this at the top (the indentations matter and should be exact):
name: warnings
on:
schedule:
- cron: '*/10 * * * *' # <-- Set your cron here (UTC). Uses github which can be ~2-10 mins late.
workflow_dispatch:
You need to save your work back to your repository for it to keep after you close your browser today. Read on for how to do that.
This is an ephemperal instance! The instance will live in your account for a few days, but unless you take active steps, it will disappear. Which is good!
But if you make changes to the code you want to save, you need to proactively save your code back to the repository to make sure you have it. Here's how:
- Save all of the files you want to commit to your code
- Maybe even close them to make sure!
- Click the github source-control button
- Enter a commit message, like "edited readme"
- Use the blue dropdown arrow
- Pick "Commit & Sync"
- You will be warned that there are no changes staged, and do you want to stage and all of your changes. Say "Yes"
Running computers cost money. You get 60 hours free Codespace time every month and 15 gigabytes of storage. The Codespace will shut down after you haven't used it for a while, but but let's not waste those free minutes!
- While logged into Github, go to (github.com/codespaces)[https://github.com/codespaces]
- Pick the three dots next to the Active codespace.
- Chose "Stop codespace"
- If you forget, don't worry: It'll shut down automatically after 30 minutes. But why waste that?
- Go back to the main tab, and you'll see it's gone
- Can restart