Changeset 901


Ignore:
Timestamp:
08/05/06 15:54:09 (13 years ago)
Author:
domlowe
Message:

Code to batch run scanner for multiple datagranules

Location:
TI02-CSML/trunk/Scanner
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/Scanner/csmlscan.py

    r758 r901  
    9494 
    9595 
    96  
    97 #Main program: 
    98 #*************** 
    99 #Get command line arguments 
    100 try: 
    101         opts, args = getopt.getopt(sys.argv[1:], "d:c:t:fro:h", ["directory=", "csmlfeaturetype=", "timedimension=", "filemapping=", "recursive", "outputfile=", "help"]) 
    102 except getopt.error, msg: 
    103         print "Invalid options, use --help for help" 
    104         sys.exit() 
     96def main(optargs=None): 
     97    #Main program: 
     98    #*************** 
     99    #Get command line arguments 
     100    if optargs: 
     101        #if called as main(args) from another python module use these args, else use  
     102        #sys.argv if called from command line. 
     103        sys.argv =optargs 
     104    try: 
     105            opts, args = getopt.getopt(sys.argv[1:], "d:c:t:fro:h", ["directory=", "csmlfeaturetype=", "timedimension=", "filemapping=", "recursive", "outputfile=", "help"]) 
     106    except getopt.error, msg: 
     107            print "Invalid options, use --help for help" 
     108            sys.exit() 
     109    print sys.argv 
     110    # process options 
     111    directory = None 
     112    csmlfeaturetype = 'GridSeriesFeature'   #default feature type 
     113    timedimension  = 't' 
     114    mapping = None 
     115    recursive = 0 
     116    individual = False 
     117    outputfile = 'csmloutput.xml' 
     118    for o, v in opts: 
     119            if o in ("-d", "--directory"): 
     120                    directory = v 
     121            elif o in ("-c", "--csmlfeaturetype"): 
     122                    csmlfeaturetype = v 
     123            elif o in ("-t", "--timedimension"): 
     124                    timedimension = v 
     125            elif o in ("-f", "--filemapping"): 
     126                    if v == '11': 
     127                        mapping = 'onetoone' 
     128                    elif v == '1n': 
     129                        mapping = 'onetomany' 
     130            elif o in ("-o", "--outputfile"): 
     131                    outputfile = v 
     132            elif o in ("-h", "--help"): 
     133                    print usage 
     134                    sys.exit()                           
     135                     
    105136     
    106 # process options 
    107 directory = None 
    108 csmlfeaturetype = 'GridSeriesFeature'   #default feature type 
    109 timedimension  = 't' 
    110 mapping = None 
    111 recursive = 0 
    112 individual = False 
    113 outputfile = 'csmloutput.xml' 
    114 for o, v in opts: 
    115         if o in ("-d", "--directory"): 
    116                 directory = v 
    117         elif o in ("-c", "--csmlfeaturetype"): 
    118                 csmlfeaturetype = v 
    119         elif o in ("-t", "--timedimension"): 
    120                 timedimension = v 
    121         elif o in ("-f", "--filemapping"): 
    122                 if v == '11': 
    123                     mapping = 'onetoone' 
    124                 elif v == '1n': 
    125                     mapping = 'onetomany' 
    126         elif o in ("-o", "--outputfile"): 
    127                 outputfile = v 
    128         elif o in ("-h", "--help"): 
    129                 print usage 
    130                 sys.exit()                               
    131                  
    132  
    133          
    134 #create CSML: 
    135 if csmlfeaturetype == "PointFeature": 
    136     #NOT YET IMPLEMENTED# 
    137     if mapping is None: 
    138         mapping = 'onetoone' #default filemapping for PointFeature (?) 
    139          
    140 elif csmlfeaturetype == "ProfileFeature": 
    141     #NOT YET IMPLEMENTED# 
    142     if mapping is None: 
    143         mapping = 'onetoone' #default filemapping for ProfileFeature (?) 
    144          
    145 elif csmlfeaturetype == "GridFeature": 
    146         #NOT YET IMPLEMENTED# 
    147     if mapping is None: 
    148         mapping = 'onetoone' #default filemapping for GridFeature  
    149  
    150 elif csmlfeaturetype == "PointSeriesFeature": 
    151     if mapping is None: 
    152         mapping = 'onetomany' 
    153  
    154 elif csmlfeaturetype == "ProfileSeriesFeature": 
    155     if mapping is None:     #NOT YET IMPLEMENTED# 
    156         mapping = 'onetomany' #default filemapping for ProfileSeriesFeature (?) 
    157          
    158 elif csmlfeaturetype == "GridSeriesFeature": 
    159     if mapping is None: 
    160         mapping = 'onetomany' #default filemapping for GridSeriesFeature 
    161  
    162 csmldataset=csmllibs.csmlbuilder.csmlBuilder(directory,csmlfeaturetype,mapping,timedimension, outputfile) 
    163 print "building csml..." 
    164 csmldataset.build() 
     137             
     138    #create CSML: 
     139    if csmlfeaturetype == "PointFeature": 
     140        #NOT YET IMPLEMENTED# 
     141        if mapping is None: 
     142            mapping = 'onetoone' #default filemapping for PointFeature (?) 
     143             
     144    elif csmlfeaturetype == "ProfileFeature": 
     145        #NOT YET IMPLEMENTED# 
     146        if mapping is None: 
     147            mapping = 'onetoone' #default filemapping for ProfileFeature (?) 
     148             
     149    elif csmlfeaturetype == "GridFeature": 
     150            #NOT YET IMPLEMENTED# 
     151        if mapping is None: 
     152            mapping = 'onetoone' #default filemapping for GridFeature  
     153     
     154    elif csmlfeaturetype == "PointSeriesFeature": 
     155        if mapping is None: 
     156            mapping = 'onetomany' 
     157     
     158    elif csmlfeaturetype == "ProfileSeriesFeature": 
     159        if mapping is None:     #NOT YET IMPLEMENTED# 
     160            mapping = 'onetomany' #default filemapping for ProfileSeriesFeature (?) 
     161             
     162    elif csmlfeaturetype == "GridSeriesFeature": 
     163        if mapping is None: 
     164            mapping = 'onetomany' #default filemapping for GridSeriesFeature 
     165     
     166    csmldataset=csmllibs.csmlbuilder.csmlBuilder(directory,csmlfeaturetype,mapping,timedimension, outputfile) 
     167    print "building csml..." 
     168    csmldataset.build() 
     169     
     170     
     171    print '' 
     172    print '********************************************************************' 
     173    print 'CSML file is at: ' + outputfile 
     174    print '********************************************************************'                 
     175    print '' 
    165176 
    166177 
    167 print '' 
    168 print '********************************************************************' 
    169 print 'CSML file is at: ' + outputfile 
    170 print '********************************************************************'             
    171 print '' 
     178if __name__=='__main__': 
     179    main() 
    172180 
    173181 
     
    185193 
    186194 
    187  
    188  
    189  
Note: See TracChangeset for help on using the changeset viewer.