Changeset 3570 for DPPP


Ignore:
Timestamp:
10/03/08 12:58:08 (11 years ago)
Author:
spascoe
Message:

Some quick fixes to make pywms align the grid properly. WARNING: This isn't generic code and needs revising.

Location:
DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms/impl.py

    r3568 r3570  
    1111from render_imp import RGBARenderer 
    1212from matplotlib.cm import get_cmap 
     13 
     14import logging 
     15log = logging.getLogger(__name__) 
    1316 
    1417class CdmsLayer(ILayer): 
     
    2528            self.title = cdmsVar.id 
    2629 
    27         self._layer = SimpleCdmsLayer(cdmsVar, minValue=minValue, maxValue=maxValue, GridClass=GridClass) 
     30        self._layer = SimpleCdmsLayer(cdmsVar, GridClass=GridClass) 
    2831        self.abstract = None 
    2932        self.crss = [GridClass.crs] 
    3033        self.units = self._layer.units 
     34        self.minValue = minValue 
     35        self.maxValue = maxValue 
    3136 
    3237        dims = {} 
     
    6469        self.bbox = layer.getBBox(crs) 
    6570 
    66         self._renderer = RGBARenderer(renderOpts['minValue'], renderOpts['maxValue']) 
     71        self._renderer = RGBARenderer(self.layer.minValue, self.layer.maxValue) 
    6772 
    6873    def getImage(self, bbox, width, height): 
    6974        grid = self.layer._layer.selectGrid(bbox, self.dimValues) 
    7075        cmap = get_cmap(self.renderOpts.get('cmap', 'jet')) 
    71  
    7276        img = self._renderer.renderGrid(grid, bbox, width, height, cmap) 
    7377        img.save('dump.png') 
  • DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms/render_imp.py

    r3568 r3570  
    5959                           abs(pxPerGrid_y * grid.ny)))) 
    6060 
    61         # We assume the grid points represent the centre of the grid boxes 
    62         # therefore we can calculate the upper-left position of the image 
     61        #!NO: We assume the grid points represent the centre of the grid boxes 
     62        #!NO: therefore we can calculate the upper-left position of the image 
     63        # Adapted so that the grid points represent the lower left corner of grid boxes 
    6364 
    6465        # Find top-left corner of grid 
     
    8081 
    8182        # Apply half width of grid box 
    82         ox = int(cx - pxPerGrid_x / 2) 
    83         oy = int(cy - pxPerGrid_y / 2) 
     83        #ox = int(cx - pxPerGrid_x / 2) 
     84        #oy = int(cy - pxPerGrid_y / 2) 
     85        ox,oy = int(cx), int(cy-pxPerGrid_y) 
    8486        logger.debug('Offset: %s x, %s y' % (ox, oy)) 
    8587 
  • DPPP/ukcip02_server/trunk/ukcip_server/ukcip_server/model/pywms/wms_cdms.py

    r3533 r3570  
    149149 
    150150    def selectGrid(self, bbox, dimensionSpec): 
     151        """ 
     152        @warning: Hacked for UKCIP02. 
     153        @todo: replace lat/lon references with generic X/Y code. 
     154 
     155        """ 
    151156        (lon1, lat1, lon2, lat2) = bbox 
    152         sel = dict(latitude=(lat1, lat2, 'cce'), longitude=(lon1, lon2, 'cce')) 
     157        sel = dict(northings=(lat1, lat2, 'cce'), eastings=(lon1, lon2, 'cce')) 
    153158        if 'time' in self.dimensions: 
    154159            sel['time'] = self.dimensions['time'].iso2reltime(dimensionSpec['time']) 
Note: See TracChangeset for help on using the changeset viewer.