Leaf Photosynthesis MultispeQ V1.0 SHORT - 50uE


Photosynthesis protocol which includes Phi2 and other similar protocols. Sets the light intensity to 50 uE
// CALCULATIONS FOR PROTON MOTIVE FORCE VIA ECS PORTION OF THE TRACE
//----------------------------

var output = {};
var spad;
var data = json.data_raw;
var vhplus;
var tau;
var ECSt;
var quality_flag = 0;
var i = 0;
var j = 0;
var h = 0;
var k = 0;
//var smooth1 = data.slice(280,600);
//var smooth0 = data.slice(280,600);

///*

// CALCULATIONS FOR ABSORBANCE / SPAD PORTION OF THE TRACE
//----------------------------

var abs_starts = 280; // when does the Phi2 measurement start
var data = json.data_raw;
var lights = [1,2,3,4,6,8,9,10];// define the lights to have absorbance measured
var wavelengths = ["530","650","605","420","940","850","730","880"];// define the lights to have absorbance measured
var raw_at_blank1 = [0,0,0,0,0,0,0,0];
var raw_at_blank2 = [0,0,0,0,0,0,0,0];
var raw_at_blank3 = [0,0,0,0,0,0,0,0];
var abs_at_blank1 = [0,0,0,0,0,0,0,0];
var abs_at_blank2 = [0,0,0,0,0,0,0,0];
var abs_at_blank3 = [0,0,0,0,0,0,0,0];
var trans_at_blank1 = [0,0,0,0,0,0,0,0];
var trans_at_blank2 = [0,0,0,0,0,0,0,0];
var trans_at_blank3 = [0,0,0,0,0,0,0,0];
var spad_at_blank1 = [0,0,0,0,0,0,0,0];
var spad_at_blank2 = [0,0,0,0,0,0,0,0];
var spad_at_blank3 = [0,0,0,0,0,0,0,0];
var minolta_spad1 = 0;
var minolta_spad2 = 0;
var minolta_spad3 = 0;
var minolta_spad = 0;
var minolta_spad_averages = 0;
var choose = 0;
var light;
var wavelengthString;
var pulses = 10;// number of pulses in a cycle

/* // this is what the recall object looks like --> 
"recall":{"colorcal_blank1[1]":0.000000,"colorcal_blank1[2]":0.000000,"colorcal_blank1[3]":0.000000,"colorcal_blank1[4]":0.00000
0,"colorcal_blank1[6]":0.000000,"colorcal_blank1[8]":0.000000,"colorcal_blank1[9]":0.000000,"colorcal_blank1[10]":0.000000,"colo
rcal_blank2[1]":0.000000,"colorcal_blank2[2]":0.000000,"colorcal_blank2[3]":0.000000,"colorcal_blank2[4]":0.000000,"colorcal_bla
nk2[6]":0.000000,"colorcal_blank2[8]":0.000000,"colorcal_blank2[9]":0.000000,"colorcal_blank2[10]":0.000000,"colorcal_blank3[1]"
:0.000000,"colorcal_blank3[2]":0.000000,"colorcal_blank3[3]":0.000000,"colorcal_blank3[4]":0.000000,"colorcal_blank3[6]":0.00000
0,"colorcal_blank3[8]":0.000000,"colorcal_blank3[9]":0.000000,"colorcal_blank3[10]":0.000000},
*/

/*
** Loop through the lights.  If it's zero, skip it.  If it's not in the acceptable range (>500 but <65534 (max)) skip it.
** Then choose the first blank (starting with 1 moving to 3) which fulfills this criteria
** Otherwise, calculate absorbance and transmittance and a 'spad'-like value using LED 6 (940 on clamp) to calibrate thickness
*/
//----------------------------

for (var i = 0;i<lights.length;i++) { // loop through and save one averaged 'point' for each of the cycles
  light = lights[i];
  wavelengthString = wavelengths[i];
  var value1 = MathMEDIAN(json.data_raw.slice((abs_starts + i*pulses+2),(abs_starts + i*pulses+8)));
  var value2 = MathMEDIAN(json.data_raw.slice((abs_starts + i*pulses+82),(abs_starts + i*pulses+88)));
  var value3 = MathMEDIAN(json.data_raw.slice((abs_starts + i*pulses+162),(abs_starts + i*pulses+168)));
  raw_at_blank1[light] = value1;
  raw_at_blank2[light] = value2;
  raw_at_blank3[light] = value3;
  if (json.recall["colorcal_blank1["+light+"]"] != 0 && raw_at_blank1[light] > 500 && raw_at_blank1[light] < 65534) {
    abs_at_blank1[light] = MathROUND(-1*MathLOG(raw_at_blank1[light]/json.recall["colorcal_blank1["+light+"]"]),3);
//    trans_at_blank1[light] = MathROUND(raw_at_blank1[light]/json.recall["colorcal_blank1["+light+"]"],3);
//	output ["light".concat(light.toString(),"_transmittance")]  = trans_at_blank1[light];
    output ["absorbance_".concat(wavelengthString)]  = abs_at_blank1[light];
//	output ["light".concat(light.toString(),"_blank1")]  = json.recall["colorcal_blank1["+light+"]"];
  }
}

// so the raw value needs to be >~2000, while the 940 needs to be greater than ~5000, otherwise it's out of range
// the acceptable range is different for each blank (1,2,3) thus a separate if statement for each blank.
// once you hit an intensity which is within the acceptable range, then keep that value and skip the rest

