-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from desihub/disp-models
Summary of new features from this branch: - display "second model" which can be the Nth best fit, or standard templates - table with redrock results shows N best fits - ivar-weighting when smoothing - imaging cross-hair - line list - several bug fixes + code restructure - new widgets (eg "standard VI comments") + widget layout
- Loading branch information
Showing
19 changed files
with
1,350 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ distribute-*.tar.gz | |
.DS_Store | ||
|
||
# data directory | ||
data | ||
#data | ||
|
||
# Generated HTML | ||
plotframes.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Utility javascript function | ||
// (Standalone module) | ||
|
||
// Return array of string values | ||
function CSVtoArray(text) { | ||
var re_value = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g | ||
var a = [] | ||
text.replace(re_value, // "Walk" the string using replace with callback. | ||
function(m0, m1, m2, m3) { | ||
// Remove backslash from \' in single quoted values. | ||
if (m1 !== undefined) a.push(m1.replace(/\\'/g, "'")) | ||
// Remove backslash from \" in double quoted values. | ||
else if (m2 !== undefined) a.push(m2.replace(/\\"/g, '"')) | ||
else if (m3 !== undefined) a.push(m3) | ||
return '' // Return empty string. | ||
}) | ||
// Handle special case of empty last value. | ||
if (/,\s*$/.test(text)) a.push('') | ||
return a | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Utility javascript function used in CustomJS callbacks | ||
// (Standalone module) | ||
|
||
function adapt_plotrange(pmin, pmax, data) { | ||
// Used to adapt plotting range to a data vector | ||
|
||
// copy before sorting to not impact original, and filter out NaN | ||
var dx = data.slice().filter(Boolean) | ||
dx.sort() | ||
var imin = Math.floor(pmin * dx.length) | ||
var imax = Math.floor(pmax * dx.length) | ||
|
||
return [dx[imin], dx[imax]] | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Utility javascript function used in CustomJS callbacks | ||
// Requires to include functions in: interp_grid.js | ||
|
||
function coadd_brz_cameras(wave_in, flux_in, noise_in) { | ||
// Camera-coadd brz spectra. | ||
// each "_in" must have 3 entries (brz) | ||
// TODO handle case of no noise | ||
|
||
// Find b,r,z ordering in input arrays | ||
var wave_start = [wave_in[0][0], wave_in[1][0], wave_in[2][0]] | ||
var i_b = wave_start.indexOf(Math.min.apply(Math, wave_start)) | ||
var i_z = wave_start.indexOf(Math.max.apply(Math, wave_start)) | ||
var i_r = 1 | ||
for (var i=0; i<3; i++) { | ||
if ( (i_b != i) && (i_z != i) ) i_r = i | ||
} | ||
|
||
var wave_out = [] | ||
var flux_out = [] | ||
var noise_out = [] | ||
var margin = 20 | ||
for (var i=0; i<wave_in[i_b].length; i++) { // b | ||
if (wave_in[i_b][i] < wave_in[i_b][wave_in[i_b].length-1] - margin) { | ||
wave_out.push(wave_in[i_b][i]) | ||
flux_out.push(flux_in[i_b][i]) | ||
noise_out.push(noise_in[i_b][i]) | ||
} | ||
} | ||
var the_lim = wave_out[wave_out.length-1] | ||
for (var i=0; i<wave_in[i_r].length; i++) { // r | ||
if ( (wave_in[i_r][i] < wave_in[i_r][wave_in[i_r].length-1] - margin) && (wave_in[i_r][i] > the_lim)) { | ||
wave_out.push(wave_in[i_r][i]) | ||
flux_out.push(flux_in[i_r][i]) | ||
noise_out.push(noise_in[i_r][i]) | ||
} | ||
} | ||
the_lim = wave_out[wave_out.length-1] | ||
for (var i=0; i<wave_in[i_z].length; i++) { // z | ||
if (wave_in[i_z][i] > the_lim) { | ||
wave_out.push(wave_in[i_z][i]) | ||
flux_out.push(flux_in[i_z][i]) | ||
noise_out.push(noise_in[i_z][i]) | ||
} | ||
} | ||
for (var i=0; i<wave_out.length; i++) { // combine in overlapping regions | ||
var b1 = -1 | ||
var b2 = -1 | ||
if ( (wave_out[i] > wave_in[i_r][0]) && (wave_out[i] < wave_in[i_b][wave_in[i_b].length-1]) ) { // br | ||
b1 = 0 | ||
b2 = 1 | ||
} | ||
if ( (wave_out[i] > wave_in[i_z][0]) && (wave_out[i] < wave_in[i_r][wave_in[i_r].length-1]) ) { // rz | ||
b1 = 1 | ||
b2 = 2 | ||
} | ||
if (b1 != -1) { | ||
var phi1 = interp_grid(wave_out[i], wave_in[b1], flux_in[b1]) | ||
var noise1 = interp_grid(wave_out[i], wave_in[b1], noise_in[b1]) | ||
var phi2 = interp_grid(wave_out[i], wave_in[b2], flux_in[b2]) | ||
var noise2 = interp_grid(wave_out[i], wave_in[b2], noise_in[b2]) | ||
if ( noise1 > 0 && noise2 > 0 ) { | ||
var iv1 = 1/(noise1*noise1) | ||
var iv2 = 1/(noise2*noise2) | ||
var iv = iv1+iv2 | ||
noise_out[i] = 1/Math.sqrt(iv) | ||
flux_out[i] = (iv1*phi1+iv2*phi2)/iv | ||
} | ||
} | ||
} | ||
return [wave_out, flux_out, noise_out] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Utility javascript functions used in CustomJS callbacks | ||
// (Standalone module) | ||
|
||
function index_dichotomy(point, grid) { | ||
// Find nearest index in grid, left from point; use dichotomy method | ||
if ( point < grid[0] ) return 0 | ||
if ( point > grid[grid.length-1] ) return grid.length-2 | ||
var i_left = 0 | ||
var i_center = 0 | ||
var i_right = grid.length-1 | ||
while ( i_right - i_left != 1) { | ||
i_center = i_left + Math.floor((i_right-i_left)/2) | ||
if ( point >= grid[i_center] ) { | ||
i_left = i_center | ||
} else { | ||
i_right = i_center | ||
} | ||
} | ||
return i_left | ||
} | ||
|
||
function interp_grid(xval, xarr, yarr) { | ||
// Basic linear interpolation of [xarr,yarr] on point xval | ||
var index = index_dichotomy(xval, xarr) | ||
var a = (yarr[index+1] - yarr[index])/(xarr[index+1] - xarr[index]) | ||
var b = yarr[index]-a*xarr[index] | ||
var yval = a*xval+b | ||
return yval | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// CustomJS, callback for the "Reset X-Y range" button | ||
// - Requires to include function in: adapt_plotrange.js | ||
// - args = fig, xmin, xmax, spectra | ||
|
||
// x-range : use fixed x-range determined once for all | ||
fig.x_range.start = xmin | ||
fig.x_range.end = xmax | ||
|
||
var ymin = 0.0 | ||
var ymax = 0.0 | ||
for (var i=0; i<spectra.length; i++) { | ||
var data = spectra[i].data | ||
var tmp = adapt_plotrange(0.01, 0.99, data['plotflux']) | ||
ymin = Math.min(ymin, tmp[0]) | ||
ymax = Math.max(ymax, tmp[1]) | ||
} | ||
if(ymin<0) { | ||
fig.y_range.start = ymin * 1.4 | ||
} else { | ||
fig.y_range.start = ymin * 0.6 | ||
} | ||
fig.y_range.end = ymax * 1.4 |
Oops, something went wrong.