second try long


Saves the 'blackbody' reflection at each wavelength .
var data = json.data_raw;
var output = {};

//  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_blank2[light] = MathROUND(100*MathLOG((raw_at_blank2[6] / json.recall["colorcal_blank2[6]"])/(raw_at_blank2[light] / json.recall["colorcal_blank2["+light+"]"])),2);

// 100 * log ( ( trans940s / trans940c ) / (trans650s / trans650c )  

var wavelengths = [370, 395, 420, 530, 605, 650, 730, 850, 880, 940];
var pulses = 150;
var raw_array = [];
var trans_array = [];
var spad_array = [];
var max_reflectance_High = [json.recall["userdef[0]"],json.recall["userdef[1]"],json.recall["userdef[2]"],json.recall["userdef[3]"],json.recall["userdef[4]"],json.recall["userdef[5]"],json.recall["userdef[6]"],json.recall["userdef[7]"],json.recall["userdef[8]"],json.recall["userdef[9]"]];
var max_reflectance_Low = [json.recall["userdef[10]"],json.recall["userdef[11]"],json.recall["userdef[12]"],json.recall["userdef[13]"],json.recall["userdef[14]"],json.recall["userdef[15]"],json.recall["userdef[16]"],json.recall["userdef[17]"],json.recall["userdef[18]"],json.recall["userdef[19]"]];
var max_reflectance = [];
 for (j = 0; j < 10; j++) {
   max_reflectance[i] = max_reflectance_High - max_reflectance_Low;
}
var max_reflectance = [json.recall["userdef[0]"],json.recall["userdef[1]"],json.recall["userdef[2]"],json.recall["userdef[3]"],json.recall["userdef[4]"],json.recall["userdef[5]"],json.recall["userdef[6]"],json.recall["userdef[7]"],json.recall["userdef[8]"],json.recall["userdef[9]"]];
var max_rawMedian_940 = max_reflectance[9];
var rawMedian_940 = MathROUND(MathMEDIAN(json.data_raw.slice(pulses*9 + pulses*(2/3),pulses*(9+1))),0);
var tester = wavelengths.length;

output["toDevice"] = "set_user_defined+";
for (var i = 0; i < wavelengths.length; i++) {
  // pull out average value from however many pulses, skipping first and last 2 points (they can be noisy)
  var rawMedianAll = MathROUND(MathMEDIAN(json.data_raw.slice(pulses*i,pulses*(i+1))),0);
  var rawMedian = MathROUND(MathMEDIAN(json.data_raw.slice(pulses*i + pulses*(2/3),pulses*(i+1))),0);
  var rawValuesAll = json.data_raw.slice(pulses*i,pulses*(i+1));
  var rawValues = json.data_raw.slice(pulses*i + pulses*(2/3),pulses*(i+1));
//  var rawTrans =  max_reflectance[i] - rawMedian;
  var rawTrans =  rawMedian;
  var rawStd = MathSTDEV(rawValues);
  var bits = ( 15 - MathLOG(rawStd*2) / MathLOG(2) );
  var spad = 100 * Math.log ( ( rawMedian_940 / max_rawMedian_940 ) / (rawMedian / max_reflectance[i] ) );
  output["raw_trans_"+wavelengths[i]] = rawTrans;
  output["percent_trans_"+wavelengths[i]] = MathROUND(1 - ( rawTrans / max_reflectance[i]),2);
//  output["spad_"+wavelengths[i]] = MathROUND(spad,2);
//  output["cal_"+wavelengths[i]] = max_reflectance[i];
  output["rawValuesAll"+wavelengths[i]] = rawValuesAll;
//  output["rawValues"+wavelengths[i]] = rawValues;
  output["std_"+wavelengths[i]] = MathROUND(rawStd,1);
  output["bits_"+wavelengths[i]] = MathROUND(bits,1);
  raw_array[i] = rawMedian;
  trans_array[i] = rawMedian;
  spad_array[i] = rawMedian;
//  output["toDevice"] += i + "+" + raw_array[i]+"+";
 }

output["toDevice"] += "-1+";
output["max_reflectance_Low"] = max_reflectance_Low;
output["raw_array"] = raw_array;
//output["max_reflectance"] = max_reflectance;
//output["max_reflectance_High"] = max_reflectance_High;
//output["max_reflectance_Low"] = max_reflectance_Low;
//output["max_rawMedian_940"] = max_rawMedian_940;
//output["rawMedian_940"] = rawMedian_940;

