def get_forecast(latitude, longitude, include_hourly=False, grib2_dir=None): """ Main method determines forecast based on latitude and longitude and returns json-formatted result Args: latitude - forecast point latitude longitude - forecast point longitude include_hourly - flag to include hourly forecast, defaults to false grib2_dir - grib2 data directory, if omitted, the SOAP web service will be used Returns: json-formatted string - see README """ info("Latitude: {0}".format(latitude)) info("Longitude: {0}".format(longitude)) if include_hourly: info("Include hourly forecast") if grib2_dir: info("Using grib2 dir: {0}".format(grib2_dir)) # If grib2 directory is provided, use grib2 files if grib2_dir: grib2.verbose = verbose xml = grib2.xml(grib2_dir, latitude, longitude) info(xml) # Otherwise, use SOAP web service else: xml = noaa_ws.xml(latitude, longitude) info(xml) # Initialize object for data print(forecast.process_xml(xml, include_hourly)) # TODO fix json call
def test_nws(self): nws_data = self._nws_data() print(nws_data) xml = noaa_ws.xml(latitude, longitude) pysky_data = forecast.process_xml(xml, False) print(pysky_data) for d in pysky_data['daily']: date = d['date'] if date in nws_data.keys(): self.assertEquals(nws_data[date]['high'], d['high']) self.assertEquals(nws_data[date]['low'], d['low'])