test_gs_kin_1


This macro converts and displays a stream of environmental sensors data sets obtained using the _protocol_set_ feature.
/**
* Macro for data evaluation on PhotosynQ.org
* by: David M. Kramer
* created: 2017-05-12 @ 11:07:27

The macro converts a stream of environmental data sets obtained using the _protocol_set_ feature 
into arrays and displays them.

For example, the following protocol will take temperature_humidity_pressure2, and light_intensity
once per second for 20 times. 
[{ "_protocol_set_":
[
	{
		"environmental": [
		["temperature_humidity_pressure2"],
        ["light_intensity"]
		],
     "protocols":20,
     "protocols_delay":1000
	}
]
}]

The macro will generate one array for each sensor, i.,e. temperature2, humidity2 and PAR,
as well as time. The time array is not displayed unless you un-comment the following line:

 //output.timescale = output.time;

Note: It is important to exclude data sets that are arrays, especially data_raw. This is done 
by adding the "data_raw"] to the list exclude_these:

var exclude_these=["data_raw"];

The macro can be modified to exclude the output and display of other the paramters by adding 
the names to the list called exclude_these. For example, I do not want to see "data_raw", "r", 
"g", "b", "light_intensity_raw"

var exclude_these=["data_raw", "r", "g", "b", "light_intensity_raw"];

*/


// Define the output object here
var output = {};

// Check if the key time exists in json
if (json.time !== undefined){

   //add values to exclude from the analyses
   var exclude_these=["data_raw", "r", "g", "b", "light_intensity_raw"];

	keys = Object.keys(json.set[2]); //find the keys to the sensors
   Object.keys(json.set[2]).join(","); //join them in a string for display
   number_sensors=keys.length;  // find the number of sensors
   output.number_sensors=number_sensors; //display the number of sensors

   // Add key time and value to output
   number_measurements=json.set.length;  	
   output.number_measurements=number_measurements;

  // var number_sensors = json.set[1]
 for (var j=0; j< number_sensors; j++){

   use_this_key=keys[j];
   if (exclude_these.indexOf(use_this_key)<0){
   temp=[];
  var i;
   for (i=1; i < number_measurements; i++){
     var t=json.set[i][use_this_key];
     temp.push(t);
   }
   output[use_this_key]=temp;
   }
 }
 //output.timescale = output.time;
}
var first_pt=31;
var slope_point=34;
var steady_state_point =88;

var slope1=[];
var slope2=[];
var slope3=[];

for (i=2; i<output.humidity2.length; i++){
  slope1.push(output.humidity2[i]-output.humidity2[i-1]);
  slope2.push((output.humidity2[i]-output.humidity2[i-2])/2);
  temp=[output.humidity2[i],output.humidity2[i-2], output.humidity2[i-3]];
   var m,a,b,c;
  var linreg = MathLINREG([1,2,3], temp);

  slope3.push(-1*linreg.m);
}


var diff_humidity=[];

for (i in output.humidity) {
  diff_humidity.push(output.humidity[i]-output.humidity2[i]); //-output.humidity2;
}
output.diff_humidity=diff_humidity;

output.temp=keys[0];

output.max_slope1=MathROUND(MathMAX(slope1),2);
output.max_slope2=MathROUND(MathMAX(slope2),2);
output.max_slope3=MathROUND(MathMAX(slope3),2);

output.slope1=slope1;
output.slope2=slope2;
output.slope3=slope3;

output.first_value=MathROUND(output.humidity2[first_pt],2);
output.slope_value=MathROUND(output.humidity2[slope_point],2);
output.initial_slope=MathROUND((output.humidity2[slope_point]-output.humidity2[first_pt])/(slope_point-first_pt),2);
output.rh_change=MathROUND(output.humidity2[steady_state_point]-output.humidity2[first_pt],2);

output.rh_change_2=MathROUND((MathMAX(output.humidity2.slice(30,60))-MathMIN(output.humidity2.slice(20,40))),2);

