Raben Systems, Inc

Raben Systems, Inc

  • 822 W Mulberry St
  • Louisville, Colorado
  • 80027-9404

Description

This article discusses the code to retrieve Planetary Kp data from a drupal webservice. Previously in Part 1 was a discussion of Planetary Kp data itself. Part 2 was a discussion of the code to create a bargraph to display the data. A couple classes are defined to represent the data to be retrieved. The first is called SpaceWeatherData which is a container for the time series data. Class variables start and end are used to store the start and end times of the data retrieved. The variable dataType is used to represent the type of data contained is in this case equal to "Kp". The variable vals is an array containing TimeSeriesData TimerSeriesData is used to represent the Planetary Kp values as well as other types of space weather time series data. It consists simply of a date, the name, and a value. Next up is discussion of the class that actually retrieves the data from a space weather restfull interface, SpaceWeatherRetriever. (I'd guess that object-oriented purists will shutter at the concept, but I've always done it this way through the years.... I have no justification other than convenience). It consists mainly of a method that goes out and gets JSON encoded data from a RESTful spaceweather webservice . The JSON data received resembles the following structure: The URL of the webservice is defined in the constant "SWD_URL". Most of the code is concerned with parsing variables in the JSON markup (lines 43 thru 103) . A new TimeSeriesData object is created when the parser encounters a new JSON element (lines 51 to 54). The TimeSeriesData is inserted the SpaceWeather array when the end of the element is detected (lines 55 to 58). The space weather data attributes ("dataset", "start", and "end") are set as the event is received (lines 63 to 84). Similarly, time series data attributes ("date", "name", and "val") are set as corresponding event is received (lines 85 to 99). After the data is received and parsed, the Kp chart is updated (line 114). Error handling is pretty simplistic (ie needs improvement). An Alert dialog is popped up if there is an http code other than 200 is recieved (lines 129 to 133). In the next article I'll discuss the drupal module that implements the space weather service which provides the Planetary Kp data.

Companies nearby