//output["tester"] = tester;

// = "set_user_defined+1+"+shinybody_530+"+2+"+shinybody_650+"+3+"+shinybody_605+"+4+"+shinybody_420+"+5+"+shinybody_940+"+6+"+shinybody_850+"+7+"+shinybody_730+"+8+"+shinybody_880+"+-1+";

return output;
{
  "time_offset": 240,
  "time": 1506099997850,
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "03:22:01:96",
  "device_battery": 14,
  "device_firmware": 1.17,
  "sample": [
    {
      "time": 1506099997860,
      "protocol_id": 1,
      "recall": {
        "time": 1506100000860,
        "userdef[0]": 48864,
        "userdef[1]": 48712,
        "userdef[2]": 48680,
        "userdef[3]": 62354,
        "userdef[4]": 36774,
        "userdef[5]": 41336,
        "userdef[6]": 54660,
        "userdef[7]": 36513,
        "userdef[8]": 47996,
        "userdef[9]": 51074,
        "userdef[10]": 32997,
        "userdef[11]": 32874,
        "userdef[12]": 32874,
        "userdef[13]": 29474,
        "userdef[14]": 24910,
        "userdef[15]": 19392,
        "userdef[16]": 18960,
        "userdef[17]": 19360,
        "userdef[18]": 27598,
        "userdef[19]": 26985
      },
      "data_raw": [
        47246,
        47122,
        47056,
        46990,
        46960,
        46898,
        46888,
        46862,
        46808,
        46798,
        46766,
        46728,
        46700,
        46696,
        46648,
        46640,
        46632,
        46632,
        46600,
        46600,
        46586,
        46568,
        46568,
        46536,
        46520,
        46512,
        46504,
        46504,
        46504,
        46504,
        46472,
        46472,
        46472,
        46444,
        46464,
        46444,
        46440,
        46440,
        46440,
        46408,
        46408,
        46398,
        46394,
        46388,
        46390,
        46398,
        46376,
        46378,
        46382,
        46376,
        46352,
        46376,
        46332,
        46344,
        46350,
        46344,
        46344,
        46344,
        46328,
        46320,
        46316,
        46316,
        46314,
        46312,
        46348,
        46376,
        46376,
        46376,
        46376,
        46332,
        46376,
        46344,
        46330,
        46328,
        46328,
        46344,
        46344,
        46312,
        46312,
        46328,
        46330,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46312,
        46286,
        46312,
        46312,
        46280,
        46280,
        46280,
        46284,
        46282,
        46280,
        46280,
        46280,
        46260,
        46280,
        46264,
        46260,
        46264,
        46260,
        46252,
        46260,
        46256,
        46256,
        46252,
        46256,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46248,
        46200,
        46200,
        46248,
        46222,
        46218,
        46206,
        46218,
        46248,
        46216,
        46218,
        46216,
        46216,
        46248,
        46208,
        46202,
        46200,
        46216,
        46204,
        46216,
        46194,
        46204,
        46200,
        46186,
        46200,
        46188,
        46190,
        46200,
        46216,
        46188,
        46188,
        46184,
        46184,
        46190,
        46190,
        46184,
        46186,
        46184,
        46184,
        46184,
        46186,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46184,
        46140,
        46156,
        46152,
        46184,
        46184,
        46154,
        46184,
        46184,
        46184,
        46152,
        46184,
        46184,
        46184,
        46152,
        46154,
        46184,
        46152,
        46184,
        46152,
        46152,
        46152,
        46154,
        46152,
        46152,
        46154,
        46136,
        46152,
        46144,
        46152,
        46136,
        46152,
        46152,
        46144,
        46152,
        46152,
        46152,
        46152,
        46120,
        46122,
        46136,
        46136,
        46142,
        46120,
        46090,
        46088,
        46088,
        46088,
        46088,
        46072,
        46088,
        46080,
        46072,
        46076,
        46074,
        46064,
        46088,
        46070,
        46074,
        46068,
        46076,
        46074,
        46068,
        46064,
        46088,
        46066,
        46064,
        46064,
        46056,
        46088,
        46074,
        46074,
        46072,
        46072,
        46076,
        46074,
        46072,
        46060,
        46072,
        46060,
        46060,
        46060,
        46056,
        46064,
        46056,
        46056,
        46064,
        46056,
        46064,
        46060,
        46056,
        46056,
        46056,
        46056,
        46060,
        46056,
        46056,
        46058,
        46062,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46060,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46058,
        46056,
        46056,
        46056,
        46058,
        46056,
        46066,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46030,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46056,
        46026,
        46056,
        46056,
        46056,
        46026,
        46056,
        46028,
        46024,
        46056,
        46056,
        46056,
        46024,
        46030,
        46024,
        46024,
        46056,
        46056,
        46056,
        46026,
        46024,
        46056,
        46056,
        46056,
        46026,
        46024,
        46056,
        46056,
        46024,
        46056,
        46010,
        46024,
        46026,
        46024,
        46024,
        46024,
        46024,
        46024,
        46056,
        46010,
        46056,
        46028,
        46028,
        46014,
        46014,
        46010,
        46024,
        46014,
        46024,
        46024,
        46024,
        46072,
        46008,
        46024,
        46008,
        46024,
        46024,
        45992,
        46056,
        46056,
        46074,
        46074,
        46076,
        46072,
        46060,
        46060,
        46088,
        46072,
        46072,
        46072,
        46058,
        46062,
        46072,
        46072,
        46072,
        46088,
        46072,
        46064,
        46066,
        46062,
        46064,
        46064,
        46056,
        46056,
        46072,
        46062,
        46060,
        46058,
        46074,
        46056,
        46072,
        46074,
        46060,
        46060,
        46064,
        46062,
        46066,
        46058,
        46058,
        46056,
        46072,
        46060,
        46074,
        46056,
        46058,
        46064,
        46064,
        46058,
        46056,
        46056,
        46028,
        46056,
        46060,
        46056,
        46056,
        46062,
        46056,
        41086,
        41128,
        41128,
        41130,
        41128,
        41144,
        41136,
        41146,
        41160,
        41160,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41198,
        41192,
        41224,
        41202,
        41200,
        41224,
        41212,
        41198,
        41196,
        41202,
        41214,
        41224,
        41224,
        41224,
        41224,
        41208,
        41224,
        41224,
        41224,
        41224,
        41256,
        41224,
        41256,
        41208,
        41208,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41224,
        41256,
        41224,
        41256,
        41224,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41226,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41224,
        41256,
        41256,
        41256,
        41256,
        41256,
        41256,
        41214,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41192,
        41202,
        41192,
        41196,
        41192,
        41192,
        41192,
        41196,
        41198,
        41200,
        41192,
        41192,
        41192,
        41192,
        41192,
        41208,
        41196,
        41192,
        41196,
        41192,
        41194,
        41192,
        41196,
        41192,
        41208,
        41196,
        41196,
        41192,
        41192,
        41196,
        41194,
        41192,
        41192,
        41200,
        41192,
        41202,
        41198,
        41208,
        41198,
        35110,
        35092,
        35110,
        35110,
        35142,
        35142,
        35142,
        35142,
        35142,
        35146,
        35142,
        35142,
        35150,
        35142,
        35158,
        35158,
        35162,
        35148,
        35162,
        35162,
        35206,
        35158,
        35154,
        35164,
        35160,
        35174,
        35174,
        35158,
        35206,
        35206,
        35174,
        35174,
        35180,
        35176,
        35206,
        35174,
        35206,
        35180,
        35174,
        35206,
        35206,
        35178,
        35206,
        35182,
        35206,
        35206,
        35206,
        35206,
        35174,
        35206,
        35180,
        35206,
        35182,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35180,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35210,
        35210,
        35206,
        35210,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35206,
        35208,
        35206,
        35210,
        35206,
        35212,
        35214,
        35230,
        35228,
        35240,
        35270,
        35242,
        35270,
        35270,
        35270,
        35242,
        35238,
        35270,
        35242,
        35238,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35240,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35270,
        35262,
        35270,
        35244,
        35238,
        35270,
        35270,
        35270,
        35246,
        35270,
        35270,
        35270,
        35270,
        35270,
        26474,
        26452,
        26482,
        26482,
        26486,
        26482,
        26482,
        26486,
        26484,
        26498,
        26506,
        26498,
        26516,
        26520,
        26516,
        26546,
        26546,
        26500,
        26546,
        26546,
        26546,
        26546,
        26546,
        26546,
        26546,
        26546,
        26546,
        26550,
        26546,
        26546,
        26546,
        26546,
        26550,
        26554,
        26546,
        26558,
        26546,
        26546,
        26550,
        26550,
        26578,
        26546,
        26556,
        26562,
        26554,
        26562,
        26546,
        26546,
        26562,
        26554,
        26558,
        26568,
        26564,
        26564,
        26562,
        26556,
        26554,
        26564,
        26550,
        26546,
        26552,
        26578,
        26562,
        26562,
        26562,
        26560,
        26564,
        26578,
        26578,
        26550,
        26566,
        26578,
        26564,
        26562,
        26578,
        26562,
        26562,
        26568,
        26566,
        26578,
        26578,
        26578,
        26568,
        26610,
        26568,
        26580,
        26578,
        26568,
        26602,
        26578,
        26610,
        26578,
        26580,
        26578,
        26580,
        26578,
        26580,
        26586,
        26610,
        26580,
        26578,
        26578,
        26578,
        26564,
        26602,
        26578,
        26578,
        26610,
        26578,
        26578,
        26610,
        26580,
        26562,
        26562,
        26548,
        26546,
        26548,
        26562,
        26562,
        26546,
        26562,
        26552,
        26550,
        26558,
        26562,
        26548,
        26554,
        26550,
        26556,
        26546,
        26562,
        26552,
        26546,
        26550,
        26562,
        26546,
        26564,
        26578,
        26546,
        26562,
        26564,
        26550,
        26562,
        26550,
        26550,
        26552,
        26552,
        26578,
        26564,
        26554,
        25234,
        25234,
        25240,
        25240,
        25240,
        25258,
        25256,
        25230,
        25256,
        25262,
        25256,
        25240,
        25256,
        25230,
        25256,
        25230,
        25258,
        25258,
        25256,
        25256,
        25256,
        25258,
        25256,
        25260,
        25256,
        25280,
        25256,
        25288,
        25256,
        25288,
        25256,
        25246,
        25288,
        25280,
        25256,
        25256,
        25288,
        25258,
        25260,
        25280,
        25260,
        25256,
        25256,
        25288,
        25280,
        25288,
        25280,
        25288,
        25258,
        25288,
        25288,
        25262,
        25288,
        25288,
        25288,
        25280,
        25288,
        25288,
        25280,
        25288,
        25288,
        25260,
        25288,
        25288,
        25280,
        25288,
        25288,
        25256,
        25280,
        25280,
        25280,
        25288,
        25288,
        25258,
        25280,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25260,
        25262,
        25288,
        25288,
        25288,
        25260,
        25288,
        25288,
        25288,
        25280,
        25288,
        25288,
        25288,
        25280,
        25288,
        25288,
        25288,
        25288,
        25288,
        25258,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25288,
        25304,
        25310,
        25296,
        25312,
        25320,
        25308,
        25304,
        25320,
        25308,
        25320,
        25320,
        25320,
        25320,
        25320,
        25320,
        25300,
        25306,
        25302,
        25304,
        25320,
        25306,
        25306,
        25310,
        25320,
        25320,
        25310,
        7648,
        7524,
        7520,
        7512,
        7520,
        7524,
        7512,
        7520,
        7522,
        7520,
        7520,
        7532,
        7528,
        7528,
        7530,
        7520,
        7524,
        7524,
        7540,
        7532,
        7512,
        7520,
        7520,
        7526,
        7528,
        7528,
        7524,
        7526,
        7526,
        7534,
        7524,
        7530,
        7526,
        7532,
        7530,
        7532,
        7538,
        7544,
        7528,
        7524,
        7524,
        7536,
        7530,
        7528,
        7538,
        7552,
        7536,
        7524,
        7524,
        7540,
        7538,
        7524,
        7532,
        7538,
        7536,
        7528,
        7540,
        7540,
        7538,
        7530,
        7542,
        7526,
        7540,
        7530,
        7540,
        7534,
        7542,
        7542,
        7538,
        7526,
        7538,
        7528,
        7528,
        7538,
        7538,
        7534,
        7540,
        7536,
        7534,
        7540,
        7528,
        7532,
        7538,
        7544,
        7534,
        7536,
        7534,
        7538,
        7540,
        7540,
        7530,
        7534,
        7538,
        7542,
        7534,
        7552,
        7536,
        7552,
        7540,
        7530,
        7542,
        7524,
        7540,
        7552,
        7548,
        7534,
        7540,
        7526,
        7536,
        7530,
        7528,
        7552,
        7536,
        7554,
        7548,
        7536,
        7546,
        7552,
        7544,
        7540,
        7552,
        7544,
        7536,
        7534,
        7538,
        7536,
        7544,
        7552,
        7532,
        7540,
        7532,
        7536,
        7552,
        7532,
        7524,
        7528,
        7530,
        7526,
        7526,
        7534,
        7526,
        7528,
        7526,
        7536,
        7534,
        7522,
        7522,
        7532,
        7530,
        7530,
        11446,
        11452,
        11454,
        11450,
        11454,
        11458,
        11450,
        11450,
        11450,
        11478,
        11452,
        11446,
        11450,
        11462,
        11462,
        11448,
        11450,
        11466,
        11460,
        11456,
        11454,
        11462,
        11462,
        11452,
        11452,
        11446,
        11456,
        11456,
        11454,
        11466,
        11450,
        11456,
        11458,
        11464,
        11464,
        11458,
        11454,
        11454,
        11462,
        11466,
        11464,
        11452,
        11470,
        11466,
        11466,
        11454,
        11458,
        11460,
        11458,
        11462,
        11470,
        11462,
        11448,
        11462,
        11452,
        11458,
        11456,
        11456,
        11462,
        11452,
        11450,
        11460,
        11448,
        11466,
        11458,
        11462,
        11454,
        11456,
        11470,
        11456,
        11458,
        11452,
        11464,
        11468,
        11464,
        11462,
        11446,
        11454,
        11454,
        11458,
        11460,
        11458,
        11456,
        11458,
        11466,
        11454,
        11464,
        11458,
        11452,
        11446,
        11478,
        11462,
        11458,
        11458,
        11452,
        11462,
        11466,
        11460,
        11464,
        11466,
        11462,
        11462,
        11478,
        11466,
        11468,
        11454,
        11464,
        11468,
        11464,
        11460,
        11462,
        11478,
        11468,
        11470,
        11456,
        11458,
        11454,
        11456,
        11470,
        11454,
        11450,
        11454,
        11454,
        11464,
        11458,
        11462,
        11470,
        11468,
        11478,
        11454,
        11466,
        11458,
        11456,
        11462,
        11464,
        11462,
        11466,
        11458,
        11458,
        11454,
        11458,
        11468,
        11464,
        11462,
        11484,
        11456,
        11466,
        11462,
        11466,
        11470,
        10454,
        10470,
        10486,
        10464,
        10470,
        10486,
        10486,
        10468,
        10462,
        10470,
        10486,
        10476,
        10474,
        10478,
        10478,
        10462,
        10468,
        10474,
        10486,
        10472,
        10476,
        10488,
        10478,
        10486,
        10466,
        10470,
        10472,
        10474,
        10476,
        10486,
        10486,
        10486,
        10472,
        10474,
        10472,
        10486,
        10478,
        10472,
        10486,
        10478,
        10476,
        10486,
        10472,
        10472,
        10476,
        10486,
        10486,
        10490,
        10486,
        10486,
        10470,
        10472,
        10486,
        10470,
        10486,
        10470,
        10476,
        10486,
        10486,
        10474,
        10474,
        10472,
        10472,
        10472,
        10468,
        10486,
        10476,
        10486,
        10478,
        10470,
        10462,
        10474,
        10472,
        10486,
        10486,
        10478,
        10462,
        10460,
        10472,
        10470,
        10468,
        10470,
        10470,
        10492,
        10472,
        10478,
        10478,
        10486,
        10474,
        10486,
        10486,
        10472,
        10470,
        10470,
        10460,
        10472,
        10476,
        10468,
        10476,
        10472,
        10472,
        10466,
        10486,
        10486,
        10474,
        10486,
        10476,
        10486,
        10486,
        10478,
        10468,
        10486,
        10474,
        10486,
        10486,
        10486,
        10472,
        10472,
        10468,
        10470,
        10486,
        10472,
        10486,
        10478,
        10476,
        10468,
        10474,
        10472,
        10478,
        10486,
        10486,
        10480,
        10486,
        10486,
        10476,
        10486,
        10468,
        10460,
        10486,
        10486,
        10468,
        10480,
        10474,
        10488,
        10486,
        10486,
        10476,
        10474,
        10486,
        10486
      ]
    }
  ],
  "app_os": "linux",
  "app_name": "PhotosynQ",
  "app_version": "0.3.9",
  "app_device": "x86-64",
  "location": [
    "42.2310980",
    "-83.7477436"
  ],
  "ConsoleMacro": "412"
}
Default avatar
Created by

Jon S


Protocol connections:
1
Latest Update:
Sep 2017