netcdfjs
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 = ;const NetCDFReader = ; // http://www.unidata.ucar.edu/software/netcdf/examples/files.htmlconst data = fs; var reader = data; // read the headerreader; // 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 = ;oReq;oReqresponseType = 'blob'; oReq { var blob = oReqresponse; reader_url = ; reader_url { reader = thisresult; }; reader_url;};oReq; //start process reader; // 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; { reader;} { // Reset progress indicator on new file selection. progressstylewidth = '0%'; progresstextContent = '0%'; reader = ; readeronerror = errorHandler; readeronprogress = updateProgress; reader { ; }; reader { documentclassName = 'loading'; }; reader { // Ensure that the progress bar displays 100% at the end. progressstylewidth = '100%'; progresstextContent = '100%'; ; //var reader = new NetCDFReader(reader.result); //replace reader with NetCDF reader reader = thisresult; reader; // go to offset and read it //... your program here ..// }; reader;} // Make input element <input type="file" id="files" name="file" />var input = document;inputid = 'files';inputtype = 'file';inputclassName = 'file';documentbody; // put it into the DOM // Make a Progress bar <div id="progress_bar"><div class="percent">0%</div></div>var progress = document;progressid = 'progress_bar';inner = document;innerclassName = 'percent';innerid = 'innerdiv'; // set the CSS classprogress;documentbody; // put it into the DOM //Start event listener to check if a file has been selectedrun = document ; ///Progress bar and other functions { } { // evt is an ProgressEvent. Updates progress bar if evtlengthComputable var percentLoaded = Math; // Increase the progress bar length. if percentLoaded < 100 progressstylewidth = percentLoaded + '%'; progresstextContent = percentLoaded + '%'; }