NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 384

Show
Ignore:
Timestamp:
10/21/10 18:22:08
Author:
cbc
Message:

Format timestamp column.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spongenet/trunk/spongenet/query.py

    r383 r384  
    2626import os 
    2727import glob 
     28from pycdf import CDF, CDFError 
     29import time 
    2830import csv 
    29 from pycdf import CDF, CDFError 
    3031import doctest 
    3132import unittest 
     
    139140        else: 
    140141            raise IOError("Incorrect number of arguments supplied.") 
    141     except IOError as e
    142         print e 
     142    except IOError as exc
     143        print exc 
    143144        print USAGE 
    144145    return path 
     
    377378    try: 
    378379        execfile(path, globals(), namespace) 
    379     except IOError as e
    380         print e 
     380    except IOError as exc
     381        print exc 
    381382        print USAGE 
    382     except SyntaxError as e
    383         print e 
     383    except SyntaxError as exc
     384        print exc 
    384385        print USAGE 
    385386    return (namespace.get("NCDIR"), 
     
    426427    # Sanity check the time arrays 
    427428    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: 
    430431        if any(varmap[time0] != varmap[time1]): 
    431432            raise CDFError("Time arrays are not equivalent.") 
    432     varmap["time"] = varmap[time0
     433    varmap["time"] = varmap[time_list[0][0]
    433434 
    434435    # Create the rows. 
    435     rows = [[] for time in varmap["time"]] 
     436    rows = [[] for cell in varmap["time"]] 
    436437    for column in columns: 
    437438        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) 
    439444 
    440445    # Output the CSV file. 
     
    539544                query(*_config) 
    540545            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." 
    542548                print USAGE 
    543549