view python/pavement.py @ 433:d40ad901b272

added kernel smoothing
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 29 Nov 2013 02:38:41 -0500
parents 4970fa64f636
children 9a714f32fc9f
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, measure, ligneNum):
        from numpy import isnan
        dataLabel = '{}_{}'.format(measure, ligneNum)
        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)