C mineralization for desktop


Measured SOIL parameters: Environment TEMPERATURE/HUMIDITY - SOIL CO2 EVOLUTION (ppm)
// for "pochatkova"
var blank = 0;
var blank = json.message[0][2];

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

  var output = {};  
  var pressure = 101325; 
  var mole_wt = 12.01; 
  var mole_conversion = 0.000001;  
  var R_constant = 8.31441; 
  var unit = 1000; 
  var unit2 = 100;
  var day_unit = 86400;
  var volume = 0.000432;
  var area = 0.007854;
  var temperature = 297.15; 
  var Jarspace = 500; // jar V in ml
  var Temp = 298;
  var Rconstant = 82.05;
//conversion factor is assuming 25g soil (soil g x 1000)
  var conversionfactor = 25000;
  var conversionfactor_n = 25000000; // gramm soil in microgramm
//converts to weight of C only and not of CO2
  var conversionfactor2 = 12000;

  //calculate volumetric soil moisture content and CO2
  var soil_moisture = json.analog_read;
  var soil_temperature = json.soil_temperature;
  var soil_temperature = json.soil_humidity;
  var co2produced = json.co2;
  var co2max = MathMAX(json.co2);
  var co2min = MathMIN(json.co2);
  var co2increase = co2max - co2min;
  var co2increase_blank = (co2max - blank);
  var ugCgsoil = MathROUND((((co2increase * Jarspace) / conversionfactor) / (Temp * Rconstant)) * conversionfactor2);
  var ugCgsoil_blank = MathROUND((((co2increase_blank * Jarspace) / conversionfactor) / (Temp * Rconstant)) * conversionfactor2);
  var mgCm2 = ((((mole_wt * pressure * co2increase * mole_conversion) / (R_constant * temperature)) * unit) * volume) / area;
  var kgCha_day = (mgCm2 / unit2) * day_unit;
  // Other way
  var ugCgsoil_C_na_mkg = ((pressure * Jarspace * co2increase * 12) / (8.31 * Temp)) / conversionfactor_n; 
  //var ugCgsoil_na_mg = ((7.22 * co2increase * pressure) / (Temp)) / conversionfactor;

  
  
  //Show value and name in output CO2
  output ["Co2-produced"] = json.co2;
  output["CO2 increase"] = co2increase;
  output["Max CO2"] = co2max;
  output["Min CO2"] = co2min;
  output ["mg C m2"] = mgCm2;
  output ["kg C ha-1 day-1"] = kgCha_day;
  output["ugC.gsoil"] = ugCgsoil;
  output["ugC.gsoil_na_mkg"] = ugCgsoil_C_na_mkg;


/*output["ugC.gsoil_Carbon_na_mg_gruntu"] = ugCgsoil_na_mg;
//Show value and name in output Soil Moisture
  output ["Soil moisture content"] = json.analog_read;
  output["Soil-temperature"] = json.soil_temperature;
  output["Soil-humidity"] = json.soil_humidity;

*/


// if user didn't entera blank, output "pochatkova" as the co2min values
if (blank == 0) {
  output ["bez pererahunka na pochatkovu, ugC.gsoil"] = ugCgsoil;
}
// if user did enter "pochatkova", output blank and pererahunok "na pochatkova" 
else {
  output ["z vrahuvanjam pochatkovoii, ugC.gsoil "] = ugCgsoil_blank;
  output ["raw blank"] = json.message[0][2];
}

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

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

  return output;

{
  "time_offset": -120,
  "time": 1516097652721,
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "09:21:95:12",
  "device_battery": 172,
  "device_firmware": 1.17,
  "sample": [
    {
      "time": 1516097652744,
      "protocol_id": 1,
      "co2": [
        "3654.000000",
        "3659.000000",
        "3675.000000",
        "3684.000000",
        "3692.000000",
        "3696.000000"
      ],
      "temperature2": [
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000"
      ],
      "humidity2": [
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000"
      ],
      "pressure2": [
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000",
        "0.000000"
      ],
      "analog_read": [
        "32494.000000",
        "31895.000000",
        "31676.000000",
        "31462.000000",
        "31392.000000",
        "31294.000000"
      ],
      "invalid_entry": [
        "nan",
        "nan",
        "nan",
        "nan",
        "nan",
        "nan"
      ],
      "data_raw": [
        65535,
        65535,
        65535,
        65535,
        65535,
        65535
      ]
    }
  ],
  "app_os": "win",
  "app_name": "PhotosynQ",
  "app_version": "0.3.9",
  "app_device": "x86-32",
  "location": [
    "49.5479629",
    "25.6082044"
  ],
  "ConsoleMacro": "326"
}

Protocol connections:
1
Latest Update:
19 days ago