view python/pavement.py @ 434:9a714f32fc9f

small updates
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 30 Nov 2013 18:03:35 -0500
parents d40ad901b272
children 830136bc0e18
line wrap: on
line source

#! /usr/bin/env python
'''Tools for processing and analyzing pavement marking data'''

__metaclass__ = type

class RTSS:
    'class for data related to a RTSS, including agregating pavement marking measurements'
    pass

class MarkingTest:
    '''class for a test site for a given product'''

    def __init__(self, siteId, paintingDate, paintingType, color, data):
        self.siteId = siteId
        self.paintingDate = paintingDate
        self.paintingType = paintingType
        self.color = color
        self.data = data
        self.nMeasures = len(data)

    def plot(self, measure, options = 'o', dayRatio = 1., **kwargs):
        from matplotlib.pyplot import plot
        plot(self.data['jours']/float(dayRatio), 
             self.data[measure], options, **kwargs)

    def getMarkingMeasures(self, dataLabel):
        from numpy import isnan
        nonZeroIndices = ~isnan(self.data[dataLabel])
        return self.data[nonZeroIndices]['jours'], self.data[nonZeroIndices][dataLabel]

    def plotMarkingMeasures(self, measure, options = 'o', dayRatio = 1., **kwargs):
        for i in range(1,7):
            self.plot('{}_{}'.format(measure, i), options, dayRatio, **kwargs)