Demo entry 5042171

Function

   

Submitted by anonymous on Jun 01, 2016 at 11:57
Language: Python 3. Code size: 38.0 kB.

import numpy as np
import pandas as pd
import os
import time


def noise_footprint(bfsnr)
    start_time = time.time()

    print("--- %s seconds ---" % (time.time() - start_time))

    #read the csv file with panda
    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Matsim Data//'
    datalist = pd.read_csv(rootdir + 'bfsnr.csv', sep = ',')

    #number of agents in the file

    noa = datalist.shape[0]

    #array of each demand, seperate
    car_demand = datalist['car_demand']
    trobus_demand = datalist['trobus_demand']
    regbus_demand = datalist['regbus_demand']
    regtrain_demand = datalist['regtrain_demand']
    metrotrain_demand = datalist['metrotrain_demand']
    tram_demand = datalist['tram_demand']
    residents = np.sum(datalist['hh_size'])





    ### regbus general
    ### with urban/suburban/rural differenciation but - no day/night differenciation

    regbus_demand = np.array(regbus_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//regbus//csv//'
    regbus_specifics = pd.read_csv(rootdir + 'regbus_specifics.csv', delimiter = ';')
    regbus_characterisation_conversion = pd.read_csv(rootdir + 'regbus_characterisation_conversion.csv', delimiter = ';')
    regbus_rolling_propulsion = pd.read_csv(rootdir + 'regbus_rolling_propulsion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = regbus_characterisation_conversion['conversion'][0]
    CF_urban_timeless = regbus_characterisation_conversion['cf_urban_unsp']
    CF_suburban_timeless = regbus_characterisation_conversion['cf_suburban_unsp']
    CF_rural_timeless = regbus_characterisation_conversion['cf_rural_unsp']
    frequences = regbus_rolling_propulsion['frequency']
    avrg_load = regbus_specifics['avrg_load'][0]
    arolling = regbus_rolling_propulsion['arolling_noise']
    brolling = regbus_rolling_propulsion['brolling_noise']
    apropulsion = regbus_rolling_propulsion['apropulsion_noise']
    bpropulsion = regbus_rolling_propulsion['bpropulsion_noise']
    usage_percent = np.array([regbus_specifics['urban'][0], regbus_specifics['suburban'][0], regbus_specifics['rural'][0]])
    velocity_spec = np.array([regbus_specifics['urban'][1], regbus_specifics['suburban'][1], regbus_specifics['rural'][1]])
    velocity_urban = regbus_specifics['urban'][1]
    velocity_suburban = regbus_specifics['suburban'][1]
    velocity_rural = regbus_specifics['rural'][1]
    usage_urban = regbus_specifics['urban'][0]
    usage_suburban = regbus_specifics['suburban'][0]
    usage_rural = regbus_specifics['rural'][0]

    #calculate average velocity of the train and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = regbus_demand * usage_urban
    distance_suburban = regbus_demand * usage_suburban
    distance_rural = regbus_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #calculate rolling and propulsion until sound power level in [w]

    reference_speed = regbus_specifics['reference_speed'][0]
    Lwr_urban = arolling + brolling*np.log10(velocity_urban/reference_speed)
    Lwp_urban = apropulsion + bpropulsion*velocity_urban/reference_speed
    Lwr_suburban = arolling + brolling*np.log10(velocity_suburban/reference_speed)
    Lwp_suburban = apropulsion + bpropulsion*velocity_suburban/reference_speed
    Lwr_rural = arolling + brolling*np.log10(velocity_rural/reference_speed)
    Lwp_rural = apropulsion + bpropulsion*velocity_rural/reference_speed
    Lwtot_urban = 10*np.log10(np.power(10, Lwr_urban/10)+np.power(10, Lwp_urban/10))
    Lwtot_suburban = 10*np.log10(np.power(10, Lwr_suburban/10)+np.power(10, Lwp_suburban/10))
    Lwtot_rural = 10*np.log10(np.power(10, Lwr_rural/10)+np.power(10, Lwp_rural/10))
    W_urban = np.power(10, -12.0)*np.power(10, Lwtot_urban/10)
    W_suburban = np.power(10, -12.0)*np.power(10, Lwtot_suburban/10)
    W_rural = np.power(10, -12.0)*np.power(10, Lwtot_rural/10)

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W_urban[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W_suburban[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W_rural[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_urban_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_suburban_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_rural_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by regbus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_regbus_usr = np.sum(NFtot)




    ### trobus general
    ### with urban/suburban/rural differenciation but - no day/night differenciation
    ### only rolling, propulsion = 0 due to electrical engine. U/S/R fit urban context

    trobus_demand = np.array(trobus_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//trobus//csv//'
    trobus_specifics = pd.read_csv(rootdir + 'trobus_specifics.csv', delimiter = ';')
    trobus_characterisation_conversion = pd.read_csv(rootdir + 'trobus_characterisation_conversion.csv', delimiter = ';')
    trobus_rolling_propulsion = pd.read_csv(rootdir + 'trobus_rolling_propulsion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = trobus_characterisation_conversion['conversion'][0]
    CF_urban_timeless = trobus_characterisation_conversion['cf_urban_unsp']
    CF_suburban_timeless = trobus_characterisation_conversion['cf_suburban_unsp']
    CF_rural_timeless = trobus_characterisation_conversion['cf_rural_unsp']
    frequences = trobus_rolling_propulsion['frequency']
    avrg_load = trobus_specifics['avrg_load'][0]
    arolling = trobus_rolling_propulsion['arolling_noise']
    brolling = trobus_rolling_propulsion['brolling_noise']
    apropulsion = trobus_rolling_propulsion['apropulsion_noise']
    bpropulsion = trobus_rolling_propulsion['bpropulsion_noise']
    usage_percent = np.array([trobus_specifics['urban'][0], trobus_specifics['suburban'][0], trobus_specifics['rural'][0]])
    velocity_spec = np.array([trobus_specifics['urban'][1], trobus_specifics['suburban'][1], trobus_specifics['rural'][1]])
    velocity_urban = trobus_specifics['urban'][1]
    velocity_suburban = trobus_specifics['suburban'][1]
    velocity_rural = trobus_specifics['rural'][1]
    usage_urban = trobus_specifics['urban'][0]
    usage_suburban = trobus_specifics['suburban'][0]
    usage_rural = trobus_specifics['rural'][0]

    #calculate average velocity of the train and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = trobus_demand * usage_urban
    distance_suburban = trobus_demand * usage_suburban
    distance_rural = trobus_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #calculate rolling and propulsion until sound power level in [w]

    reference_speed = trobus_specifics['reference_speed'][0]
    Lwr_urban = arolling + brolling*np.log10(velocity_urban/reference_speed)
    Lwp_urban = apropulsion + bpropulsion*velocity_urban/reference_speed
    Lwr_suburban = arolling + brolling*np.log10(velocity_suburban/reference_speed)
    Lwp_suburban = apropulsion + bpropulsion*velocity_suburban/reference_speed
    Lwr_rural = arolling + brolling*np.log10(velocity_rural/reference_speed)
    Lwp_rural = apropulsion + bpropulsion*velocity_rural/reference_speed
    Lwtot_urban = 10*np.log10(np.power(10, Lwr_urban/10)+np.power(10, Lwp_urban/10))
    Lwtot_suburban = 10*np.log10(np.power(10, Lwr_suburban/10)+np.power(10, Lwp_suburban/10))
    Lwtot_rural = 10*np.log10(np.power(10, Lwr_rural/10)+np.power(10, Lwp_rural/10))
    W_urban = np.power(10, -12.0)*np.power(10, Lwtot_urban/10)
    W_suburban = np.power(10, -12.0)*np.power(10, Lwtot_suburban/10)
    W_rural = np.power(10, -12.0)*np.power(10, Lwtot_rural/10)

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W_urban[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W_suburban[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W_rural[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_urban_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_suburban_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_rural_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by trobus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_trobus_usr = np.sum(NFtot)






    ### metrotrain general
    ### with urban/suburban/rural differenciation but - no day/night differenciation
    ### specifics the same, save u/r/s fit the suburban context

    ### metrotrain general
    ### with urban/suburban/rural differenciation but - no day/night differenciation

    metrotrain_demand = np.array(metrotrain_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//metrotrain//csv//'
    metrotrain_specifics = pd.read_csv(rootdir + 'metrotrain_specifics.csv', delimiter = ';')
    metrotrain_characterisation_conversion = pd.read_csv(rootdir + 'metrotrain_characterisation_conversion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = metrotrain_characterisation_conversion['conversion'][0]
    CF_urban_timeless = metrotrain_characterisation_conversion['CF_urban_unsp']
    CF_suburban_timeless = metrotrain_characterisation_conversion['CF_suburban_unsp']
    CF_rural_timeless = metrotrain_characterisation_conversion['CF_rural_unsp']
    frequences = metrotrain_characterisation_conversion['frequence']
    avrg_load = metrotrain_specifics['passengers_per_journey'][0]
    usage_percent = np.array([metrotrain_specifics['urban'][0], metrotrain_specifics['suburban'][0], metrotrain_specifics['rural'][0]])
    velocity_spec = np.array([metrotrain_specifics['urban'][1], metrotrain_specifics['suburban'][1], metrotrain_specifics['rural'][1]])
    velocity_urban = metrotrain_specifics['urban'][1]
    velocity_suburban = metrotrain_specifics['suburban'][1]
    velocity_rural = metrotrain_specifics['rural'][1]
    usage_urban = metrotrain_specifics['urban'][0]
    usage_suburban = metrotrain_specifics['suburban'][0]
    usage_rural = metrotrain_specifics['rural'][0]

    #calculate average velocity of the metrotrain and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = metrotrain_demand * usage_urban
    distance_suburban = metrotrain_demand * usage_suburban
    distance_rural = metrotrain_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #Lwtot and W are already given in the specifics

    Lwtot = metrotrain_specifics['Lwtot']
    W = metrotrain_specifics['W']

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_urban_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_suburban_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_rural_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by bus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_metrotrain_usr = np.sum(NFtot)








    ### regtrain general
    ### with urban/suburban/rural differenciation but - no day/night differenciation

    regtrain_demand = np.array(regtrain_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//regtrain//csv//'
    regtrain_specifics = pd.read_csv(rootdir + 'regtrain_specifics.csv', delimiter = ';')
    regtrain_characterisation_conversion = pd.read_csv(rootdir + 'regtrain_characterisation_conversion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = regtrain_characterisation_conversion['conversion'][0]
    CF_urban_timeless = regtrain_characterisation_conversion['CF_urban_unsp']
    CF_suburban_timeless = regtrain_characterisation_conversion['CF_suburban_unsp']
    CF_rural_timeless = regtrain_characterisation_conversion['CF_rural_unsp']
    frequences = regtrain_characterisation_conversion['frequence']
    avrg_load = regtrain_specifics['passengers_per_journey'][0]
    usage_percent = np.array([regtrain_specifics['urban'][0], regtrain_specifics['suburban'][0], regtrain_specifics['rural'][0]])
    velocity_spec = np.array([regtrain_specifics['urban'][1], regtrain_specifics['suburban'][1], regtrain_specifics['rural'][1]])
    velocity_urban = regtrain_specifics['urban'][1]
    velocity_suburban = regtrain_specifics['suburban'][1]
    velocity_rural = regtrain_specifics['rural'][1]
    usage_urban = regtrain_specifics['urban'][0]
    usage_suburban = regtrain_specifics['suburban'][0]
    usage_rural = regtrain_specifics['rural'][0]

    #calculate average velocity of the regtrain and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = regtrain_demand * usage_urban
    distance_suburban = regtrain_demand * usage_suburban
    distance_rural = regtrain_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #Lwtot and W are already given in the specifics

    Lwtot = regtrain_specifics['Lwtot']
    W = regtrain_specifics['W']

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_urban_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_suburban_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_rural_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by bus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_regtrain_usr = np.sum(NFtot)






    ### tram general
    ### with urban/suburban/rural differenciation but - no day/night differenciation
    ### u/s/r fit urban context, also velocities are adapted

    tram_demand = np.array(tram_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//tram//csv//'
    tram_specifics = pd.read_csv(rootdir + 'tram_specifics.csv', delimiter = ';')
    tram_characterisation_conversion = pd.read_csv(rootdir + 'tram_characterisation_conversion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = tram_characterisation_conversion['conversion'][0]
    CF_urban_timeless = tram_characterisation_conversion['CF_urban_unsp']
    CF_suburban_timeless = tram_characterisation_conversion['CF_suburban_unsp']
    CF_rural_timeless = tram_characterisation_conversion['CF_rural_unsp']
    frequences = tram_characterisation_conversion['frequence']
    avrg_load = tram_specifics['passengers_per_journey'][0]
    usage_percent = np.array([tram_specifics['urban'][0], tram_specifics['suburban'][0], tram_specifics['rural'][0]])
    velocity_spec = np.array([tram_specifics['urban'][1], tram_specifics['suburban'][1], tram_specifics['rural'][1]])
    velocity_urban = tram_specifics['urban'][1]
    velocity_suburban = tram_specifics['suburban'][1]
    velocity_rural = tram_specifics['rural'][1]
    usage_urban = tram_specifics['urban'][0]
    usage_suburban = tram_specifics['suburban'][0]
    usage_rural = tram_specifics['rural'][0]

    #calculate average velocity of the tram and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = tram_demand * usage_urban
    distance_suburban = tram_demand * usage_suburban
    distance_rural = tram_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #Lwtot and W are already given in the specifics

    Lwtot = tram_specifics['Lwtot']
    W = tram_specifics['W']

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_urban_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_suburban_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_rural_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by bus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_tram_usr = np.sum(NFtot)








    ### car general
    ### with urban/suburban/rural differenciation but - no day/night differenciation
    ### velocity adapted to 50 km/h

    car_demand = np.array(car_demand)

    #read the characterisation and conversion factors, specific data and rolling+propulsion into, first access folder (rootdir)

    rootdir = r'C://Data//Documents//Studium//6. Semester//Bachelorarbeit//Files//Vehicle specific data//car//csv//'
    car_specifics = pd.read_csv(rootdir + 'car_specifics.csv', delimiter = ';')
    car_characterisation_conversion = pd.read_csv(rootdir + 'car_characterisation_conversion.csv', delimiter = ';')
    car_rolling_propulsion = pd.read_csv(rootdir + 'car_rolling_propulsion.csv', delimiter = ';')

    #store variables, velocities and percentages are place-specific

    conversion_timeless = car_characterisation_conversion['conversion'][0]
    CF_timeless = car_characterisation_conversion['cf_unsp']
    frequences = car_rolling_propulsion['frequency']
    avrg_load = car_specifics['avrg_load'][0]
    arolling = car_rolling_propulsion['arolling_noise']
    brolling = car_rolling_propulsion['brolling_noise']
    apropulsion = car_rolling_propulsion['apropulsion_noise']
    bpropulsion = car_rolling_propulsion['bpropulsion_noise']
    usage_percent = np.array([car_specifics['urban'][0], car_specifics['suburban'][0], car_specifics['rural'][0]])
    velocity_spec = np.array([car_specifics['urban'][1], car_specifics['suburban'][1], car_specifics['rural'][1]])
    velocity_urban = car_specifics['urban'][1]
    velocity_suburban = car_specifics['suburban'][1]
    velocity_rural = car_specifics['rural'][1]
    usage_urban = car_specifics['urban'][0]
    usage_suburban = car_specifics['suburban'][0]
    usage_rural = car_specifics['rural'][0]

    #calculate average velocity of the train and read specific velocities

    velocity_aver = np.dot(usage_percent, velocity_spec)

    #distances multiplied with the percentages of use per place

    distance_urban = car_demand * usage_urban
    distance_suburban = car_demand * usage_suburban
    distance_rural = car_demand * usage_rural

    #calculate the time needed in hours (not per passenger)

    time_needed_urban = distance_urban/velocity_urban
    time_needed_suburban = distance_suburban/velocity_suburban
    time_needed_rural = distance_rural/velocity_rural

    #calculate the time needed in seconds per passenger

    time_needed_passenger_urban = time_needed_urban * 3600/avrg_load
    time_needed_passenger_suburban = time_needed_suburban * 3600/avrg_load
    time_needed_passenger_rural = time_needed_rural * 3600/avrg_load

    #calculate rolling and propulsion until sound power level in [w]

    reference_speed = car_specifics['reference_speed'][0]
    Lwr_urban = arolling + brolling*np.log10(velocity_urban/reference_speed)
    Lwp_urban = apropulsion + bpropulsion*velocity_urban/reference_speed
    Lwr_suburban = arolling + brolling*np.log10(velocity_suburban/reference_speed)
    Lwp_suburban = apropulsion + bpropulsion*velocity_suburban/reference_speed
    Lwr_rural = arolling + brolling*np.log10(velocity_rural/reference_speed)
    Lwp_rural = apropulsion + bpropulsion*velocity_rural/reference_speed
    Lwtot_urban = 10*np.log10(np.power(10, Lwr_urban/10)+np.power(10, Lwp_urban/10))
    Lwtot_suburban = 10*np.log10(np.power(10, Lwr_suburban/10)+np.power(10, Lwp_suburban/10))
    Lwtot_rural = 10*np.log10(np.power(10, Lwr_rural/10)+np.power(10, Lwp_rural/10))
    W_urban = np.power(10, -12.0)*np.power(10, Lwtot_urban/10)
    W_suburban = np.power(10, -12.0)*np.power(10, Lwtot_suburban/10)
    W_rural = np.power(10, -12.0)*np.power(10, Lwtot_rural/10)

    #begin with the specific noise calculations per person, build the dataframe for m in [J]

    m_urban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_urban[i] = W_urban[i]*time_needed_passenger_urban
    m_urbanpd = pd.DataFrame(np.transpose(m_urban), index=range(noa), columns = range(8))

    m_suburban = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_suburban[i] = W_suburban[i]*time_needed_passenger_suburban
    m_suburbanpd = pd.DataFrame(np.transpose(m_suburban), index=range(noa), columns = range(8))

    m_rural = [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        m_rural[i] = W_rural[i]*time_needed_passenger_rural
    m_ruralpd = pd.DataFrame(np.transpose(m_rural), index=range(noa), columns = range(8))

    #calculate the Characterisation with the unspecified CF to HN in [person x Pa x sec]

    HN_urban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_urban[i] = m_urban[i]*CF_timeless[i]
    HN_urbanpd = pd.DataFrame(np.transpose(HN_urban), index=range(noa), columns = range(8))

    HN_suburban =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_suburban[i] = m_suburban[i]*CF_timeless[i]
    HN_suburbanpd = pd.DataFrame(np.transpose(HN_suburban), index=range(noa), columns = range(8))

    HN_rural =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        HN_rural[i] = m_rural[i]*CF_timeless[i]
    HN_ruralpd = pd.DataFrame(np.transpose(HN_rural), index=range(noa), columns = range(8))

    #the following steps are no more place specific, so the three types are summed up

    HN = [x + y + z for x, y, z in zip(HN_urban, HN_suburban, HN_rural)]
    HNpd = pd.DataFrame(np.transpose(HN), index=range(noa), columns = range(8))

    #calculate into DALY with the unspecified conversion factor [years/person]

    NF =  [[0 for x in range(noa)] for y in range(8)]
    for i in range(8):
        NF[i] = HN[i] * conversion_timeless
    NFpd = pd.DataFrame(np.transpose(NF), index=range(noa), columns = range(8))

    #sum up all the frequencies, NFtotpd holds the Noise Footprints of each person in [years]

    NFtot = [0 for x in range(noa)]
    for i in range(noa):
        for j in range(8):
            NFtot[i] = NFtot[i] + NFpd[j][i]
    NFtotpd = pd.DataFrame(np.transpose(NFtot), index=range(noa))

    #sum up all the citizens, NFtot_3374_general holds the Noise Footprint of the village in [years] induced by bus transport
    #general (no urban/suburban/rural differenciation) - (no day/night differenciation)

    NFtot_general_car = np.sum(NFtot)





    ### total NF per village and then per person in this village

    NF_general = (NFtot_general_car + NFtot_general_regbus_usr + NFtot_general_trobus_usr +
                      NFtot_general_regtrain_usr + NFtot_general_metrotrain_usr + NFtot_general_tram_usr)
    NF_general_person = NF_general/residents

    NF_general_Switz = NF_general_Switz + [bfsnr, NF_general]
    NF_general_person_Switz = NF_general_person_Switz + [bfsnr, NF_general_person]

This snippet took 0.06 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).