Soil C mineralization test2


This macro calculates the CO2-C mineralized from 50 g of soil in 1 pint canning jars. If you are using a different amount of soil or a different container, you will need to modify the macro.
//============================================
// Macro for data evaluation on PhotosynQ.org
// created: 19/07/2016
//============================================

//Define the output object here

// Fix for CO2 array
for (var i = 0; i < json.co2.length; i++) {
  json.co2[i] = parseFloat(json.co2[i]);
}


var output = {};
var co2 = [];
for(i in json.co2){
	if(json.co2[i] > 10000)
      co2.push(null);
   else
     co2.push(json.co2[i]);
}
  
var co2max = MathMAX(co2);

var co2min = MathMIN(json.co2);
var co2increase = co2max - co2min;


var Headspace = 460.8;
var Temp = 298;
var Rconstant = 82.05;
//conversion factor is assuming 25g soil (soil g x 1000)
var conversionfactor = 25000;
//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"] = NA;
  output["CO2 increase"] = NA;
  output["ugC.gsoil"] = NA;
  danger ('the CO2 level is too high and has saturated the sensor, try diluting the sample', output);
}


output["co2.array"] = co2;
output["Max CO2"] = co2max;
output["Min CO2"] = co2min;
output["CO2 increase"] = co2increase;
output["ugC.gsoil"] = ugCgsoil;



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

	//Add key time and value to output
	output["time"] = json.time;
}

//Return data
return output;
{
  "time_offset": 300,
  "time": 1487792400839,
  "device_version": "1",
  "device_id": "d4:f5:ff:ff:ff:ff",
  "device_battery": -288,
  "device_firmware": "1.14",
  "firmware_version": "1.14",
  "device_time": 1484318651,
  "sample": [
    {
      "time": 1487792400849,
      "protocol_id": 1,
      "co2": [
        "633.000000",
        "2356.000000",
        "3397.000000",
        "5098.000000",
        "6200.000000",
        "6852.000000",
        "6830.000000",
        "6563.000000",
        "5973.000000",
        "5509.000000",
        "4882.000000",
        "4478.000000",
        "3931.000000",
        "3598.000000",
        "3161.000000",
        "2865.000000",
        "2520.000000",
        "2318.000000",
        "2052.000000",
        "1896.000000",
        "1700.000000",
        "1598.000000",
        "1459.000000",
        "1378.000000",
        "1259.000000",
        "1197.000000",
        "1113.000000",
        "1064.000000",
        "1001.000000",
        "966.000000",
        "939.000000",
        "1152.000000",
        "1587.000000",
        "1761.000000",
        "1851.000000",
        "1834.000000",
        "1828.000000",
        "1870.000000",
        "1928.000000",
        "1914.000000",
        "1787.000000",
        "1736.000000",
        "1697.000000",
        "1657.000000",
        "1577.000000",
        "1528.000000",
        "1426.000000",
        "1350.000000",
        "1235.000000",
        "1179.000000"
      ],
      "data_raw": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
      ]
    }
  ],
  "app_os": "win",
  "app_name": "PhotosynQ",
  "app_version": "0.3.6",
  "app_device": "x86-32",
  "location": [
    "42.7226191",
    "-84.4746747"
  ],
  "ConsoleMacro": "262"
}
Sam 0645   copy   copy  2
Created by

Dan TerAvest


Protocol connections:
3
Latest Update:
Aug 2017