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

Fix a bug in getCalculatedIndex that could return a negative index value.O

parent 2e92f510
...@@ -12,35 +12,33 @@ ...@@ -12,35 +12,33 @@
#------------------------------------------------------------# #------------------------------------------------------------#
# We will use Centos for our image # We will use Centos for our image
FROM debian:buster FROM centos:latest
RUN printf "deb http://httpredir.debian.org/debian buster-backports main non-free\ndeb-src http://httpredir.debian.org/debian buster-backports main non-free" > /etc/apt/sources.list.d/backports.list
RUN apt-get update
# Updating Ubuntu packages # Updating Ubuntu packages
RUN apt-get install -y apt-transport-https RUN yum install -y emacs
# Adding wget and bzip2 # Adding wget and bzip2
RUN apt-get install -y wget bzip2 RUN yum install -y wget bzip2
# Install tcl stuff # Install tcl stuff
RUN apt-get install -y tcl RUN yum install -y tcl
RUN apt-get install -y tcl-dev RUN yum install -y tcl-devel
RUN apt-get install -y libsm6 libxext6 libxrender-dev
# Add sudo # Add sudo
RUN apt-get install -y sudo RUN yum install -y sudo
#RUN groupadd sudo RUN groupadd sudo
RUN cat /etc/group RUN cat /etc/group
# Installing nodejs # Installing nodejs
RUN apt-get -y install curl RUN yum -y install curl
RUN curl --silent --location https://deb.nodesource.com/setup_9.x |sudo apt install -f - RUN curl --silent --location https://rpm.nodesource.com/setup_9.x |sudo bash -
RUN apt-get -y install nodejs npm RUN yum -y install nodejs
#Install apidoc #Install apidoc
RUN npm install -g apidoc RUN npm install -g apidoc
# Add user partemix with no password, add to sudo group # Add user partemix with no password, add to sudo group
RUN adduser partemix RUN adduser -G sudo -d /home/partemix partemix
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN ls /home/partemix RUN ls /home/partemix
...@@ -127,3 +125,4 @@ RUN ls -l /home/partemix/anaconda3/pkgs/matplotlib-3.0.3-py37h5429711_0/lib/ ...@@ -127,3 +125,4 @@ RUN ls -l /home/partemix/anaconda3/pkgs/matplotlib-3.0.3-py37h5429711_0/lib/
# ./yafitss/serverWsgi.michel will be listening at 4251 # ./yafitss/serverWsgi.michel will be listening at 4251
EXPOSE 4251 EXPOSE 4251
# We will use Centos for our image # We will use Centos for our image
FROM debian:buster FROM centos:latest
RUN printf "deb http://httpredir.debian.org/debian buster-backports main non-free\ndeb-src http://httpredir.debian.org/debian buster-backports main non-free" > /etc/apt/sources.list.d/backports.list
RUN apt-get update
# The version of nodejs # The version of nodejs
#FROM node:9 #FROM node:9
# Updating Ubuntu packages # Updating Ubuntu packages
RUN apt-get install -y apt-transport-https RUN yum install -y emacs
# Adding wget and bzip2 # Adding wget and bzip2
RUN apt-get install -y wget bzip2 RUN yum install -y wget bzip2
# Add sudo # Add sudo
RUN apt-get install -y sudo RUN yum install -y sudo
#RUN groupadd sudo RUN groupadd sudo
RUN cat /etc/group RUN cat /etc/group
# Installing nodejs # Installing nodejs
RUN apt-get -y install curl RUN yum -y install curl
RUN curl --silent --location https://deb.nodesource.com/setup_9.x |sudo apt install -f - RUN curl --silent --location https://rpm.nodesource.com/setup_9.x |sudo bash -
RUN apt-get -y install nodejs npm RUN yum -y install nodejs
#Install Java #Install Java
#RUN apt-get -y install java-1.7.0-openjdk java-1.7.0-openjdk-dev #RUN yum -y install java-1.7.0-openjdk java-1.7.0-openjdk-devel
#RUN apt-get -y install icedtea-web #RUN yum -y install icedtea-web
#RUN apt-get -y install xorg sudo #RUN yum -y install xorg sudo
# Add user partemix with no password, add to sudo group # Add user partemix with no password, add to sudo group
RUN adduser partemix RUN adduser -G sudo -d /home/partemix partemix
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN ls /home/partemix RUN ls /home/partemix
...@@ -82,3 +80,4 @@ COPY --chown=partemix:partemix . /home/partemix/yafitsv ...@@ -82,3 +80,4 @@ COPY --chown=partemix:partemix . /home/partemix/yafitsv
RUN ls -l /home/partemix/yafitsv RUN ls -l /home/partemix/yafitsv
EXPOSE 3000 EXPOSE 3000
...@@ -181,6 +181,9 @@ function unitRescale(unit) { ...@@ -181,6 +181,9 @@ function unitRescale(unit) {
** and returns the sum multiplied by a coefficient coeff. ** and returns the sum multiplied by a coefficient coeff.
*/ */
function sumArr(arr, i0, i1, coeff) { function sumArr(arr, i0, i1, coeff) {
console.log("SumArr");
console.log(arr);
console.log("i0 : "+i0 + " , i1 : " + i1 + " coeff : "+ coeff);
i0 = Math.max(0, i0); i0 = Math.max(0, i0);
i1 = Math.min(arr.length-1, i1); i1 = Math.min(arr.length-1, i1);
...@@ -238,19 +241,3 @@ function EXIT() { ...@@ -238,19 +241,3 @@ function EXIT() {
} }
console.log(result + ": exiting"); 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
...@@ -366,12 +366,13 @@ ...@@ -366,12 +366,13 @@
} }
/** /**
calculate the value displayed as titrle of summed average spectrum calculate the value displayed as title of summed average spectrum
avgSpectrum array is reversed if data are radial velocities and avgSpectrum array is reversed if data are radial velocities and
cdelt3 < 0 cdelt3 < 0
*/ */
function getSummedSpectrumTitle(avgSpectrum, imin, imax, cdelt3prim){ function getSummedSpectrumTitle(avgSpectrum, imin, imax, cdelt3prim){
let result = 0; let result = 0;
console.log(" ###getSummedSpectrumTitle");
if (_ctype3 === 'VRAD' && _cdelt3 < 0){ if (_ctype3 === 'VRAD' && _cdelt3 < 0){
let copy = (x) => x; let copy = (x) => x;
let arraycopy = avgSpectrum.map(copy); let arraycopy = avgSpectrum.map(copy);
...@@ -384,15 +385,8 @@ ...@@ -384,15 +385,8 @@
} }
function getCalculatedIndex(value){ function getCalculatedIndex(value){
let result = 0;
let val1 = (unitFactor[defaultOutputUnit[_ctype3]]/unitFactor[getCunit3()]) / _cdelt3; let val1 = (unitFactor[defaultOutputUnit[_ctype3]]/unitFactor[getCunit3()]) / _cdelt3;
let result = Math.abs(value * val1) - _crval3 + _crpix3 -1;
if(_cdelt3 > 0){
result = value * val1 - _crval3 + _crpix3 -1;
}else{
result = value * (-val1) - _crval3 + _crpix3 -1;
}
return Math.round(result); return Math.round(result);
} }
......
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