Skip to content

How to Use It? #2

@jamiejackson

Description

@jamiejackson

I can't find much documentation on this and the README is both bare-bones and pretty opaque. A real-world use case would help.

The following is my naive attempt. I know it's wrong but it will be useful to show what I need. Also note that the grid spacing of the known data is not even. (By the way, here is my working example using python.)

I am also interested in extrapolating values outside of the known data bounds. Is the ndarray-linar-interpolate library capable of that?

var ndarray = require("ndarray");
var interp = require("ndarray-linear-interpolate");

// Create the 2D ndarray object from the given data
// The first column is "diameter in inches" and the first row is "psi"
// The first cell (A:1)is a dummy value
var data = ndarray(new Float32Array([
  0, 60, 120, 240, 360, 480,
  4, 71, 100, 142, 173, 200,
  6, 106, 150, 212, 260, 300,
  8, 142, 200, 283, 347, 400 ,
  10, 177, 250, 354, 433, 500,
  12, 212, 300, 425, 520, 601,
  14,  248, 350, 495, 607, 701,
  16,  283, 400, 566, 693, 801,
  18,  318, 450, 637, 780, 901,
  20,  354, 500, 708, 867, 1001,
  22,  389, 550, 779, 953, 1101
]), [10,6]);

console.log(interp(data, 4.1, 61)); // x=4.1 inches, y=61 psi. expect a value of a little over 72 but it returns 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions