//1 count the number of rows and columns nRows = phi2.getRowCount() nCols = phi2.getColumnCount() //2 get arrays containing values for light, phi2, and reflectance phi2_vals = phi2.getValueMatrix() size_vals = size.getValueMatrix() light_vals = phi2.getExtraRowValues( "light_intensity" ) //3 create an array containing delta-times for each column times = phi2.getTimeLabels() dt = new Array(nCols) for( col = 1 ; col < nCols ; col++ ) { dt[col] = times[col]-times[col-1] } dt[0] = dt[1] //4 create an empty 2D array that will eventually contain computed LEF values totalP_vals = new Array(nRows) for ( row = 0 ; row < nRows ; row++) { totalP_vals[row] = new Array(nCols) } //5 iterate through each cell in the phi2 data for ( row = 0; row < nRows; row++) { for ( col = 0; col < nCols; col++) { //6 get the phi2, size, light, and delta-time values for this cell phi2_cell = phi2_vals[row][col] size_cell = size_vals[row][col] light_cell = light_vals[col] dt_cell = dt[col] //7 compute totalP for this cell and add it to the result array (as a cumulative) totalP_cell = phi2_cell * light_cell * .42 * size_cell * dt_cell totalP_vals[row][col] = totalP_cell if( col > 0 ) totalP_vals[row][col] += totalP_vals[row][col-1] } } //8 display a total photosynthesis heatmap using the same times, and row labels as phi2 row_labels = phi2.getRowLabels(true) totalP = new Heatmap( row_labels, times, totalP_vals ) totalP.setTitle( "Total Photosynthesis" ) GLOBAL.display( totalP )