示例#1
0
    def __init__(self, logger=LookupLogger()):
        self.logger = logger
        self.worldAttributes = SpatialAttributesSampler(logger)
        self.dburi = None  # Database URI
        self.dbschema = None  # Database schema containing table(s) of interest
        self.dbtable = None  # Database table containing world features
        self.databaseLocation = None  # File containing sqlite database

        self.templateShapefile = None
        self.templateEpsgCode = None
        self.outputLayer = None  # actual qgsVectorLayer representing output layer
        self.countryAssignments = None  # Pandas series containing the country assigned to each ID used in the output layer

        # Store raw values from database
        self.attrs = None
        self.wdBuildingCycles = None
        self.weBuildingCycles = None
        self.wdTransportCycles = None
        self.weTransportCycles = None
        self.weekendDays = None
        self.fixedHolidays = None
        # Placeholders for populations. Note population is used to disaggregate national totals, which are per person.
        self.resPops = None  # Residential populaton in buildings
        self.vehPop = None  # Effective population in vehicle emitting areas
        self.metabPop = None  # Residential population in metabolism-friendly areas

        # set new QGIS project layers (created herein) to inherit the project EPSG code (initially) to avoid annoying popups
        s = QSettings()
        s.setValue("/Projections/defaultBehaviour", "useProject")
示例#2
0
 def __init__(self,
              studyAreaTimezone,
              weekendDays,
              use_uk_holidays,
              other_holidays=[],
              logger=LookupLogger()):
     '''
     Create dailyTemperature object
     :param studyAreaTimezone: timezone string for city being represented (e.g. Europe/London)
     :param weekendDays: List of integers specifying which day(s) of week are weekend (0=Mon, 6=Sun)
                         Empty list means weekends (inc. public holidays) and weekdays are equivalent
     :param use_uk_holidays: Boolean: Whether or not to use standard UK holidays
     :param other_holidays: List of specific dates to use as public holidays (in addition to UK if enabled)
     :param logger: Logger object
     '''
     self.logger = logger
     self.temperature = DailyLoading(logger=self.logger)
     self.temperature.setCountry(studyAreaTimezone)
     # If weekend days not specified, then weekends, weekdays and holidays have no distinction
     # In this case, un-set the holidays because they do not matter
     if len(weekendDays) == 0:
         self.temperature.useUKHolidays(False)
         self.temperature.specialHolidays([])
         self.logger.addEvent(
             'TemporalSampler', None, None, None,
             'No weekend days set, so any public holidays will be ignored')
     else:
         self.temperature.useUKHolidays(use_uk_holidays)
         self.temperature.specialHolidays(other_holidays)
     self.weekendDays = weekendDays
示例#3
0
    def __init__(self,
                 city,
                 use_uk_holidays,
                 customHolidays=[],
                 logger=LookupLogger()):
        ''' Instantiate
        :param city: String specifying the city being modelled (must be in timezone format e.g. Europe/London)
        :param timezone : String specifying which timezone to use. Must be compatible with pytz.timezone standard
        :param use_uk_holidays : Boolean: use (True) or don't use (False) standard UK bank holidays (calculated internally)
        :param customHolidays : list() of public holidays (datetime objects). These always get used, regardless of use_uk_holidays.
        '''

        self.logger = logger

        self.motorcycles = TemporalProfileSampler(logger=self.logger)
        self.motorcycles.useUKHolidays(use_uk_holidays)
        self.motorcycles.setCountry(city)
        self.motorcycles.specialHolidays(customHolidays)
        self.motorcycles.setWeekendDays([5, 6])

        self.taxis = TemporalProfileSampler(logger=self.logger)
        self.taxis.useUKHolidays(use_uk_holidays)
        self.taxis.setCountry(city)
        self.taxis.specialHolidays(customHolidays)
        self.taxis.setWeekendDays([5, 6])

        self.cars = TemporalProfileSampler(logger=self.logger)
        self.cars.useUKHolidays(use_uk_holidays)
        self.cars.setCountry(city)
        self.cars.specialHolidays(customHolidays)
        self.cars.setWeekendDays([5, 6])

        self.buses = TemporalProfileSampler(logger=self.logger)
        self.buses.useUKHolidays(use_uk_holidays)
        self.buses.setCountry(city)
        self.buses.specialHolidays(customHolidays)
        self.buses.setWeekendDays([5, 6])

        self.lgvs = TemporalProfileSampler(logger=self.logger)
        self.lgvs.useUKHolidays(use_uk_holidays)
        self.lgvs.setCountry(city)
        self.lgvs.specialHolidays(customHolidays)
        self.lgvs.setWeekendDays([5, 6])

        self.rigids = TemporalProfileSampler(logger=self.logger)
        self.rigids.useUKHolidays(use_uk_holidays)
        self.rigids.setCountry(city)
        self.rigids.specialHolidays(customHolidays)
        self.rigids.setWeekendDays([5, 6])

        self.artics = TemporalProfileSampler(logger=self.logger)
        self.artics.useUKHolidays(use_uk_holidays)
        self.artics.setCountry(city)
        self.artics.specialHolidays(customHolidays)
        self.artics.setWeekendDays([5, 6])
