###To prodce a standardised ascii data set for use in a SOM###

1. First extract the data from NCEP into a .dat file as usual using grads (have a look at extractForSTD.scr)

2. The c code: Tweak if you need to ExtractAndSTD.c at lines 7 to 11, this includes:
   - Setting the lat/lon (NLAT/NLON is the number of grids in the lat and lon)
   - Set the start date
   

3.  Then Compile the ExtractandSTD.c using cc or gcc.
    	

4a. To run the compiled script like so:
   (Have a look at ExtractAndSTD.scr)
  
  Usage:a.out input.file output.file latmin latmax lonmin lonmax [date tinc(hrs) leap/not(0/1) months
    input.file - your grads file that was extracted from ncep, but without the '.dat' (see the ExtractAndSTD.scr)
    output.file - name of output file, I kept it the same as the input file but added a STD so I could differentiate
    date - startdate
    tinc - time increment in hours
    leap - set to 0 to account for leap years, 1 not to
    months - the months you want, so 1 for only Jan; 1 2 3...12 for the whole year

  Do this for each variable you will use in the SOM but have a look at ExtractAndSTD.scr for an example, 
  this is for a whole host of variables.

4b. This will produce 3 types of files: 
   .dte (dates for each day used to train the SOM)
   .log (log file, cunningly named)
   .txt (standardised data file, which you use in the SOM)

   NB: remember to add in the first line of the file you are using to train the SOM the rowlength!


5. If you are using multiple variables to train the SOM (I used 12), you need to combine the seperate datasets 
   into one big one with all the variables per day on one line. For this use CJ's python script, MergeVariables.py 
   You will need to edit the script for the number of variables you have, so if 
   you have 2 files you only need file1, file2 and lines1, lines 2 etc (and there is 
   no comma at the end of the print line)

   Use it like so:
   python MergeVariables.py > all.variables.asc
   
   NB: remember to add in the first line of the file you are using to train the SOM the rowlength!

   
   
   

   