// Return data
return output;
{
  "time": "1501773902456",
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "01:06:11:92",
  "device_battery": 79,
  "device_firmware": 1.2,
  "sample": [
    [
      {
        "time": "1501773902456",
        "light_intensity_raw": 0,
        "data_raw": [

        ],
        "protocol_id": 1,
        "set": [
          {
            "time": "1501773902457",
            "blank:": "blank"
          },
          {
            "time": "1501773902468",
            "label": "",
            "temperature": 28.75,
            "humidity": 43.277,
            "pressure": 986.954,
            "temperature2": 27.79,
            "humidity2": 51.312,
            "pressure2": 985.703,
            "contactless_temp": 26.48,
            "data_raw": [

            ]
          },
          {
            "time": "1501773902770",
            "label": "",
            "temperature": 28.75,
            "humidity": 43.267,
            "pressure": 986.954,
            "temperature2": 27.78,
            "humidity2": 51.312,
            "pressure2": 985.712,
            "contactless_temp": 26.52,
            "data_raw": [

            ]
          },
          {
            "time": "1501773903073",
            "label": "",
            "temperature": 28.75,
            "humidity": 43.267,
            "pressure": 986.93,
            "temperature2": 27.78,
            "humidity2": 51.312,
            "pressure2": 985.702,
            "contactless_temp": 27.34,
            "data_raw": [

            ]
          },
          {
            "time": "1501773903376",
            "label": "",
            "temperature": 28.75,
            "humidity": 43.244,
            "pressure": 986.946,
            "temperature2": 27.79,
            "humidity2": 51.313,
            "pressure2": 985.705,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773903680",
            "label": "",
            "temperature": 28.75,
            "humidity": 43.266,
            "pressure": 986.921,
            "temperature2": 27.79,
            "humidity2": 51.302,
            "pressure2": 985.709,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773903982",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.932,
            "temperature2": 27.79,
            "humidity2": 51.302,
            "pressure2": 985.712,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773904285",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.911,
            "temperature2": 27.79,
            "humidity2": 51.302,
            "pressure2": 985.701,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773904588",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.254,
            "pressure": 986.908,
            "temperature2": 27.79,
            "humidity2": 51.302,
            "pressure2": 985.683,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773904891",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.254,
            "pressure": 986.952,
            "temperature2": 27.79,
            "humidity2": 51.291,
            "pressure2": 985.684,
            "contactless_temp": 26.52,
            "data_raw": [

            ]
          },
          {
            "time": "1501773905194",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.919,
            "temperature2": 27.79,
            "humidity2": 51.291,
            "pressure2": 985.687,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773905497",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.938,
            "temperature2": 27.79,
            "humidity2": 51.28,
            "pressure2": 985.707,
            "contactless_temp": 25.63,
            "data_raw": [

            ]
          },
          {
            "time": "1501773905800",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.974,
            "temperature2": 27.79,
            "humidity2": 51.269,
            "pressure2": 985.711,
            "contactless_temp": 25.67,
            "data_raw": [

            ]
          },
          {
            "time": "1501773906103",
            "label": "",
            "temperature": 28.74,
            "humidity": 43.253,
            "pressure": 986.944,
            "temperature2": 27.8,
            "humidity2": 51.269,
            "pressure2": 985.718,
            "contactless_temp": 25.67,
            "data_raw": [

            ]
          },
          {
            "time": "1501773906406",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.947,
            "temperature2": 27.8,
            "humidity2": 51.271,
            "pressure2": 985.723,
            "contactless_temp": 27.38,
            "data_raw": [

            ]
          },
          {
            "time": "1501773906709",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.929,
            "temperature2": 27.8,
            "humidity2": 51.259,
            "pressure2": 985.685,
            "contactless_temp": 26.28,
            "data_raw": [

            ]
          },
          {
            "time": "1501773907013",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.949,
            "temperature2": 27.8,
            "humidity2": 51.237,
            "pressure2": 985.696,
            "contactless_temp": 25.94,
            "data_raw": [

            ]
          },
          {
            "time": "1501773907315",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.953,
            "temperature2": 27.8,
            "humidity2": 51.006,
            "pressure2": 985.707,
            "contactless_temp": 26.08,
            "data_raw": [

            ]
          },
          {
            "time": "1501773907618",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.241,
            "pressure": 986.945,
            "temperature2": 27.8,
            "humidity2": 50.696,
            "pressure2": 985.67,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773907921",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.942,
            "temperature2": 27.8,
            "humidity2": 50.433,
            "pressure2": 985.679,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773908225",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.241,
            "pressure": 986.937,
            "temperature2": 27.8,
            "humidity2": 50.135,
            "pressure2": 985.667,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773908528",
            "label": "",
            "temperature": 28.73,
            "humidity": 43.242,
            "pressure": 986.93,
            "temperature2": 27.8,
            "humidity2": 49.97,
            "pressure2": 985.709,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773908831",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.241,
            "pressure": 986.929,
            "temperature2": 27.8,
            "humidity2": 49.804,
            "pressure2": 985.668,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773909134",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.24,
            "pressure": 986.914,
            "temperature2": 27.8,
            "humidity2": 49.661,
            "pressure2": 985.696,
            "contactless_temp": 26.18,
            "data_raw": [

            ]
          },
          {
            "time": "1501773909437",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.229,
            "pressure": 986.944,
            "temperature2": 27.8,
            "humidity2": 49.54,
            "pressure2": 985.668,
            "contactless_temp": 27.1,
            "data_raw": [

            ]
          },
          {
            "time": "1501773909740",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.24,
            "pressure": 986.916,
            "temperature2": 27.81,
            "humidity2": 49.43,
            "pressure2": 985.685,
            "contactless_temp": 27.04,
            "data_raw": [

            ]
          },
          {
            "time": "1501773910043",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.229,
            "pressure": 986.935,
            "temperature2": 27.81,
            "humidity2": 49.319,
            "pressure2": 985.693,
            "contactless_temp": 26.24,
            "data_raw": [

            ]
          },
          {
            "time": "1501773910346",
            "label": "",
            "temperature": 28.72,
            "humidity": 43.229,
            "pressure": 986.93,
            "temperature2": 27.81,
            "humidity2": 49.232,
            "pressure2": 985.654,
            "contactless_temp": 26.18,
            "data_raw": [

            ]
          },
          {
            "time": "1501773910649",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.229,
            "pressure": 986.929,
            "temperature2": 27.81,
            "humidity2": 49.1,
            "pressure2": 985.678,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773910952",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.229,
            "pressure": 986.923,
            "temperature2": 27.81,
            "humidity2": 49.012,
            "pressure2": 985.669,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773911255",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.229,
            "pressure": 986.919,
            "temperature2": 27.81,
            "humidity2": 48.924,
            "pressure2": 985.662,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773911558",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.229,
            "pressure": 986.925,
            "temperature2": 27.82,
            "humidity2": 48.847,
            "pressure2": 985.68,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773911862",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.229,
            "pressure": 986.915,
            "temperature2": 27.82,
            "humidity2": 48.77,
            "pressure2": 985.697,
            "contactless_temp": 26.24,
            "data_raw": [

            ]
          },
          {
            "time": "1501773912165",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.228,
            "pressure": 986.927,
            "temperature2": 27.82,
            "humidity2": 48.692,
            "pressure2": 985.68,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773912467",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.228,
            "pressure": 986.922,
            "temperature2": 27.81,
            "humidity2": 48.615,
            "pressure2": 985.661,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773912771",
            "label": "",
            "temperature": 28.7,
            "humidity": 43.228,
            "pressure": 986.914,
            "temperature2": 27.81,
            "humidity2": 48.549,
            "pressure2": 985.683,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773913073",
            "label": "",
            "temperature": 28.7,
            "humidity": 43.228,
            "pressure": 986.912,
            "temperature2": 27.81,
            "humidity2": 48.482,
            "pressure2": 985.678,
            "contactless_temp": 26.24,
            "data_raw": [

            ]
          },
          {
            "time": "1501773913376",
            "label": "",
            "temperature": 28.71,
            "humidity": 43.228,
            "pressure": 986.915,
            "temperature2": 27.82,
            "humidity2": 48.405,
            "pressure2": 985.663,
            "contactless_temp": 25.33,
            "data_raw": [

            ]
          },
          {
            "time": "1501773913679",
            "label": "",
            "temperature": 28.7,
            "humidity": 43.228,
            "pressure": 986.879,
            "temperature2": 27.82,
            "humidity2": 48.328,
            "pressure2": 985.674,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773913982",
            "label": "",
            "temperature": 28.7,
            "humidity": 43.228,
            "pressure": 986.919,
            "temperature2": 27.82,
            "humidity2": 48.262,
            "pressure2": 985.668,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773914285",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.228,
            "pressure": 986.922,
            "temperature2": 27.82,
            "humidity2": 48.197,
            "pressure2": 985.703,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773914588",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.216,
            "pressure": 986.904,
            "temperature2": 27.82,
            "humidity2": 48.142,
            "pressure2": 985.7,
            "contactless_temp": 26.24,
            "data_raw": [

            ]
          },
          {
            "time": "1501773914891",
            "label": "",
            "temperature": 28.7,
            "humidity": 43.216,
            "pressure": 986.924,
            "temperature2": 27.82,
            "humidity2": 48.087,
            "pressure2": 985.66,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773915194",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.216,
            "pressure": 986.885,
            "temperature2": 27.82,
            "humidity2": 48.031,
            "pressure2": 985.673,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773915497",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.228,
            "pressure": 986.914,
            "temperature2": 27.83,
            "humidity2": 47.977,
            "pressure2": 985.657,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773915800",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.215,
            "pressure": 986.903,
            "temperature2": 27.83,
            "humidity2": 47.91,
            "pressure2": 985.685,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773916103",
            "label": "",
            "temperature": 28.69,
            "humidity": 43.227,
            "pressure": 986.899,
            "temperature2": 27.83,
            "humidity2": 47.856,
            "pressure2": 985.671,
            "contactless_temp": 26.24,
            "data_raw": [

            ]
          },
          {
            "time": "1501773916406",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.227,
            "pressure": 986.895,
            "temperature2": 27.83,
            "humidity2": 47.812,
            "pressure2": 985.695,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773916709",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.227,
            "pressure": 986.924,
            "temperature2": 27.83,
            "humidity2": 47.767,
            "pressure2": 985.67,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773917012",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.215,
            "pressure": 986.933,
            "temperature2": 27.83,
            "humidity2": 47.724,
            "pressure2": 985.667,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773917316",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.215,
            "pressure": 986.903,
            "temperature2": 27.83,
            "humidity2": 47.69,
            "pressure2": 985.677,
            "contactless_temp": 25.39,
            "data_raw": [

            ]
          },
          {
            "time": "1501773917618",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.204,
            "pressure": 986.941,
            "temperature2": 27.83,
            "humidity2": 47.636,
            "pressure2": 985.682,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          },
          {
            "time": "1501773917921",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.227,
            "pressure": 986.921,
            "temperature2": 27.83,
            "humidity2": 47.592,
            "pressure2": 985.669,
            "contactless_temp": 26.28,
            "data_raw": [

            ]
          },
          {
            "time": "1501773918224",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.214,
            "pressure": 986.925,
            "temperature2": 27.84,
            "humidity2": 47.547,
            "pressure2": 985.679,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          },
          {
            "time": "1501773918528",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.226,
            "pressure": 986.908,
            "temperature2": 27.84,
            "humidity2": 47.492,
            "pressure2": 985.677,
            "contactless_temp": 27.14,
            "data_raw": [

            ]
          },
          {
            "time": "1501773918830",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.214,
            "pressure": 986.943,
            "temperature2": 27.83,
            "humidity2": 47.459,
            "pressure2": 985.655,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          },
          {
            "time": "1501773919133",
            "label": "",
            "temperature": 28.67,
            "humidity": 43.214,
            "pressure": 986.925,
            "temperature2": 27.83,
            "humidity2": 47.415,
            "pressure2": 985.625,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          },
          {
            "time": "1501773919436",
            "label": "",
            "temperature": 28.67,
            "humidity": 43.226,
            "pressure": 986.946,
            "temperature2": 27.84,
            "humidity2": 47.382,
            "pressure2": 985.684,
            "contactless_temp": 26.32,
            "data_raw": [

            ]
          },
          {
            "time": "1501773919739",
            "label": "",
            "temperature": 28.67,
            "humidity": 43.213,
            "pressure": 986.933,
            "temperature2": 27.84,
            "humidity2": 47.349,
            "pressure2": 985.689,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          },
          {
            "time": "1501773920042",
            "label": "",
            "temperature": 28.68,
            "humidity": 43.214,
            "pressure": 986.916,
            "temperature2": 27.84,
            "humidity2": 47.305,
            "pressure2": 985.675,
            "contactless_temp": 27.14,
            "data_raw": [

            ]
          },
          {
            "time": "1501773920345",
            "label": "",
            "temperature": 28.67,
            "humidity": 43.213,
            "pressure": 986.901,
            "temperature2": 27.84,
            "humidity2": 47.271,
            "pressure2": 985.712,
            "contactless_temp": 25.43,
            "data_raw": [

            ]
          }
        ]
      }
    ]
  ],
  "app_os": "darwin-x64",
  "app_name": "PhotosynQ",
  "app_version": "0.0.11-DMK",
  "app_device": "x64",
  "location": false,
  "time_offset": "America/Detroit"
}
Dave in cap img 4615
Created by

David M. Kramer


Protocol connections:
4
Latest Update:
Aug 2017