Whippo's Sandbox


Exploration
// 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(300,600);
var smooth0 = data.slice(300,600);

///*

// 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;
}
baseline = 0;

/*
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];

//    -----------------------------  //
//    -----------------------------  //
//    -----------------------------  //
//        ps2_0  
//    -----------------------------  //
//    -----------------------------  //
//    -----------------------------  //
var ps2_0_start = 0; // when does the Phi2 measurement start - usando el nuevo protocolo
// Set our Apparent Fm_0_Prime, 3 Fm_0_Prime steps, and Fs_0 to calculate both traditional fv/fm and new Multi-phase flash fv/fm
//----------------------------
var Fs_0 = MathMEAN(data.slice(ps2_0_start + 1,ps2_0_start + 4)) - baseline; // take only the first 4 values in the Fs range, excluding the very first
var Fs_0_std = MathSTDEV(data.slice(ps2_0_start + 1,ps2_0_start + 4)); // create standard deviation for this value for error checking

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

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

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

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

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

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

// Calculations for corrected Fm_0_Prime using multi-phase flash
// ----------------------------
var reg_0 = MathLINREG(inverse_intensity, [A0FmP,Fm_0_P_step1,Fm_0_P_step2,Fm_0_P_step3]);

// Calculate Phi2 w/ and w/out multi-phase flash
// ----------------------------
var fv_0_fm_noMPF = (A0FmP-Fs_0)/A0FmP;
var fv_0_fm_MPF = (reg_0.b-Fs_0)/reg_0.b;


// Calculate NPQt,PhiNPQ_0, PhiNO_0, qL w/ and w/out multi-phase flash
// ----------------------------
var npqt_0_MPF = (4.88 / ((reg_0.b / Fo_0_Prime) -1) )-1;
var npqt_0_noMPF = (4.88 / ((A0FmP / Fo_0_Prime) -1) )-1;
var qL_0_MPF = ((reg_0.b - Fs_0)*Fo_0_Prime)/((reg_0.b-Fo_0_Prime)*Fs_0);
var qL_0_noMPF = ((A0FmP - Fs_0)*Fo_0_Prime)/((A0FmP-Fo_0_Prime)*Fs_0);
var PhiNO_0_MPF = 1/(npqt_0_MPF + 1 + qL_0_MPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNO_0_noMPF = 1/(npqt_0_noMPF + 1 + qL_0_noMPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNPQ_0_MPF = 1-fv_0_fm_MPF-PhiNO_0_MPF; //based on equation 53 in Kramer et al., 2004 PRES 
var PhiNPQ_0_noMPF = 1-fv_0_fm_noMPF-PhiNO_0_noMPF; //based on equation 53 in Kramer et al., 2004 PRES 

var qP_0_MPF = (reg_0.b - Fs_0)/(reg_0.b - Fo_0_Prime);
var qP_0_noMPF = (Fm_0_Prime - Fs_0)/(Fm_0_Prime - Fo_0_Prime);
var FvP_Fm_0_P_MPF = (reg_0.b-Fo_0_Prime)/reg_0.b;
var FvP_Fm_0_P_noMPF = (A0FmP-Fo_0_Prime)/A0FmP;

// Create the variables to be printed (assume to use the MPF values unless there is a good reason not to)
// ----------------------------
var fv_0_fm = fv_0_fm_MPF;
var npqt_0  = npqt_0_MPF;
var PhiNO_0 = PhiNO_0_MPF;
var PhiNPQ_0 = PhiNPQ_0_MPF;
var qL_0 = qL_0_MPF;
var Fm_0_Prime = reg_0.b;
var qP_0 = qP_0_MPF;
var FvP_Fm_0_P = FvP_Fm_0_P_MPF;
var b = json.b;
var r = json.r;
var g = json.g;


//    -----------------------------  //
//    -----------------------------  //
//    -----------------------------  //
//        ps2_50 
//    -----------------------------  //
//    -----------------------------  //
//    -----------------------------  //
var ps2_50_start = 280; // when does the Phi2 measurement start - usando el nuevo protocolo
// Set our Apparent Fm_50_Prime, 3 Fm_50_Prime steps, and Fs_50to calculate both traditional fv/fm and new Multi-phase flash fv/fm
//----------------------------
var Fs_50= MathMEAN(data.slice(ps2_50_start + 1,ps2_50_start + 4)) - baseline; // take only the first 4 values in the Fs range, excluding the very first
var Fs_50_std = MathSTDEV(data.slice(ps2_50_start + 1,ps2_50_start + 4)); // create standard deviation for this value for error checking

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

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

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

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

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

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

// Calculations for corrected Fm_50_Prime using multi-phase flash
// ----------------------------
var reg_50= MathLINREG(inverse_intensity, [A0FmP,Fm_50_P_step1,Fm_50_P_step2,Fm_50_P_step3]);

// Calculate Phi2 w/ and w/out multi-phase flash
// ----------------------------
var fv_50_fm_noMPF = (A0FmP-Fs_50)/A0FmP;
var fv_50_fm_MPF = (reg_50.b-Fs_50)/reg_50.b;


// Calculate NPQt,PhiNPQ_50, PhiNO_50, qL w/ and w/out multi-phase flash
// ----------------------------
var npqt_50_MPF = (4.88 / ((reg_50.b / Fo_50_Prime) -1) )-1;
var npqt_50_noMPF = (4.88 / ((A0FmP / Fo_50_Prime) -1) )-1;
var qL_50_MPF = ((reg_50.b - Fs_50)*Fo_50_Prime)/((reg_50.b-Fo_50_Prime)*Fs_50);
var qL_50_noMPF = ((A0FmP - Fs_50)*Fo_50_Prime)/((A0FmP-Fo_50_Prime)*Fs_50);
var PhiNO_50_MPF = 1/(npqt_50_MPF + 1 + qL_50_MPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNO_50_noMPF = 1/(npqt_50_noMPF + 1 + qL_50_noMPF*4.88); //based on equation 52 in Kramer et al., 2004 PRES
var PhiNPQ_50_MPF = 1-fv_50_fm_MPF-PhiNO_50_MPF; //based on equation 53 in Kramer et al., 2004 PRES 
var PhiNPQ_50_noMPF = 1-fv_50_fm_noMPF-PhiNO_50_noMPF; //based on equation 53 in Kramer et al., 2004 PRES 

var qP_50_MPF = (reg_50.b - Fs_50)/(reg_50.b - Fo_50_Prime);
var qP_50_noMPF = (Fm_50_Prime - Fs_50)/(Fm_50_Prime - Fo_50_Prime);
var FvP_Fm_50_P_MPF = (reg_50.b-Fo_50_Prime)/reg_50.b;
var FvP_Fm_50_P_noMPF = (A0FmP-Fo_50_Prime)/A0FmP;

// Create the variables to be printed (assume to use the MPF values unless there is a good reason not to)
// ----------------------------
var fv_50_fm = fv_50_fm_MPF;
var npqt_50 = npqt_50_MPF;
var PhiNO_50= PhiNO_50_MPF;
var PhiNPQ_50= PhiNPQ_50_MPF;
var qL_50= qL_50_MPF;
var Fm_50_Prime = reg_50.b;
var qP_50= qP_50_MPF;
var FvP_Fm_50_P = FvP_Fm_50_P_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_0, PhiNO_0... 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_0.m > 0) {
  fv_0_fm = fv_0_fm_noMPF;
  npqt_0 = npqt_0_noMPF;
  PhiNO_0 = PhiNO_0_noMPF;
  PhiNPQ_0 = PhiNPQ_0_noMPF;
  qL_0 = qL_0_noMPF;
  Fm_0_Prime = A0FmP;
  qP = qP_0_noMPF;
  FvP_Fm_0_P = fv_0_fm_noMPF;
  
  if (fv_0_fm <= 0) {
    output["Phi2_0"] 			= 0;
	warning('Phi2_0 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_0_noMPF"] 	= MathROUND(npqt_0,3);
  }
  if (fv_0_fm >=.85) {
    output["Phi2_0"] 			= -1;
	danger("Phi2_0 above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);

  }
  else {
	  output["Phi2_0"] 		= MathROUND(fv_0_fm,3);
  }
  
  if (npqt_0 <= 0) {
	output["PhiNPQ_0"]		= 0;
    output["NPQt_0"]			= 0;
	warning("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_0_noMPF and PhiNPQ_noMPF variable",output);
	output["PhiNPQ_0_noMPF"]  = MathROUND(PhiNPQ_0,3);
	output["npqt_0_noMPF"]	= MathROUND(npqt_0,3);
  }
  else {
	output["PhiNPQ_0"]  = MathROUND(PhiNPQ_0,3);
	output["NPQt_0"]		= MathROUND(npqt_0,3);
  }
	output["PhiNO_0"]		= MathROUND(PhiNO_0,3);
	output["qL_0"]		= MathROUND(qL_0,3);
    output['FvP/Fm_0_P']		= MathROUND(FvP_Fm_0_P,3);
    output['qP_0']			= MathROUND(qP_0,3);
}

// Otherwise, use the multi-phase flash calculation for Phi2, NPQt, PhiNPQ, PhiNO_0... 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 (fv_0_fm <= 0) {
    output["Phi2_0"] 			= 0;
	warning("Phi2_0 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_0_MPF"] 	= MathROUND(npqt_0,3);
  }
  if (fv_0_fm >=.85) {
    output["Phi2_0"] 			= -1;
	danger("Phi2_0 above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);
  }
  else {
    output["Phi2_0"]			= MathROUND(fv_0_fm,3);
  }
  if (npqt_0 <= 0) {
	output["PhiNPQ_0"]		= 0;
    output["NPQt_0"]			= 0;
	warning("NPQt_0 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_0_MPF and PhiNPQ_MPF variables",output);
	output["PhiNPQ_0_MPF"]  = MathROUND(PhiNPQ,3);
	output["npqt_0_MPF"]		= MathROUND(npqt_0,3);
  }
  else {
	output["PhiNPQ_0"]  = MathROUND(PhiNPQ_0,3);
	output["NPQt_0"]		= MathROUND(npqt_0,3);
  }
	output["PhiNO_0"]		= MathROUND(PhiNO_0,3);
	output["qL_0"]			= MathROUND(qL_0,3);
    output['FvP/Fm_0_P']		= MathROUND(FvP_Fm_0_P,3);
    output['qP_0']			= MathROUND(qP_0,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((fv_0_fm  * 0.45 * json.light_intensity),3);
}

if (Fs_0_std > 100) {
	danger("noisy Fs_0", output);
}
/*
if (A0FmP_std > 300) {
	danger("noisy Fm_0_Prime", output);
}
*/
if (Fm_0_P_step1_std > 120 | Fm_0_P_step2_std > 120 | Fm_0_P_step3_std > 120 | Fm_0_P_end_std > 300) {
	danger("noisy  multi-phase flash steps",output);
}

