Changeset 2588 for TI05-delivery


Ignore:
Timestamp:
14/06/07 14:13:35 (12 years ago)
Author:
spascoe
Message:

Configured a custom temporary directory for CSML extracts.

Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/development.ini

    r2501 r2588  
    2121session_secret = somesecret 
    2222csml_dir = /research/home/spascoe/host/saturn/data/ddc_data/obs 
     23tmp_dir = %(here)s/data/tmp 
    2324ows_common_config = %(here)s/eg_ows_capabilities.xml 
    2425 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wms.py

    r2586 r2588  
    1010""" 
    1111from ows_server.lib.base import * 
    12 from ows_server.controllers.csml_api import get_csml_doc 
    1312from ows_server.lib.decorators import * 
    1413from ows_server.lib import grid_util, render 
    15 from ows_server.lib.csml_util import get_csml_doc 
     14from ows_server.lib.csml_util import get_csml_doc, extract 
    1615import ows_server.lib.validators as V 
    1716 
     
    2423 
    2524import cdms 
    26 import tempfile, os 
     25import os 
    2726from cStringIO import StringIO 
    2827import MA 
     
    151150            except KeyError: 
    152151                raise OWS_E.MissingParameterValue('%s dimension not specified' % dim, dim) 
    153              
    154         # Subset the feature 
    155         (fd, filename) = tempfile.mkstemp('.nc', 'csml_wms_'); os.close(fd) 
    156         feature.subsetToGridSeries(ncname=os.path.basename(filename), 
    157                                    outputdir=os.path.dirname(filename), 
    158                                    time=sel['time'] # workarround for CSML bug 
    159                                    #**sel 
    160                                    ) 
    161         d = cdms.open(filename) 
    162         #var = d(feature.name.CONTENT, squeeze=1) 
    163         var = d(feature.name.CONTENT, longitude=sel['longitude'], latitude=sel['latitude'], 
    164                 squeeze=1) 
     152 
     153        # Extract via CSML.subsetToGridSeries() 
     154        var = extract(feature, sel) 
    165155         
    166156        # Deduce min and max 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/csml_util.py

    r2529 r2588  
    1010from pylons import Response, c, g, cache, request, session 
    1111 
    12 import csml 
     12import csml, cdms 
    1313import os 
    1414import zipfile 
     15import tempfile 
    1516 
    1617def get_csml_doc(file): 
     
    3637         
    3738    return d 
     39 
     40 
     41def extract(feature, sel): 
     42    # Get temporary extract dir 
     43    extract_dir = request.environ['paste.config']['app_conf']['tmp_dir'] 
     44     
     45    # Subset the feature 
     46    (fd, filename) = tempfile.mkstemp('.nc', 'csml_wms_', extract_dir); os.close(fd) 
     47    feature.subsetToGridSeries(ncname=os.path.basename(filename), 
     48                               outputdir=os.path.dirname(filename), 
     49                               time=sel['time'] # work around for CSML bug 
     50                               #**sel 
     51                               ) 
     52    d = cdms.open(filename) 
     53    #var = d(feature.name.CONTENT, squeeze=1) 
     54    # Work around for CSML bug 
     55    var = d(feature.name.CONTENT, longitude=sel['longitude'], latitude=sel['latitude'], 
     56            squeeze=1) 
     57 
     58    d.close() 
     59    os.remove(filename) 
     60 
     61    return var 
    3862         
    3963class CsmlBundle(csml.API.csmlContainer.Container): 
Note: See TracChangeset for help on using the changeset viewer.