GithubHelp home page GithubHelp logo

neutrons / webanalysis Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 1.0 11.98 MB

Web Data Analysis for Small Angle Neutron Scattering (SANS) and Neutron Triple-Axis Spectrometry (TAS)

JavaScript 33.39% HTML 28.09% Python 0.56% Vue 37.88% CSS 0.08%
vuejs neutrons sans task vuetifyjs

webanalysis's Introduction

sns-vuetify

Data visualization application for SANS data.

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

# run unit tests
npm run unit

# run e2e tests
npm run e2e

# run all tests
npm test

For detailed explanation on how things work, checkout the guide and docs for vue-loader.

vuetify-plotfit

webanalysis's People

Contributors

nguernse avatar ricleal avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ricleal

webanalysis's Issues

Users Feedback

The users tested this on reduction.sns.gov

  • Tagging not working in browsing data

  • Edit equation not working

  • Exclude points from fitting (delete points like we did for SANS)

  • Rename 'Chart' to 'Plot' in export and reset

  • File fields (drop downs) not intuitive. Can we Have text on them? Like this:
    image

  • Hide the LM settings in it's own separator (should be hidden when the Fit Configuration is selected).

  • Options to customise the plot?? Eventually create a PlotLy of it because once you have a plotly you can edit it...
    I would have a button saying generate plotly and open in a new window a simple plotly plot with a link Edit chart ». See:
    https://codepen.io/plotly/pen/LVMRMO
    https://codepen.io/plotly/pen/epdjem
    Note the {showLink: true} in Plotly.newPlot which generates the Edit chart » link. This a way to send the users to plotly and then they can edit/format the plot.

  • Title Graph Data instead of Fit Data

  • Shall we add fitting to the legend box? ("Fit" name?)

Garret suggestions

  • 1) How do I choose a different experiment?
    The first question I suspect is how do I try this with my data? Ric: I'll do that

  • 2) Let’s put Error bars on the browser plot Ric: sqrt(y)

  • 3) I’d like to be able to see the metadata and the plot without having to scroll up and down.
    Could we make it so you could drag the plot area smaller to do this?
    Ric:

  • Tooltip in the > saying they can use the cursor.

  • Show data and metadata in different tabs

  • Use dedicated scroll bars for these panels

  • Split Key=Value by = and create a striped table.

  • 4) Does the export chart work on the fit ?

  • 5) When browsing data the transitions between scans is a little to fancy.
    I want to understand what it is trying to convey, but it does not mean anything. I would just blank and then redraw the plot.

  • 6) Do the tags work?

  • 7) On the fit metadata, the reduced chi^2 and the uncertainty on each parameter should be available.
    Ric I will do that

  • 8) on the browse data, they like to see the full data file with the plot.
    Ric: Same as point 3 (data table tab)

  • 9) let’s work though the combine data tab. Ric: See graffiti operations on the data: sum + subtraction.

  • 10) let’s add a lorentzian squared to the fit functions:
    Ric: Normal lorentzian: A * ( (fwhm/2) / ( (x-center)**2 + (fwhm/2)**2 ) ) squared A * ((fwhm/2) / ((x-center)**2 + (fwhm/2)**2))**2. Note that the Amplitude is not squared.

By the way Masa really likes being able to download the fitted curve and to be able to select a range to fit

Score

For the scores calculation I get this code working:

var levenbergMarquardt = require('ml-levenberg-marquardt');

function linearFit(m, b) { return (t) => (m * t + b); }

var data = {
  x : [
    0.005, 0.01,  0.015, 0.02,  0.025, 0.03,  0.035, 0.04,  0.045,
    0.05,  0.055, 0.06,  0.065, 0.07,  0.075, 0.08,  0.085, 0.09,
    0.095, 0.1,   0.105, 0.11,  0.115, 0.12,  0.125, 0.13,  0.135,
    0.14,  0.145, 0.15,  0.155, 0.16,  0.165, 0.17,  0.175
  ],
  y : [
    1.059053, 0.820483, 0.889606, 0.695512, 0.578699, 0.527058, 0.541055,
    0.585198, 0.484689, 0.513663, 0.412635, 0.380731, 0.351293, 0.324131,
    0.29907,  0.271001, 0.25461,  0.234924, 0.21676,  0.216298, 0.184536,
    0.177404, 0.145856, 0.124078, 0.121299, 0.123407, 0.126478, 0.110142,
    0.096938, 0.091407, 0.086616, 0.076146, 0.072392, 0.071292, 0.060748
  ]
};