for (var i = 0;i<8;i++) { // loop through and save one averaged SPAD value for each of the cycles.  If we have additional calibration values (like minolta spad) use those and output that value
  light = lights[i];
  wavelengthString = wavelengths[i];
  spad_at_blank2[light] = MathROUND(100*MathLOG((raw_at_blank2[6] / json.recall["colorcal_blank2[6]"])/(raw_at_blank2[light] / json.recall["colorcal_blank2["+light+"]"])),2);
  spad_at_blank1[light] = MathROUND(100*MathLOG((raw_at_blank1[6] / json.recall["colorcal_blank1[6]"])/(raw_at_blank1[light] / json.recall["colorcal_blank1["+light+"]"])),2);
  spad_at_blank3[light] = MathROUND(100*MathLOG((raw_at_blank3[6] / json.recall["colorcal_blank3[6]"])/(raw_at_blank3[light] / json.recall["colorcal_blank3["+light+"]"])),2);
  if (light == 2) { // if it's the red light, the also calculate minolta spad
    output ["light".concat(light.toString(),"_raw1")]  = raw_at_blank1[light];
    output ["light6_raw1"]  = raw_at_blank1[6];
    output ["spad_raw1"]  = spad_at_blank1[2];
    output ["light".concat(light.toString(),"_raw2")]  = raw_at_blank2[light];
    output ["light6_raw2"]  = raw_at_blank2[6];
    output ["spad_raw2"]  = spad_at_blank2[2];
    output ["light".concat(light.toString(),"_raw3")]  = raw_at_blank3[light];
    output ["light6_raw3"]  = raw_at_blank3[6];
    output ["spad_raw3"]  = spad_at_blank3[2];
  }
  if (json.recall["colorcal_blank1["+light+"]"] != 0 && raw_at_blank1[light] > 30 && raw_at_blank1[light] < 65534 
      && raw_at_blank1[6] > 4500 && raw_at_blank1[6] < 65534) {
    if (light == 2) { // if it's the red light, the also calculate minolta spad
      minolta_spad = (spad_at_blank1[2] - json.recall["colorcal_intensity1_yint[2]"]) / json.recall["colorcal_intensity1_slope[2]"];	
      output ["SPAD_".concat(wavelengthString)]  = MathROUND(minolta_spad,2);
      output ["SPAD_".concat(wavelengthString,"_intensity")]  = 1;
        choose = 1;
      continue;
    }
    else if (light != 6) {
      output ["SPAD_".concat(wavelengthString)] = MathROUND(spad_at_blank1[light],2);
      output ["SPAD_".concat(wavelengthString,"_intensity")] = 1;
//      output ["SPAD1_".concat(wavelengthString)] = MathROUND(spad_at_blank1[light],2);
//      output ["SPAD1_".concat(wavelengthString,"_intensity")] = 1;
      continue;
    }
  }
  if (json.recall["colorcal_blank2["+light+"]"] != 0 && raw_at_blank2[light] > 500 && raw_at_blank2[light] < 65534 
      && raw_at_blank2[6] > 3000 && raw_at_blank2[6] < 65534) {
    if (light == 2) { // if it's the red light, the also calculate minolta spad
      minolta_spad = (spad_at_blank2[2] - json.recall["colorcal_intensity2_yint[2]"]) / json.recall["colorcal_intensity2_slope[2]"];
      output ["SPAD_".concat(wavelengthString)] = MathROUND(minolta_spad,2);
      output ["SPAD_".concat(wavelengthString,"_intensity")] = 2;
        choose = 2;
      continue;
    }
    else if (light != 6) {
      output ["SPAD_".concat(wavelengthString)] = MathROUND(spad_at_blank2[light],2);
      output ["SPAD_".concat(wavelengthString,"_intensity")] = 2;
//      output ["SPAD2_".concat(wavelengthString)] = MathROUND(spad_at_blank2[light],2);
//      output ["SPAD2_".concat(wavelengthString,"_intensity")] = 2;
      continue;
    }
  }
  if (json.recall["colorcal_blank3["+light+"]"] != 0 && raw_at_blank3[light] > 750 && raw_at_blank3[light] < 65534 
      && raw_at_blank3[6] > 3000 && raw_at_blank3[6] < 65534) {
    if (light == 2) { // if it's the red light, the also calculate minolta spad
      minolta_spad = (spad_at_blank3[2] - json.recall["colorcal_intensity3_yint[2]"]) / json.recall["colorcal_intensity3_slope[2]"];
      output ["SPAD_".concat(wavelengthString)]  = MathROUND(minolta_spad,2);
      output ["SPAD_".concat(wavelengthString,"_intensity")]  = 3;
      choose = 3;
      continue;
    }
    else if (light != 6) {
      output ["SPAD_".concat(wavelengthString)] = MathROUND(spad_at_blank3[light],2);
      output ["SPAD_".concat(wavelengthString,"_intensity")] = 3;
//      output ["SPAD3_".concat(wavelengthString)] = MathROUND(spad_at_blank3[light],2);
//      output ["SPAD3_".concat(wavelengthString,"_intensity")] = 3;
      continue;
    }
  }
}

if (choose == 0) {
  output ["SPAD_650"]  = 0;
  danger("Chlorophyll content SPAD is outside the acceptable range.  The leaf may be too thick, too thin, or have holes in it.", output);
}
else if (minolta_spad <= 2) {
  danger("Chlorophyll Content SPAD is very low.  If leaf is visibly green, ensure leaf completely covers the light guide and retry.  If still too low, consider recalibrating device.", output);
}
else if (minolta_spad >= 100) {
  danger("Chlorophyll Content SPAD is very high.  If this value is associated with a typical leaf, consider recalibrating device.", output);
}

/*
    if (minolta_spad <= 2) {
      info("Chlorophyll Content SPAD is very low.  If leaf is visibly green, ensure leaf completely covers the light guide and retry.  If still too low, consider recalibrating device.", output);
    }
    else if (minolta_spad1 >= 100) {
      info("Chlorophyll Content SPAD is very high.  If this value is associated with a typical leaf, consider recalibrating device.", output);
    }
*/

// calculate chlorophyll content SPAD values with Minolta SPAD calibration -->

