mirror of
https://github.com/cheminfo/netcdfjs.git
synced 2026-01-25 16:07:08 +00:00
Updated example for use in client side computing over an node run server.
netcdfjs
Read and explore NetCDF files
Installation
$ npm install netcdfjs
API Documentation
For further information about the grammar you should go to this link.
Example
const fs = require('fs');
const NetCDFReader = require('netcdfjs');
// http://www.unidata.ucar.edu/software/netcdf/examples/files.html
const data = fs.readFileSync('madis-sao.nc');
var reader = new NetCDFReader(data); // read the header
reader.getDataVariable('wmoId'); // go to offset and read it
Example II: Load from URL (does not require node)
// First load the netcdfjs library as normal : <script src='./dist/netcdfjs.js'></script>
var urlpath = "http://www.unidata.ucar.edu/software/netcdf/examples/madis-sao.nc"
var reader;
var oReq = new XMLHttpRequest();
oReq.open("GET", urlpath, true);
oReq.responseType = "blob";
oReq.onload = function(oEvent) {
var blob = oReq.response;
reader_url = new FileReader();
reader_url.onload = function(e) {
reader = new netcdfjs(this.result);
}
reader_url.readAsArrayBuffer(blob);
};
oReq.send(); //start process
reader.getDataVariable('wmoId'); // go to offset and read it
License
Description
Languages
nesC
63.4%
Mathematica
36.2%
JavaScript
0.4%