source: TI02-CSML/trunk/Examples/ScanningStuff/determineFT.py @ 1460

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/Examples/ScanningStuff/determineFT.py@1460
Revision 1460, 1.6 KB checked in by domlowe, 15 years ago (diff)

Moving various non-core scripts etc out of scanner directory

Line 
1#!/usr/bin/env python
2#test module for implementing rules for determining feature types
3#CSML modules
4import csmllibs
5import sys
6import getopt
7
8
9def analyseVar(DI,var):
10    DI.setVariable(var)
11    axeslist=DI.getVariableAxes()
12    print 'Phenomenon: "%s%s (%d axes)' %(var, str(axeslist), len(axeslist))
13   
14def determineFeatures(filename=None, directory=None):
15    if filename is not None:
16        DI = csmllibs.csmldataiface.DataInterface()
17        DI = DI.getUnknownInterfaceType(filename)
18        DI.openFile(filename)
19        varlist= DI.getListofVariables()
20        print 'The file contains the following variables/phenomena [axes in brackets]:'
21        for var in varlist:
22            analyseVar(DI,var)
23            #do some tests
24           
25        DI.closeFile()
26    elif directory is not None:
27        #need to test for variables spanning multiple files.
28        #tests... etc
29        pass
30
31def main(optargs=None):
32
33    #Get command line arguments
34    if optargs:
35        #if called as main(args) from another python module use these args, else use
36        #sys.argv if called from command line.
37        sys.argv =optargs
38    try:
39        opts, args = getopt.getopt(sys.argv[1:], "f:d:", ["filename=", "directory="])
40    except getopt.error, msg:
41        print "Invalid options, must provide a filename, -f [filename]"
42        sys.exit()
43    direct=None
44    fileNm=None
45    for o, v in opts:
46        if o in ("-f", "--filename"):
47            fileNm = v
48        elif o in ("-d", "--directory"):
49            direct = v
50    #print 'file to test = %s'% filename
51    determineFeatures(filename = fileNm, directory=direct)
52
53if __name__=='__main__':
54    main()
Note: See TracBrowser for help on using the repository browser.