def fcd2fzp(inpFCD, outSTRM, further): """ Reformats the contents of the given fcd-output file into a .fzp file, readable by PHEM. The fcd-output "fcd" must be a valid file name of an fcd-output. The "sIDm" parameter must be a map from SUMO-edge ids to their numerical representation as generated by toSTR(inpNET, outSTRM). Returns two maps, the first from vehicle ids to a numerical representation, the second from vehicle type ids to a numerical representation. """ sIDm = further["phemStreetMap"] if outSTRM is not None: print("t,WeltX,WeltY,Veh. No,v,Gradient,veh.Typ-Id,Str-Id", file=outSTRM) vIDm = sumolib._Running(further["orig-ids"], True) vtIDm = sumolib._Running() vtIDm.g("PKW") vtIDm.g("PKW_equipped") vtIDm.g("LKW") vtIDm.g("BUS") for q in inpFCD: if q.vehicle: for v in q.vehicle: vid = vIDm.g(v.id) aType = _convType(v.type) vtid = vtIDm.g(aType) sid = sIDm.g(v.edge) percSlope = math.sin(float(v.slope)) * 100. if outSTRM is not None: print("%s,%s,%s,%s,%.3f,%s,%s,%s" % (sumolib._intTime(q.time), float(v.x), float(v.y), vid, float(v.speed) * 3.6, percSlope, vtid, sid), file=outSTRM) return vIDm, vtIDm
def fcd2fzp(inpFCD, outSTRM, further): """ Reformats the contents of the given fcd-output file into a .fzp file, readable by PHEM. The fcd-output "fcd" must be a valid file name of an fcd-output. The "sIDm" parameter must be a map from SUMO-edge ids to their numerical representation as generated by toSTR(inpNET, outSTRM). Returns two maps, the first from vehicle ids to a numerical representation, the second from vehicle type ids to a numerical representation. """ sIDm = further["phemStreetMap"] if outSTRM != None: print( "t,WeltX,WeltY,Veh. No,v,Gradient,veh.Typ-Id,Str-Id", file=outSTRM) vIDm = sumolib._Running(further["orig-ids"], True) vtIDm = sumolib._Running() vtIDm.g("PKW") vtIDm.g("PKW_equipped") vtIDm.g("LKW") vtIDm.g("BUS") for q in inpFCD: if q.vehicle: for v in q.vehicle: vid = vIDm.g(v.id) aType = _convType(v.type) vtid = vtIDm.g(aType) sid = sIDm.g(v.edge) percSlope = math.sin(float(v.slope)) * 100. if outSTRM != None: print("%s,%s,%s,%s,%s,%s,%s,%s" % ( sumolib._intTime(q.time), float(v.x), float(v.y), vid, float(v.speed) * 3.6, percSlope, vtid, sid), file=outSTRM) return vIDm, vtIDm
def fcd2dri(inpFCD, outSTRM, ignored): """ Reformats the contents of the given fcd-output file into a .dri file, readable by PHEM. The fcd-output "fcd" must be a valid file name of an fcd-output. The following may be a matter of changes: - the engine torque is not given """ #print >> outSTRM, "v1\n<t>,<v>,<grad>,<n>\n[s],[km/h],[%],[1/min]\n" print("v1\n<t>,<v>,<grad>\n[s],[km/h],[%]", file=outSTRM) for q in inpFCD: if q.vehicle: for v in q.vehicle: percSlope = math.sin(float(v.slope))*100. print("%s,%s,%s" % (sumolib._intTime(q.time), float(v.speed)*3.6, percSlope), file=outSTRM)
def fcd2dri(inpFCD, outSTRM, ignored): """ Reformats the contents of the given fcd-output file into a .dri file, readable by PHEM. The fcd-output "fcd" must be a valid file name of an fcd-output. The following may be a matter of changes: - the engine torque is not given """ #print >> outSTRM, "v1\n<t>,<v>,<grad>,<n>\n[s],[km/h],[%],[1/min]\n" print("v1\n<t>,<v>,<grad>\n[s],[km/h],[%]", file=outSTRM) for q in inpFCD: if q.vehicle: for v in q.vehicle: percSlope = math.sin(float(v.slope)) * 100. print("%s,%s,%s" % ( sumolib._intTime(q.time), float(v.speed) * 3.6, percSlope), file=outSTRM)