source: DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/config/ukcip02.py @ 3360

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/config/ukcip02.py@3360
Revision 3360, 568 bytes checked in by spascoe, 13 years ago (diff)

Quick import of code I have been working on to server ukcip02 data.
This code may well move soon.

Line 
1"""
2Load UKCIP02 data
3
4"""
5
6import os
7from glob import glob
8
9from pylons import config, g
10from ukcip02.model.wms_cdms import SimpleCdmsLayer
11
12import cdms
13
14def load_data():
15    data_dir = config['ukcip02.data_dir']
16
17    layers = {}
18    datasets = {}
19    for f in glob(os.path.join(data_dir, '*.nc')):
20        ds = cdms.open(f)
21        for varName in ds.listvariables():
22            #!TODO: Min/Max values
23            layers[varName] = SimpleCdmsLayer(ds[varName], 0, 100)
24        dataset[f] = ds
25       
26    g.ukcip02_datasets = datasets
27    g.ukcip02_layers = layers
Note: See TracBrowser for help on using the repository browser.