if (Fo_0_Prime_std > 150) {
	danger("noisy Fo_0_Prime", output);
}
/*
if (reg_0.m > 0) {
	info("Used Phi2_0 and not Phi2_0 MPF - ambient light level was too low to apply MPF calculation", output);
}
if (Fm_0_P_end/A0FmP - A0FmP/A0FmP > .1) {	
	info("Fm_0_Prime 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 (Fm_0_P_end/A0FmP - A0FmP/A0FmP < -.1) {
	info("Fm_0_Prime slopes up.  This may mean that saturating flash is too bright... consider using a protocol with higher saturating light on these samples",output);
}
*/




/****************OUTPUT VALUES FROM MACRO fro 50umol*******************/

// If multi-phase flash steps are flat or positive slope, then just use the normal Phi2, NPQt, PhiNPQ_50, PhiNO_50... 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_50.m > 0) {
  fv_50_fm = fv_50_fm_noMPF;
  npqt_50= npqt_50_noMPF;
  PhiNO_50= PhiNO_50_noMPF;
  PhiNPQ_50= PhiNPQ_50_noMPF;
  qL_50= qL_50_noMPF;
  Fm_50_Prime = A0FmP;
  qP = qP_50_noMPF;
  FvP_Fm_50_P = fv_50_fm_noMPF;
  
  if (fv_50_fm <= 0) {
    output["Phi2_50"] 			= 0;
	warning('Phi2_50is 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_50_noMPF"] 	= MathROUND(npqt_50,3);
  }
  if (fv_50_fm >=.85) {
    output["Phi2_50"] 			= -1;
	danger("Phi2_50above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);

  }
  else {
	  output["Phi2_50"] 		= MathROUND(fv_50_fm,3);
  }
  
  if (npqt_50<= 0) {
	output["PhiNPQ_50"]		= 0;
    output["NPQt_50"]			= 0;
	warning("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_50_noMPF and PhiNPQ_noMPF variable",output);
	output["PhiNPQ_50_noMPF"]  = MathROUND(PhiNPQ_50,3);
	output["npqt_50_noMPF"]	= MathROUND(npqt_50,3);
  }
  else {
	output["PhiNPQ_50"]  = MathROUND(PhiNPQ_50,3);
	output["NPQt_50"]		= MathROUND(npqt_50,3);
  }
	output["PhiNO_50"]		= MathROUND(PhiNO_50,3);
	output["qL_50"]		= MathROUND(qL_50,3);
    output['FvP/Fm_50_P']		= MathROUND(FvP_Fm_50_P,3);
    output['qP_50']			= MathROUND(qP_50,3);
}

// Otherwise, use the multi-phase flash calculation for Phi2, NPQt, PhiNPQ, PhiNO_50... 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 (fv_50_fm <= 0) {
    output["Phi2_50"] 			= 0;
	warning("Phi2_50is 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_50_MPF"] 	= MathROUND(npqt_50,3);
  }
  if (fv_50_fm >=.85) {
    output["Phi2_50"] 			= -1;
	danger("Phi2_50above the normal range (0 - 0.85).  Please check the raw trace and seriously consider excluding this point.", output);
  }
  else {
    output["Phi2_50"]			= MathROUND(fv_50_fm,3);
  }
  if (npqt_50<= 0) {
	output["PhiNPQ_50"]		= 0;
    output["NPQt_50"]			= 0;
	warning("NPQt_50is 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_50_MPF and PhiNPQ_MPF variables",output);
	output["PhiNPQ_50_MPF"]  = MathROUND(PhiNPQ,3);
	output["npqt_50_MPF"]		= MathROUND(npqt_50,3);
  }
  else {
	output["PhiNPQ_50"]  = MathROUND(PhiNPQ_50,3);
	output["NPQt_50"]		= MathROUND(npqt_50,3);
  }
	output["PhiNO_50"]		= MathROUND(PhiNO_50,3);
	output["qL_50"]			= MathROUND(qL_50,3);
    output['FvP/Fm_50_P']		= MathROUND(FvP_Fm_50_P,3);
    output['qP_50']			= MathROUND(qP_50,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((fv_50_fm  * 0.45 * json.light_intensity),3);
}

