Create weather metric


#1

First, create weather stations by triggering the creation job with:

// create weather stations
var job = Location.refreshWeatherStations();
c3Grid(WeatherStationCreator.fetch({filter: Filter.eq('id', job.id)}))
// once job completed and weather stations created, fetch weather data
Location.refreshWeatherStations()

Check the weather data with a metric of the sort:

var sm = SimpleMetric.make({
    "id": "AverageDailyTemp_Facility",
    "name": "AverageDailyTemp",
    "srcType": "Facility",
    "path": "placedAt.weatherStation",
    "expression": "avg(avg(normalized.data.temperature))",
    "unit": {
      "id": "degrees_fahrenheit"
    }
  });
c3Viz(Facility.evalMetricsWithMetadata({
  ids: ['0082'],
  expressions: ['AverageDailyTemp'],
  start: '2018-10-01',
  end: '2018-11-31',
  interval: 'DAY'
},[sm]));

To debug issues related to temperature data, check this thread WeatherDataUpdater debug