Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disp models #42

Merged
merged 24 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc1d087
first version of viewer with a Select button to show a second model =…
armengau Apr 7, 2020
1023e5a
integrate modifs from redshift-handling branch (this will avoid merge…
armengau Apr 8, 2020
e82af66
debug
armengau Apr 8, 2020
4111daf
Nth fit results are displayed. Code clean
armengau Apr 10, 2020
b8a1cb3
update imaging data only when ifiberslider value changes
armengau Apr 11, 2020
05d8607
interface cosmetics
armengau Apr 11, 2020
0cb15dd
1) adapt std template rescaling to waverange [3600-9800]. 2) option -…
armengau Apr 14, 2020
92c9c2b
dummy (avoid stash)
armengau Apr 17, 2020
db2fda5
bug fix: systematically use 'var' in js code.
armengau May 1, 2020
c8c0153
1) Solve issue in interaction between select_model and update_plot ca…
armengau May 2, 2020
6354802
changed set of options to display other models. In particular, if num…
armengau May 5, 2020
37ee664
ivar-weighting when smoothing data+noise
armengau May 7, 2020
9680500
bug fix: smoothing kernel definition (missing square of nsmooth in ga…
armengau May 7, 2020
8c59439
emission/absorption line data is now in separate text files. For each…
armengau May 15, 2020
da18821
Line list updated: see https://github.com/desihub/prospect/issues/27.
armengau May 16, 2020
f210d5a
cross-hair in imaging figure + link to legacy survey viewer with mark…
armengau May 16, 2020
343478d
widget for standardised comments: their list is given in utils_specvi…
armengau May 18, 2020
06d92f4
fix issue https://github.com/desihub/prospect/issues/30
armengau May 18, 2020
1fd4b4e
code restructure: js functions to save VI (to localStorage or to csv …
armengau May 19, 2020
7368ddc
changes to output VI file format. See https://github.com/desihub/pros…
armengau May 21, 2020
cf93880
overlap_bands handling when switching single-arm/coadd. Widget layout…
armengau May 29, 2020
568a452
Camera-coadding algo in python now identical to the one used in js (f…
armengau May 29, 2020
3d640dc
Change max smoothing length. Other model: for 'STD' spectra, display …
armengau Jun 11, 2020
60f418d
Merge branch 'master' into disp-models
armengau Jun 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ distribute-*.tar.gz
.DS_Store

# data directory
data
#data

# Generated HTML
plotframes.html
20 changes: 20 additions & 0 deletions js/CSVtoArray.js
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
}
15 changes: 15 additions & 0 deletions js/adapt_plotrange.js
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]]
}

77 changes: 0 additions & 77 deletions js/autosave_vi.js

This file was deleted.

71 changes: 71 additions & 0 deletions js/coadd_brz_cameras.js
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]
}
49 changes: 0 additions & 49 deletions js/download_vi.js

This file was deleted.

29 changes: 29 additions & 0 deletions js/interp_grid.js
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
}
26 changes: 5 additions & 21 deletions js/recover_autosave_vi.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
// CustomJS, recover auto-saved VI infos from browser
// recover_vi_callback() CustomJS
// Requires to include functions in: CSVtoArray.js

// Recover auto-saved VI infos from browser's localStorage
// args = title, cds_targetinfo, vi_file_fields, ifiber,
// vi_comment_input, vi_name_input, vi_class_input, vi_issue_input, vi_issue_slabels, vi_class_labels

// 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
}

if (title in localStorage) {
var recovered_csv = localStorage.getItem(title)
var recovered_entries = recovered_csv.split("\n")
for (var j=0; j<recovered_entries.length; j++) {
var row = CSVtoArray(recovered_entries[j])
var i_spec = Number(row[0])
for (var k=1; k<row.length; k++) {
if (vi_file_fields[k-1][1].includes('VI')) {
if (vi_file_fields[k-1][1].includes('VI')) {
cds_targetinfo.data[vi_file_fields[k-1][1]][i_spec] = row[k]
}
}
Expand All @@ -46,4 +31,3 @@ if (title in localStorage) {
}
cds_targetinfo.change.emit()
}

22 changes: 22 additions & 0 deletions js/reset_plotrange.js
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