Changeset 3319 for DPPP


Ignore:
Timestamp:
06/02/08 15:55:27 (12 years ago)
Author:
mkochan
Message:

Added comments in csmlGrapher.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py

    r3318 r3319  
    1717log = logging.getLogger(__name__) 
    1818 
    19 # [TODO] . Add correct labeling of time axis 
    20 #        . Comments 
    21 #        . Add security (especially checking of input parameters). 
     19# [TODO] . Add security (especially checking of input parameters). 
    2220#        . Add configurable URL for the data source web service (preferably explicitly on localhost) 
    2321class CsmlgrapherController(BaseController): 
     
    4038            Plot a PointSeries feature using matplotlib, into a temporary file 
    4139            ''' 
    42             (lon, lat) = map(float, feature.location.CONTENT.split()) 
    43             print 'Feature "%s" (%s) at: (%f,%f)' % (feature.id, feature.description.CONTENT, lon, lat) 
    44  
     40             
     41            # Make sure that time is considered to be UTC time. This is because all CSML data is supposed to be in UTC, 
     42            # but actually pylab is "time zone aware" and will interpret the time as local time zone time. 
     43            # Not quite sure if this would be a problem, but rather enforce it is UTC. 
    4544            def _enforce_UTC_timezone(datestr): 
    4645                if datestr[-1] == 'Z': 
     
    4847                else: 
    4948                    return datestr + 'Z' 
     49             
     50            # Isolate time points     
    5051            times=feature.value.pointSeriesDomain.timePositionList.CONTENT.split() 
    5152            times = map(_enforce_UTC_timezone, times) 
    52                  
    53             print 'All times (%s of them): '% len(times) 
    54             print times 
    5553             
     54            # Note the start and end date (they are actually date+time), and time span between them 
    5655            start_date = dates.dateutil.parser.parse(times[0]) 
    5756            end_date = dates.dateutil.parser.parse(times[-1]) 
    5857            span = datestr2num(times[-1]) - datestr2num(times[0]) 
    59             print 'The span is ' + str(span) + ' days.' 
    6058 
     59            # Make a list of times as float numbers being days passed since start of epoch (here 01-01-0001) 
    6160            elapsed_times = map(datestr2num, times) 
    6261 
     62            # Generate tick locator and formatter; these determine the time axis: locator determines tick positions 
     63            # and formatter format of time 
    6364            (tickLocator, tickFormatter) = dates.date_ticker_factory(span, numticks=8) 
    64             print 'tickLocator:%s\ntickFormatter:%s' % (tickLocator, tickFormatter) 
    65  
    66             print 'All times (%s of them) as days since 01-01-0001 UTC: '% len(elapsed_times) 
    67             print elapsed_times 
    6865 
    6966            # We may need to do this for bodc data (i.e. not inline data) 
    7067            # vals=feature.value.rangeSet.valueArray.valueComponent.insertedExtract.components.getDataFromChunks(0,19) 
    7168 
    72             # We use this for inline data: 
     69            # Get values of the measured quantity 
    7370            ql = feature.value.rangeSet.quantityList 
    7471            vals = map(float, ql.CONTENT.split()) 
    75             print 'Measurement values (%s of them):\n%s' % (len(vals), repr(vals)) 
    7672 
    7773            # Determine the units of measurement 
     
    8177            if ql.uom.isupper(): 
    8278                uom = uom.upper() 
    83             print 'Units of measurement: %s' % uom 
    8479 
    85             # Plot the figure 
     80            # Prepare the plot the figure (actual plotting actions are postponed until save) 
    8681            fig = figure() 
    8782            plot_date(elapsed_times, vals, '-o', xdate=True, lw=2) 
    8883            ax = gca() 
    89             ml = ax.xaxis.get_major_locator() 
    9084            ax.xaxis.set_major_locator(tickLocator) 
    9185            ax.xaxis.set_major_formatter(tickFormatter) 
    92             fig.autofmt_xdate() 
     86            fig.autofmt_xdate()  # show times without overlaps 
    9387            time_format = '%d-%b-%Y %H:%M:%S UTC' 
    9488            xlabel('Times between %s and %s ' % (start_date.strftime(time_format), end_date.strftime(time_format))) 
     
    9690            title('"%s" (%s)' % (feature.id, feature.description.CONTENT)) 
    9791            grid(True) 
    98  
    99             print start_date 
    100             print end_date 
    10192 
    10293            # Save the figure to a temporary file 
     
    131122        #------------------------------------------------------------------------------------------------------------------- 
    132123 
    133         # get feature ID from HTTP request 
     124        # Get feature ID from HTTP request 
    134125        feature_id = None; station_id = None 
    135126        try: 
Note: See TracChangeset for help on using the changeset viewer.