if (Fs_50_std > 100) {
	danger("noisy Fs_50", output);
}
/*
if (A0FmP_std > 300) {
	danger("noisy Fm_50_Prime", output);
}
*/
if (Fm_50_P_step1_std > 120 | Fm_50_P_step2_std > 120 | Fm_50_P_step3_std > 120 | Fm_50_P_end_std > 300) {
	danger("noisy  multi-phase flash steps",output);
}

if (Fo_50_Prime_std > 150) {
	danger("noisy Fo_50_Prime", output);
}
/*
if (reg_50.m > 0) {
	info("Used Phi2_50and not Phi2_50MPF - ambient light level was too low to apply MPF calculation", output);
}
if (Fm_50_P_end/A0FmP - A0FmP/A0FmP > .1) {	
	info("Fm_50_Prime 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 (Fm_50_P_end/A0FmP - A0FmP/A0FmP < -.1) {
	info("Fm_50_Prime slopes up.  This may mean that saturating flash is too bright... consider using a protocol with higher saturating light on these samples",output);
}
*/





output["Fm_0_Prime"] 		= MathROUND(Fm_0_Prime,3);
output["Fs_0"] 			= MathROUND(Fs_0,1);
output['Fo_0_Prime']		= MathROUND(Fo_0_Prime,0);
output["RFd"]           = Number(MathROUND(((Fm_0_Prime/Fs_0)-1),3));
//output["ratio MPF/noMPF, Phi2_0"] = MathROUND(fv_0_fm_MPF / fv_0_fm_noMPF,5);
//output["ratio MPF/noMPF, PhiNPQ_0"] = MathROUND(PhiNPQ_0_MPF / PhiNPQ_0_noMPF,5);
//output["ratio MPF/noMPF, PhiNO_0"] = MathROUND(PhiNO_0_MPF / PhiNO_0_noMPF,5);
//output["ratio MPF/noMPF, PhiNO_0"] = MathROUND(npqt_0_MPF / npqt_0_noMPF,5);
output["MPF_slope_0"] 	= MathROUND(reg_0.m,3);
output["MPF_rsquared_0"] 	= MathROUND(reg_0.r,3);
/*
output["Phi2_0_MPF"] 		= MathROUND(fv_0_fm_MPF,3);
output["Phi2_0_noMPF"] 	= MathROUND(fv_0_fm,3);
output["Fm_0_Prime_MPF"] 	= MathROUND(reg_0.b,3);
output["Fm_0_Prime_noMPF"] = MathROUND(A0FmP,1);
output['qL_0_MPF']		= MathROUND(qL_0_MPF,3);
output['qL_0_noMPF']      = MathROUND(qL,3);
output['PhiNPQ_MPF']    = MathROUND(PhiNPQ_MPF,3);
output['PhiNPQ_noMPF']  = MathROUND(PhiNPQ,3);
output['PhiNO_0_MPF']		= MathROUND(PhiNO_0_MPF,3);
output['PhiNO_0_noMPF']	= MathROUND(PhiNO_0,3);
output["Fs_0_std"] 			= MathROUND(Fs_0_std,1);
output["A0FmP_std"] 			= MathROUND(A0FmP_std,1);
output["Fm_0_P_step1_std"] 	= MathROUND(Fm_0_P_step1_std,1);
output["Fm_0_P_step2_std"] 	= MathROUND(Fm_0_P_step2_std,1);
output["Fm_0_P_step3_std"] 	= MathROUND(Fm_0_P_step3_std,1);
output["Fm_0_P_end_std"] 		= MathROUND(Fm_0_P_end_std,1);
output["Fo_0_Prime_std"] 			= MathROUND(Fo_0_Prime_std,1);
*/

