Mercurial Hosting > traffic-intelligence
changeset 458:28ff95845c65
update to include speed limit
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 19 Feb 2014 17:46:26 -0500 |
parents | 95a8eb38d9a2 |
children | 2a4e9ef469e5 |
files | python/pavement.py |
diffstat | 1 files changed, 19 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/python/pavement.py Wed Feb 19 16:33:49 2014 -0500 +++ b/python/pavement.py Wed Feb 19 17:46:26 2014 -0500 @@ -1,6 +1,8 @@ #! /usr/bin/env python '''Tools for processing and analyzing pavement marking data''' +import utils + import numpy as np __metaclass__ = type @@ -19,31 +21,13 @@ 60: "Acces ressources", 51: "Local 1", 52: "Local 2", - 53: "Local 3" + 53: "Local 3", 15: "Aut (PRN)", 25: "Nat (PRN)", 70: "Acces isolees", 99: "Autres" } -def occ_max(a): - if a != []: - s = set(a) - l = list(s) - occ = [] - for i in range(len(l)): - b = 0 - for j in range(len(a)): - if a[j] == l[i]: - b += 1 - occ.append([l[i], b]) - nbre_occs = [] - for i in range(len(occ)): - nbre_occs.append(occ[i][1]) - return occ[nbre_occs.index(max(nbre_occs))][0] - else: - return "" - def caracteristiques(rtss, maintenanceLevel, rtssWeatherStation, fmr, paintType): '''Computes characteristic data for the RTSS (class rtss) maintenanceLevel = pylab.csv2rec('C:\Users\Alexandre\Desktop\Projet_maitrise_recherche\BDD_access\\analyse_donnees_deneigement\\exigence_circuits.txt', delimiter = ';') @@ -69,7 +53,7 @@ x_moy, y_moy = '','' # determination info fmr - age_revtm, classe_fonct, type_revtm, milieu, djma, pourc_camions = [], [], [], [], [], [] + age_revtm, classe_fonct, type_revtm, milieu, djma, pourc_camions, vit_max = [], [], [], [], [], [], [] if rtss.id in fmr['rtss_debut']: for i in range(len(fmr)): if fmr['rtss_debut'][i] == rtss.id: @@ -79,18 +63,22 @@ milieu.append(fmr['des_cod_mil'][i]) djma.append(fmr['val_djma'][i]) pourc_camions.append(fmr['val_pourc_camns'][i]) - age_revtm = occ_max(age_revtm) - classe_fonct = occ_max(classe_fonct) - type_revtm = occ_max(type_revtm) - milieu = occ_max(milieu) - djma = occ_max(djma) - pourc_camions = occ_max(pourc_camions) + vit_max.append(fmr['val_limt_vitss'][i]) + age_revtm = utils.mostCommon(age_revtm) + classe_fonct = utils.mostCommon(classe_fonct) + type_revtm = utils.mostCommon(type_revtm) + milieu = utils.mostCommon(milieu) + djma = utils.mostCommon(djma) + vit_max = utils.mostCommon(vit_max) + if vit_max < 0: + vit_max = '' + pourc_camions = utils.mostCommon(pourc_camions) if pourc_camions == "" or pourc_camions < 0: djma_camions = "" else: djma_camions = pourc_camions*djma/100 else: - age_revtm, classe_fonct, type_revtm, milieu, djma, djma_camions = '','','','','','' + age_revtm, classe_fonct, type_revtm, milieu, djma, djma_camions, vit_max = '','','','','','','' # determination type peinture peinture_rd, peinture_rg, peinture_cl = [], [], [] @@ -101,13 +89,13 @@ peinture_rd.append((paintType['peinture_rd'][i])) peinture_rg.append((paintType['peinture_rg'][i])) peinture_cl.append((paintType['peinture_cl'][i])) - peinture_lrd = occ_max(peinture_rd) - peinture_lrg = occ_max(peinture_rg) - peinture_lc = occ_max(peinture_cl) + peinture_lrd = utils.mostCommon(peinture_rd) + peinture_lrg = utils.mostCommon(peinture_rg) + peinture_lc = utils.mostCommon(peinture_cl) else: peinture_lrd, peinture_lrg, peinture_lc = '','','' - return (exigence, x_moy, y_moy, age_revtm, classe_fonct, type_revtm, milieu, djma, djma_camions, peinture_lrd, peinture_lrg, peinture_lc) + return (exigence, x_moy, y_moy, age_revtm, classe_fonct, type_revtm, milieu, djma, djma_camions, vit_max, peinture_lrd, peinture_lrg, peinture_lc) def winterMaintenanceIndicators(data, startDate, endDate, circuitReference, snowThreshold): '''Computes several winter maintenance indicators