Changeset 384
- Timestamp:
- 10/21/10 18:22:08
- Files:
-
- spongenet/trunk/spongenet/query.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spongenet/trunk/spongenet/query.py
r383 r384 26 26 import os 27 27 import glob 28 from pycdf import CDF, CDFError 29 import time 28 30 import csv 29 from pycdf import CDF, CDFError30 31 import doctest 31 32 import unittest … … 139 140 else: 140 141 raise IOError("Incorrect number of arguments supplied.") 141 except IOError as e :142 print e 142 except IOError as exc: 143 print exc 143 144 print USAGE 144 145 return path … … 377 378 try: 378 379 execfile(path, globals(), namespace) 379 except IOError as e :380 print e 380 except IOError as exc: 381 print exc 381 382 print USAGE 382 except SyntaxError as e :383 print e 383 except SyntaxError as exc: 384 print exc 384 385 print USAGE 385 386 return (namespace.get("NCDIR"), … … 426 427 # Sanity check the time arrays 427 428 time_list = [var for var in varmap.keys() if var.endswith(".time")] 428 time_list = zip(time_list[:-1], time_list[1:])429 for time0, time1 in time_list:429 time_list = zip(time_list[:-1], time_list[1:]) 430 for time0, time1 in time_list: 430 431 if any(varmap[time0] != varmap[time1]): 431 432 raise CDFError("Time arrays are not equivalent.") 432 varmap["time"] = varmap[time 0]433 varmap["time"] = varmap[time_list[0][0]] 433 434 434 435 # Create the rows. 435 rows = [[] for timein varmap["time"]]436 rows = [[] for cell in varmap["time"]] 436 437 for column in columns: 437 438 for pos in range(len(rows)): 438 rows[pos].append(varmap[column][pos]) 439 cell = varmap[column][pos] 440 if column == "time": 441 cell = time.strftime("%m/%d/%Y %H:%M:%S", 442 time.gmtime(cell)) 443 rows[pos].append(cell) 439 444 440 445 # Output the CSV file. … … 539 544 query(*_config) 540 545 else: 541 print "Config file", _config_path, "does not contain all necessary parameters." 546 print "Config file", _config_path, \ 547 "does not contain all necessary parameters." 542 548 print USAGE 543 549