npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

maka-netcdf

v0.0.2

Published

First Pass

Downloads

6

Readme

netcdfjs

NPM version build status Test coverage npm download

Read and explore NetCDF v3 files.

Installation

$ npm install netcdfjs

API Documentation

For further information about the grammar you should go to this link.

Example I: NodeJS

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>
// You could use the oficial CDN: <script src='http://www.lactame.com/lib/netcdfjs/0.3.0/netcdfjs.min.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

Example III: Client side file upload

This example creates a file input element and allows the user to select a file from their personal machine.

var reader;
var progress = document.querySelector('.percent');
function abortRead() {
  reader.abort();
}

function handleFileSelect(evt) {
  // Reset progress indicator on new file selection.
  progress.style.width = '0%';
  progress.textContent = '0%';

  reader = new FileReader();
  reader.onerror = errorHandler;
  reader.onprogress = updateProgress;
  reader.onabort = function(e) {
    alert('File read cancelled');
  };
  reader.onloadstart = function(e) {
    document.getElementById('progress_bar').className = 'loading';
  };
  reader.onload = function(e) {
    // Ensure that the progress bar displays 100% at the end.
    progress.style.width = '100%';
    progress.textContent = '100%';
    setTimeout("document.getElementById('progress_bar').className='';", 2000);
    //var reader = new NetCDFReader(reader.result);

    //replace reader with NetCDF reader
    reader = new netcdfjs(this.result);
    reader.getDataVariable('wmoId'); // go to offset and read it

    //... your program here  ..//
  };
  reader.readAsArrayBuffer(evt.target.files[0]);
}

// Make input element <input type="file" id="files" name="file" />
var input = document.createElement('input');
input.id = 'files';
input.type = 'file';
input.className = 'file';
document.body.appendChild(input); // put it into the DOM

// Make a Progress bar <div id="progress_bar"><div class="percent">0%</div></div>
var progress = document.createElement('div');
progress.id = 'progress_bar';
inner = document.createElement('div');
inner.className = 'percent';
inner.id = 'innerdiv'; // set the CSS class
progress.appendChild(inner);
document.body.appendChild(progress); // put it into the DOM

//Start event listener to check if a file has been selected
run = document
  .getElementById('files')
  .addEventListener('change', handleFileSelect, false);

///Progress bar and other functions
function errorHandler(evt) {
  switch (evt.target.error.code) {
    case evt.target.error.NOT_FOUND_ERR:
      alert('File Not Found!');
      break;
    case evt.target.error.NOT_READABLE_ERR:
      alert('File is not readable');
      break;
    case evt.target.error.ABORT_ERR:
      break;
    default:
      alert('An error occurred reading this file.');
  }
}

function updateProgress(evt) {
  // evt is an ProgressEvent. Updates progress bar
  if (evt.lengthComputable) {
    var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
    // Increase the progress bar length.
    if (percentLoaded < 100) {
      progress.style.width = percentLoaded + '%';
      progress.textContent = percentLoaded + '%';
    }
  }
}

License

MIT