//output["Fm_0_P_step1"] = MathROUND(Fm_0_P_step1,3);
//output["Fm_0_P_step2"] = MathROUND(Fm_0_P_step2,3);
//output["Fm_0_P_step3"] = MathROUND(Fm_0_P_step3,3);
//output["intensity inverse"] = inverse_intensity;
//output["steps"] = [A0FmP,Fm_0_P_step1,Fm_0_P_step2,Fm_0_P_step3];
//output["slopey"] = Fm_0_P_end/A0FmP - A0FmP/A0FmP ;

  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)"] = json.light_intensity;
output["Leaf Temp Differential"] = json.contactless_temp - json.temperature;

 	
output["Ambient Temperature"] = json.temperature;
output["Ambient Humidity"] = json.humidity;
output["Leaf Angle"] = json.angle;


output["Fm_50_Prime"] 		= MathROUND(Fm_50_Prime,3);
output["Fs_50"] 			= MathROUND(Fs_50,1);
output['Fo_50_Prime']		= MathROUND(Fo_50_Prime,0);
output["RFd"]           = Number(MathROUND(((Fm_50_Prime/Fs_50)-1),3));
//output["ratio MPF/noMPF, Phi2_50"] = MathROUND(fv_50_fm_MPF / fv_50_fm_noMPF,5);
//output["ratio MPF/noMPF, PhiNPQ_50"] = MathROUND(PhiNPQ_50_MPF / PhiNPQ_50_noMPF,5);
//output["ratio MPF/noMPF, PhiNO_50"] = MathROUND(PhiNO_50_MPF / PhiNO_50_noMPF,5);
//output["ratio MPF/noMPF, PhiNO_50"] = MathROUND(npqt_50_MPF / npqt_50_noMPF,5);
output["MPF_slope_50"] 	= MathROUND(reg_50.m,3);
output["MPF_rsquared_50"] 	= MathROUND(reg_50.r,3);
/*
output["Phi2_50_MPF"] 		= MathROUND(fv_50_fm_MPF,3);
output["Phi2_50_noMPF"] 	= MathROUND(fv_50_fm,3);
output["Fm_50_Prime_MPF"] 	= MathROUND(reg_50.b,3);
output["Fm_50_Prime_noMPF"] = MathROUND(A0FmP,1);
output['qL_50_MPF']		= MathROUND(qL_50_MPF,3);
output['qL_50_noMPF']      = MathROUND(qL,3);
output['PhiNPQ_MPF']    = MathROUND(PhiNPQ_MPF,3);
output['PhiNPQ_noMPF']  = MathROUND(PhiNPQ,3);
output['PhiNO_50_MPF']		= MathROUND(PhiNO_50_MPF,3);
output['PhiNO_50_noMPF']	= MathROUND(PhiNO_50,3);
output["Fs_50_std"] 			= MathROUND(Fs_50_std,1);
output["A0FmP_std"] 			= MathROUND(A0FmP_std,1);
output["Fm_50_P_step1_std"] 	= MathROUND(Fm_50_P_step1_std,1);
output["Fm_50_P_step2_std"] 	= MathROUND(Fm_50_P_step2_std,1);
output["Fm_50_P_step3_std"] 	= MathROUND(Fm_50_P_step3_std,1);
output["Fm_50_P_end_std"] 		= MathROUND(Fm_50_P_end_std,1);
output["Fo_50_Prime_std"] 			= MathROUND(Fo_50_Prime_std,1);
*/

