comparison python/pavement.py @ 450:c0786fe4ad94

small additions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 11 Feb 2014 02:55:02 -0500
parents 1e4c1b6b0e0b
children 15c6f1bc30a2
comparison
equal deleted inserted replaced
449:1e4c1b6b0e0b 450:c0786fe4ad94
2 '''Tools for processing and analyzing pavement marking data''' 2 '''Tools for processing and analyzing pavement marking data'''
3 3
4 import numpy as np 4 import numpy as np
5 5
6 __metaclass__ = type 6 __metaclass__ = type
7
8 durabilities = {1: 98, #96 to 100
9 2: 85, #75 to 96
10 3: 72, #50 to 75
11 4: 32, #15 to 50
12 5: 7 #0 to 15
13 }
7 14
8 def occ_max(a): 15 def occ_max(a):
9 if a != []: 16 if a != []:
10 s = set(a) 17 s = set(a)
11 l = list(s) 18 l = list(s)
172 neigeEC_sup_seuil = 1 179 neigeEC_sup_seuil = 1
173 return (nbre_jours_T_negatif,nbre_jours_gel_degel, deltas_T, nbre_jours_gel_consecutifs, pluie_tot, neige_tot, neigeEC_sup_seuil, ecart_type_T) 180 return (nbre_jours_T_negatif,nbre_jours_gel_degel, deltas_T, nbre_jours_gel_consecutifs, pluie_tot, neige_tot, neigeEC_sup_seuil, ecart_type_T)
174 else: 181 else:
175 return [None]*2+[[None]*len(seuils_T)]+[None]*5 182 return [None]*2+[[None]*len(seuils_T)]+[None]*5
176 183
184
177 class RTSS: 185 class RTSS:
178 'class for data related to a RTSS: 186 '''class for data related to a RTSS:
179 - agregating pavement marking measurements 187 - agregating pavement marking measurements
180 - RTSS characteristics from FMR: pavement type, age, AADT, truck AADT 188 - RTSS characteristics from FMR: pavement type, age, AADT, truck AADT
181 - winter maintenance level from V155' 189 - winter maintenance level from V155
182 190
183 def __init__(self, id): 191 If divided highway, the RTSS ends with G or D and are distinct: there is no ambiguity
184 self.id = id 192 - retroreflectivity types: there are CB, RJ and RB
193 If undivided, ending with C
194 - durability is fine: ETAT_MARQG_RG ETAT_MARQG_CL ETAT_MARQG_RD (+SG/SD, but recent)
195 - retroreflectivity: CJ is center line, RB and SB are left/right if DEBUT-FIN>0 or <0
196 '''
197
198 def __init__(self, _id, name, data):
199 self.id = _id
200 self.name = name
201 self.data = data
185 202
186 class MarkingTest: 203 class MarkingTest:
187 '''class for a test site for a given product 204 '''class for a test site for a given product
188 205
189 including the series of measurements over the years''' 206 including the series of measurements over the years'''
190 207
191 def __init__(self, id, paintingDate, paintingType, color, data): 208 def __init__(self, _id, paintingDate, paintingType, color, data):
192 self.id = id 209 self.id = _id
193 self.paintingDate = paintingDate 210 self.paintingDate = paintingDate
194 self.paintingType = paintingType 211 self.paintingType = paintingType
195 self.color = color 212 self.color = color
196 self.data = data 213 self.data = data
197 self.nMeasures = len(data) 214 self.nMeasures = len(data)
231 days = self.data[nonZeroIndices]['jours'] 248 days = self.data[nonZeroIndices]['jours']
232 dates = self.data[nonZeroIndices]['date_mesure'] 249 dates = self.data[nonZeroIndices]['date_mesure']
233 measures = self.data[nonZeroIndices][dataLabel] 250 measures = self.data[nonZeroIndices][dataLabel]
234 for i in range(1, len(dates)): 251 for i in range(1, len(dates)):
235 nDaysTNegative, nDaysThawFreeze, deltaTemp, nConsecutiveFrozenDays, totalRain, totalSnow, snowAboveThreshold, stdevTemp = ecWeatherIndicators(weatherData, dates[i-1], dates[i], snowThreshold, minProportionMeasures) 252 nDaysTNegative, nDaysThawFreeze, deltaTemp, nConsecutiveFrozenDays, totalRain, totalSnow, snowAboveThreshold, stdevTemp = ecWeatherIndicators(weatherData, dates[i-1], dates[i], snowThreshold, minProportionMeasures)
236 variationData.append([measures[i-1]-measures[i], measures[i-1], days[i]-days[i-1], days[i-1], nDaysTNegative, nDaysThawFreeze] + deltaTemp + [nConsecutiveFrozenDays, totalRain, totalSnow, snowAboveThreshold, stdevTemp]) 253 if dates[i-1].year+1 == dates[i].year:
254 winter = 1
255 if days[i-1]<365:
256 firstWinter = 1
257 else:
258 winter = 0
259 firstWinter = 0
260 variationData.append([measures[i-1]-measures[i], measures[i-1], days[i]-days[i-1], days[i-1], winter, firstWinter, nDaysTNegative, nDaysThawFreeze] + deltaTemp + [nConsecutiveFrozenDays, totalRain, totalSnow, snowAboveThreshold, stdevTemp])
237 return variationData 261 return variationData