Commit e47fd5f7 authored by Caillat Michel's avatar Caillat Michel
Browse files

Serious work of variables renaming

parent fd26d71b
......@@ -34,44 +34,44 @@ var renderingCapabilities = null;
var clienthttp = {
server : "http://"+yafitssHost+":"+yafitssPort+"/artemix",
setData : function(relFITSFilePath, sessionID, callback){
request(this.server+"/setData?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID, { json: true }, function(error, response, body){
request(this.server+"/setData?relFITSFilePath="+relFITSFilePath, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
degToHMSDMS : function(relFITSFilePath, iRA, iDEC, sessionID=0, callback){
request(this.server+"/degToHMSDMS?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&iRA="+iRA+"&iDEC="+iDEC, { json: true }, function(error, response, body){
request(this.server+"/degToHMSDMS?relFITSFilePath="+relFITSFilePath+"&iRA="+iRA+"&iDEC="+iDEC, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
rangeToHMS : function(relFITSFilePath, sessionID, start, end, step, callback){
request(this.server+"/rangeToHMS?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&start="+start+"&end="+end+"&step="+step, { json: true }, function(error, response, body){
rangeToHMS : function(relFITSFilePath, sessionID, iRA0, iRA1, iRAstep, callback){
request(this.server+"/rangeToHMS?relFITSFilePath="+relFITSFilePath+"&iRA0="+iRA0+"&iRA1="+iRA1+"&iRAstep="+iRAstep, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
rangeToDMS : function(relFITSFilePath, sessionID, start, end, step, callback){
request(this.server+"/rangeToDMS?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&start="+start+"&end="+end+"&step="+step, { json: true }, function(error, response, body){
rangeToDMS : function(relFITSFilePath, sessionID, iDEC0, iDEC1, iDECstep, callback){
request(this.server+"/rangeToDMS?relFITSFilePath="+relFITSFilePath+"&iDEC0="+iDEC0+"&iDEC1="+iDEC1+"&iDECstep="+iDECstep, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
getSlice : function(relFITSFilePath, sessionID, sliceNumb, step, callback){
request(this.server+"/getSlice?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&sliceNumb="+sliceNumb+"&step="+step, { json: true }, function(error, response, body){
getSlice : function(relFITSFilePath, sessionID, iFREQ, step, callback){
request(this.server+"/getSlice?relFITSFilePath="+relFITSFilePath+"&iFREQ="+iFREQ, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
getAverage : function(relFITSFilePath, sessionID, step, startY, endY, startX, endX, startZ, endZ, callback){
request(this.server+"/getAverage?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&step="+step+"&startY="+startY+"&endY="+endY+"&startX="+startX+"&endX="+endX+"&startZ="+startZ+"&endZ="+endZ,
getAverage : function(relFITSFilePath, sessionID, step, iDEC0, iDEC1, iRA0, iRA1, iFREQ0, iFREQ1, retFITS, callback){
request(this.server+"/getAverage?relFITSFilePath="+relFITSFilePath+"&step="+step+"&iFREQ0="+iFREQ0+"&iFREQ1="+iFREQ1+"&iRA0="+iRA0+"&iRA1="+iRA1+"&startZ="+startZ+"&endZ="+endZ,
{ json: true }, function(error, response, body){
callback(error, response, body);
});
},
getFreq : function(relFITSFilePath, sessionID, x, y, startZ, endZ, callback){
request(this.server+"/getFreq?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&x="+x+"&y="+y+"&startZ="+startZ+"&endZ="+endZ,
getSpectrum : function(relFITSFilePath, sessionID, iRA, iDEC, iFREQ0, iFREQ1, callback){
request(this.server+"/getSpectrum?relFITSFilePath="+relFITSFilePath+"&iRA="+iRA+"&iDEC="+iDEC+"&iFREQ0="+iFREQ0+"&iFREQ1="+iFREQ1,
{ json: true }, function(error, response, body){
callback(error, response, body);
});
......@@ -88,17 +88,17 @@ var clienthttp = {
});
},
getAverageSpectrum : function(relFITSFilePath, sessionID, startY, endY, startX, endX,retFITS, callback){
request(this.server+"/getAverageSpectrum?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID+"&startY="+startY+"&endY="+endY+"&startX="+startX+"&endX="+endX+"&retFITS="+retFITS,
getAverageSpectrum : function(relFITSFilePath, sessionID, iDEC0, iDEC1, iRA0, iRA1,retFITS, callback){
request(this.server+"/getAverageSpectrum?relFITSFilePath="+relFITSFilePath+"&iDEC0="+iDEC0+"&iDEC1="+iDEC1+"&iRA0="+iRA0+"&iRA1="+iRA1+"&retFITS="+retFITS,
{ json: true }, function(error, response, body){
callback(error, response, body);
});
},
getSumOverSliceRectArea : function(relFITSFilePath, sessionID, sliceIndex, RAPix0, RAPix1, DECPix0, DECPix1, callback) {
getSumOverSliceRectArea : function(relFITSFilePath, sessionID, iFREQ, RAPix0, RAPix1, DECPix0, DECPix1, callback) {
request(this.server+"/getSumOverSliceRectArea?relFITSFilePath="+relFITSFilePath+
"&sessionID="+sessionID+
"&sliceIndex="+sliceIndex+
"&iFREQ="+iFREQ+
"&RAPix0="+RAPix0+
"&RAPix1="+RAPix1+
"&DECPix0="+DECPix0+
......@@ -110,21 +110,21 @@ var clienthttp = {
},
RADECRangeInDegrees : function(relFITSFilePath, sessionID, callback){
request(this.server+"/RADECRangeInDegrees?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID, { json: true }, function(error, response, body){
request(this.server+"/RADECRangeInDegrees?relFITSFilePath="+relFITSFilePath, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
getHeader : function (relFITSFilePath, sessionID, callback) {
request(this.server+"/getHeader?relFITSFilePath="+relFITSFilePath+"&sessionID="+sessionID, { json: true }, function(error, response, body){
request(this.server+"/getHeader?relFITSFilePath="+relFITSFilePath, { json: true }, function(error, response, body){
callback(error, response, body);
});
},
getOneSliceAsPNG : function(relFITSFilePath, sliceIndex, ittName, lutName, vmName, sessionID, callback) {
getOneSliceAsPNG : function(relFITSFilePath, iFREQ, ittName, lutName, vmName, sessionID, callback) {
let input = {
"relFITSFilePath": relFITSFilePath,
"sliceIndex": sliceIndex,
"iFREQ": iFREQ,
"ittName" : ittName,
"lutName" : lutName,
"vmName" : vmName,
......@@ -135,11 +135,11 @@ var clienthttp = {
});
},
getSummedSliceRangeAsPNG: function(relFITSFilePath, sliceIndex0, sliceIndex1, ittName, lutName, vmName, sessionID, callback ) {
getSummedSliceRangeAsPNG: function(relFITSFilePath, iFREQ0, iFREQ1, ittName, lutName, vmName, sessionID, callback ) {
let input = {
"relFITSFilePath": relFITSFilePath,
"sliceIndex0": sliceIndex0,
"sliceIndex1": sliceIndex1,
"iFREQ0": iFREQ0,
"iFREQ1": iFREQ1,
"ittName" : ittName,
"lutName" : lutName,
"vmName" : vmName,
......@@ -303,21 +303,19 @@ router.get('/',
/* A route to retrieve a PNG file indexed by a slice index */
router.get('/:product/:sliceIndex', function(req, res, next) {
sliceIndex = req.params['sliceIndex'];
router.get('/:product/:iFREQ', function(req, res, next) {
iFREQ = req.params['iFREQ'];
product = req.params['product'];
console.log(JSON.stringify(req.params, 0, 4));
var files = fs.readdirSync(PNG_ROOT_DIR+product);
console.log("Number of files " + files.length);
let sliceNumber = files.length;
fs.createReadStream(PNG_ROOT_DIR+product+'/'+sliceIndex+'.png')
fs.createReadStream(PNG_ROOT_DIR+product+'/'+iFREQ+'.png')
.pipe(new PNG({
filterType: -1
}))
.on('metadata', function() {
res.render('index', { title: 'Express', op: 'slice', sliceIndex:sliceIndex, product:product, width:this.width, height:this.height, sliceNumber : sliceNumber });
res.render('index', { title: 'Express', op: 'slice', iFREQ:iFREQ, product:product, width:this.width, height:this.height, sliceNumber : sliceNumber });
});
});
......@@ -330,7 +328,6 @@ router.get('/:product/:sliceIndex', function(req, res, next) {
/* The index post route. It will trigger a behaviour based on the value of "method" parameter */
router.post('/', function(req, res, next) {
console.log("router.post('/', function(req, res, next) { : entering");
console.log('method ='+req.body.method);
var method = req.body.method;
var self = res;
......@@ -411,7 +408,6 @@ router.post('/', function(req, res, next) {
clienthttp.getSlice(req.body.relFITSFilePath, req.sessionID ?req.sessionID : 0, sliceB, step, (error, response, body)=>{
console.log("getSlice callback : entering ");
self.setHeader('Content-Type', 'application/json');
console.log("getSlice : start sending slice to client");
self.send(JSON.stringify({ data: body }));
console.log("getSlice callback : exiting ");
});
......@@ -425,34 +421,33 @@ router.post('/', function(req, res, next) {
clienthttp.getAverage(req.body.relFITSFilePath, req.sessionID ?req.sessionID : 0, step, null, null, null, null, zmin, zmax, (error, response, body)=>{
console.log("getAverage callback : entering");
self.setHeader('Content-Type', 'application/json');
console.log("getAverage : start sending slice to client");
self.send(JSON.stringify({ data: body }));
console.log("getAverage callback : exiting");
});
}
else if(method === "getFreq") {
var x = req.body.x ? req.body.x : 0;
var y = req.body.y ? req.body.y : 0;
else if(method === "getSpectrum") {
var iRA = req.body.iRA;
var iDEC = req.body.iDEC
clienthttp.getFreq(req.body.relFITSFilePath, req.sessionID ? req.sessionID:0, parseInt(x), parseInt(y), null, null, (error, response, body)=>{
console.log("getFreq callback : entering");
clienthttp.getSpectrum(req.body.relFITSFilePath, req.sessionID ? req.sessionID:0, iRA, iDEC, null, null, (error, response, body)=>{
console.log("getSpectrum callback : entering");
self.setHeader('Content-Type', 'application/json');
self.send(JSON.stringify({ data: body }));
console.log("getFreq callback : exiting");
console.log("getSpectrum callback : exiting");
});
}
else if(method === "getAverageSpectrum") {
console.log("About to execute the code for getAverageSpectrum");
var xmin = req.body.xmin ? parseInt(req.body.xmin) : 0;
var ymin = req.body.ymin ? parseInt(req.body.ymin) : 0;
var xmax = parseInt(req.body.xmax)|| null;
var ymax = parseInt(req.body.ymax) || null;
var iRA0 = req.body.iRA0;
var iDEC0 = req.body.iDEC0;
var iRA1 = req.body.iRA1;
var iDEC1 = req.body.iDEC1;
var retFITS = useSAMP;
clienthttp.getAverageSpectrum(req.body.relFITSFilePath, req.sessionID ?req.sessionID : 0, ymin, ymax, xmin, xmax, retFITS, (error, response, body)=>{
console.log("getAverageSpectrum callback : entering");
clienthttp.getAverageSpectrum(req.body.relFITSFilePath, req.sessionID ?req.sessionID : 0, iDEC0, iDEC1, iRA0, iRA1, retFITS, (error, response, body)=>{
console.log("getAverageSpectrum callback : entering");
//console.log("error = " + JSON.stringify(error));
if (error) {
var message = error.toString();
......@@ -503,7 +498,7 @@ router.post('/', function(req, res, next) {
clienthttp.getSumOverSliceRectArea(
req.body.relFITSFilePath,
req.body.sessionID ? req.body.sessionID : 0,
req.body.sliceIndex ? parseInt(req.body.sliceIndex) : 0,
req.body.iFREQ ? parseInt(req.body.iFREQ) : 0,
req.body.RAPix0 ? parseInt(req.body.RAPix0) : 0,
req.body.RAPix1 ? parseInt(req.body.RAPix1) : null,
req.body.DECPix0 ? parseInt(req.body.DECPix0) : 0,
......@@ -529,11 +524,12 @@ router.post('/', function(req, res, next) {
);
}
else if(method === "createFits") {
console.log("createFits callback : entering");
var iRA = req.body.iRA;
var iDEC = req.body.iDEC;
var relFITSFilePath = req.body.relFITSFilePath
clienthttp.createFits(relFITSFilePath, iRA, iDEC ,(error, response, body)=>{
console.log("createFits callback : entering");
//console.log("error = " + JSON.stringify(error));
//console.log("response = " + JSON.stringify(response));
//console.log("body = " + JSON.stringify(body));
......
......@@ -832,7 +832,6 @@ var SAMPPNGPublishControl = (function (Control) {
ittName = $('#ITTSelector').find(':selected').text().trim()
lutName = $('#LUTSelector').find(':selected').text().trim()
vmName = $('#VideoModeSelector').find(':selected').text().trim()
console.log("ittName = " + ittName + ", lutName = " + lutName + "videoModeNamee = " + vmName);
$.post('png', {'si': _sliceIndex, 'relFITSFilePath': _relFITSFilePath, 'ittName': ittName, 'lutName': lutName , 'vmName' : vmName}).done(
function(resp) {
console.log("$.post('/png', {'si': _sliceIndex, 'relFITSFilePath': _relFITSFilePath}).done(: entering");
......@@ -849,11 +848,9 @@ var SAMPPNGPublishControl = (function (Control) {
}
}
var path_to_png = resp["result"]["path_to_png"];
console.log("path_to_png="+path_to_png);
if (_im_layer_1) {
_map_1.removeLayer(_im_layer_1);
}
console.log("I'll display " + path_to_png);
_im_layer_1 = new ol.layer.Image({
source: new ol.source.ImageStatic({
......@@ -876,7 +873,6 @@ var SAMPPNGPublishControl = (function (Control) {
let _displaySlice = function(relFITSFilePath, sliceIndex) {
console.log('_displaySlice : entering');
console.log("relFITSFilePath = ", relFITSFilePath);
_sliceIndex = sliceIndex;
_relFITSFilePath = relFITSFilePath;
......@@ -903,7 +899,6 @@ var SAMPPNGPublishControl = (function (Control) {
if (_im_layer_2) {
_map_2.removeLayer(_im_layer_2);
_map_2.removeLayer(_box_layer_2);
console.log("removed _box_layer_2");
}
_im_layer_2 = new ol.layer.Image({
source : new ol.source.ImageStatic({
......@@ -975,7 +970,6 @@ var SAMPPNGPublishControl = (function (Control) {
};
if (_selected_box_2) {
console.log('There is one box to remove');
_selected_box_2.setStyle(styleForget);
_box_source_2.removeFeature(_selected_box_2);
_box_source_2.refresh();
......@@ -1004,13 +998,13 @@ var SAMPPNGPublishControl = (function (Control) {
_map_1.on("click", function(event) {
sliceViewer.markLastClickInSlice(event.coordinate);
spectrumViewer.setFrequencyMarker(_sliceIndex);
spectrumViewer.plot(event.coordinate[0], event.coordinate[1]);
spectrumViewer.plot(Math.floor(event.coordinate[0]), Math.floor(event.coordinate[1]));
});
_map_2.on("click", function(event) {
sliceViewer.markLastClickInSlice(event.coordinate);
spectrumViewer.setFrequencyMarker(_sliceIndex);
spectrumViewer.plot(event.coordinate[0], event.coordinate[1]);
spectrumViewer.plot(Math.floor(event.coordinate[0]), Math.floor(event.coordinate[1]));
});
console.log("SliceViewer : exiting");
......@@ -1358,23 +1352,22 @@ var SAMPPNGPublishControl = (function (Control) {
** and updates the behaviour of the plot area in response to a number of
** events.
*/
this.plot = function (x, y) {
this.plot = function (iRA, iDEC) {
console.log("plot: entering.");
if (typeof x === 'undefined') {
x = Math.floor(_naxis1 / 2 );
if (typeof iRA === 'undefined') {
iRA = Math.floor(_naxis1 / 2 );
}
if (typeof y === 'undefined') {
y = Math.floor(_naxis2 / 2 );
if (typeof iDEC === 'undefined') {
iDEC = Math.floor(_naxis2 / 2 );
}
console.log("plot: requested at (" + x +"," + y + ")");
document.getElementById('loading').style.display="block";
$.post("",{"method":"getFreq","relFITSFilePath":_relFITSFilePath, "x": x,"y": y}).done(
$.post("",{"method":"getSpectrum","relFITSFilePath":_relFITSFilePath, "iRA": iRA,"iDEC": iDEC, "iFREQ0": 0, "iFREQ1": _naxis3-1}).done(
/*
** This is the function which actually performs the plot as a callback on
** return from a call to the FITS file server in order to get the spectrum to draw.
*/
function(resp) {
console.log("getFreq callback : entering");
console.log("getSpectrum callback : entering");
if ( resp.data["status"] == false ) {
alert(resp.data["message"]);
return;
......@@ -1426,7 +1419,6 @@ var SAMPPNGPublishControl = (function (Control) {
}
plotData.x = xData; // abscissa ( frequency, wavelength, velocity, ...);
console.log(JSON.stringify(plotData.x, 0, 4));
switch (_ctype3) {
case 'FREQ' :
if (_cdelt3 > 0) {
......@@ -1466,12 +1458,11 @@ var SAMPPNGPublishControl = (function (Control) {
<%if(useSAMP){%>
//Create a FITS file containing the spectrum supposedly to publish it via SAMP.
if(_ctype3 === "FREQ" || _ctype3 === "VRAD"){
$.post("",{"method":"createFits","relFITSFilePath":_relFITSFilePath, "iRA": Math.round(x), "iDEC": Math.round(y)})
$.post("",{"method":"createFits","relFITSFilePath":_relFITSFilePath, "iRA": iRA, "iDEC": iDEC})
.done(
function(resp) {
console.log("A FITS file has been created for the spectrum.");
var x = JSON.parse(resp);
console.log("Response was " + JSON.stringify(x, 0, 4));
sAMPPublisher.setSpectrumPath(x["result"]);
}
)
......@@ -1497,13 +1488,11 @@ var SAMPPNGPublishControl = (function (Control) {
var layout = _frequencyLayout;
layout.title = toptitle;
layout.xaxis.range = [plotData.x[0], plotData.x[plotData.x.length-1]];
console.log("------->" + JSON.stringify(layout.xaxis.range));
layout.yaxis.range = [minVal, maxVal];
layout.xaxis.title = xtitle; //"Frequency (GHz) " + specsys;
_itsGD.data = [plotData, _frequencyMarker];
_itsGD.layout = layout;
console.log("About to plot frequency/flux graph");
Plotly.redraw(_itsGD);
sliceViewer.setFluxDensityInPopup(plotData.y[ifrequencyMarker]);
......@@ -1555,7 +1544,6 @@ var SAMPPNGPublishControl = (function (Control) {
// Update the position of the red dot at the right frequency :
_frequencyMarker.x = [point.x];
console.log("Freq marker to be plotted at ", _frequencyMarker.x[0]);
// 1) In the frequency-flux graph:
Plotly.redraw(_itsGD);
......@@ -1576,7 +1564,7 @@ var SAMPPNGPublishControl = (function (Control) {
if (pdata["dragmode"]==="select") {
;
}
else if (pdata["dragmode"]==="zoom") {parseFloat
else if (pdata["dragmode"]==="zoom") {
// We just clicked on the zoom button ... do nothing special
_itsGD.layout.dragmode = "select";
}
......@@ -1633,7 +1621,7 @@ var SAMPPNGPublishControl = (function (Control) {
console.log("_itsGD.on('plotly_relayout', function(pdata) { : exiting");
}
);
console.log("getFreq callback : exiting");
console.log("getSpectrum callback : exiting");
}
);
document.getElementById('loading').style.display="none";
......@@ -1801,18 +1789,17 @@ var SAMPPNGPublishControl = (function (Control) {
Plotly.newPlot(_itsGD, _frequencyPlot, _layout);
this.plot = function (xmin, xmax, ymin, ymax, zmin, zmax) {
this.plot = function (iRA0, iRA1, iDEC0, iDEC1, zmin, zmax) {
ENTER();
document.getElementById('loading').style.display = 'block';
$.post("",{"method":"getAverageSpectrum", "relFITSFilePath":_relFITSFilePath, "xmin": xmin, "xmax": xmax, "ymin": ymin, "ymax": ymax }).done(function(resp) {
$.post("",{"method":"getAverageSpectrum", "relFITSFilePath":_relFITSFilePath, "iRA0": iRA0, "iRA1": iRA1, "iDEC0": iDEC0, "iDEC1": iDEC1 }).done(function(resp) {
console.log("SummedPixelsSpectrumViewer : callback of getAverageSpectrum: entering ");
var x = JSON.parse(resp);
<%if(useSAMP){%>
// Let's inform the SAMP hub
if ("absFITSFilePath" in x["result"]) {
console.log("Yes we have an absolute path for the FITS file : " + x["result"]["absFITSFilePath"]);
sAMPPublisher.setAverageSpectrumFile(x["result"]["absFITSFilePath"]);
}
else {
......@@ -1912,7 +1899,6 @@ var SAMPPNGPublishControl = (function (Control) {
case 'VRAD':
case 'WAVE':
case 'WAVN':
console.log(unitRescale(summedPixelsSpectrumUnit(_bunit)));
averageSpectrum = averageSpectrum.map(function(x) {return x* unitRescale(summedPixelsSpectrumUnit(_bunit))});
if (_cdelt3 > 0) {
plotData.y = averageSpectrum;
......@@ -1927,9 +1913,7 @@ var SAMPPNGPublishControl = (function (Control) {
break;
}
console.log("cdelt3prim="+cdelt3prim);
summedAverageSpectrum = sumArr(averageSpectrum, start, end, cdelt3prim);
console.log("summedAverageSpectrum = " + summedAverageSpectrum);
var maxVal = Math.max.apply(Math, plotData.y);
var minVal = Math.min.apply(Math, plotData.y);
......@@ -1951,7 +1935,6 @@ var SAMPPNGPublishControl = (function (Control) {
_itsGD.data = [ plotData, _frequencyPlotBorder];
_itsGD.layout = _layout;
console.log("About to call redraw on _itsGD");
Plotly.redraw(_itsGD);
_itsGD.removeAllListeners('plotly_relayout');
......@@ -2033,7 +2016,6 @@ var SAMPPNGPublishControl = (function (Control) {
function(pdata){
console.log("_itsGD.on('plotly_selected', function(pdata){ : entering");
console.log("selection : " , JSON.stringify(pdata["range"], null, 4))
if (pdata == undefined) {
return;
}
......@@ -2353,7 +2335,7 @@ var SAMPPNGPublishControl = (function (Control) {
spectrumViewer.plot(width/2,height/2);
summedPixelsSpectrumViewer.plot();
summedPixelsSpectrumViewer.plot(0, width-1, 0, height-1);
$('a#rccap').click(function () {sliceViewer.refresh()});
......
Supports Markdown
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