//output["Fm_50_P_step1"] = MathROUND(Fm_50_P_step1,3);
//output["Fm_50_P_step2"] = MathROUND(Fm_50_P_step2,3);
//output["Fm_50_P_step3"] = MathROUND(Fm_50_P_step3,3);
//output["intensity inverse"] = inverse_intensity;
//output["steps"] = [A0FmP,Fm_50_P_step1,Fm_50_P_step2,Fm_50_P_step3];
//output["slopey"] = Fm_50_P_end/A0FmP - A0FmP/A0FmP ;

  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)"] = json.light_intensity;
output["Leaf Temp Differential"] = json.contactless_temp - json.temperature;

 	
output["Ambient Temperature"] = json.temperature;
output["Ambient Humidity"] = json.humidity;
output["Leaf Angle"] = json.angle;



output["order"] = ["Phi2_0","PhiNPQ_0","PhiNO_0","Leaf Temp Differential","Leaf Angle", "Light Intensity (PAR)","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": 360,
  "time": 1501270730139,
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "01:12:54:42",
  "device_battery": 97,
  "device_firmware": 1.17,
  "sample": [
    {
      "time": 1501270730156,
      "protocol_id": 1,
      "detector_read1": 12425,
      "detector_read2": 12930,
      "light_intensity": 5,
      "r": 0,
      "g": 0,
      "b": 0,
      "light_intensity_raw": 1,
      "temperature": 23.51,
      "humidity": 69.930664,
      "pressure": 929.789978,
      "temperature2": 23.25,
      "humidity2": 70.545898,
      "pressure2": 930.831238,
      "contactless_temp": 23.49,
      "thickness": -0.35,
      "compass_direction": "E",
      "compass": "90.00",
      "angle": 7.4,
      "angle_direction": "E",
      "pitch": 2.49,
      "roll": 6.97,
      "recall": {
        "time": 1501275750980,
        "colorcal_blank1[1]": 22484.5,
        "colorcal_blank1[2]": 27065,
        "colorcal_blank1[3]": 32860.5,
        "colorcal_blank1[4]": 40252.5,
        "colorcal_blank1[6]": 38283,
        "colorcal_blank1[8]": 38008,
        "colorcal_blank1[9]": 33120.5,
        "colorcal_blank1[10]": 37690,
        "colorcal_blank2[1]": 23463.5,
        "colorcal_blank2[2]": 20083,
        "colorcal_blank2[3]": 26342,
        "colorcal_blank2[4]": 20624,
        "colorcal_blank2[6]": 16690,
        "colorcal_blank2[8]": 18247,
        "colorcal_blank2[9]": 18707,
        "colorcal_blank2[10]": 16693,
        "colorcal_blank3[1]": 20523,
        "colorcal_blank3[2]": 9804,
        "colorcal_blank3[3]": 22400,
        "colorcal_blank3[4]": 13380,
        "colorcal_blank3[6]": 5748,
        "colorcal_blank3[8]": 6499,
        "colorcal_blank3[9]": 5335,
        "colorcal_blank3[10]": 5898.5,
        "colorcal_intensity1_slope[2]": 2.45,
        "colorcal_intensity1_yint[2]": -0.3,
        "colorcal_intensity2_slope[2]": 2.537,
        "colorcal_intensity2_yint[2]": 0.4,
        "colorcal_intensity3_slope[2]": 2.638,
        "colorcal_intensity3_yint[2]": -19.299999,
        "ir_baseline_slope[5]": 12727,
        "ir_baseline_yint[5]": 19085,
        "ir_baseline_slope[3]": 688.5,
        "ir_baseline_yint[3]": 900.5
      },
      "data_raw": [
        5087,
        5173,
        5246,
        5327,
        5399,
        5468,
        5543,
        5614,
        5671,
        5738,
        5797,
        5847,
        5886,
        5936,
        5967,
        5996,
        6026,
        6053,
        6062,
        6081,
        6094,
        16667,
        19815,
        21036,
        21598,
        22043,
        22541,
        23075,
        23591,
        24014,
        24351,
        24583,
        24727,
        24818,
        24873,
        24902,
        24920,
        24933,
        24928,
        24932,
        24929,
        24920,
        24915,
        24911,
        24907,
        24903,
        24901,
        24894,
        24893,
        24886,
        24885,
        24884,
        24876,
        24871,
        24865,
        24868,
        24866,
        24864,
        24863,
        24851,
        24847,
        24843,
        24844,
        24832,
        24829,
        24820,
        24819,
        24807,
        24801,
        24799,
        24798,
        24787,
        24794,
        24791,
        24781,
        24783,
        24771,
        24762,
        24766,
        24757,
        24750,
        24746,
        24734,
        24741,
        24732,
        24727,
        24731,
        24722,
        24716,
        24717,
        24715,
        24708,
        24705,
        24694,
        24686,
        24678,
        24694,
        24681,
        24672,
        24663,
        24657,
        24651,
        24645,
        24646,
        24626,
        24632,
        24631,
        24617,
        24613,
        24613,
        24610,
        24594,
        24586,
        24587,
        24587,
        24583,
        24569,
        24563,
        24556,
        24545,
        24545,
        20724,
        19265,
        18496,
        18006,
        17667,
        17416,
        17211,
        17028,
        16863,
        16719,
        16579,
        16443,
        16311,
        16175,
        16046,
        15917,
        15793,
        15673,
        15555,
        11599,
        11683,
        11795,
        11885,
        11967,
        12037,
        12117,
        12183,
        12247,
        12315,
        12389,
        12435,
        12493,
        12547,
        12610,
        12661,
        12713,
        12762,
        12823,
        12877,
        4951,
        4979,
        4993,
        5008,
        5017,
        5024,
        5031,
        5039,
        5046,
        5044,
        5049,
        5052,
        5058,
        5060,
        5064,
        5064,
        5064,
        5071,
        5070,
        5067,
        5064,
        15367,
        16818,
        17187,
        17398,
        17597,
        17797,
        17992,
        18145,
        18266,
        18349,
        18420,
        18472,
        18513,
        18540,
        18557,
        18579,
        18589,
        18605,
        18608,
        18621,
        18619,
        18625,
        18618,
        18625,
        18625,
        18619,
        18622,
        18613,
        18611,
        18603,
        18609,
        18599,
        18596,
        18592,
        18591,
        18588,
        18581,
        18580,
        18567,
        18573,
        18562,
        18569,
        18557,
        18562,
        18549,
        18553,
        18539,
        18549,
        18537,
        18541,
        18541,
        18535,
        18542,
        18529,
        18532,
        18527,
        18531,
        18528,
        18527,
        18523,
        18528,
        18525,
        18523,
        18523,
        18517,
        18526,
        18514,
        18522,
        18512,
        18527,
        18521,
        18521,
        18523,
        18521,
        18523,
        18513,
        18523,
        18518,
        18525,
        18519,
        18529,
        18523,
        18531,
        18523,
        18531,
        18527,
        18532,
        18536,
        18532,
        18541,
        18533,
        18546,
        18535,
        18549,
        18539,
        18549,
        18549,
        18555,
        18556,
        18561,
        10629,
        8354,
        7650,
        7371,
        7210,
        7107,
        7035,
        6979,
        6933,
        6896,
        6862,
        6831,
        6810,
        6794,
        6772,
        6761,
        6747,
        6724,
        6717,
        5415,
        5398,
        5419,
        5435,
        5444,
        5444,
        5450,
        5446,
        5454,
        5453,
        5461,
        5454,
        5448,
        5458,
        5451,
        5465,
        5449,
        5456,
        5457,
        5445,
        5069,
        5101,
        5117,
        5141,
        5155,
        5159,
        5171,
        5183,
        5192,
        5194,
        5207,
        5213,
        5213,
        5222,
        5227,
        5233,
        5226,
        5233,
        5239,
        5235,
        5241,
        14260,
        15173,
        15393,
        15499,
        15615,
        15783,
        16007,
        16230,
        16415,
        16538,
        16615,
        16661,
        16686,
        16702,
        16707,
        16711,
        16709,
        16706,
        16703,
        16696,
        16690,
        16681,
        16677,
        16670,
        16657,
        16651,
        16639,
        16631,
        16618,
        16612,
        16601,
        16592,
        16582,
        16575,
        16567,
        16553,
        16548,
        16541,
        16529,
        16522,
        16513,
        16503,
        16494,
        16485,
        16481,
        16470,
        16463,
        16456,
        16452,
        16450,
        16436,
        16426,
        16421,
        16416,
        16405,
        16402,
        16397,
        16384,
        16383,
        16374,
        16371,
        16364,
        16358,
        16357,
        16350,
        16344,
        16339,
        16334,
        16331,
        16323,
        16321,
        16316,
        16312,
        16310,
        16310,
        16303,
        16303,
        16293,
        16293,
        16293,
        16290,
        16285,
        16286,
        16283,
        16281,
        16276,
        16276,
        16274,
        16271,
        16267,
        16271,
        16265,
        16263,
        16262,
        16262,
        16263,
        16262,
        16260,
        16257,
        16258,
        8069,
        6898,
        6667,
        6576,
        6510,
        6467,
        6437,
        6404,
        6387,
        6372,
        6361,
        6345,
        6334,
        6332,
        6327,
        6314,
        6314,
        6310,
        6305,
        5151,
        5130,
        5151,
        5157,
        5168,
        5163,
        5177,
        5177,
        5173,
        5180,
        5184,
        5175,
        5184,
        5183,
        5186,
        5186,
        5181,
        5185,
        5184,
        5178,
        4583,
        4599,
        4614,
        4624,
        4641,
        4649,
        4657,
        4666,
        4671,
        4674,
        4678,
        4689,
        4695,
        4702,
        4703,
        4708,
        4707,
        4708,
        4712,
        4721,
        4720,
        9504,
        9978,
        10122,
        10210,
        10299,
        10417,
        10586,
        10755,
        10887,
        10992,
        11050,
        11095,
        11119,
        11136,
        11145,
        11153,
        11158,
        11163,
        11167,
        11163,
        11158,
        11164,
        11152,
        11160,
        11153,
        11151,
        11152,
        11142,
        11143,
        11134,
        11135,
        11132,
        11128,
        11127,
        11109,
        11112,
        11101,
        11105,
        11095,
        11093,
        11089,
        11081,
        11081,
        11071,
        11073,
        11066,
        11066,
        11060,
        11048,
        11047,
        11037,
        11041,
        11039,
        11035,
        11028,
        11019,
        11022,
        11013,
        11015,
        11010,
        11006,
        11001,
        10993,
        10996,
        10987,
        10993,
        10992,
        10983,
        10985,
        10977,
        10980,
        10974,
        10976,
        10974,
        10972,
        10971,
        10963,
        10968,
        10962,
        10966,
        10967,
        10963,
        10961,
        10957,
        10963,
        10955,
        10961,
        10957,
        10960,
        10962,
        10952,
        10958,
        10953,
        10957,
        10954,
        10959,
        10961,
        10950,
        10958,
        10951,
        6590,
        5842,
        5701,
        5650,
        5615,
        5594,
        5569,
        5554,
        5551,
        5541,
        5530,
        5524,
        5511,
        5509,
        5510,
        5508,
        5503,
        5501,
        5490,
        5048,
        5017,
        5034,
        5046,
        5054,
        5055,
        5057,
        5065,
        5063,
        5069,
        5071,
        5070,
        5072,
        5075,
        5070,
        5069,
        5074,
        5072,
        5072,
        5075,
        4384,
        4399,
        4409,
        4423,
        4429,
        4441,
        4443,
        4456,
        4455,
        4470,
        4467,
        4477,
        4479,
        4487,
        4485,
        4496,
        4493,
        4502,
        4501,
        4505,
        4508,
        7190,
        7333,
        7389,
        7427,
        7477,
        7550,
        7635,
        7750,
        7837,
        7906,
        7953,
        7983,
        8011,
        8020,
        8030,
        8026,
        8036,
        8041,
        8036,
        8027,
        8027,
        8031,
        8028,
        8025,
        8015,
        8013,
        8014,
        8010,
        8005,
        7996,
        7991,
        7995,
        7987,
        7983,
        7973,
        7975,
        7974,
        7969,
        7958,
        7956,
        7958,
        7951,
        7946,
        7937,
        7940,
        7938,
        7933,
        7927,
        7918,
        7921,
        7919,
        7915,
        7909,
        7911,
        7910,
        7909,
        7903,
        7895,
        7900,
        7900,
        7899,
        7889,
        7886,
        7892,
        7889,
        7888,
        7879,
        7881,
        7885,
        7883,
        7882,
        7873,
        7876,
        7876,
        7878,
        7877,
        7869,
        7871,
        7874,
        7873,
        7863,
        7864,
        7870,
        7868,
        7867,
        7859,
        7861,
        7869,
        7862,
        7863,
        7857,
        7856,
        7861,
        7860,
        7858,
        7850,
        7861,
        7858,
        7857,
        7849,
        5508,
        5038,
        4945,
        4897,
        4875,
        4852,
        4841,
        4831,
        4814,
        4808,
        4797,
        4798,
        4786,
        4784,
        4774,
        4774,
        4769,
        4767,
        4763,
        4771,
        4747,
        4772,
        4772,
        4777,
        4788,
        4793,
        4788,
        4801,
        4800,
        4797,
        4799,
        4804,
        4805,
        4801,
        4806,
        4803,
        4803,
        4805,
        4805,
        4553,
        4639,
        4722,
        4785,
        4860,
        4915,
        4965,
        5019,
        5061,
        5106,
        5144,
        5180,
        5208,
        5230,
        5258,
        5273,
        5297,
        5314,
        5329,
        5340,
        5346,
        13360,
        14833,
        15659,
        16284,
        16764,
        17105,
        17328,
        17486,
        17590,
        17674,
        17725,
        17761,
        17789,
        17805,
        17820,
        17830,
        17830,
        17833,
        17828,
        17829,
        17827,
        17823,
        17816,
        17818,
        17815,
        17812,
        17804,
        17801,
        17794,
        17785,
        17778,
        17771,
        17764,
        17761,
        17750,
        17736,
        17731,
        17726,
        17717,
        17708,
        17702,
        17702,
        17693,
        17689,
        17673,
        17671,
        17661,
        17653,
        17645,
        17639,
        17630,
        17624,
        17613,
        17598,
        17594,
        17581,
        17576,
        17568,
        17562,
        17557,
        17550,
        17541,
        17531,
        17522,
        17512,
        17503,
        17490,
        17486,
        17472,
        17459,
        17445,
        17439,
        17429,
        17419,
        17409,
        17404,
        17389,
        17383,
        17374,
        17365,
        17354,
        17339,
        17329,
        17315,
        17304,
        17291,
        17277,
        17265,
        17251,
        17241,
        17232,
        17220,
        17208,
        17201,
        17186,
        17170,
        17152,
        17146,
        17128,
        17118,
        10307,
        8075,
        7283,
        7016,
        6890,
        6807,
        6756,
        6710,
        6663,
        6636,
        6609,
        6581,
        6565,
        6540,
        6533,
        6516,
        6494,
        6488,
        6471,
        5359,
        5354,
        5385,
        5394,
        5398,
        5411,
        5414,
        5411,
        5418,
        5421,
        5420,
        5416,
        5423,
        5424,
        5416,
        5423,
        5421,
        5419,
        5414,
        5418
      ]
    }
  ],
  "app_os": "win",
  "app_name": "PhotosynQ",
  "app_version": "0.3.8",
  "app_device": "x86-64",
  "location": [
    "46.8791756",
    "-102.7896242"
  ],
  "ConsoleMacro": null
}
 6melhxy 400x400
Created by

Craig Whippo


Protocol connections:
0
Latest Update:
Jul 2017