source: DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/ukcip02.py @ 3565

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

Uses new ows_common interface. Works with Cadcorp (at least partially).

Line 
1"""
2Load UKCIP02 data
3
4"""
5
6import os
7from glob import glob
8
9from pylons import config
10from ukcip_server.model.pywms.wms_cdms import CdmsBNGGrid
11from ukcip_server.model.pywms.impl import CdmsLayer
12from ows_common.service.wms_iface import ILayerMapper
13
14import cdms2 as cdms
15
16import logging
17log = logging.getLogger(__name__)
18
19
20class UKCIP02LayerMapper(ILayerMapper):
21    def __init__(self):
22        self.dataFile = config['ukcip02.data']
23        log.debug('Input data set to set to %s' % self.dataFile)
24
25    def map(self, **kwargs):
26        # Ignore kwargs
27        ds = cdms.open(self.dataFile)
28       
29        layers = {}
30        for varName in ds.listvariables():
31            log.debug('Found layer %s' % varName)
32            #!TODO: Min/Max values
33            layers[varName] = CdmsLayer(ds[varName], GridClass=CdmsBNGGrid)
34
35        return layers
36
Note: See TracBrowser for help on using the repository browser.