CoralspeQ | Calibrate for Reflectance Spectra - Black - chris


Pick a spectrum measured against black electrical tape, check for saturation and save it back to the CoralspeQ device
//============================================
// Macro for data evaluation on PhotosynQ.org
// created: 4/20/2016
//============================================

//Define the output object here
var output = {};

// Number of pixel per spectrum
var pixels = 256;

// Number of spectra collected
var specNum = 3;

// Integration times
var intTimes = [100,200,400];

// Split the rawtrace up into separate spectra
var spectra = [];
for (i=0,j=json.data_raw.length; i<j; i+=pixels) {
    spectra.push(json.data_raw.slice(i,i+pixels));   
}

if(spectra.length != specNum)
	danger('Insufficent number of spectra collected!',output);

//Spectrum to determine black
var SpectrumForBlack = 2;

// Pick a non saturated spectrum for black
if(MathMAX(spectra[SpectrumForBlack]) > 40000)
	SpectrumForBlack = 1;

if(MathMAX(spectra[SpectrumForBlack]) > 40000)
	SpectrumForBlack = 0;


output.black = SpectrumForBlack +1;

// Correct for the integration times
var ReferenceSpectraBlack = [];

for(i=0;i<pixels;i++){
	ReferenceSpectraBlack.push(spectra[SpectrumForBlack][i]);
}


// Output an array with the reference spectra getting saved
// to the device
if(ReferenceSpectraBlack.length != pixels)
	danger('Merged spectra have the wrong number of values',output);

output.intTimeBlack = intTimes[SpectrumForBlack];

output.toDevice = "1078+";
output.toDevice += ReferenceSpectraBlack.join('+') + '+';
//output.toDevice += "1020+";
//output.toDevice += intTimes[SpectrumForBlack] + '+0+';
//output.toDevice += "-1+";