/*
if (choose == 0) {
    output ["SPAD"]  = 0;
    output ["SPAD intensity"]  = 0;
  	
	danger("Chlorophyll content SPAD is outside the acceptable range.  The leaf may be too thick, too thin, or have holes in it.", output);
}
else if (choose == 1) {
    output ["SPAD"]  = MathROUND(minolta_spad1,2);
    output ["SPAD intensity"]  = 1;
    if (minolta_spad1 <= 2) {
      info("Chlorophyll Content SPAD is very low.  If leaf is visibly green, ensure leaf completely covers the light guide and retry.  If still too low, consider recalibrating device.", output);
    }
    else if (minolta_spad1 >= 100) {
      info("Chlorophyll Content SPAD is very high.  If this value is associated with a typical leaf, consider recalibrating device.", output);
    }
}
else if (choose == 2) {
    output ["SPAD"]  = MathROUND(minolta_spad2,2);
    output ["SPAD intensity"]  = 2;
	if (minolta_spad2 <= 2) {
      info("Chlorophyll Content SPAD is very low.  If leaf is visibly green, ensure leaf completely covers the light guide and retry.  If still too low, consider recalibrating device.", output);
    }
    else if (minolta_spad2 >= 100) {
      info("Chlorophyll Content SPAD is very high.  If this value is associated with a typical leaf, consider recalibrating device.", output);
    }
}
else if (choose == 3) {
    output ["SPAD"]  = MathROUND(minolta_spad3,2);
    output ["SPAD intensity"]  = 3;
	if (minolta_spad3 <= 2) {
      info("Chlorophyll Content SPAD is very low.  If leaf is visibly green, ensure leaf completely covers the light guide and retry.  If still too low, consider recalibrating device.", output);
    }
    else if (minolta_spad3 >= 100) {
      info("Chlorophyll Content SPAD is very high.  If this value is associated with a typical leaf, consider recalibrating device.", output);
    }
}
*/

// consider adding some warnings here... could be noisy, but also if the signal is > blank (suggest to recalibate?)



// consider adding some warnings here... could be noisy, but also if the signal is > blank (suggest to recalibate?)


// CALCULATIONS FOR PHI2 PORTION OF THE TRACE
//----------------------------

// calculate the ir baseline for LED 3 which is used as the measuring light.  This subtract IR generated by the LED from the IR generated by the plant
//----------------------------
var sample_cal = json.detector_read1;

var shinyness = (sample_cal-json.recall["ir_baseline_yint[5]"])/json.recall["ir_baseline_slope[5]"]; // where 0 is dull black electrical tape, and 1 is shiny aluminum
var baseline = json.recall["ir_baseline_slope[3]"]*shinyness+json.recall["ir_baseline_yint[3]"];

if (!baseline || !json.recall["ir_baseline_yint[5]"] || sample_cal == 65535) {						// if it hasn't been calibrated or there's an error or it's maxed, set baseline == 0
  baseline = 0;
}

output["baseline"] = baseline;

/*
output["shinyness"] = shinyness;
output["baseline"] = baseline;
output["recall led slope"] = json.recall["ir_baseline_slope[3]"];
output["recall led yint"] = json.recall["ir_baseline_yint[3]"];
output["recall cal slope"] = json.recall["ir_baseline_slope[5]"];
output["recall cal yint"] = json.recall["ir_baseline_yint[5]"];
output["sample led"] = json.detector_read1;
*/

//var sample_cal = MathMEAN(data.slice(2,18));

var inverse_intensity = [1/4500,1/4050,1/3600,1/3150];
var ps2_starts = 0; // when does the Phi2 measurement start

// Set our Apparent FmPrime, 3 FmPrime steps, and Fs to calculate both traditional fv/fm and new Multi-phase flash fv/fm
//----------------------------
var Fs = MathMEAN(data.slice(ps2_starts + 1,ps2_starts + 4)) - baseline; // take only the first 4 values in the Fs range, excluding the very first
var Fs_std = MathSTDEV(data.slice(ps2_starts + 1,ps2_starts + 4)); // create standard deviation for this value for error checking

var sat_vals = data.slice(ps2_starts + 25,ps2_starts + 48).sort();  // sort the saturating light values from low to high
var AFmP = MathMEAN(sat_vals.slice(2,20)) - baseline; // take the 18 largest values and average them
var AFmP_std = MathSTDEV(sat_vals); // create standard deviation for this value for error checkingjson.data_raw.slice(953,955)

sat_vals = data.slice(ps2_starts + 84,ps2_starts + 110).sort();  // sort the saturating light values from low to high
var FmP_end = MathMEAN(sat_vals.slice(2,23)) - baseline; // take the 21 largest values and average them
var FmP_end_std = MathSTDEV(sat_vals); // create standard deviation for this value for error checking

sat_vals = data.slice(ps2_starts + 52,ps2_starts + 60).sort();  // sort the saturating light values from low to high
var FmP_step1 = MathMEAN(sat_vals.slice(2,6)) - baseline; // take the 4 largest values and average them
var FmP_step1_std = MathSTDEV(sat_vals); // create standard deviation for this value for error checking

sat_vals = data.slice(ps2_starts + 62,ps2_starts + 70).sort();  // sort the saturating light values from low to high
var FmP_step2 = MathMEAN(sat_vals.slice(2,6)) - baseline; // take the 4 largest values and average them
var FmP_step2_std = MathSTDEV(sat_vals); // create standard deviation for this value for error checking

sat_vals = data.slice(ps2_starts + 72,ps2_starts + 80).sort();  // sort the saturating light values from low to high
var FmP_step3 = MathMEAN(sat_vals.slice(2,6)) - baseline; // take the 4 largest values and average them
var FmP_step3_std = MathSTDEV(sat_vals); // create standard deviation for this value for error checking

// Calculations for F0'
// ----------------------------
var FoPrime_values = json.data_raw.slice(ps2_starts + 160,ps2_starts + 270).sort();
var FoPrime = MathMEAN(FoPrime_values.slice(5,10)) - baseline;
var FoPrime_std = MathSTDEV(FoPrime_values); // create standard deviation for this value for error checking

// Calculations for corrected FmPrime using multi-phase flash
// ----------------------------
var reg = MathLINREG(inverse_intensity, [AFmP,FmP_step1,FmP_step2,FmP_step3]);

// Calculate Phi2 w/ and w/out multi-phase flash
// ----------------------------
var fvfm_noMPF = (AFmP-Fs)/AFmP;
var fvfm_MPF = (reg.b-Fs)/reg.b;


