Commit 9ba1b5b3 authored by Tom Dwelly's avatar Tom Dwelly
Browse files

still sorting out crap

parent ef909283
Pipeline #3440 skipped
......@@ -313,15 +313,20 @@ function readSpecFileASCII()
skyArray[j] = Number(data[3]);
modelArray[j] = Number(data[4]);
residualArray[j] = Number(fluxArray[j] - modelArray[j]);
if ( modelArray[j] > 1.0 * fluxerrArray[j] )
{ // the numeric value is the number of sigmas to accept
if ( fluxArray[j] < y0 ) y0 = fluxArray[j];
if ( fluxArray[j] > y1 ) y1 = fluxArray[j];
if ( fluxArray[j] > -1e10) {
fluxMean = fluxMean + Number(fluxArray[j]);
nfluxMean++;
}
}
//calculate a clipped version of the mean of the flux
if ( lambdaArray[j] >= 3800. && lambdaArray[j] <= 10000. )
{
if ( Math.abs(fluxerrArray[j] - modelArray[j]) < 1.0 * Math.abs(modelArray[j]))
{ // the numeric value is the number of multiples of model flux to accept
if ( fluxArray[j] < y0 ) y0 = fluxArray[j];
if ( fluxArray[j] > y1 ) y1 = fluxArray[j];
if ( fluxArray[j] > -1e10) {
fluxMean = fluxMean + Number(fluxArray[j]);
nfluxMean++;
}
}
}
}
j ++;
}
......@@ -330,7 +335,10 @@ function readSpecFileASCII()
var str = "There was a problem with the specified specfile='"+specfile+"' (lambdaArray.length="+lambdaArray.length+")";
alert(str);
}else{
dy = (y1-Math.max(y0,0.0))*0.02; //only expand the range a little
if ( y1 <= y0 ) { y1 = y0 + 1.0; fluxMean = 0.5*(y0+y1);} //catch cases where no valid points
// console.log(y0);
// console.log(y1);
dy = (y1-Math.max(y0,0.0))*0.02; //expand the range a little
y1 = y1 + dy;
if(y0>=0.0) {
y0 = y0 - dy;
......@@ -373,7 +381,7 @@ function readSpecFileASCII()
function readSpecFile()
{
var extension = specfile.split('.').pop();
console.log(extension);
// console.log(extension);
if ( extension === "fits" ) {
readSpecFileFITS();
} else {
......@@ -502,7 +510,7 @@ function plotData() {
ctx.textAlign="center";
var zratio = (1. + znow)/(1. + modelz0);
var dx_inv = (xsize-padx)/(x1-x0);
var dy_inv = (ysize-padx)/(y1-y0);
var dy_inv = (ysize-2.*pady)/(y1-y0);
var dx2_inv = (xsize-padx)*(1.+znow)/(x1-x0);
ctx.clearRect (0 ,0,canvas.width, canvas.height);
ctx.strokeStyle = "#000000";
......@@ -1153,17 +1161,20 @@ document.body.addEventListener('mousedown', function (evt){
var ysize = canvas.height;
if ( mousePos.x >= 0.0 && mousePos.x <= xsize &&
mousePos.y >= 0.0 && mousePos.y <= ysize ) {
var dx = (x1-x0)/(xsize-padx);
var dy = (y1-y0)/(ysize-2.*pady);
var lobs = (mousePos.x - padx1)*dx + x0;
var flux = (ysize - mousePos.y - pady)*dy + y0;
var lrest = lobs / (znow + 1.);
var str = sprintf("(%s,%s,F%s)=(%.2f%s, %.2f%s, %.2f%s)",
var dl_dx = (x1-x0)/(xsize-padx);
var dflux_dy = (y1-y0)/(ysize-2.*pady);
var lobs = (mousePos.x - padx1)*dl_dx + x0;
var flux = (ysize - mousePos.y - pady)*dflux_dy + y0;
//https://en.wikipedia.org/wiki/AB_magnitude
var Jy = 3.34e4*(lobs*lobs)*flux*1e-17;
var AB = -2.5*Math.log10(Jy/3631.);
var lrest = lobs / (znow + 1.);
var str = sprintf("(%s,%s,F%s,AB)=(%.2f%s, %.2f%s, %.2f%s, %.2f)",
String.fromCharCode(955,8338), String.fromCharCode(955,7523), String.fromCharCode(955),
lobs,String.fromCharCode(8491),lrest,String.fromCharCode(8491),flux,
String.fromCharCode(215)+"10"+String.fromCharCode(8315,185,8311)+" erg cm"+String.fromCharCode(8315,178) +" s"+ String.fromCharCode(8315,185) + " " + String.fromCharCode(8491,8315,185));
ctx.clearRect (xsize-44.*padx2, ysize-0.6*pady, xsize, ysize);
ctx.fillText(str, xsize-22.*padx2, ysize-0.2*pady);
String.fromCharCode(215)+"10"+String.fromCharCode(8315,185,8311)+" erg cm"+String.fromCharCode(8315,178) +" s"+ String.fromCharCode(8315,185) + " " + String.fromCharCode(8491,8315,185), AB);
ctx.clearRect (xsize-47.*padx2, ysize-0.6*pady, xsize, ysize);
ctx.fillText(str, xsize-23.*padx2, ysize-0.2*pady);
}
}
else
......
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