NodeJS Command-Line-Interface weather app, which uses the CLI to fetch the current weather conditions for a geospatial location input. Python Flask server written to fetch/parse JSON data from the Dark Sky API, and, D3 used to visualize weather data. Currently, the browser front end is in development, but the goal is to create the Front-End using React
JavaScript
, Python/Pandas
, D3.js
, (React.js
)A CLI weather-tool / (app) which fetches a lat/lon coordinates of user-input address (postal codes, zip codes, cities, etc.), from the Google maps API, and uses those coordinates to fetch the past, current, and forecasted weather data from the forecast.io (darksky.net) API (requires an API-key). Currently, this only functions as a CLI (command-line-interface) tool, where functionality is run by Node.js
(e.g. $node app.js -a [address]
) based on the user-input address.
The goal of this project is to ultimately use React.js
to create the font-end of an on-line app where current, hourly, and minutely weather data will be displayed, both visually as time-series figures and as data tables, depending on the input-address from the user. Visual representation will be presented by using D3.js
; Back-end will be powered by Node.js
(currently, to test out and learn the D3.js
library, the back-end server will be powered by Python
); Data fetching, parsing, and manipulations will be done so using Python/Pandas
.
JavaScript
)The CLI tool is a quick way of fetching the current weather conditions from the DarkSky API. Simply call the app.js
script via. node
and the -a
flag to specify a specific address (either a city’s name - i.e. Vancouver, or a postal/zip code, or even a country’s name) to output the current weather conditions for the specified address.
Python/D3.js
)The web-app is still a work-in-progress, but from the current code there is a currently functional MVP with the current code-base.
Currently, there are two parts to the MVP. Firstly, weather.py
is run, to fetch the weather data from the DarkSky API. Second, when all the data has been fetched, parsed, and saved, the Flask server passes the data to the static html files that renders the data using D3
.
1. Revise the D3
code to be more modular → complete
- Also, research and fix the D3
to render the temperature data returned from both the forecast and time-machine requests. → complete (the problem was the x/y-axis min/max limits between the two data sets being used, I think…)
The D3
rendered figure for the /hindcast
end-point is missing both the y-axis and x-axis bars.
Then, the multi-line (time-machine & forecast requests) D3
rendered figure will have to be resolved. complete! (note the original goal of the project was to produce a time series figure showing both the historical and forecasted temperature data).
2. Refactor the flask_server.py
script such that all the data fetching/parsing will be done with requests to particular end-points. complete
3. Start constructing the front-end
- Update:
- The Landing Page has now been created and can be seen in the image below.
-
- __Update__:
- The idea is to have a single __*Landing Page*__ which will have links to *different weather parameters that will be rendered by `D3`.
- The *Landing Page* will have a __search bar__, which will ta`p into Google Maps' API to auto complete the search when given a query for a city's name (e.g. *Vancouver B.C., Canada*).
- With the city's name in hand, a call will be made to the Google Maps API to fetch the lat/lon coordinates of that location.
- Given the location, a request can then be routed to the DarkSky API to retrieve the *hourly* weather data for said location.
- I'd like to construct data-panels which allows the client to view weather time-series' for a variety of weather parameters, etc.
- There is also the possibility of doing the above using `React.js`.
- ...either way, this third step will involve lots more planning and research.
https://api.darksky.net/forecast/[key]/[latitude],[longitude]
https://api.darksky.net/forecast/[api-key]/[latitude],[longitude],[time]
cd
into python/flask-d3/
from the projects’ root directory.python flask_server.py
to start the server (on localhost::8080
)/
: Index/home page (rendering templates/index.html
)
/
end-point currently renders an <ul>
element, listing href
links for different parts of the project
Temperature
will take you to a static html
page for the D3)/about
: Gives a summary of what the project is all about (i.e. what tech stack is used, what API is being used, etc.)/temperature
: Renders the temperature data for both the forecast and time-machine requests to the DarkSky API. Currently, there are some problems encoutered with this end-point (refer to the question posted on stackoverflow), which I’m currently attempting to solve./forecast
: Renders the static D3
HTML
page, producing a figure of the temperature data returned from a forecast request to the DarkSky API.D3.js
can be viewed on as an Observable notebook.D3.js
instead of matplotlib.Since the data was not rendering properly (despite being successfully passed from server to html), I hard-coded the data into the HTML page to produce this figure. I’ll have to explore the code and read up more, on D3
to hopefully solve the issue.
Update: This has now been solved (see figure below).
D3
calls to the data, the time series properly rendered!(for full details on request response formats, see here)
apparentTemperature
: ‘feels like’ temp in FarenheitcloudCover
: percentage of sky occluded by clouds, between 0 and 1, inclusive.dewPoint
: dew point in deg. Farenheithumidity
: relative humidity, between 0 and 1, inclusiveicon
: machine-readable text summary of data-point, suitable for selecting an icon for display.
clear-day
clear-night
rain
snow
sleet
wind
fog
cloudy
partly-cloudy-day
partly-cloudy-night
ozone
: columnar density of total atmospheric ozone at the given time (in Dobson units)precipIntensity
: intensity (in inches of liquid of water per hour) of precipitation occurring at a given time.precipProbability
: probability of precipitation occurring, between 0 and 1, inclusiveprecipType
: type of precipitation occurring at a given time.pressure
: sea-level pressure in millibarssummary
: human-readable text summary of data pointtemperature
: air-temp in deg. Farenheittime
(unix
timestamp): UNIX
time at which data point begins.uvIndex
: UV indexvisibility
: average visibility in miles, capped at 10 mileswindBearing
: direction that the wind is coming from in degrees, with true north at 0$^o$ and progressing clockwisewindGust
: wind gust in miles / hrwindSpeed
: wind speed in miles / hr