//Return data
return output;
{
  "time_offset": 240,
  "time": 1461939493924,
  "device_id": 145,
  "firmware_version": "0.456",
  "sample": [
    [
      {
        "time": 1461939493941,
        "protocol_id": 1,
        "light_intensity": 0,
        "r": 0,
        "g": 0,
        "b": 0,
        "data_raw": [
          6162,
          6158,
          6098,
          6129,
          5220,
          6268,
          6273,
          6178,
          6060,
          6050,
          6020,
          6016,
          5973,
          6024,
          6065,
          6189,
          6162,
          6032,
          5980,
          6040,
          6095,
          6002,
          6053,
          5961,
          5694,
          5999,
          6079,
          6227,
          6289,
          6259,
          6386,
          6563,
          6985,
          7668,
          8637,
          10151,
          11752,
          13278,
          14091,
          14102,
          13418,
          12260,
          10920,
          8491,
          8726,
          7939,
          8238,
          7387,
          7267,
          6846,
          6576,
          6556,
          6474,
          6524,
          6282,
          6315,
          6186,
          6123,
          6188,
          5987,
          6008,
          6077,
          5804,
          5546,
          5953,
          5965,
          6000,
          6027,
          6072,
          6158,
          6114,
          6070,
          6051,
          6109,
          6216,
          6136,
          6112,
          6179,
          6241,
          6245,
          6093,
          6036,
          4620,
          5818,
          5852,
          5976,
          6098,
          6124,
          6200,
          6170,
          6054,
          6056,
          6103,
          6183,
          6129,
          6053,
          6189,
          6190,
          6136,
          6159,
          6159,
          5789,
          6093,
          6193,
          6216,
          6035,
          6099,
          6100,
          6008,
          6071,
          6234,
          6232,
          6228,
          6193,
          6198,
          6255,
          6351,
          6380,
          6411,
          6282,
          6318,
          6526,
          6362,
          6443,
          6416,
          6361,
          6484,
          6525,
          6505,
          6343,
          6306,
          6263,
          6338,
          6214,
          6224,
          6235,
          6336,
          6399,
          6280,
          6316,
          6262,
          6822,
          6863,
          6612,
          6593,
          6398,
          6287,
          6371,
          6355,
          6418,
          6254,
          6288,
          6305,
          6194,
          6176,
          6046,
          6036,
          6105,
          6114,
          6139,
          6257,
          6176,
          6158,
          6142,
          6103,
          6169,
          6125,
          6046,
          6044,
          6127,
          6110,
          6021,
          6066,
          6131,
          6210,
          6143,
          6078,
          6033,
          5989,
          4888,
          6017,
          5901,
          5933,
          6053,
          6008,
          5961,
          5971,
          5941,
          5952,
          6028,
          6039,
          6066,
          6048,
          6065,
          6056,
          6063,
          6051,
          6108,
          5962,
          5538,
          5984,
          6031,
          6000,
          5930,
          5884,
          5934,
          5941,
          5901,
          5886,
          5983,
          6067,
          6047,
          5905,
          5969,
          5958,
          5969,
          6061,
          6096,
          4646,
          5860,
          5938,
          5995,
          6093,
          6179,
          6157,
          6068,
          6007,
          6009,
          6029,
          5933,
          5942,
          6002,
          6115,
          6552,
          6755,
          6431,
          6535,
          6011,
          5896,
          6168,
          6171,
          6240,
          6243,
          6295,
          6171,
          6211,
          6292,
          6317,
          6336,
          6211,
          6121,
          6164,
          6017,
          6065,
          5948,
          5896,
          6112,
          6175,
          6185,
          6168,
          6332,
          6896,
          6539,
          6654,
          6378,
          6396,
          4999,
          6178,
          6269,
          6066,
          6207,
          6138,
          6024,
          6114,
          6111,
          6223,
          6134,
          6113,
          6218,
          6205,
          6167,
          6305,
          6277,
          6324,
          6435,
          6027,
          6372,
          7183,
          8160,
          9670,
          11710,
          14488,
          17673,
          20296,
          21744,
          21906,
          20475,
          18112,
          15581,
          13400,
          11560,
          10128,
          8947,
          8018,
          7535,
          6309,
          6908,
          6823,
          6666,
          6632,
          6712,
          6641,
          6583,
          6614,
          6694,
          6775,
          6664,
          6576,
          6389,
          6361,
          6267,
          6258,
          6282,
          6211,
          5639,
          6373,
          6418,
          6386,
          6226,
          6357,
          6423,
          6359,
          6451,
          6321,
          6310,
          6375,
          6445,
          6486,
          6409,
          6360,
          6502,
          6483,
          6292,
          6301,
          6587,
          6306,
          6348,
          6336,
          6385,
          6349,
          6361,
          6429,
          6403,
          6399,
          7028,
          7129,
          6851,
          6959,
          6793,
          6861,
          6696,
          6688,
          6774,
          5872,
          6932,
          6817,
          6693,
          6654,
          6517,
          6615,
          6599,
          6464,
          6636,
          6578,
          6711,
          6704,
          6478,
          6594,
          6578,
          6601,
          6612,
          6647,
          6726,
          6635,
          6579,
          6684,
          6729,
          6736,
          6674,
          6591,
          6689,
          6552,
          6486,
          6475,
          6478,
          6528,
          6599,
          6565,
          6531,
          6576,
          6570,
          6471,
          5406,
          6530,
          6457,
          6445,
          6519,
          6459,
          6389,
          6439,
          6519,
          6552,
          6473,
          6405,
          6437,
          6322,
          6266,
          6237,
          6224,
          6119,
          6131,
          6000,
          5582,
          6000,
          6064,
          6113,
          6185,
          6155,
          6055,
          6058,
          6082,
          5976,
          5918,
          6035,
          6112,
          6035,
          6183,
          6198,
          6141,
          6000,
          5962,
          4547,
          5711,
          5782,
          5819,
          5994,
          6004,
          6094,
          6997,
          6410,
          6464,
          6482,
          6248,
          6363,
          6180,
          6146,
          6091,
          6127,
          6157,
          6051,
          5668,
          5784,
          6034,
          6070,
          5999,
          6028,
          6027,
          5945,
          5944,
          6110,
          6124,
          6086,
          6078,
          6011,
          6068,
          6200,
          6226,
          6201,
          6149,
          6091,
          5385,
          6085,
          6164,
          6254,
          6171,
          6234,
          6349,
          6258,
          6074,
          6105,
          5991,
          6080,
          5971,
          5943,
          6055,
          6119,
          6178,
          6115,
          5964,
          5470,
          6131,
          6124,
          6162,
          5979,
          6044,
          6119,
          6122,
          6144,
          6081,
          6104,
          6255,
          6212,
          6138,
          6145,
          6199,
          6271,
          6268,
          5700,
          6050,
          6211,
          6298,
          6260,
          6304,
          6429,
          6419,
          6229,
          6261,
          6149,
          6185,
          6263,
          6143,
          6206,
          6228,
          6344,
          6475,
          6289,
          6309,
          6517,
          6480,
          6591,
          6650,
          6837,
          7496,
          8728,
          10887,
          13323,
          17455,
          22686,
          28768,
          33973,
          37073,
          37315,
          34423,
          29887,
          24677,
          20187,
          15909,
          13932,
          11804,
          10102,
          8889,
          8275,
          7753,
          7479,
          7210,
          7063,
          6989,
          6901,
          6935,
          6957,
          6980,
          6963,
          6880,
          6883,
          6626,
          6607,
          6765,
          6530,
          6518,
          6557,
          6508,
          6532,
          6484,
          6481,
          6477,
          6520,
          6573,
          6694,
          6678,
          6652,
          6640,
          6692,
          6819,
          6755,
          6696,
          5734,
          6878,
          6810,
          6758,
          6658,
          6595,
          6595,
          6611,
          6611,
          6569,
          6631,
          6744,
          6720,
          6694,
          6617,
          6669,
          6746,
          6672,
          6705,
          6705,
          6264,
          6709,
          6836,
          6877,
          7009,
          6953,
          6882,
          6904,
          6846,
          6866,
          6850,
          6792,
          6875,
          7094,
          7075,
          7083,
          7056,
          7044,
          7070,
          5839,
          7092,
          7120,
          7933,
          7926,
          7760,
          7731,
          7474,
          7645,
          7545,
          7507,
          7397,
          7323,
          7296,
          7172,
          7152,
          7167,
          7149,
          7145,
          6810,
          6536,
          6936,
          6919,
          6984,
          7004,
          6924,
          6820,
          6772,
          6729,
          6727,
          6651,
          6803,
          6765,
          6725,
          6751,
          6744,
          6756,
          6583,
          6567,
          5078,
          6301,
          6373,
          6372,
          6527,
          6564,
          6614,
          6640,
          6442,
          6495,
          6505,
          6516,
          6512,
          6347,
          6431,
          6454,
          6422,
          6401,
          6343,
          5919,
          6327,
          6410,
          6319,
          6195,
          6196,
          6209,
          6084,
          6115,
          6255,
          6204,
          6304,
          6259,
          6066,
          6163,
          6145,
          6158,
          6208,
          6241,
          6261,
          6542,
          6238,
          6302,
          6279,
          6169,
          6240,
          6256,
          6248,
          6072,
          5973,
          6023,
          6031,
          5978,
          6007,
          5912,
          6115,
          6074,
          5960,
          6043,
          6228,
          6682,
          6651,
          6575,
          6308,
          6284,
          6152,
          6339,
          6295,
          6194,
          6196,
          6184,
          6298,
          6047,
          6014,
          6081,
          6032,
          5978,
          6031,
          6133,
          6233,
          6249,
          6182,
          6206,
          6175,
          6204,
          6248,
          6234,
          6240,
          6263,
          6227,
          6259,
          6330,
          6307,
          6328,
          6355,
          6313
        ],
        "tcs_dac_values": [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0
        ]
      }
    ]
  ],
  "app_os": "win",
  "app_name": "PhotosynQ",
  "app_version": "0.3.2",
  "app_device": "x86-32",
  "location": [
    "42.7225424",
    "-84.4748420"
  ]
}
Img 20161024 131107688 hdr
Created by

Christopher


Protocol connections:
1
Latest Update:
Apr 2016