示例#4
0
    def __init__(self, logger=LookupLogger()):
        self.logger = logger
        self.residential = SpatialTemporalResampler_LUCY(logger)

        self.templateShapefile = None
        self.templateEpsgCode = None
        self.templateIdField = None
        self.outputLayer = None  # actual qgsVectorLayer

        # set new QGIS project layers (created herein) to inherit the project EPSG code (initially) to avoid annoying popups
        s = QSettings()
        s.setValue("/Projections/defaultBehaviour", "useProject")
示例#5
0
 def __init__(self,
              city,
              useUKholidays,
              customHolidays=[],
              logger=LookupLogger()):
     self.logger = logger
     self.gas = DailyLoading(logger=self.logger)
     self.gas.useUKHolidays(useUKholidays)
     self.gas.setCountry(city)
     self.gas.specialHolidays(customHolidays)
     self.electricity = DailyLoading(logger=self.logger)
     self.electricity.useUKHolidays(useUKholidays)
     self.electricity.setCountry(city)
     self.electricity.specialHolidays(customHolidays)
示例#6
0
    def __init__(self, logger=LookupLogger()):

        self.logger = logger

        self.roadLengths = SpatialTemporalResampler(logger=self.logger)
        self.vehicleOwnership = SpatialTemporalResampler(logger=self.logger)
        self.energy = SpatialTemporalResampler(
            logger=self.logger
        )  # TODO: Remove this because we want to calculate it

        self.templateShapefile = None
        self.templateEpsgCode = None
        self.templateIdField = None
        self.outputLayer = None  # actual qgsVectorLayer

        # set new QGIS project layers (created herein) to inherit the project EPSG code (initially) to avoid annoying popups
        s = QSettings()
        s.setValue("/Projections/defaultBehaviour", "useProject")
示例#7
0
    def __init__(self, fuelConsumption, modelParams, logger=LookupLogger()):
        '''
        :param fuelConsumption: FuelConsumption: Populated GQF fuel consumption object
        :param modelParams: Parameters: Populated GQF Model parameters
        :param logger: LookupLogger object (optional) to record the results of disaggregations and lookups
        '''
        self.logger = logger
        self.modelParams = modelParams
        self.fc = fuelConsumption
        self.transport = SpatialTemporalResampler(logger=logger)
        # If traffic flow data for each road segment is broken down by vehicle, two sets of vehicle types are accepted
        # 1. The most detailed breakdown (by vehicle) of traffic counts. Based on LAEI data.
        self.completeInputs = [
            'diesel_car', 'petrol_car', 'diesel_lgv', 'petrol_lgv',
            'motorcycle', 'taxi', 'bus', 'coach', 'rigid', 'artic'
        ]
        # 2. A less specific breakdown that matches the model outputs.
        self.modelledTypes = [
            'car', 'lgv', 'motorcycle', 'taxi', 'bus', 'rigid', 'artic'
        ]
        self.roadTypes = [
            'motorway', 'primary_road', 'secondary_road'
        ]  # The road type headings used internally by the model

        # The methods in this object manufacture a shapefile of fuel consumption in each area. The names of the fields:
        self.dieselNames = {
            'motorcycle': '_FC_Dmcyc',
            'artic': '_FC_Dart',
            'rigid': '_FC_Drig',
            'taxi': '_FC_Dtaxi',
            'car': '_FC_Dcar',
            'bus': '_FC_Dbus',
            'lgv': '_FC_Dlgv'
        }
        self.petrolNames = {
            'motorcycle': '_FC_Pmcyc',
            'artic': '_FC_Part',
            'rigid': '_FC_Prig',
            'taxi': '_FC_Ptaxi',
            'car': '_FC_Pcar',
            'bus': '_FC_Pbus',
            'lgv': '_FC_Plgv'
        }
