Open weather map API queries

edit 4/27/2015

This curl examples for this API are broken. – the API now requires a key: http://openweathermap.org/api

notes

I’m using this API now instead of the CORDC wind forecast data for the internet-sensors wind example. You can get 7 day forecast data for practically anywhere. Also historical data is available. And its free.

Get forecast by city id

Weather forecast in the city for the next 7 days.

http://api.openweathermap.org/data/2.1/forecast/city/{CITY_ID}

http://api.openweathermap.org/data/2.1/forecast/city/524901

{"message":"","cod":"200","calctime":0.0189,"list":[
{"dt":1345251600,
    "main":{"temp":286.6,"humidity":98,"pressure":1002,"temp_min":286,"temp_max":287},
    "wind":{"speed":0,"deg":-2},
    "rain":{"3h":2},
    "clouds":{"all":56},
    "weather":{"id":803,"main":"Clouds","description":"broken clouds", "img":"..." }
....

This gets city code for santa cruz – 5393052

curl http://api.openweathermap.org/data/2.1/find/name?q=santa%20cruz,US

this gets 7 days of santa cruz forecasts with time stamps

curl http://api.openweathermap.org/data/2.1/forecast/city/5393052

typical JSON response (for one datapoint):

{
		"dt": 1364176800,
		"main": {
			"temp": 285.54,
			"temp_min": 282.6,
			"temp_max": 287.5,
			"pressure": 1015.99,
			"humidity": 87.6,
			"temp_kf": 2.94
		},
		"weather": [{
			"id": 801,
			"main": "Clouds",
			"description": "few clouds",
			"icon": "02n"
		}],
		"clouds": {
			"all": 17,
			"low": 0,
			"middle": 0,
			"high": 17
		},
		"wind": {
			"speed": 4.29,
			"deg": 311,
			"gust": 5.1
		},
		"dt_txt": "2013-03-25 02:00:00"
	}

So… to get precipitation, we need to just look for “rain”, or “snow”  indicator

 

domain ping machine in Web Audio

A ‘mini’ version of the Google domain ping synthesizer from the internet-sensors collection (Using the Mashape API). This one runs in Web Audio, using the Web Audio Playground with OSC.

Looks like a card game. Anyway it sounds cool. Doesn’t have the panning of the original, but it has an organic sound due to portamento in frequency changes, and more ‘beating’. Here’s a short excerpt.

Another example of Max controlling WAP https://reactivemusic.net/?p=6193

download

https://github.com/tkzic/WebAudio

folder is: WebAudio/osctest/

files

  • wapOSCserver-ping.rb
  • wapPingTest.maxpat
  • WAP patch: – ping2 (5 osc’s -> 5 gains, -> 1 master gain) – ping2.json
  • Web Page: WebAudio/index.html

instructions

update: you can run an online version of WAP Web client at http://zerokidz.com/wap/index.html – If you load this page, skip to step 3.

1. run the node webserver in WebAudio

node nodeserver.js

(it will run on localhost port 8081 – for example http://127.0.0.1:8081)

2. In Chrome web browser, run: 127.0.0.1:8081/index.html

3. From a terminal window, go to the osctest/ folder and start the server by typing:

./wapOSCserver-ping.rb

4. Load the Max patch:

wapPingTest.maxpat

5. In Chrome, click the OSC button – the ruby server should open a socket connection

6. Also in Chrome, load the patch: ping2 (note that there is a json copy of this patch ping2.json that can be pasted in, if it doesn’t show up in the menu)

6.5 In WAP, Click the square buttons on the 5 Oscillators to start them playing. You should hear sounds at this point.

7. Now back in Max patch – click green toggle to start polling and you probably want to increase the polling rate to about 50 ms instead of 1000 ms

suggestions
  • If it doesn’t seem like there is much action in the patch, try adjusting the FREQ_MULT and GAIN_MULT inside the ruby script.
  • You will probably also want to open the developer javascript console in Chrome to see what is going on.