Ignore:
Timestamp:
25/01/08 14:05:32 (12 years ago)
Author:
domlowe
Message:

Documenting CSML code - not complete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/API/genSubset.py

    r3068 r3267  
    1 '''#getSubset.py contains generic subsetting code that can be reused for multiple features 
     1'''getSubset.py contains generic subsetting code that can be reused for multiple features 
    22Dominic Lowe, CCLRC, 31/01/2007''' 
    33 
     
    88 
    99def checkNeighbours(domain, **kwargs): 
    10     #for any non-range requests, get nearest neighbour 
    11     #e.g if 'latitude': (11) requested, latitude=12 may be the nearest value 
     10    ''' 
     11    Compares a subset request (kwargs) to the feature domain and gets nearest neighbour 
     12    e.g if 'latitude': (11) requested, latitude=12 may be the nearest value, calls nudgeSingleValuesToAxisValues 
     13    @param domain:   dictionary 
     14    @param kwargs: dictionary 
     15    returns:    modified kwargs 
     16     
     17    ''' 
    1218    for key in kwargs: 
    1319        #handle single values 
     
    3137def subsetDomain(timeaxis,times, domain,**kwargs): 
    3238    '''takes the domain and returns a subset according to the keyword selection criteria 
    33     time = name of time dimension 
    34     times = string of times 
    35     '''        
     39    @param timeaxis:  name of time dimension 
     40    @param times:    string of times 
     41    @param domain:     feature domain dictionary 
     42    @param kwargs:      keyword selection 
     43    @return:    subsetted domain (dictionary) and a totalArraySize (integer) 
     44   '''        
    3645    #reduce requests with same max and min eg (45,45) down to single value. 
    3746    for kw in kwargs: 
     
    133142 
    134143def _getTimes(timeSelection, timeName, domain): 
     144    ''' Given a selection of times (min_t, max_t) or (t1, t2, t3,...tn) or just 't' and the name of the time axis in the CRS, and the domain, returns subset of times 
     145    @param timeSelection:  times - in one of 3 forms: (min_t, max_t) or (t1, t2, t3,...tn) or just 't'  
     146    @param timeName:      name of the time axis 
     147    @param domain:        the domain dictionary 
     148    @return:     subset of times. e.g if a range is selected, returns all the times in that range. Times are correctly formatted. 
     149    ''' 
    135150    #currently supporting domain subsetting only by CRS name  
    136151    #(but should be easy to extend later) 
     
    162177 
    163178def _getTimeToFileRatio(feature,domain, timeName): 
     179    ''' Calculates the ratio of times to files... i.e are there 5 times in each data file? 500 times?  
     180    @param feature: a feature instance 
     181    @param domain: the domain dictonary 
     182    @param timeName: the name of the time axis in the domain dictionary 
     183    @return:    ratio of times to files (integer) 
     184    ''' 
     185     
    164186    if hasattr(feature.value.rangeSet, 'valueArray'): 
    165187        if hasattr(feature.value.rangeSet.valueArray.valueComponent, 'insertedExtract'):             
     
    177199 
    178200def getCoordTransformTable(domainSubset, crs, frame): 
     201    ''' 
     202    Given a domainSubset and a crs and a temporal reference fram returns a csml.parser.coordTransformTable object 
     203    @param domainSubset:    dictionary 
     204    @param crs:    a crs identifier 
     205    @param frame:      a temporal reference system identifier 
     206    ''' 
    179207    cTT=csml.parser.GridCoordinatesTable() 
    180208    ords =[] 
     
    204232 
    205233def getTheData(feature, selection, times,timeName, timeAxis): 
     234    ''' 
     235    Wraps a lot of the detail involved in making a request for data 
     236    @param feature:    a feature instance 
     237    @param selection:    the selection object 
     238    @param times:       the times to select 
     239    @param timeName:     the name of the time axis 
     240    @param timeaxis: TODO REMOVE THIS. 
     241    @return:  times, axisorder, units, fulldata, fillvalue, where fulldata contains the actual data array, and the rest is ancilliary info about the data. 
     242    ''' 
     243     
    206244    #SOME OF THIS SHOULD PROBABLY BE IN THE DATA IO LAYER 
    207245    #add time range back into the selection  
     
    245283                except: 
    246284                    files.append(comp.fileName.CONTENT) 
    247                  
    248  
    249              
    250285            if fulldata is None: 
    251286                fulldata=data 
     
    262297 
    263298def genericSubset(feature, outputdir, ncname, domain, kwargs): 
     299    '''  
     300    High level wrapper method for subsetting features, calls most of the other functions in this module. 
     301    @param feature:   a feature instance 
     302    @param outputdir:    outputdir to write files 
     303    @param  ncname:    name of netcdf file to create 
     304    @param domain:      domain of feature(dictionary) 
     305    @param kwargs:       subset request (dictionary) 
     306    ''' 
     307     
    264308    if outputdir is not None: 
    265309        pathToSubsetNetCDF=outputdir+'/' +ncname 
Note: See TracChangeset for help on using the changeset viewer.