示例#8
0
    def __init__(self, logger=LookupLogger()):
        '''
        :param logger: LookupLogger object (optional)
        '''

        self.logger = logger

        self.domGas = SpatialTemporalResampler(self.logger)
        self.indGas = SpatialTemporalResampler(self.logger)
        self.domElec = SpatialTemporalResampler(self.logger)
        self.indElec = SpatialTemporalResampler(self.logger)
        self.economy7Elec = SpatialTemporalResampler(self.logger)

        self.templateShapefile = None
        self.templateEpsgCode = None
        self.templateIdField = None

        # set new QGIS project layers (created herein) to inherit the project EPSG code (initially) to avoid annoying popups
        s = QSettings()
        s.setValue("/Projections/defaultBehaviour", "useProject")
示例#9
0
    def __init__(self,
                 areaTimezone,
                 weekendDays,
                 use_uk_holidays,
                 other_holidays=[],
                 logger=LookupLogger()):
        ''' Instantiate
        :param areaTimezone: Time zone string defining the study area's time zone
        :param weekendDays: list of int specifying which days of week are weekend days. 0 = Monday, 6 = Sunday.
        :param timezone : String specifying which timezone to use. Must be compatible with pytz.timezone standard
        :param use_uk_holidays : Boolean: use (True) or don't use (False) standard UK bank holidays (calculated internally)
        :param other_holidays : list() of public holidays (datetime objects). These always get used, regardless of use_uk_holidays.
        '''
        self.logger = logger

        self.diurnal = TemporalProfileSampler(self.logger)
        self.diurnal.setCountry(areaTimezone)
        self.diurnal.useUKHolidays(use_uk_holidays)
        self.diurnal.specialHolidays(other_holidays)
        self.diurnal.setWeekendDays(weekendDays)
        self.useUkHolidays = use_uk_holidays
    def __init__(self,
                 city,
                 use_uk_holidays,
                 customHolidays=[],
                 logger=LookupLogger()):
        ''' Instantiate
        :param city: string: City being modelled (in time zone format e.g. Europe/London)
        :param use_uk_holidays : Boolean: use (True) or don't use (False) standard UK bank holidays (calculated internally)
        :param customHolidays : list() of public holidays (datetime objects). These always get used, regardless of use_uk_holidays.
        '''
        self.logger = logger
        self.energy = TemporalProfileSampler(logger=self.logger)
        self.energy.useUKHolidays(use_uk_holidays)
        self.energy.setCountry(city)
        self.energy.specialHolidays(customHolidays)
        self.energy.setWeekendDays([5, 6])

        self.fraction = TemporalProfileSampler(logger=self.logger)
        self.fraction.useUKHolidays(use_uk_holidays)
        self.fraction.setCountry(city)
        self.fraction.specialHolidays(customHolidays)
        self.fraction.setWeekendDays([5, 6])
示例#11
0
    def __init__(self, city, use_uk_holidays, customHolidays = [], logger=LookupLogger()):
        ''' Instantiate
        :param city : String specifying which city is being modelled (e.g. Europe/London). Must be compatible with pytz.timezone standard
        :param use_uk_holidays : Boolean: use (True) or don't use (False) standard UK bank holidays (calculated internally)
        :param other_holidays : list() of public holidays (datetime objects). These always get used, regardless of use_uk_holidays.
        :param logger: LookupLogger: Logger object
        '''
        self.logger = logger

        self.domesticElectricity = TemporalProfileSampler(logger=self.logger)
        self.domesticElectricity.useUKHolidays(use_uk_holidays)
        self.domesticElectricity.setCountry(city)
        self.domesticElectricity.specialHolidays(customHolidays)
        self.domesticElectricity.setWeekendDays([5,6]) # Future version: Support other weekdays

        self.economy7 = TemporalProfileSampler(logger=self.logger)
        self.economy7.useUKHolidays(use_uk_holidays)
        self.economy7.setCountry(city)
        self.economy7.specialHolidays(customHolidays)
        self.economy7.setWeekendDays([5,6])

        self.domesticGas = TemporalProfileSampler(logger=self.logger)
        self.domesticGas.useUKHolidays(use_uk_holidays)
        self.domesticGas.setCountry(city)
        self.domesticGas.specialHolidays(customHolidays)
        self.domesticGas.setWeekendDays([5,6])

        self.industrialElectricity = TemporalProfileSampler(logger=self.logger)
        self.industrialElectricity.useUKHolidays(use_uk_holidays)
        self.industrialElectricity.setCountry(city)
        self.industrialElectricity.specialHolidays(customHolidays)
        self.industrialElectricity.setWeekendDays([5,6])

        self.industrialGas = TemporalProfileSampler(logger=self.logger)
        self.industrialGas.useUKHolidays(use_uk_holidays)
        self.industrialGas.setCountry(city)
        self.industrialGas.specialHolidays(customHolidays)
        self.industrialGas.setWeekendDays([5,6])