Commit 47903a8a authored by Caillat Michel's avatar Caillat Michel
Browse files

correction in summedSpctra title calculation

parent 72e0cf42
......@@ -364,7 +364,37 @@
});
}
/**
calculate the value displayed as titrle of summed average spectrum
avgSpectrum array is reversed if data are radial velocities and
cdelt3 < 0
*/
function getSummedSpectrumTitle(avgSpectrum, imin, imax, cdelt3prim){
let result = 0;
if (_ctype3 === 'VRAD' && _cdelt3 < 0){
let copy = (x) => x;
let arraycopy = avgSpectrum.map(copy);
result = sumArr(arraycopy.reverse(), imin, imax, cdelt3prim);
}else{
result = sumArr(avgSpectrum, imin, imax, cdelt3prim);
}
return result/unitRescale(summedPixelsSpectrumUnit(_bunit));
}
function getCalculatedIndex(value){
let result = 0;
let val1 = (unitFactor[defaultOutputUnit[_ctype3]]/unitFactor[getCunit3()]) / _cdelt3;
if(_cdelt3 > 0){
result = value * val1 - _crval3 + _crpix3 -1;
}else{
result = value * (-val1) - _crval3 + _crpix3 -1;
}
return Math.round(result);
}
//
// A object to mark informations related to a position
......@@ -1652,14 +1682,9 @@ var SAMPPNGPublishControl = (function (Control) {
};
$("#zoomin").on('click', function(){
console.log(spectrumChart);
console.log(" min :" + spectrumChart.xAxis[0].min + " max : " + spectrumChart.xAxis[0].max);
let factor = Math.abs((spectrumChart.xAxis[0].min - spectrumChart.xAxis[0].max) * 0.2);
let minVal = spectrumChart.xAxis[0].min + factor;
let maxVal = spectrumChart.xAxis[0].max - factor;
console.log("factor : "+factor);
console.log("min : "+minVal + " , max : "+ maxVal);
let maxVal = spectrumChart.xAxis[0].max - factor;
spectrumChart.xAxis[0].setExtremes(minVal, maxVal);
});
......@@ -1696,7 +1721,6 @@ var SAMPPNGPublishControl = (function (Control) {
var imax = Math.round((max - summedData.x[0]) / (summedData.x[1]-summedData.x[0]));
if (getCunit3() in unitFactor) {
console.log("### CASE : "+ _ctype3);
switch (_ctype3) {
case 'FREQ':
if (_cdelt3 > 0) {
......@@ -1793,17 +1817,7 @@ var SAMPPNGPublishControl = (function (Control) {
panning: true,
panKey: 'shift',
events:{
/*render : function(event){
console.log("### RENDER");
let summedAverageSpectrum = computeSummedAverageSpectrum(this.xAxis[0].dataMin, this.xAxis[0].dataMax);
if(isTitleInitialized === false){
this.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
isTitleInitialized = true;
}
return false;
},*/
selection: function(event){
console.log("### SELECTION");
this.xAxis[0].update({
plotBands : [{
from: event.xAxis[0].min,
......@@ -1811,26 +1825,20 @@ var SAMPPNGPublishControl = (function (Control) {
color: 'rgba(68, 170, 213, .2)'
}]
});
console.log("### MIN/MAX");
console.log(event.xAxis[0].min + " " + event.xAxis[0].max);
console.log(averageSpectrum);
console.log(this.series[0].data);
let summedSpectrum = self.computeSummedAverageSpectrum(event.xAxis[0].min, event.xAxis[0].max);
let summedSpectrum = self.computeSummedAverageSpectrum(event.xAxis[0].min, event.xAxis[0].max);
let xData = [];
for(let i = 0; i< this.series[0].data.length; i++){
xData.push(this.series[0].data[i].x);
}
}
let imin = getIndex(xData, event.xAxis[0].min);
let imax = getIndex(xData, event.xAxis[0].max);
let imin = getCalculatedIndex(event.xAxis[0].min);
let imax = getCalculatedIndex(event.xAxis[0].max);
console.log("min / max : "+ imin + " "+ imax);
let summedSp = sumArr(averageSpectrum, imin, imax, cdelt3prim);
this.setTitle({text:toptitle(summedSp/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
let title = getSummedSpectrumTitle(averageSpectrum, imin, imax, cdelt3prim);
this.setTitle({text:toptitle(title, toptitle_unit)});
return false;
/*let summedAverageSpectrum = computeSummedAverageSpectrum(event.xAxis[0].min, event.xAxis[0].max);
this.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
return false;*/
}
}
......@@ -2022,11 +2030,8 @@ var SAMPPNGPublishControl = (function (Control) {
addYAxisSeries(summedPixelsSpectrumChart);
addYAxisSeries(spectrumChart);
console.log("### SUMARR");
console.log(averageSpectrum);
console.log(summedPixelsSpectrumChart.xAxis[0]);
let summedSp = sumArr(averageSpectrum, 0, averageSpectrum.length-1, cdelt3prim);
summedPixelsSpectrumChart.setTitle({text:toptitle(summedSp/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
let title = getSummedSpectrumTitle(averageSpectrum, 0, averageSpectrum.length-1, cdelt3prim);
summedPixelsSpectrumChart.setTitle({text:toptitle(title, toptitle_unit)});
document.getElementById('loading').style.display = 'none';
console.log("SummedPixelsSpectrumViewer : callback of getAverageSpectrum: exiting ");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment