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
75c32f49
Commit
75c32f49
authored
Jan 09, 2020
by
Moreau Nicolas
Browse files
change calculation of SummedSpectrum graph title
parent
72e0cf42
Changes
1
Hide whitespace changes
Inline
Side-by-side
yafitsv/views/olqv.ejs
View file @
75c32f49
...
@@ -364,7 +364,37 @@
...
@@ -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
// A object to mark informations related to a position
...
@@ -1652,14 +1682,9 @@ var SAMPPNGPublishControl = (function (Control) {
...
@@ -1652,14 +1682,9 @@ var SAMPPNGPublishControl = (function (Control) {
};
};
$
(
"
#zoomin
"
).
on
(
'
click
'
,
function
(){
$
(
"
#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
factor
=
Math
.
abs
((
spectrumChart
.
xAxis
[
0
].
min
-
spectrumChart
.
xAxis
[
0
].
max
)
*
0.2
);
let
minVal
=
spectrumChart
.
xAxis
[
0
].
min
+
factor
;
let
minVal
=
spectrumChart
.
xAxis
[
0
].
min
+
factor
;
let
maxVal
=
spectrumChart
.
xAxis
[
0
].
max
-
factor
;
let
maxVal
=
spectrumChart
.
xAxis
[
0
].
max
-
factor
;
console
.
log
(
"
factor :
"
+
factor
);
console
.
log
(
"
min :
"
+
minVal
+
"
, max :
"
+
maxVal
);
spectrumChart
.
xAxis
[
0
].
setExtremes
(
minVal
,
maxVal
);
spectrumChart
.
xAxis
[
0
].
setExtremes
(
minVal
,
maxVal
);
});
});
...
@@ -1696,7 +1721,6 @@ var SAMPPNGPublishControl = (function (Control) {
...
@@ -1696,7 +1721,6 @@ var SAMPPNGPublishControl = (function (Control) {
var
imax
=
Math
.
round
((
max
-
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
)
{
if
(
getCunit3
()
in
unitFactor
)
{
console
.
log
(
"
### CASE :
"
+
_ctype3
);
switch
(
_ctype3
)
{
switch
(
_ctype3
)
{
case
'
FREQ
'
:
case
'
FREQ
'
:
if
(
_cdelt3
>
0
)
{
if
(
_cdelt3
>
0
)
{
...
@@ -1793,17 +1817,7 @@ var SAMPPNGPublishControl = (function (Control) {
...
@@ -1793,17 +1817,7 @@ var SAMPPNGPublishControl = (function (Control) {
panning
:
true
,
panning
:
true
,
panKey
:
'
shift
'
,
panKey
:
'
shift
'
,
events
:{
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
){
selection
:
function
(
event
){
console
.
log
(
"
### SELECTION
"
);
this
.
xAxis
[
0
].
update
({
this
.
xAxis
[
0
].
update
({
plotBands
:
[{
plotBands
:
[{
from
:
event
.
xAxis
[
0
].
min
,
from
:
event
.
xAxis
[
0
].
min
,
...
@@ -1811,26 +1825,20 @@ var SAMPPNGPublishControl = (function (Control) {
...
@@ -1811,26 +1825,20 @@ var SAMPPNGPublishControl = (function (Control) {
color
:
'
rgba(68, 170, 213, .2)
'
color
:
'
rgba(68, 170, 213, .2)
'
}]
}]
});
});
console
.
log
(
"
### MIN/MAX
"
);
console
.
log
(
event
.
xAxis
[
0
].
min
+
"
"
+
event
.
xAxis
[
0
].
max
);
let
summedSpectrum
=
self
.
computeSummedAverageSpectrum
(
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
=
[];
let
xData
=
[];
for
(
let
i
=
0
;
i
<
this
.
series
[
0
].
data
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
series
[
0
].
data
.
length
;
i
++
){
xData
.
push
(
this
.
series
[
0
].
data
[
i
].
x
);
xData
.
push
(
this
.
series
[
0
].
data
[
i
].
x
);
}
}
let
imin
=
get
Index
(
xData
,
event
.
xAxis
[
0
].
min
);
let
imin
=
get
CalculatedIndex
(
event
.
xAxis
[
0
].
min
);
let
imax
=
get
Index
(
xData
,
event
.
xAxis
[
0
].
max
);
let
imax
=
get
CalculatedIndex
(
event
.
xAxis
[
0
].
max
);
console
.
log
(
"
min / max :
"
+
imin
+
"
"
+
imax
);
let
title
=
getSummedSpectrumTitle
(
averageSpectrum
,
imin
,
imax
,
cdelt3prim
);
let
summedSp
=
sumArr
(
averageSpectrum
,
imin
,
imax
,
cdelt3prim
);
this
.
setTitle
({
text
:
toptitle
(
title
,
toptitle_unit
)});
this
.
setTitle
({
text
:
toptitle
(
summedSp
/
unitRescale
(
summedPixelsSpectrumUnit
(
_bunit
)),
toptitle_unit
)});
return
false
;
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) {
...
@@ -2022,11 +2030,8 @@ var SAMPPNGPublishControl = (function (Control) {
addYAxisSeries
(
summedPixelsSpectrumChart
);
addYAxisSeries
(
summedPixelsSpectrumChart
);
addYAxisSeries
(
spectrumChart
);
addYAxisSeries
(
spectrumChart
);
console
.
log
(
"
### SUMARR
"
);
let
title
=
getSummedSpectrumTitle
(
averageSpectrum
,
0
,
averageSpectrum
.
length
-
1
,
cdelt3prim
);
console
.
log
(
averageSpectrum
);
summedPixelsSpectrumChart
.
setTitle
({
text
:
toptitle
(
title
,
toptitle_unit
)});
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
'
;
document
.
getElementById
(
'
loading
'
).
style
.
display
=
'
none
'
;
console
.
log
(
"
SummedPixelsSpectrumViewer : callback of getAverageSpectrum: exiting
"
);
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