Commit 11407f15 authored by alain's avatar alain 💾

adjust to calibrated data

parent e4e3c103
......@@ -39,7 +39,7 @@ export default {
all: async function(parameter) {
try {
const allResponse = await fetch(`https://data.waag.org/api/muv/getHoluStations`)
const allResponse = await fetch(`https://data.waag.org/api/muv/getCalibratedStations`)
const all = await allResponse.json()
const latestRawResponse = await fetch(`https://data.waag.org/api/getAllSensors`)
......@@ -56,11 +56,13 @@ export default {
const data = all.filter(sensor => {
return filterExtended ? sensor.extended : true
}).map(sensor => {
const sensorData = latest.find(o => +o.id === +sensor.id)
//const kitType = sensor.id > 1000000 ? "MUV-kit" : "HOLU-kit"
const idPrefix = sensor.id > 1000000 ? "HLL_MUV_device_" : ""
const sensorData = latest.find(o => o.id.toString().replace(idPrefix, "") === sensor.id.toString())
const sensorDataReturn = {
id: sensor.id.toString(),
//name: `HOLU-kit ${sensor.id.toString()}: ${sensor.tag} - ${sensor.name}`,
id: idPrefix + sensor.id,
name: `${sensor.tag}: ${sensor.name}`,
source: "holu",
type: sensor.extended ? "extended" : "basic",
......@@ -145,7 +147,12 @@ export default {
let data = []
if(parameter === "pm25" || parameter === "pm10") {
const responseRaw = await fetch(`https://data.waag.org/api/getHourlyValuesSensor?sensor_id=${station.id}&start=${start}&end=${end}`)
let rawURL = `https://data.waag.org/api/getHourlyValuesSensor?sensor_id=${station.id}&start=${start}&end=${end}`
if(station.id.includes('MUV')) {
rawURL = `https://data.waag.org/api/muv/ms/hourly?sensor_id=${station.id.replace('HLL_MUV_device_','')}&start=${start}&end=${end}`
}
const responseRaw = await fetch(rawURL)
const jsonRaw = await responseRaw.json()
let dataRaw = jsonRaw.map(m => {
......
......@@ -58,7 +58,16 @@ export default {
const prefix = getPrefix(parameter)
const data = all.filter(sensor => sensor.latitude).map(sensor => {
const data = all
.filter(sensor => sensor.latitude)
.filter(sensor => {
if(sensor.city_id && sensor.city_id.city_name === "Amsterdam") {
return false
}
return true
})
.map(sensor => {
let sensorData = latest.find(o => o.ms === sensor.ms)
const place = (sensor.city_id ? sensor.city_id.city_name : null)
......@@ -99,7 +108,7 @@ export default {
return sensorDataReturn
})
latest.forEach(sensor => {
if(!all.find(o => +o.ms === +sensor.ms)) {
unregisteredSensors.push(sensor.ms)
......@@ -143,10 +152,15 @@ export default {
//const data = addMissingDataPoints(conformedData, granularity)
// let's get data from a quicker api for now...
const response = await fetch(`https://data.waag.org/api/muv/getSensorData?sensor_id=${station.id}&start=${start}&end=${end}`)
//const response = await fetch(`https://data.waag.org/api/muv/getSensorData?sensor_id=${station.id}&start=${start}&end=${end}`)
const response = await fetch(`https://data.waag.org/api/muv/ms/hourly?sensor_id=${station.id}&start=${start}&end=${end}`)
const responseData = await response.json()
const downsampledData = downsampleData(responseData, granularity, { timestamp: "time", value: getPrefix(parameter) })
let prefix = parameter
if(parameter === 'temperature') prefix = 't_out'
if(parameter === 'humidity') prefix = 'h_out'
const downsampledData = downsampleData(responseData, granularity, { timestamp: "time", value: prefix + '_mean' })
const conformedData = downsampledData.map(m => { return { ...m, timestamp: new Date(m.timestamp).getTime() }}).filter(m => m.timestamp < new Date(end).getTime())
const data = addMissingDataPoints(conformedData, conformedData[0].timestamp, new Date(end).getTime(), granularity)
......
Subproject commit fd8c430b8cdb0df3fb240b10811577923d73acbc
Subproject commit 6adf8df0033d295a7de74fec2db6e706b8b99575
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment