dbetke / js-normals

javascript program for parsing climate data normals from a dataset for NEMAC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JS-Normals

A javascript program for parsing climate data normals from NOAA's 1981-2010 datasets.

Installation

Clone this repository and add any desired NOAA datasets to the Data directory. Load the data file as text, then use the generateNormals function to process the data.

See test.html for an example.

Usage

The object is returned with meta data (the station information) and the normals data. The format is as follows:

obj.meta = {
              'Station Name' : '',
              'GHCN Daily ID' : '',
              'Latitude' : '',
              'Longitude' : '',
              'Elevation' : ''
           }
           
obj.data = {  
              header :  {  
                          subheader : { 
                                        description : // either an object, 
                                                      //an array containing an object, 
                                                      //or a nested array of arrays containing objects
                                      }
                        }
           }
           
/****************************************************  
 *  header example: 'Temperature-Related Normals',  * 
 *  subheader example: 'Daily',                     * 
 *  description example: 'dly-tmax-normal'          *
 ****************************************************/

Examples

When parsing the USC00230657.normals.txt stored in the Data directory, these are some examples of the data which can be accessed.

Accessing meta data :

From lines 1 and 2 of the data file

obj.meta['Station Name'] //will return 'MO BILLINGS 1SW'
obj.meta['HCN Daily ID'] //will return 'USC00230657'

Accessing monthly data :

mly-tmax-normal for Jan from line 11 of the data file

obj.data['Temperature-Related Normals']['monthly']['mly-tmax-normal'][0].value //will return 446
obj.data['Temperature-Related Normals']['monthly']['mly-tmax-normal'][0].flag //will return C

Accessing daily data :

dly-tmax-normal for Jan 1st from line 54 of the data file

obj.data['Temperature-Related Normals']['Daily']['dly-tmax-normal'][0][0].value //will return 438
obj.data['Temperature-Related Normals']['Daily']['dly-tmax-normal'][0][0].flag //will return C

Accessing annual/seasonal data :

ann-tmax-normal from line 399 of the data file

obj.data['Temperature-Related Normals']['Annual/Seasonal']['ann-tmax-normal'].value //will return 686
obj.data['Temperature-Related Normals']['Annual/Seasonal']['ann-tmax-normal'].flag //will return R

Additional Resources

For information regarding how to read the climate data normals, including what the flags mean, reference NOAA's README file.

About

javascript program for parsing climate data normals from a dataset for NEMAC


Languages

Language:JavaScript 100.0%