// Calculate NPQt, PhiNPQ, PhiNO, qL w/ and w/out multi-phase flash
// ----------------------------
var npqt_MPF = (4.88 / ((reg.b / FoPrime) -1) )-1;
var npqt_noMPF = (4.88 / ((AFmP / FoPrime) -1) )-1;
var qL_MPF = ((reg.b - Fs)*FoPrime)/((reg.b-FoPrime)*Fs);
var qL_noMPF = ((AFmP - Fs)*FoPrime)/((AFmP-FoPrime)*Fs);
var PhiNO_MPF = 1/(npqt_MPF + 1 + qL_MPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNO_noMPF = 1/(npqt_noMPF + 1 + qL_noMPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNPQ_MPF = 1-fvfm_MPF-PhiNO_MPF; //based on equation 53 in Kramer et al., 2004 PRES 
var PhiNPQ_noMPF = 1-fvfm_noMPF-PhiNO_noMPF; //based on equation 53 in Kramer et al., 2004 PRES 

var qP_MPF = (reg.b - Fs)/(reg.b - FoPrime);
var qP_noMPF = (FmPrime - Fs)/(FmPrime - FoPrime);
var FvP_FmP_MPF = (reg.b-FoPrime)/reg.b;
var FvP_FmP_noMPF = (AFmP-FoPrime)/AFmP;

// Create the variables to be printed (assume to use the MPF values unless there is a good reason not to)
// ----------------------------
var fvfm = fvfm_MPF;
var npqt = npqt_MPF;
var PhiNO = PhiNO_MPF;
var PhiNPQ = PhiNPQ_MPF;
var qL = qL_MPF;
var FmPrime = reg.b;
var qP = qP_MPF;
var FvP_FmP = FvP_FmP_MPF;
var b = json.b;
var r = json.r;
var g = json.g;


/****************OUTPUT VALUES FROM MACRO *******************/

// If multi-phase flash steps are flat or positive slope, then just use the normal Phi2, NPQt, PhiNPQ, PhiNO... etc.
// If Phi2 or NPQt is less than zero, make zero and give user warning.  If Phi2 is higher than .85, give user danger flag.
// ----------------------------
if (reg.m > 0) {
  fvfm = fvfm_noMPF;
  npqt = npqt_noMPF;
  PhiNO = PhiNO_noMPF;
  PhiNPQ = PhiNPQ_noMPF;
  qL = qL_noMPF;
  FmPrime = AFmP;
  qP = qP_noMPF;
  FvP_FmP = FvP_FmP_noMPF;
  
  if (fvfm <= 0) {
    output["Phi2"] 			= 0;
	danger('Phi2 is negative (should be positive).  This may be due to a sample that is not doing photosynthesis, or you may have missed the leaf.  It has been set to zero, but check raw trace and consider excluding this point.  To see original negative value, see Phi2_noMPF variable',output);
	output["Phi2_noMPF"] 	= MathROUND(npqt,3);
  }
  if (fvfm >=.85) {
    output["Phi2"] 			= -1;
	danger("Phi2 above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);

  }
  else {
	  output["Phi2"] 		= MathROUND(fvfm,3);
  }
  
  if (npqt <= 0) {
	output["PhiNPQ"]		= 0;
    output["NPQt"]			= 0;
	danger("NPQt is negative (should be positive).  This may be due to a sample that is not doing photosynthesis, or you may have missed the leaf.  It has been set to zero, but check raw trace and consider excluding this point.  To see original negative value, see NPQt_noMPF and PhiNPQ_noMPF variable",output);
	output["PhiNPQ_noMPF"]  = MathROUND(PhiNPQ,3);
	output["NPQt_noMPF"]	= MathROUND(npqt,3);
  }
  else {
	output["PhiNPQ"]  = MathROUND(PhiNPQ,3);
	output["NPQt"]		= MathROUND(npqt,3);
  }
	output["PhiNO"]		= MathROUND(PhiNO,3);
	output["qL"]		= MathROUND(qL,3);
    output['FvP/FmP']		= MathROUND(FvP_FmP,3);
    output['qP']			= MathROUND(qP,3);
}

// Otherwise, use the multi-phase flash calculation for Phi2, NPQt, PhiNPQ, PhiNO... etc.
// If Phi2 or NPQt is less than zero, make zero and give user warning.  If Phi2 is higher than .85, give user danger flag.
// ----------------------------
else {
  if (fvfm <= 0) {
    output["Phi2"] 			= 0;
	danger("Phi2 is negative (should be positive).  This may be due to a sample that is not doing photosynthesis, or you may have missed the leaf.  It has been set to zero, but check raw trace and consider excluding this point.  To see original negative value, see Phi2_MPF variable",output);
	output["Phi2_MPF"] 	= MathROUND(npqt,3);
  }
  if (fvfm >=.85) {
    output["Phi2"] 			= -1;
	danger("Phi2 above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);
  }
  else {
    output["Phi2"]			= MathROUND(fvfm,3);
  }
  if (npqt <= 0) {
	output["PhiNPQ"]		= 0;
    output["NPQt"]			= 0;
	danger("NPQt is negative (should be positive).  This may be due to a sample that is not doing photosynthesis, or you may have missed the leaf.  It has been set to zero, but check raw trace and consider excluding this point.  To see original negative value, see NPQt_MPF and PhiNPQ_MPF variables",output);
	output["PhiNPQ_MPF"]  = MathROUND(PhiNPQ,3);
	output["NPQt_MPF"]		= MathROUND(npqt,3);
  }
  else {
	output["PhiNPQ"]  = MathROUND(PhiNPQ,3);
	output["NPQt"]		= MathROUND(npqt,3);
  }
	output["PhiNO"]		= MathROUND(PhiNO,3);
	output["qL"]			= MathROUND(qL,3);
    output['FvP/FmP']		= MathROUND(FvP_FmP,3);
    output['qP']			= MathROUND(qP,3);
}

// only display LEF if there is a light intensity measurement > 0 
// ----------------------------
if (typeof json.light_intensity != "undefined" && json.light_intensity > 0) {
	output["LEF"] 		= MathROUND((fvfm  * 0.45 * 50),3);
}

if (Fs_std > 100) {
	danger("noisy Fs", output);
}
/*
if (AFmP_std > 300) {
	danger("noisy FmPrime", output);
}
*/
if (FmP_step1_std > 120 | FmP_step2_std > 120 | FmP_step3_std > 120 | FmP_end_std > 300) {
	danger("noisy  multi-phase flash steps",output);
}

if (FoPrime_std > 150) {
	danger("noisy FoPrime", output);
}
/*
if (reg.m > 0) {
	info("Used Phi2 and not Phi2 MPF - ambient light level was too low to apply MPF calculation", output);
}
if (FmP_end/AFmP - AFmP/AFmP > .1) {	
	info("FmPrime slopes down.  This may mean that saturating flash is not bright enough... consider using a protocol with lower saturating light on these samples", output);
}
if (FmP_end/AFmP - AFmP/AFmP < -.1) {
	info("FmPrime slopes up.  This may mean that saturating flash is too bright... consider using a protocol with higher saturating light on these samples",output);
}
*/

output["FmPrime"] 		= MathROUND(FmPrime,3);
output["Fs"] 			= MathROUND(Fs,1);
output['FoPrime']		= MathROUND(FoPrime,0);
output["RFd"]           = Number(MathROUND(((FmPrime/Fs)-1),3));
output["ratio MPF/noMPF, Phi2"] = MathROUND(fvfm_MPF / fvfm_noMPF,5);
output["ratio MPF/noMPF, PhiNPQ"] = MathROUND(PhiNPQ_MPF / PhiNPQ_noMPF,5);
output["ratio MPF/noMPF, PhiNO"] = MathROUND(PhiNO_MPF / PhiNO_noMPF,5);
output["ratio MPF/noMPF, PhiNO"] = MathROUND(npqt_MPF / npqt_noMPF,5);
output["MPF_slope"] 	= MathROUND(reg.m,3);
output["MPF_rsquared"] 	= MathROUND(reg.r,3);
/*
output["Phi2_MPF"] 		= MathROUND(fvfm_MPF,3);
output["Phi2_noMPF"] 	= MathROUND(fvfm,3);
output["FmPrime_MPF"] 	= MathROUND(reg.b,3);
output["FmPrime_noMPF"] = MathROUND(AFmP,1);
output['qL_MPF']		= MathROUND(qL_MPF,3);
output['qL_noMPF']      = MathROUND(qL,3);
output['PhiNPQ_MPF']    = MathROUND(PhiNPQ_MPF,3);
output['PhiNPQ_noMPF']  = MathROUND(PhiNPQ,3);
output['PhiNO_MPF']		= MathROUND(PhiNO_MPF,3);
output['PhiNO_noMPF']	= MathROUND(PhiNO,3);
output["Fs_std"] 			= MathROUND(Fs_std,1);
output["AFmP_std"] 			= MathROUND(AFmP_std,1);
output["FmP_step1_std"] 	= MathROUND(FmP_step1_std,1);
output["FmP_step2_std"] 	= MathROUND(FmP_step2_std,1);
output["FmP_step3_std"] 	= MathROUND(FmP_step3_std,1);
output["FmP_end_std"] 		= MathROUND(FmP_end_std,1);
output["FoPrime_std"] 			= MathROUND(FoPrime_std,1);
*/

//output["FmP_step1"] = MathROUND(FmP_step1,3);
//output["FmP_step2"] = MathROUND(FmP_step2,3);
//output["FmP_step3"] = MathROUND(FmP_step3,3);
//output["intensity inverse"] = inverse_intensity;
//output["steps"] = [AFmP,FmP_step1,FmP_step2,FmP_step3];
//output["slopey"] = FmP_end/AFmP - AFmP/AFmP ;

  output["baseline"] 	= baseline;

// Check for data quality issues and add warning or danger flags
//----------------------------

// Finally, use the "order" object to define the order of the outputs (focus on the top 6 most important for the user to see)
//----------------------------
output["Light Intensity (PAR)"] = 50;
output["Leaf Temp Differential"] = json.contactless_temp - json.temperature;
output["Relative Chlorophyll"] = minolta_spad;
output ["Rel Chl intensity"]  = choose;  	
output["Ambient Temperature"] = json.temperature;
output["Ambient Humidity"] = json.humidity;
output["Leaf Angle"] = json.angle;

output["order"] = ["Phi2","PhiNPQ","PhiNO","Relative Chlorophyll","Leaf Temp Differential","Leaf Angle", "Light Intensity (PAR)","NPQt","LEF","Ambient Temperature","Ambient Humidity"];

maxvalue = MathMAX([json.r,json.g,json.b]);
output["R"] = Number(json.r);
output["G"] = Number(json.g);
output["B"] = Number(json.b);

//output["rval"] = json.r*(255/maxvalue);
//output["gval"] = json.g*(255/maxvalue);
//output["bval"] = json.b*(255/maxvalue);

//output["Color"] = [MathROUND(json.r*(255/maxvalue),2),MathROUND(json.g*(255/maxvalue),2),MathROUND(json.b*(255/maxvalue),2)];

return output;
{
  "time_offset": 240,
  "time": 1471466929426,
  "device_version": "1",
  "device_id": "d4:f5:10:14:06:65",
  "device_battery": 90,
  "device_firmware": "1.06",
  "firmware_version": "1.06",
  "device_time": 1471450983,
  "sample": [
    [
      {
        "time": 1471466929451,
        "protocol_id": 1,
        "detector_read1": 2319,
        "detector_read2": 3051,
        "light_intensity": 11,
        "r": 30,
        "g": 15,
        "b": 9,
        "light_intensity_raw": 49,
        "temperature": 27.43,
        "humidity": 65.174805,
        "pressure": 984.203064,
        "temperature2": 27.51,
        "humidity2": 62.969727,
        "pressure2": 985.48407,
        "contactless_temp": 26.53,
        "thickness": 1.07,
        "compass_direction": "NW",
        "compass": "315.06",
        "angle": 1.09,
        "angle_direction": "N",
        "pitch": 0.88,
        "roll": 0.65,
        "recall": {
          "time": 1471466933605,
          "colorcal_blank1[1]": 7839.5,
          "colorcal_blank1[2]": 12927,
          "colorcal_blank1[3]": 12024.5,
          "colorcal_blank1[4]": 36130,
          "colorcal_blank1[6]": 26263.5,
          "colorcal_blank1[8]": 24891.5,
          "colorcal_blank1[9]": 20946.5,
          "colorcal_blank1[10]": 27715,
          "colorcal_blank2[1]": 17226.5,
          "colorcal_blank2[2]": 15096,
          "colorcal_blank2[3]": 12841,
          "colorcal_blank2[4]": 13510.5,
          "colorcal_blank2[6]": 35288,
          "colorcal_blank2[8]": 38212.5,
          "colorcal_blank2[9]": 36138,
          "colorcal_blank2[10]": 32846,
          "colorcal_blank3[1]": 16779,
          "colorcal_blank3[2]": 10041,
          "colorcal_blank3[3]": 15482,
          "colorcal_blank3[4]": 16311,
          "colorcal_blank3[6]": 30774,
          "colorcal_blank3[8]": 30418,
          "colorcal_blank3[9]": 20022.5,
          "colorcal_blank3[10]": 20597.5,
          "colorcal_intensity1_slope[2]": 2.464,
          "colorcal_intensity1_yint[2]": 7.4,
          "colorcal_intensity2_slope[2]": 2.208,
          "colorcal_intensity2_yint[2]": 10.4,
          "colorcal_intensity3_slope[2]": 1.49,
          "colorcal_intensity3_yint[2]": 10.6,
          "ir_baseline_slope[5]": 9459.5,
          "ir_baseline_yint[5]": 13594.5,
          "ir_baseline_slope[3]": 251.5,
          "ir_baseline_yint[3]": 482
        },
        "data_raw": [
          25190,
          26768,
          26778,
          26783,
          26787,
          26789,
          26777,
          26787,
          26785,
          26784,
          26771,
          26782,
          26782,
          26780,
          26779,
          26777,
          26779,
          26782,
          26777,
          26777,
          26780,
          26779,
          26777,
          26778,
          26777,
          26775,
          26776,
          26775,
          26779,
          26773,
          26773,
          26772,
          26779,
          26771,
          26773,
          26776,
          26777,
          26766,
          26773,
          26772,
          26775,
          26760,
          26775,
          26773,
          26776,
          26765,
          26774,
          26773,
          26777,
          26761,
          26774,
          26774,
          26775,
          26763,
          26776,
          26775,
          26773,
          26767,
          26773,
          26774,
          26767,
          26766,
          26772,
          26770,
          26762,
          26770,
          26770,
          26771,
          26759,
          26774,
          26770,
          26771,
          26763,
          26768,
          26768,
          26774,
          26765,
          26772,
          26769,
          26775,
          26771,
          26770,
          26772,
          26762,
          26773,
          26766,
          26771,
          26769,
          26770,
          26767,
          26768,
          26763,
          26772,
          26763,
          26772,
          26759,
          26767,
          26770,
          26772,
          26765,
          26766,
          26769,
          26771,
          26765,
          26769,
          26769,
          26766,
          26765,
          26769,
          26770,
          26759,
          26769,
          26767,
          26766,
          26765,
          26767,
          26766,
          26771,
          26762,
          26767,
          26760,
          26770,
          26759,
          26763,
          26771,
          26772,
          26763,
          26761,
          26775,
          26763,
          26769,
          26766,
          26771,
          26763,
          26764,
          26769,
          26769,
          26761,
          26762,
          26763,
          26767,
          26755,
          26767,
          26765,
          26769,
          26759,
          26767,
          26766,
          26762,
          26757,
          26764,
          26770,
          26758,
          26767,
          26765,
          26771,
          26757,
          26765,
          26761,
          26763,
          26764,
          26762,
          26765,
          26773,
          26763,
          26764,
          26761,
          26773,
          26768,
          26762,
          26766,
          26763,
          26763,
          26759,
          26770,
          26757,
          26759,
          26766,
          26767,
          26758,
          26762,
          26769,
          26767,
          26759,
          26769,
          26766,
          26765,
          26764,
          26765,
          26766,
          26757,
          26767,
          26759,
          26767,
          26760,
          26766,
          26762,
          26761,
          26765,
          26763,
          26763,
          26762,
          26765,
          26763,
          26765,
          26758,
          26762,
          26762,
          26768,
          26758,
          26761,
          26765,
          26766,
          26756,
          26766,
          26765,
          26760,
          26763,
          26763,
          26762,
          26760,
          26765,
          26759,
          26770,
          26759,
          26763,
          26759,
          26767,
          26758,
          26759,
          26766,
          26766,
          26761,
          26758,
          26768,
          26757,
          26758,
          26764,
          26761,
          26756,
          26761,
          26759,
          26763,
          26758,
          26762,
          26761,
          26763,
          26761,
          26761,
          26763,
          26762,
          26764,
          26763,
          26758,
          26759,
          26758,
          26760,
          26765,
          26756,
          26757,
          26757,
          26769,
          26760,
          26761,
          26767,
          26763,
          26761,
          26758,
          26765,
          26758,
          26761,
          26757,
          26768,
          26757,
          26758,
          26767,
          26765,
          26758,
          26759,
          26764,
          26764,
          26762,
          26764,
          26765,
          26757,
          26758,
          26763,
          26766,
          26755,
          26759,
          26769,
          26763,
          26760,
          26759,
          26768,
          26758,
          26759,
          26764,
          26761,
          26754,
          26756,
          26764,
          26758,
          26754,
          26760,
          26767,
          26762,
          26759,
          26764,
          26767,
          26757,
          26757,
          26765,
          26764,
          26756,
          26766,
          26766,
          26763,
          26762,
          26762,
          26765,
          26757,
          26767,
          26763,
          26762,
          26761,
          26763,
          26761,
          26770,
          26763,
          26764,
          26761,
          26761,
          26764,
          26759,
          26772,
          26760,
          26761,
          26767,
          26762,
          26760,
          26759,
          26767,
          26760,
          26759,
          26763,
          26768,
          26757,
          26759,
          26763,
          26768,
          26758,
          26767,
          26767,
          26763,
          26760,
          26761,
          26767,
          26757,
          26763,
          26765,
          26767,
          26758,
          26766,
          26767,
          26759,
          26759,
          26767,
          26764,
          26758,
          26766,
          26764,
          26766,
          26755,
          26763,
          26765,
          26762,
          26763,
          26768,
          26767,
          26757,
          26766,
          26761,
          26764,
          26758,
          26767,
          26769,
          26759,
          26769,
          26761,
          26765,
          26759,
          26763,
          26765,
          26761,
          26765,
          26764,
          26762,
          26761,
          26763,
          26763,
          26760,
          26759,
          26761,
          26765,
          26761,
          26767,
          26764,
          26766,
          26757,
          26763,
          26761,
          26762,
          26763,
          26762,
          26765,
          26760,
          26766,
          26764,
          26761,
          26761,
          26766,
          26758,
          26763,
          26760,
          26759,
          26763,
          26767,
          26766,
          26762,
          26767,
          26760,
          26763,
          26760,
          26768,
          26761,
          26761,
          26765,
          26759,
          26761,
          26763,
          26767,
          26755,
          26766,
          26766,
          26764,
          26758,
          26763,
          26767,
          26759,
          26765,
          26761,
          26760,
          26760,
          26763,
          26760,
          26770,
          26761,
          26759,
          26768,
          26767,
          26765,
          26758,
          26767,
          26758,
          26762,
          26769,
          26764,
          26768,
          26761,
          26769,
          26760,
          26761,
          26758,
          26767,
          26763,
          26762,
          26766,
          26763,
          26765,
          26759,
          26771,
          26757,
          26759,
          26769,
          26767,
          26762,
          26767,
          26769,
          26760,
          26759,
          26762,
          26771,
          26757,
          26764,
          26769,
          26765,
          26762,
          26768,
          26766,
          26761,
          26767,
          26765,
          26766,
          26761,
          26765,
          26767,
          26758,
          26766,
          26762,
          26767,
          26756,
          26764,
          26766,
          26763,
          26768,
          26764,
          26768,
          26759,
          26768,
          26761,
          26766,
          26765,
          26766,
          26764,
          26762,
          26766,
          26764,
          26763,
          26764,
          26765,
          26767,
          26767,
          26767,
          26759,
          26765,
          26763,
          26765,
          26762,
          26765,
          26761,
          26767,
          26770,
          26763,
          26769,
          26764,
          26766,
          26758,
          26763,
          26763,
          26764,
          26759,
          26765,
          26768,
          26757,
          26765,
          26766,
          26767,
          26757,
          26764,
          26767,
          26761,
          26766,
          26764,
          26767,
          26757,
          26766,
          26766,
          26769,
          26759,
          26769,
          26767,
          26758,
          26766,
          26763,
          26764,
          26757,
          26765,
          26765,
          26759,
          26768,
          26763,
          26769,
          26756,
          26766,
          26765,
          26761,
          26765,
          26764,
          26767,
          26757,
          26763,
          26763,
          26766,
          26764,
          26765,
          26766,
          26761,
          26768,
          26761,
          26769,
          26759,
          26767,
          26763,
          26760,
          26768,
          26765,
          26768,
          26755,
          26765,
          26765,
          26764,
          26763,
          26761,
          26761,
          26756,
          26764,
          26762,
          26758,
          26762,
          26761,
          26763,
          26755,
          26761,
          26761,
          26758,
          26763,
          26759,
          26758,
          26755,
          26764,
          26761,
          26759,
          26756,
          26763,
          26763,
          26761,
          26762,
          26759,
          26759,
          26757,
          26757,
          26759,
          26767,
          26760,
          26759,
          26765,
          26758,
          26761,
          26755,
          26763,
          26759,
          26758,
          26763,
          26760,
          26762,
          26759,
          26762,
          26758,
          26759,
          26760,
          26758,
          26760,
          26759,
          26764,
          26754,
          26760,
          26763,
          26757,
          26759,
          26760,
          26767,
          26756,
          26757,
          26763,
          26764,
          26759,
          26761,
          26764,
          26755,
          26761,
          26763,
          26760,
          26755,
          26766,
          26765,
          26756,
          26759,
          26762,
          26763,
          26755,
          26761,
          26765,
          26758,
          26758,
          26760,
          26764,
          26757,
          26759,
          26766,
          26759,
          26763,
          26759,
          26767,
          26753,
          26757,
          26762,
          26759,
          26759,
          26756,
          26765,
          26753,
          26759,
          26760,
          26761,
          26760,
          26754,
          26767,
          26757,
          26759,
          26758,
          26763,
          26761,
          26761,
          26761,
          26758,
          26757,
          26756,
          26765,
          26761,
          26759,
          26759,
          26757,
          26757,
          26762,
          26761,
          26763,
          26758,
          26758,
          26758,
          26759,
          26759,
          26766,
          26762,
          26759,
          26763,
          26757,
          26758,
          26759,
          26765,
          26765,
          26759,
          26763,
          26757,
          26757,
          26757,
          26763,
          26758,
          26756,
          26764,
          26758,
          26759,
          26761,
          26764,
          26763,
          26759,
          26765,
          26757,
          26761,
          26756,
          26766,
          26761,
          26759,
          26763,
          26757,
          26760,
          26758,
          26767,
          26759,
          26758,
          26766,
          26751,
          26759,
          26757,
          26764,
          26760,
          26757,
          26767,
          26757,
          26759,
          26763,
          26763,
          26759,
          26755,
          26765,
          26754,
          26761,
          26758,
          26764,
          26759,
          26762,
          26767,
          26755,
          26758,
          26759,
          26762,
          26762,
          26757,
          26768,
          26756,
          26758,
          26761,
          26763,
          26762,
          26757,
          26767,
          26757,
          26756,
          26767,
          26759,
          26757,
          26761,
          26765,
          26756,
          26759,
          26761,
          26759,
          26762,
          26762,
          26764,
          26757,
          26759,
          26766,
          26762,
          26758,
          26763,
          26763,
          26753,
          26758,
          26767,
          26758,
          26758,
          26764,
          26761,
          26756,
          26763,
          26762,
          26757,
          26759,
          26760,
          26763,
          26753,
          26763,
          26764,
          26755,
          26761,
          26762,
          26763,
          26756,
          26762,
          26763,
          26759,
          26765,
          26758,
          26764,
          26757,
          26759,
          26765,
          26751,
          26765,
          26758,
          26760,
          26761,
          26759,
          26762,
          26758,
          26759,
          26761,
          26757,
          26763,
          26759,
          26762,
          26758,
          26761,
          26763,
          26755,
          26763,
          26756,
          26758,
          26757,
          26760,
          26763,
          26755,
          26764,
          26763,
          26763,
          26757,
          26762,
          26766,
          26754,
          4600,
          4602,
          4599,
          4593,
          4594,
          4592,
          4590,
          4588,
          4587,
          4590,
          4589,
          4590,
          4588,
          4589,
          4587,
          4588,
          4589,
          4589,
          4590,
          4589,
          10547,
          11367,
          11919,
          12590,
          13286,
          13853,
          14241,
          14500,
          14686,
          14810,
          14910,
          14987,
          15048,
          15083,
          15126,
          15154,
          15177,
          15206,
          15211,
          15233,
          15239,
          15246,
          15255,
          15252,
          15258,
          15255,
          15262,
          15259,
          15246,
          15245,
          15139,
          15128,
          15108,
          15104,
          15090,
          15086,
          15074,
          15069,
          15062,
          15056,
          14914,
          14894,
          14875,
          14865,
          14859,
          14837,
          14831,
          14823,
          14812,
          14798,
          14623,
          14605,
          14581,
          14563,
          14549,
          14542,
          14532,
          14523,
          14512,
          14507,
          14937,
          14969,
          14981,
          14990,
          14984,
          14981,
          14979,
          14968,
          14961,
          14951,
          14945,
          14935,
          14924,
          14923,
          14909,
          14898,
          14890,
          14879,
          14873,
          14870,
          14851,
          14846,
          14841,
          14823,
          14819,
          14818,
          14800,
          14794,
          14795,
          14780,
          8343,
          7363,
          7017,
          6834,
          6704,
          6594,
          6518,
          6454,
          6404,
          6351,
          6314,
          6287,
          6257,
          6228,
          6199,
          6182,
          6157,
          6138,
          6117,
          6107,
          5471,
          5318,
          5285,
          5270,
          5248,
          5239,
          5237,
          5219,
          5216,
          5215,
          5199,
          5201,
          5201,
          5191,
          5189,
          5193,
          5183,
          5185,
          5182,
          5185,
          5177,
          5174,
          5177,
          5167,
          5169,
          5173,
          5162,
          5167,
          5166,
          5161,
          5161,
          5163,
          5157,
          5158,
          5161,
          5155,
          5154,
          5159,
          5147,
          5150,
          5154,
          5146,
          5149,
          5154,
          5142,
          5143,
          5150,
          5142,
          5142,
          5147,
          5138,
          5137,
          5142,
          5137,
          5137,
          5143,
          5137,
          5134,
          5133,
          5131,
          5135,
          5125,
          5127,
          5134,
          5125,
          5126,
          5127,
          5125,
          5124,
          5118,
          5117,
          5123,
          5110,
          5113,
          5119,
          5113,
          5111,
          5112,
          5109,
          5113,
          5104,
          5107,
          5107,
          5106,
          5105,
          5105,
          5104,
          5108,
          5097,
          5102,
          5102,
          5098,
          5104,
          5094,
          5098,
          5098,
          5095,
          5097,
          5093,
          5094,
          5090,
          5092,
          5100,
          5093,
          5091,
          5083,
          5091,
          5093,
          5090,
          5087,
          5082,
          5085,
          5090,
          5082,
          5088,
          5078,
          5083,
          5087,
          5084,
          5087,
          5082,
          5080,
          5074,
          5080,
          5080,
          5077,
          5082,
          5079,
          5081,
          5072,
          5075,
          5071,
          5073,
          5078,
          5075,
          5077,
          5073,
          5073,
          5071,
          5071,
          5071,
          5070,
          5077,
          5069,
          5074,
          5071,
          5073,
          5066,
          5070,
          5064,
          1860,
          620,
          592,
          586,
          581,
          582,
          581,
          577,
          579,
          577,
          274,
          299,
          297,
          300,
          300,
          297,
          300,
          298,
          297,
          300,
          5983,
          683,
          625,
          613,
          613,
          614,
          611,
          612,
          612,
          612,
          160,
          238,
          235,
          236,
          236,
          235,
          236,
          236,
          235,
          240,
          22734,
          9248,
          9035,
          9010,
          9003,
          9002,
          8985,
          8987,
          8989,
          8978,
          30310,
          8485,
          8144,
          8111,
          8098,
          8083,
          8080,
          8073,
          8075,
          8076,
          12507,
          9285,
          9239,
          9234,
          9229,
          9229,
          9230,
          9229,
          9228,
          9228,
          13264,
          10133,
          10076,
          10067,
          10069,
          10065,
          10063,
          10066,
          10060,
          10060,
          7819,
          8654,
          8672,
          8675,
          8671,
          8671,
          8674,
          8667,
          8671,
          8675,
          2128,
          2425,
          2431,
          2430,
          2431,
          2429,
          2434,
          2429,
          2432,
          2432,
          4155,
          4800,
          4805,
          4806,
          4806,
          4805,
          4806,
          4804,
          4805,
          4805,
          591,
          657,
          660,
          658,
          658,
          662,
          658,
          659,
          660,
          657,
          62432,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          57158,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          56081,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          33582,
          37122,
          37159,
          37164,
          37165,
          37163,
          37171,
          37163,
          37161,
          37170,
          5647,
          6462,
          6474,
          6467,
          6472,
          6475,
          6471,
          6471,
          6476,
          6469,
          24218,
          29798,
          29849,
          29851,
          29847,
          29831,
          29832,
          29831,
          29815,
          29815,
          4040,
          4980,
          4996,
          5001,
          4994,
          4998,
          5001,
          4999,
          4999,
          5004,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535,
          65535
        ]
      }
    ]
  ],
  "app_os": "linux",
  "app_name": "PhotosynQ",
  "app_version": "0.3.4",
  "app_device": "x86-64",
  "location": [
    "42.7225897",
    "-84.4747067"
  ],
  "ConsoleMacro": "207"
}
Screen shot 2017 05 31 at 12.23.10 pm
Created by

PhotosynQ Admin


Protocol connections:
1
Latest Update:
26 days ago