const options = {
  damping : 0.01,
  initialValues : [ 1, 3 ],
  gradientDifference : 10e-2,
  maxIterations : 100,
  errorTolerance : 10e-3
};

var result = levenbergMarquardt(data, linearFit, options);

/**
 * Return the correlation coefficient of determination (r) and chi-square.
 * From: https://github.com/mljs/regression-base
 */
function score(x, y, func) {
  if (!Array.isArray(x) || !Array.isArray(y) || x.length !== y.length) {
    throw new Error('x and y must be arrays of the same length');
  }

  const n = x.length;
  const y2 = new Array(n);
  for (let i = 0; i < n; i++) {
    y2[i] = func(x[i]);
  }

  let xSum = 0;
  let ySum = 0;
  let chi2 = 0;
  let rmsd = 0;
  let xSquared = 0;
  let ySquared = 0;
  let xY = 0;
  for (let i = 0; i < n; i++) {
    xSum += y2[i];
    ySum += y[i];
    xSquared += y2[i] * y2[i];
    ySquared += y[i] * y[i];
    xY += y2[i] * y[i];
    if (y[i] !== 0) {
      chi2 += (y[i] - y2[i]) * (y[i] - y2[i]) / y[i];
    }
    rmsd = (y[i] - y2[i]) * (y[i] - y2[i]);
  }

  const r =
      (n * xY - xSum * ySum) /
      Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));

  return {r : r, r2 : r * r, chi2 : chi2, rmsd : rmsd * rmsd / n};
}

console.log(score(data.x, data.y,
  linearFit(result.parameterValues[0],result.parameterValues[1])))

The output is:

{ r: 0.9224225595952691,
  r2: 0.8508633784502877,
  chi2: 1.379485806515711,
  rmsd: 0.00000900976317247731 }

The idea is to add the function score to the code with the initial x and y and pass as func the actual fitting function and the parameters that LM found.

Those 4 parameters (only with 3 decimal digits) have to be showed after the fitting. E.g. an additional line after fitting error...

A few things for TAS when testing

  • - M. Lumsden saw the experiment file names, but only saw 403 errors rather than plots.
  • - On the fitting tab, it should default to the default x rather than pt on the x axis
  • - Even if I change the X axis to something other than pt it does not fit properly with that axis.

TODO

  • Fetch Data needs some information saying the fetch was successful

  • In the fitting I should be able to draw a curve without pressing enter and refitting

  • The Graph axis are wrong. They should change according to the Axes chose.

  • Fields should be called Axes

  • Default rows per table = 100

  • Values in the fitting should be picked in the plot (using mouse clicking)

  • tagging not working in TAS?

  • Fitting should be done only on clicking Fit (rename re-fit to fit?). button should be greyed out (?) while fitting. Increasing number of iterations you will see the fitting is much slower... See web workers!

  • Home (landing?) page with links for the several options.

  • Change iterations range. From 10 to 1000

  • When picking the coordinates from the plot all fields change to (X). Can we have that only for the field that we are picking the value? Also looks like when we are editing values all of them turn to (X):

image

  • If the parameter fetch is the the url, for example:
    http://localhost:8080/#/TAS-Browse?fetch=/external/fetch/tas
    Fetch the data automaticcly from that URL. No need to click fetch.

  • In the Browse data link arrow keys < and > with the next and previous file.
    image

  • Revise store (state management) structure. Main groups SANS & TAS. Nest modules beneath: Browse, Stitch, Fit, etc.

More stuff...

  • In TAS -> Browse Data - > Data can we add a footer with: average and standard deviation

  • Correct the files that are not rendering (Scan 11 for example)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.