CO2 protocol set 50 g soil


Works with 24 hour C mineralization burst protocol using 50 g of soil and 10 ml of water
/**
 * 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-1;

   // 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 co2 = [];
for(i in output.co2){
	if(output.co2[i] > 10000)
      co2.push("null");
   else
     co2.push(output.co2[i]);
}


output.co2 = co2;

var co2max = MathMAX(co2);
var co2min = MathMIN(co2);
var co2increase = co2max - co2min;

var Headspace = 460;
var Temp = 298;
var Rconstant = 82.05;
//conversion factor is assuming 50g soil (soil G x 1000)
var conversionfactor = 50000;
//converts to weight of C only and not of CO2
var conversionfactor2 = 12000;
var ugCgsoil = MathROUND((((co2increase * Headspace) / conversionfactor) / (Temp * Rconstant)) * conversionfactor2);


if (co2max == 10000){
  output["Max CO2"] = null;
  output["CO2 increase"] = null;
  output["ugC.gsoil"] = null;
  danger ('the CO2 level is too high and has saturated the sensor, try diluting the sample', output);
}
else{
  output["Max CO2"] = co2max;
  output["Min CO2"] = co2min;
  output["CO2 increase"] = co2increase;
  output["ugC.gsoil"] = ugCgsoil;
}

// Return data
return output;
{
  "time_offset": 240,
  "time": 1494961230678,
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "ff:ff:ff:ff",
  "device_battery": -256,
  "device_firmware": 1.18,
  "sample": [
    {
      "time": 1494961230678,
      "light_intensity_raw": 0,
      "data_raw": [

      ],
      "protocol_id": 1,
      "set": [
        {
          "time": 1494961230678,
          "blank:": "blank"
        },
        {
          "time": 1494961230720,
          "co2": 492,
          "data_raw": [

          ]
        },
        {
          "time": 1494961235837,
          "co2": 496,
          "data_raw": [

          ]
        },
        {
          "time": 1494961240988,
          "co2": 644,
          "data_raw": [

          ]
        },
        {
          "time": 1494961246140,
          "co2": 779,
          "data_raw": [

          ]
        },
        {
          "time": 1494961251291,
          "co2": 932,
          "data_raw": [

          ]
        },
        {
          "time": 1494961256441,
          "co2": 1010,
          "data_raw": [

          ]
        },
        {
          "time": 1494961261643,
          "co2": 1068,
          "data_raw": [

          ]
        },
        {
          "time": 1494961266794,
          "co2": 1088,
          "data_raw": [

          ]
        },
        {
          "time": 1494961271945,
          "co2": 1085,
          "data_raw": [

          ]
        },
        {
          "time": 1494961277096,
          "co2": 1062,
          "data_raw": [

          ]
        },
        {
          "time": 1494961282247,
          "co2": 1039,
          "data_raw": [

          ]
        },
        {
          "time": 1494961287399,
          "co2": 1008,
          "data_raw": [

          ]
        },
        {
          "time": 1494961292549,
          "co2": 65535,
          "data_raw": [

          ]
        },
        {
          "time": 1494961297751,
          "co2": 931,
          "data_raw": [

          ]
        },
        {
          "time": 1494961302901,
          "co2": 892,
          "data_raw": [

          ]
        },
        {
          "time": 1494961308052,
          "co2": 878,
          "data_raw": [

          ]
        },
        {
          "time": 1494961313204,
          "co2": 853,
          "data_raw": [

          ]
        },
        {
          "time": 1494961318355,
          "co2": 838,
          "data_raw": [

          ]
        },
        {
          "time": 1494961323505,
          "co2": 814,
          "data_raw": [

          ]
        },
        {
          "time": 1494961328657,
          "co2": 796,
          "data_raw": [

          ]
        },
        {
          "time": 1494961333910,
          "co2": 768,
          "data_raw": [

          ]
        },
        {
          "time": 1494961339060,
          "co2": 744,
          "data_raw": [

          ]
        },
        {
          "time": 1494961344210,
          "co2": 727,
          "data_raw": [

          ]
        },
        {
          "time": 1494961349362,
          "co2": 702,
          "data_raw": [

          ]
        }
      ]
    }
  ],
  "app_os": "win",
  "app_name": "PhotosynQ",
  "app_version": "0.3.7",
  "app_device": "x86-64",
  "location": [
    "42.7225890",
    "-84.4746860"
  ],
  "ConsoleMacro": "209"
}
Sam 0645   copy   copy  2
Created by

Dan TerAvest


Protocol connections:
1
Latest Update:
Sep 2017