Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Caillat Michel
yafits
Commits
72e0cf42
Commit
72e0cf42
authored
Jan 08, 2020
by
Moreau Nicolas
Browse files
correction for incorrect summed graph title calculation
parent
f2c414d8
Changes
2
Show whitespace changes
Inline
Side-by-side
yafitsv/public/javascript/olqv_utils.js
View file @
72e0cf42
...
...
@@ -238,3 +238,19 @@ function EXIT() {
}
console
.
log
(
result
+
"
: exiting
"
);
}
/**
Returns the index of the closest element in the array
for tyhe given value or null if not found
*/
function
getIndex
(
array
,
value
){
for
(
let
i
=
0
;
i
<
array
.
length
;
i
++
){
if
(
value
>=
array
[
i
]
&&
value
<
array
[
i
+
1
]){
if
(
Math
.
abs
(
array
[
i
+
1
]
-
value
)
>
Math
.
abs
(
array
[
i
]
-
value
))
return
i
;
else
return
i
+
1
;
}
}
return
null
;
}
\ No newline at end of file
yafitsv/views/olqv.ejs
View file @
72e0cf42
...
...
@@ -348,6 +348,24 @@
return
true
;
};
/**
Add a series where Y=0 in the given chart
*/
function
addYAxisSeries
(
chart
){
chart
.
addSeries
({
lineWidth
:
1
,
enableMouseTracking
:
false
,
showInLegend
:
false
,
color
:
"
#000000
"
,
marker
:
{
enabled
:
false
},
data
:
[[
chart
.
xAxis
[
0
].
dataMin
,
0
],
[
chart
.
xAxis
[
0
].
dataMax
,
0
]]
});
}
//
// A object to mark informations related to a position
// in a popup bow located close to the position passed
...
...
@@ -1597,6 +1615,8 @@ var SAMPPNGPublishControl = (function (Control) {
yAxis
:
{
gridLineColor
:
'
#000000
'
,
lineColor
:
'
#000000
'
,
lineWidth
:
1
,
gridLineWidth
:
0
,
title
:
{
text
:
ytitle
}
...
...
@@ -1604,7 +1624,7 @@ var SAMPPNGPublishControl = (function (Control) {
plotOptions
:
{
series
:
{
animation
:
false
,
lineWidth
:
1
//
lineWidth : 1
}
},
series
:
[
...
...
@@ -1659,6 +1679,7 @@ var SAMPPNGPublishControl = (function (Control) {
var
xtitle
=
"
undefined
"
;
var
ytitle
=
"
undefined
"
;
var
isTitleInitialized
=
false
;
let
_averageSpectrum
=
null
;
...
...
@@ -1667,11 +1688,44 @@ var SAMPPNGPublishControl = (function (Control) {
}
this
.
setAverageSpectrum
=
function
(
averageSpectrum
){
console
.
log
(
"
### setAverageSpectrum
"
);
console
.
log
(
averageSpectrum
);
_averageSpectrum
=
averageSpectrum
;
}
this
.
computeSummedAverageSpectrum
=
function
(
min
,
max
){
var
imin
=
Math
.
round
((
min
-
summedData
.
x
[
0
])
/
(
summedData
.
x
[
1
]
-
summedData
.
x
[
0
]));
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
)
{
sliceViewer
.
updateSummedSlices
(
summedData
.
x
.
length
-
1
-
imax
,
summedData
.
x
.
length
-
1
-
imin
);
}
else
{
sliceViewer
.
updateSummedSlices
(
imin
,
imax
);
}
break
;
case
'
VRAD
'
:
case
'
WAVE
'
:
case
'
WAVN
'
:
case
'
AWAV
'
:
if
(
_cdelt3
>
0
)
{
sliceViewer
.
updateSummedSlices
(
imin
,
imax
);
}
else
{
sliceViewer
.
updateSummedSlices
(
summedData
.
x
.
length
-
1
-
imax
,
summedData
.
x
.
length
-
1
-
imin
);
}
break
;
default
:
console
.
log
(
"
This should not happen
"
);
}
}
summedAverageSpectrum
=
sumArr
(
averageSpectrum
,
0
,
averageSpectrum
.
length
,
cdelt3prim
);
return
summedAverageSpectrum
;
}
var
toptitle_unit
=
""
;
if
(
_instrume
==
"
SITELLE
"
)
{
xtitle
=
_ctype3
+
"
(
"
+
getCunit3
()
+
"
)
"
;
...
...
@@ -1726,45 +1780,10 @@ var SAMPPNGPublishControl = (function (Control) {
hoverinfo
:
'
x+y
'
,
xaxis
:
'
x
'
};
var
plotData2
=
JSON
.
parse
(
JSON
.
stringify
(
_frequencyPlot
));
//let _companion = null;
/*
** set the companion
*/
/*this.setCompanion = function(who) {
_companion = who;
}*/
/*
** get the companion
*/
/*this.getCompanion = function() {
return _companion;
}*/
/*
** Who triggered the relayout ?
*/
//let _relayoutTriggeredBy = null;
/*
** Set who triggered the relayout
*/
/*this.setRelayoutTriggeredBy = function(who) {
_relayoutTriggeredBy = who;
}*/
/*
** Get who triggered the relayout.
*/
/*this.getRelayoutTriggeredBy = function() {
return _relayoutTriggeredBy;
}*/
//Plotly.newPlot(_itsGD, _frequencyPlot, _layout);
var
summedData
=
JSON
.
parse
(
JSON
.
stringify
(
_frequencyPlot
));
this
.
plot
=
function
(
iRA0
,
iRA1
,
iDEC0
,
iDEC1
,
zmin
,
zmax
)
{
ENTER
();
var
self
=
this
;
summedPixelsSpectrumChart
=
Highcharts
.
chart
(
_itsGD
,
{
title
:
{
text
:
''
...
...
@@ -1774,7 +1793,17 @@ 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
,
...
...
@@ -1782,38 +1811,26 @@ 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
xData
=
[];
for
(
let
i
=
0
;
i
<
this
.
series
[
0
].
data
.
length
;
i
++
){
xData
.
push
(
this
.
series
[
0
].
data
[
i
].
x
);
}
var
imin
=
Math
.
round
((
event
.
xAxis
[
0
].
min
-
plotData2
.
x
[
0
])
/
(
plotData2
.
x
[
1
]
-
plotData2
.
x
[
0
])
);
var
imax
=
Math
.
round
((
event
.
xAxis
[
0
].
max
-
plotData2
.
x
[
0
])
/
(
plotData2
.
x
[
1
]
-
plotData2
.
x
[
0
])
);
let
imin
=
getIndex
(
xData
,
event
.
xAxis
[
0
].
min
);
let
imax
=
getIndex
(
xData
,
event
.
xAxis
[
0
].
max
);
if
(
getCunit3
()
in
unitFactor
)
{
switch
(
_ctype3
)
{
case
'
FREQ
'
:
if
(
_cdelt3
>
0
)
{
sliceViewer
.
updateSummedSlices
(
plotData2
.
x
.
length
-
1
-
imax
,
plotData2
.
x
.
length
-
1
-
imin
);
}
else
{
sliceViewer
.
updateSummedSlices
(
imin
,
imax
);
}
break
;
case
'
VRAD
'
:
case
'
WAVE
'
:
case
'
WAVN
'
:
case
'
AWAV
'
:
if
(
_cdelt3
>
0
)
{
sliceViewer
.
updateSummedSlices
(
imin
,
imax
);
}
else
{
sliceViewer
.
updateSummedSlices
(
plotData2
.
x
.
length
-
1
-
imax
,
plotData2
.
x
.
length
-
1
-
imin
);
}
break
;
default
:
console
.
log
(
"
This should not happen
"
);
}
}
summedAverageSpectrum
=
sumArr
(
averageSpectrum
,
0
,
averageSpectrum
.
length
,
cdelt3prim
);
this
.
setTitle
({
text
:
toptitle
(
summedAverageSpectrum
/
unitRescale
(
summedPixelsSpectrumUnit
(
_bunit
)),
toptitle_unit
)});
console
.
log
(
"
min / max :
"
+
imin
+
"
"
+
imax
);
let
summedSp
=
sumArr
(
averageSpectrum
,
imin
,
imax
,
cdelt3prim
);
this
.
setTitle
({
text
:
toptitle
(
summedSp
/
unitRescale
(
summedPixelsSpectrumUnit
(
_bunit
)),
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;*/
}
}
...
...
@@ -1834,6 +1851,8 @@ var SAMPPNGPublishControl = (function (Control) {
yAxis
:
{
gridLineColor
:
'
#000000
'
,
lineColor
:
'
#000000
'
,
lineWidth
:
1
,
gridLineWidth
:
0
,
title
:
{
text
:
ytitle
}
...
...
@@ -1841,7 +1860,7 @@ var SAMPPNGPublishControl = (function (Control) {
plotOptions
:
{
series
:
{
animation
:
false
,
lineWidth
:
1
//
lineWidth : 1
}
},
tooltip
:{
...
...
@@ -1952,15 +1971,15 @@ var SAMPPNGPublishControl = (function (Control) {
}
}
}
plot
Data
2
.
x
=
xData
;
summed
Data
.
x
=
xData
;
switch
(
_ctype3
)
{
case
'
FREQ
'
:
if
(
_cdelt3
>
0
)
{
plot
Data
2
.
y
=
revertArray
(
averageSpectrum
);
summed
Data
.
y
=
revertArray
(
averageSpectrum
);
}
else
{
plot
Data
2
.
y
=
averageSpectrum
;
summed
Data
.
y
=
averageSpectrum
;
}
break
;
...
...
@@ -1970,10 +1989,10 @@ var SAMPPNGPublishControl = (function (Control) {
case
'
AWAV
'
:
averageSpectrum
=
averageSpectrum
.
map
(
function
(
x
)
{
return
x
*
unitRescale
(
summedPixelsSpectrumUnit
(
_bunit
))});
if
(
_cdelt3
>
0
)
{
plot
Data
2
.
y
=
averageSpectrum
;
summed
Data
.
y
=
averageSpectrum
;
}
else
{
plot
Data
2
.
y
=
revertArray
(
averageSpectrum
);
summed
Data
.
y
=
revertArray
(
averageSpectrum
);
}
break
;
...
...
@@ -1982,12 +2001,12 @@ var SAMPPNGPublishControl = (function (Control) {
break
;
}
let
highC
hartData
=
[];
for
(
let
i
=
0
;
i
<
plot
Data
2
.
x
.
length
;
i
++
){
highC
hartData
.
push
([
plot
Data
2
.
x
[
i
],
plot
Data
2
.
y
[
i
]]);
let
c
hartData
=
[];
for
(
let
i
=
0
;
i
<
summed
Data
.
x
.
length
;
i
++
){
c
hartData
.
push
([
summed
Data
.
x
[
i
],
summed
Data
.
y
[
i
]]);
}
summedPixelsSpectrumViewer
.
setAverageSpectrum
(
averageSpectrum
);
summedPixelsSpectrumChart
.
setTitle
({
text
:
toptitle
(
summedAverageSpectrum
/
unitRescale
(
summedPixelsSpectrumUnit
(
_bunit
)),
toptitle_unit
)});
//
summedPixelsSpectrumChart.setTitle({text:toptitle(summedAverageSpectrum/unitRescale(summedPixelsSpectrumUnit(_bunit)), toptitle_unit)});
summedPixelsSpectrumChart
.
series
[
0
].
update
({
name
:
''
,
// unlimited number of points when zooming
...
...
@@ -1996,12 +2015,18 @@ var SAMPPNGPublishControl = (function (Control) {
marker
:
{
radius
:
1
},
data
:
highC
hartData
,
data
:
c
hartData
,
}
);
var
data
=
[];
var
justRelayedout
=
false
;
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
)});
document
.
getElementById
(
'
loading
'
).
style
.
display
=
'
none
'
;
console
.
log
(
"
SummedPixelsSpectrumViewer : callback of getAverageSpectrum: exiting
"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment