RastonLab / Virtual-HeNDI-Spectrometer

Helium NanoDroplet Isolation - Scientific Instrument Simulator (HeNDI-SIS)
https://hendi.rastonlab.org/
GNU General Public License v3.0
0 stars 3 forks source link

Recreate interpolation Python program in JavaScript #37

Closed vanfossen closed 2 years ago

vanfossen commented 2 years ago

V0 (Isaac's Prototype)

  1. When run spectrum us clicked, send the temperature, min and max wave # to server
  2. server runs python script that: determines if temp is exactly one of the data files, or else if it false between 2 data files (anything else is an error) a. if it's exactly, one of the files, server returns the plot/data/points b. if it's between, the server does weighted average of the values and then returns (responds with) the plot/data/points
  3. browser gets the points back and gives them to the plot component that makes an interactive chart

V1 (Our Implementation)

  1. on the client side, know what the 4 actually measured temperatures are
  2. when the user clicks run, first determine if they asked for exactly a measured temp or else one that's in between (requiring interpolation)
  3. if it's exact, request that 1 data file from the server (via fetch or whatever)
  4. if it's in between, request the 2 bounding data files
  5. once you have received the file or 2 files, do the interpolation if necessary, and hand the data to the plot component

POC milestones:

  1. when button is clicked, print either a url like the following because user chose exactly the temp we have data for or else print 2 of these urls, the 2 that bound their temp https://raw.githubusercontent.com/RastonLab/Virtual-HeNDI-Spectrometer/main/interpolator/spectra/OCS_13.5K.dat
  2. instead of console.log, fetch the url(s) (console.log response)
  3. instead of logging the response, either give the data to the plot component (for the 1 url case) or calculate the data via interpolation for the 2 URL case, and hand it to the plot component

Interpolation Calculation Example

Ta=4
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109

Tb=10
0 1500
1 1501
2 1502
3 1503
4 1504
5 1505
6 1506
7 1507
8 1508
9 1509

Tr=5
0 interpolatedVal(0) # 333.333
1 interpolatedVal(1)
2 ...
3
4
5
6
7
8
9

deltaT = tb-ta # 6
normalizeTR = Tr - Ta # 1
scalingFactor = normalizeTr/delta # 1/6
interpolatedVal = Ta(x) + ( Tb(x) - Ta(x) ) * scalingFactor # 333
vanfossen commented 2 years ago

From 6/15/2022 standup --> for each of 4 data files, note the min and max wave number that it has so that during interpolation the script will know the range to use

vanfossen commented 2 years ago

Repository I used for/during testing: https://github.com/VanFossen/raston-hendi-interpolation