예제 #1
0
    def __init__(self,   scenario,
                 nodeshapefilepath, edgeshapefilepath, polyshapefilepath,
                 ident='oximporter',
                 name='OSMnx importer',
                 info='Import of network imported with the help of osmnx.',
                 logger=None, **kwargs):

        print 'OxImporter.__init__'

        self._init_common(ident,
                          parent=scenario,
                          name=name,
                          logger=logger,
                          info=info,
                          )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        # self.id_mode = attrsman.add(am.AttrConf('id_mode',  modechoices['bicycle'],
        #                                groupnames = ['options'],
        #                                choices = modechoices,
        #                                name = 'Mode',
        #                                info = 'Transport mode to be matched.',
        #                                ))

        self.nodeshapefilepath = attrsman.add(
            cm.AttrConf('nodeshapefilepath', nodeshapefilepath,
                        groupnames=['options'],
                        perm='r',
                        name='Node shape file',
                        wildcards='Node Shape file (*.shp)|*.shp',
                        metatype='filepath',
                        info="""File path of node shape file.""",
                        ))
예제 #2
0
    def __init__(self, turnflowintervals):
        # print 'AddOdWizzard',odintervals#,odintervals.times_start
        # print ' ',dir(odintervals)
        edges = turnflowintervals.get_edges()
        self._init_objman('turnflowimporter', parent=turnflowintervals,
                          name='Turnflow Wizzard',
                          info='Wizzard to add origin zone to destination zone demand informations.',
                          )
        attrsman = self.set_attrsman(cm.Attrsman(self))

        attrsman.add(am.AttrConf('t_start', 0,
                                 groupnames=['state'],
                                 perm='rw',
                                 name='Start time',
                                 unit='s',
                                 info='Start time of interval',
                                 ))

        attrsman.add(am.AttrConf('t_end', 3600,
                                 groupnames=['state'],
                                 perm='rw',
                                 name='End time',
                                 unit='s',
                                 info='End time of interval',
                                 ))

        # here we ged classes not vehicle type
        # specific vehicle type within a class will be generated later
        attrsman.add(am.AttrConf('id_mode',   MODES['private'],
                                 groupnames=['state'],
                                 choices=MODES,
                                 name='ID mode',
                                 info='ID of transport mode.',
                                 ))
예제 #3
0
    def __init__(self,
                 scenario=None,
                 net=None,
                 zones=None,
                 name='Demand',
                 info='Transport demand',
                 **kwargs):
        #print 'Network.__init__',name,kwargs

        # we need a network from somewhere
        if net == None:
            net = scenario.net
            zones = scenario.landuse.zones

        self._init_objman(ident='demand',
                          parent=scenario,
                          name=name,
                          info=info,
                          **kwargs)
        attrsman = self.set_attrsman(cm.Attrsman(self))

        self.vtypes = attrsman.add(cm.ObjConf(vehicles.VehicleTypes(self,
                                                                    net)))
        self.trips = attrsman.add(cm.ObjConf(Trips(self, net)))

        self.odintervals = attrsman.add(
            cm.ObjConf(
                origin_to_destination.OdIntervals('odintervals', self, net,
                                                  zones)))
        self.turnflows = attrsman.add(
            cm.ObjConf(turnflows.Turnflows('turnflows', self, net)))
        if scenario != None:
            self.virtualpop = attrsman.add(
                cm.ObjConf(virtualpop.Virtualpolulation(self)))
    def __init__(self, rootname, name_scenario='myscenario',
                 description='', parent=None,
                 workdirpath=None, **kwargs):

        self._init_objman(ident='scenario', parent=parent,
                          name='Scenario', info='Main scenario instance.',
                          version=0.2,
                          **kwargs)

        attrsman = self.set_attrsman(cm.Attrsman(self))

        if workdirpath is not None:
            # create a directory if path is given, but does not exist
            if not os.path.isdir(workdirpath):
                os.mkdir(workdirpath)
        else:
            workdirpath = os.getcwd()
            #workdirpath = os.path.expanduser("~")

        self.name_scenario = attrsman.add(cm.AttrConf('name_scenario', name_scenario,
                                                      groupnames=['options'],
                                                      perm='rw',
                                                      name='Name',
                                                      info='Scenario name, used for documentation purposes only.',
                                                      ))

        self.description = attrsman.add(cm.AttrConf('description', description,
                                                    groupnames=['options'],
                                                    perm='rw',
                                                    name='Description',
                                                    info='Short, free description of Scenario.',
                                                    ))

        self.rootname = attrsman.add(cm.AttrConf('rootname', rootname,
                                                 groupnames=['options'],
                                                 perm='r',
                                                 is_save=True,
                                                 name='Shortname',
                                                 info='Short name for scenario. This string is defined when saving the scenario. It is used as rootname for all files produced by this scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.',
                                                 ))

        self.workdirpath = attrsman.add(cm.AttrConf('workdirpath', workdirpath,
                                                    groupnames=['options'],
                                                    perm='r',
                                                    is_save=True,
                                                    name='Workdir',
                                                    metatype='dirpath',
                                                    info='Working directory for this scenario and can be changed when saving the scenario. Please avoid special charracters, whitespace, accents etc. ASCII is recommented in order to remain compatible between operating systems.',
                                                    ))

        self.net = attrsman.add(cm.ObjConf(network.Network(self)))

        self.landuse = attrsman.add(cm.ObjConf(landuse.Landuse(self, self.net)))

        self.demand = attrsman.add(cm.ObjConf(demand.Demand(self)))
        # if self.get_version()<0.2:
        #    self.delete('simulation')

        self._init_attributes()
예제 #5
0
    def __init__(self, ident, demand=None,
                 name='Mapmatching', info='Mapmatching functionality.',
                 **kwargs):

        self._init_objman(ident=ident, parent=demand,
                          name=name, info=info, **kwargs)

        attrsman = self.set_attrsman(cm.Attrsman(self))

        self._init_attributes()
        self._init_constants()
예제 #6
0
    def __init__(self, demand=None,
                 name='PRT service', info='PRT service',
                 **kwargs):
            # print 'PrtService.__init__',name

        self._init_objman(ident='prtservices', parent=demand,
                          name=name, info=info, **kwargs)
        attrsman = self.set_attrsman(cm.Attrsman(self))

        self._init_attributes()
        self._init_constants()
예제 #7
0
 def __init__(self, scenario,  name='Simulation',
              info='Simulation, contains simulation specific parameters and methods.', **kwargs):
     # print 'Network.__init__',name,kwargs
     self._init_objman(ident='simulation',
                       parent=scenario,
                       name=name,
                       info=info,
                       version=0.2,
                       **kwargs)
     attrsman = self.set_attrsman(cm.Attrsman(self))
     self._init_attributes()
     self._init_constants()
예제 #8
0
    def __init__(self,
                 scenario,
                 ident='oximporter',
                 name='OSMnx importer',
                 info='Import of network imported with the help of osmnx.',
                 logger=None,
                 **kwargs):

        print 'OxImporter.__init__'

        self._init_common(
            ident,
            parent=scenario,
            name=name,
            logger=logger,
            info=info,
        )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        # self.id_mode = attrsman.add(am.AttrConf('id_mode',  modechoices['bicycle'],
        #                                groupnames = ['options'],
        #                                choices = modechoices,
        #                                name = 'Mode',
        #                                info = 'Transport mode to be matched.',
        #                                ))

        self.osmdatafilepaths = attrsman.add(
            cm.AttrConf(
                'osmdatafilepaths',
                kwargs.get('osmdatafilepaths', ''),
                groupnames=['options'],
                perm='rw',
                name='OSM data file(s)',
                wildcards='Jason file (*.json)|*.json',
                metatype='filepaths',
                info=
                """One or several jason filepaths holding OSM related information.""",
            ))

        self.nxnetworkpaths = attrsman.add(
            cm.AttrConf(
                'nxnetworkpaths',
                kwargs.get('nxnetworkpaths', ''),
                groupnames=['options'],
                perm='rw',
                name='Networkx file(s)',
                wildcards='NetworkX file (*.obj)|*.obj',
                metatype='filepaths',
                info=
                """One or several network X filepaths containing topological information of simplified network.""",
            ))
예제 #9
0
    def __init__(self, net, logger=None, **kwargs):
        print 'StopAccessProvider.__init__'
        self._init_common(
            'stopaccessprovider',
            parent=net,
            name='Stop access provider',
            logger=logger,
            info=
            'Provides pedestrian (or bike) access to public transport stops.',
        )
        attrsman = self.set_attrsman(cm.Attrsman(self))

        self.init_accessprovider(**kwargs)
예제 #10
0
    def __init__(self, ident='detectorflows', demand=None,  name='Detector flows',
                 info='Flows measured by detectors, which can be used to generate vehicle routes using the DFRouter.',
                 **kwargs):
        print 'Detectorflows.__init__', name, kwargs

        self._init_objman(ident=ident,
                          parent=demand,
                          name=name,
                          info=info,
                          **kwargs)

        attrsman = self.set_attrsman(cm.Attrsman(self))
        self._init_attributes()
        self._init_constants()
예제 #11
0
    def __init__(self, ident='simresults', parent=None,
                 name='Simulation results',
                 info='Results of SUMO simulation run.',
                 outfile_prefix='out',
                 **kwargs):
        scenario = parent.get_scenario()
        # print 'Network.__init__',name,kwargs
        rootname = scenario.get_rootfilename()
        rootdirpath = scenario.get_workdirpath()

        self._init_objman(ident=ident, parent=parent, name=name,
                          info=info, **kwargs)
        attrsman = self.set_attrsman(cm.Attrsman(self))

        self._init_attributes()
예제 #12
0
파일: results.py 프로젝트: kassenov/sumo
 def __init__(self, ident= 'simresults', scenario=None, 
                 name = 'Simulation results', 
                 info ='Results of SUMO simulation run.', 
                 outfile_prefix = 'out',
                 **kwargs):
                     
     #print 'Network.__init__',name,kwargs
     rootname = scenario.get_rootfilename()
     rootdirpath = scenario.get_workdirpath()
 
     self._init_objman(ident= ident, parent=scenario, name = name, 
                         info = info, **kwargs)
     attrsman = self.set_attrsman(cm.Attrsman(self))
     
     self.edgeresults = attrsman.add(     cm.ObjConf( Edgeresults(self, scenario.net.edges) ) )
     self.tripresults = attrsman.add(     cm.ObjConf( Tripresults(self, scenario.demand.trips, scenario.net.edges) ) )
예제 #13
0
    def __init__(self,  net, logger=None, **kwargs):
        print 'StopAccessProvider.__init__'
        self._init_common('stopaccessprovider',
                          parent=net,
                          name='Stop access provider',
                          logger=logger,
                          info='Provides pedestrian (or bike) access to public transport stops.',
                          )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        self.is_bikeaccess = attrsman.add(cm.AttrConf('is_bikeaccess', kwargs.get('is_bikeaccess', False),
                                                      groupnames=['options'],
                                                      perm='rw',
                                                      name='Provide bike access',
                                                      info='If True, provides also bike access to stops.',
                                                      ))
예제 #14
0
    def __init__(self,  simulation,
                 name='Simple Platooning configuration',
                 info='Configuration of simple platooning service. Simpla is a service that allows to crate platoons in any simulation. The platooning option must be enabled in the Traci micro simulation.',
                 xmltag='configuration',
                 version=0.2,
                 **kwargs):
        # print 'SimplaConfig.__init__',name

        self._init_objman(ident='simplaconfig', parent=simulation,
                          name=name, info=info, xmltag=xmltag,
                          version=0.3,
                          **kwargs)

        attrsman = self.set_attrsman(cm.Attrsman(self))
        self._init_attributes()
        self._init_constants()

        # make PRTservice a demand object as link
        self.get_scenario().demand.add_demandobject(obj=self)
예제 #15
0
파일: taxi.py 프로젝트: qichaow/sumo
    def __init__(
            self,
            simulation,
            name='Taxi service',
            info='Taxi service configuration. In order to use vehicles as taxis, they must have the taxi device.',
            version=0.1,
            **kwargs):
        # print 'TaxiService.__init__'

        self._init_objman(ident='taxiservice',
                          parent=simulation,
                          name=name,
                          info=info,
                          version=0.1,
                          **kwargs)

        attrsman = self.set_attrsman(cm.Attrsman(self))
        self._init_attributes()
        self._init_constants()

        # make TaxiService a demand object as link
        self.get_scenario().demand.add_demandobject(obj=self)
예제 #16
0
    def __init__(self,
                 obj,
                 ident='csvimporter',
                 name='CSV importer',
                 info='Import data from a CSV file into object',
                 logger=None,
                 **kwargs):
        print 'CsvImporter.__init__'
        self._init_common(
            ident,
            parent=obj,
            name=name,
            logger=logger,
            info=info,
        )

        attrsman = self.set_attrsman(cm.Attrsman(self))
        self.csvfilepath = attrsman.add(
            cm.AttrConf(
                'csvfilepath',
                kwargs.get('csvfilepath', ''),
                groupnames=['options'],
                perm='rw',
                name='CSV file',
                wildcards='CSV file (*.csv)|*.csv|*.CSV',
                metatype='filepath',
                info="CSV plain text file path.",
            ))

        self.sep = attrsman.add(
            cm.AttrConf(
                'sep',
                kwargs.get('sep', ","),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Separator',
                info="""Seperator used in SCV file. Exampe: ; , <space key>""",
            ))

        self.is_use_default_for_invalid = attrsman.add(
            cm.AttrConf(
                'is_use_default_for_invalid',
                kwargs.get('is_use_default_for_invalid', True),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Use default for invalid',
                info="""Use default for invalid.""",
            ))

        for attrconf in obj.get_colconfigs():
            colattrname = self._get_colattrname(attrconf.attrname)
            setattr(
                self, colattrname,
                attrsman.add(
                    cm.AttrConf(
                        colattrname,
                        attrconf.attrname,
                        groupnames=['options', 'colnames'],
                        perm='rw',
                        attrname_orig=attrconf.attrname,
                        name='Column name for %s' % attrconf.get_name(),
                        info=
                        'Name of column in CSV file for column %s. Include also hyphens and other delimiters when present in CSV file.'
                        % attrconf.get_name(),
                    )))
예제 #17
0
    def __init__(self, maps, logger=None, **kwargs):
        print 'MapsImporter.__init__', maps, maps.parent.get_ident()
        self._init_common(
            'mapsimporter',
            name='Background maps importer',
            logger=logger,
            info='Downloads and converts background maps.',
        )
        self._maps = maps

        attrsman = self.set_attrsman(cm.Attrsman(self))
        #self.net = attrsman.add(   cm.ObjConf( network.Network(self) ) )
        # self.status = attrsman.add(cm.AttrConf(
        #                            'status', 'preparation',
        #                            groupnames = ['_private','parameters'],
        #                            perm='r',
        #                            name = 'Status',
        #                            info = 'Process status: preparation-> running -> success|error.'
        #                            ))

        self.width_tile = attrsman.add(
            cm.AttrConf(
                'width_tile',
                kwargs.get('width_tile', 500.0),
                groupnames=['options'],
                choices=OrderedDict([
                    ("500", 500.0),
                    ("1000", 1000.0),
                    ("2000", 2000.0),
                    ("4000", 4000.0),
                    ("8000", 8000.0),
                ]),
                perm='rw',
                name='Tile width',
                unit='m',
                info=
                'Tile width in meter of quadratic tile. This is the real width of one tile that will be downloaded.',
            ))

        self.size_tile = attrsman.add(
            cm.AttrConf(
                'size_tile',
                kwargs.get('size_tile', 1280),
                groupnames=['options'],
                perm='rw',
                name='Tile size',
                info=
                'Tile size in pixel. This is the size of one tile that will be downloaded and determins the map resolution. Maximum is 1280.',
            ))

        self.n_tiles = attrsman.add(
            cm.FuncConf(
                'n_tiles',
                'get_n_tiles',
                0,
                groupnames=['options'],
                name='Number of tiles',
                #info = 'Delete a row.',
            ))

        # self.add_option(  'maptype',kwargs.get('maptype','satellite'),
        #                     choices = ['satellite',]
        #                     perm='rw',
        #                     name = 'Map type',
        #                     info = 'Type of map to be downloaded.',
        #                     )
        # self.add_option(  'filetype',kwargs.get('filetype','png'),
        #                     choices = ['png',]
        #                     perm='rw',
        #                     name = 'File type',
        #                     info = 'Image file format to be downloaded.',
        #                     )

        # self.add_option(  'mapserver',kwargs.get('mapserver','google'),
        #                     choices = ['google',]
        #                     perm='rw',
        #                     name = 'Map server',
        #                     info = 'Map server from where to download. Some servers require username and password.',
        #                     )

        # self.add_option(  'username',kwargs.get('username',''),
        #                     perm='rw',
        #                     name = 'User',
        #                      info = 'User name of map server (if required).',
        #                     )

        # self.add_option(  'password',kwargs.get('password',''),
        #                     perm='rw',
        #                     name = 'User',
        #                     info = 'User name of map server (if required).',
        #                     )

        self.is_remove_orig = attrsman.add(
            cm.AttrConf(
                'is_remove_orig',
                kwargs.get('is_remove_orig', True),
                groupnames=['options'],
                perm='rw',
                name='Remove originals',
                info=
                'Remove original files. Original, untransformed files are not necessary, but can be kept.',
            ))
예제 #18
0
    def __init__(self,  filepath,
                 coordsconfig,
                 map_attrconfig2shapeattr=None,
                 attrconfigs=None,
                 ident='shapefileimporter', parent=None,
                 name='Shapefile importer',
                 info='Import of shape files',
                 logger=None,
                 **kwargs):

        self._filepath = filepath
        self._sf = get_shapefile(filepath)
        projparams_shape = get_proj4_from_shapefile(filepath)
        projparams_target_default = self.guess_targetproj()

        print 'ShapefileImporter.__init__', filepath  # ,projparams_target_default, projparams_shape
        self._init_common(ident,
                          parent=parent,
                          name=name,
                          logger=logger,
                          info='Import workouts and GPS points of a European cycling challange.',
                          )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        # if projparams_target == '':
        #    projparams_target = ''
        #    is_guess_targetproj = True
        #    is_use_shapeproj = False

        #projparams_shape = projparams_shapefile

        self.make_fieldinfo()

        # self.id_mode = attrsman.add(am.AttrConf('id_mode',  modechoices['bicycle'],
        #                                groupnames = ['options'],
        #                                choices = modechoices,
        #                                name = 'Mode',
        #                                info = 'Transport mode to be matched.',
        #                                ))

        self.filepath = attrsman.add(
            cm.AttrConf('filepath', filepath,
                        groupnames=['parameters'],
                        perm='r',
                        name='Shape file',
                        wildcards='Shape file (*.shp)|*.shp',
                        metatype='filepath',
                        info="""File path of shape file.""",
                        ))

        self.projparams_shape = attrsman.add(cm.AttrConf('projparams_shape', projparams_shape,
                                                         groupnames=['parameters', ],
                                                         perm='rw',
                                                         name='Shape projection',
                                                         info='Projection4 parameters of shape data.',
                                                         ))

        self.is_guess_targetproj = attrsman.add(cm.AttrConf('is_guess_targetproj', kwargs.get("is_guess_targetproj", True),
                                                            groupnames=['parameters', ],
                                                            perm='r',
                                                            name='Guess target projection?',
                                                            info='If selected, target projection will be guessed based on coordinates of the shapefile.',
                                                            ))

        self.projparams_target = attrsman.add(cm.AttrConf('projparams_target', kwargs.get("projparams_target", projparams_target_default),
                                                          groupnames=['parameters', ],
                                                          perm='r',
                                                          name='Target projection',
                                                          info='Projection4 parameters of target, where the coordinates are imported. These are typically the scenario coordinates.',
                                                          ))

        self.is_use_shapeproj = attrsman.add(cm.AttrConf('is_use_shapeproj', kwargs.get("is_use_shapeproj", False),
                                                         groupnames=['parameters', ],
                                                         perm='r',
                                                         name='Use shapefile projection?',
                                                         info='If selected, projection in shape file will be used to interpret projection. If not selected, target projection will be used.',
                                                         ))

        self.is_use_targetproj = attrsman.add(cm.AttrConf('is_use_targetproj', kwargs.get("is_use_targetproj", True),
                                                          groupnames=['parameters', ],
                                                          perm='r',
                                                          name='Use target projection?',
                                                          info='If selected, target will be used to interpret projection.',
                                                          ))

        self.is_autoffset = attrsman.add(cm.AttrConf('is_autoffset', kwargs.get("is_autoffset", True),
                                                     groupnames=['parameters', ],
                                                     perm='r',
                                                     name='Auto offset?',
                                                     info='If selected, offset will be determined automatically.',
                                                     ))

        self.offset = attrsman.add(cm.AttrConf('offset', kwargs.get("offset", np.array([0.0, 0.0, 0.0], dtype=np.float32)),
                                               groupnames=['parameters', ],
                                               perm='r',
                                               name='Offset',
                                               info='Network offset in WEP coordinates',
                                               ))

        self._coordsconfig = coordsconfig

        if map_attrconfig2shapeattr is None:
            # generate attrconfs with group 'options'
            # and default attrconfmap
            self._map_attrconfig2shapeattr = {}

        else:
            self._map_attrconfig2shapeattr = map_attrconfig2shapeattr
예제 #19
0
    def __init__(self, ident, demand, logger=None, **kwargs):
        print 'OdPlots.__init__'
        self._init_common(
            ident,
            parent=demand,
            name='OD plots',
            logger=logger,
            info='Plot of OD data.',
        )
        attrsman = self.set_attrsman(cm.Attrsman(self))
        modes = demand.parent.net.modes
        self.od_table = demand.odintervals.generate_odflows()

        self.zonefillmode = attrsman.add(
            cm.AttrConf(
                'zonefillmode',
                kwargs.get('zonefillmode', 'zone color'),
                choices=[
                    'zone color', 'flows in - flows out',
                    'flows in + flows out', 'flows in', 'flows out'
                ],
                groupnames=['options'],
                name='Zone fill mode',
                info='Defines how each zone is filled.',
            ))

        ids_mode = list(set(self.od_table.ids_mode.get_value()))
        modechoices = {}
        for id_mode, modename in zip(ids_mode, modes.names[ids_mode]):
            modechoices[modename] = id_mode

        self.ids_mode = attrsman.add(
            cm.ListConf(
                'ids_mode',
                1 * ids_mode,
                groupnames=['options'],
                choices=modechoices,
                name='Modes',
                info="""Modes to be visualized""",
            ))

        ids_inter = demand.odintervals.get_ids()
        intervalchoices = {}
        for id_int, time_start, time_end in zip(
                ids_inter, demand.odintervals.times_start[ids_inter],
                demand.odintervals.times_end[ids_inter]):
            intervalchoices[str(int(time_start / 60.0)) + 'min-' +
                            str(int(time_end / 60.0)) +
                            'min'] = (int(time_start), int(time_end))

        self.intervals = attrsman.add(
            cm.ListConf(
                'intervals',
                intervalchoices.values(),
                groupnames=['options'],
                choices=intervalchoices,
                name='Intervals',
                info="""Time intervals that get visualized""",
            ))

        self.color_zones = attrsman.add(
            cm.AttrConf(
                'color_zones',
                kwargs.get('color_zones',
                           np.array([0.9, 0.9, 0.9, 1.0], dtype=np.float32)),
                groupnames=['options', 'zones'],
                perm='wr',
                metatype='color',
                name='Zone color',
                info=
                'Fill color of Zone, in case the "zone color" is set to "color"',
            ))

        self.alpha_zones = attrsman.add(
            cm.AttrConf(
                'alpha_zones',
                kwargs.get('alpha_zones', 0.3),
                groupnames=['options', 'zones'],
                name='Zone transparency',
                info='Transparency of fill color of zones.',
            ))

        self.color_zoneborders = attrsman.add(
            cm.AttrConf(
                'color_zoneborders',
                kwargs.get('color_zoneborders',
                           np.array([0.0, 0.7, 0.0, 1.0], dtype=np.float32)),
                groupnames=['options', 'zones'],
                perm='wr',
                metatype='color',
                name='Zone border color',
                info='Color of zone border.',
            ))
        self.linewidth_zoneborders = attrsman.add(
            cm.AttrConf(
                'linewidth_zoneborders',
                kwargs.get('linewidth_zoneborders', 3),
                groupnames=['options', 'zones'],
                name='Zone border line widtg',
                info='Transparency of fill color of zones.',
            ))

        self.is_show_id_zone = attrsman.add(
            cm.AttrConf(
                'is_show_id_zone',
                kwargs.get('is_show_id_zone', True),
                groupnames=['options'],
                name='Show zone IDs',
                info='Show ID of each zone.',
            ))

        self.is_show_zonevalues = attrsman.add(
            cm.AttrConf(
                'is_show_zonevalues',
                kwargs.get('is_show_zonevalues', False),
                groupnames=['options'],
                name='Show zone values',
                info=
                'Show values of each zone. Values depend on the choise of "zonefillmode"',
            ))

        self.is_show_flows = attrsman.add(
            cm.AttrConf(
                'is_show_flows',
                kwargs.get('is_show_flows', True),
                groupnames=['options'],
                name='Show OD flows',
                info=
                'Show OD flows as arrows between the zone, these are sometimes called the "desired lines".',
            ))

        self.color_flows = attrsman.add(
            cm.AttrConf(
                'color_flows',
                kwargs.get('color_flows',
                           np.array([0.3, 0.9, 0.3, 1.0], dtype=np.float32)),
                groupnames=['options', 'zones'],
                perm='wr',
                metatype='color',
                name='Flow color',
                info='Flow color if color does not vary with flow value.',
            ))

        self.is_show_flow_colorvalues = attrsman.add(
            cm.AttrConf(
                'is_show_flow_colorvalues',
                kwargs.get('is_show_flow_colorvalues', False),
                groupnames=['options'],
                name='Show OD flows colors',
                info=
                'Show OD flows as colored arrows, where color varies with flow value.',
            ))

        self.width_flows_max = attrsman.add(
            cm.AttrConf(
                'width_flows_max',
                kwargs.get('width_flows_max', 100.0),
                groupnames=['options'],
                name='Max. OD flow width',
                info='Max. OD flow width on map.',
            ))
        # self.is_show_flowvalues = attrsman.add(cm.AttrConf( 'is_show_flowvalues', kwargs.get('is_show_flowvalues', False),
        #                                groupnames = ['options'],
        #                                name = 'Show flow values',
        #                                info = 'Label flows with flow values.',
        #                                ))

        self.add_networkoptions(**kwargs)
        self.add_facilityoptions(**kwargs)
        # self.add_zoneoptions(**kwargs)
        self.add_plotoptions_mapbase(**kwargs)
        self.add_plotoptions_base(**kwargs)
        self.add_save_options(**kwargs)
예제 #20
0
파일: exports.py 프로젝트: webia1/sumopy
    def __init__(self,
                 obj,
                 ident='csvexporter',
                 name='CSV exporter',
                 info='Export data from a CSV file into object',
                 logger=None,
                 **kwargs):
        print 'CsvExporter.__init__'
        self._init_common(
            ident,
            parent=obj,
            name=name,
            logger=logger,
            info=info,
        )

        attrsman = self.set_attrsman(cm.Attrsman(self))
        self.csvfilepath = attrsman.add(
            cm.AttrConf(
                'csvfilepath',
                kwargs.get('csvfilepath', ''),
                groupnames=['options'],
                perm='rw',
                name='CSV file',
                wildcards='CSV file (*.csv)|*.csv|*.CSV',
                metatype='filepath',
                info="CSV plain text file path.",
            ))

        self.sep = attrsman.add(
            cm.AttrConf(
                'sep',
                kwargs.get('sep', ","),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Separator',
                info="""Seperator used in SCV file. Exampe: ; , <space key>""",
            ))

        self.is_header = attrsman.add(
            cm.AttrConf(
                'is_header',
                kwargs.get('is_header', True),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Make header',
                info="""Make header with date and time.""",
            ))

        self.show_parentesis = attrsman.add(
            cm.AttrConf(
                'show_parentesis',
                kwargs.get('show_parentesis', True),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Show units in parenthesis',
                info="""Show units (if any) in parenthesis.""",
            ))
예제 #21
0
    def __init__(self,  mapmatching, logger=None, **kwargs):
        print 'EccTracesImporter.__init__', mapmatching.get_ident()
        self._init_common('traceimporter',
                          parent=mapmatching,
                          name='ECC Trace Importer',
                          logger=logger,
                          info='Import workouts and GPS points of a European cycling challange.',
                          )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        scenario = mapmatching.get_scenario()
        rootfilepath = scenario.get_rootfilepath()

        # here we ged classes not vehicle type
        # specific vehicle type within a class will be generated later
        modechoices = scenario.net.modes.names.get_indexmap()

        # print '  modechoices',modechoices
        self.id_mode = attrsman.add(am.AttrConf('id_mode',  modechoices['bicycle'],
                                                groupnames=['options'],
                                                choices=modechoices,
                                                name='Mode',
                                                info='Transport mode to be matched.',
                                                ))

        self.workoutsfilepath = attrsman.add(
            cm.AttrConf('workoutsfilepath', kwargs.get('workoutsfilepath', rootfilepath+'.workouts.csv'),
                        groupnames=['options'],
                        perm='rw',
                        name='Workout file',
                        wildcards='CSV file (*.csv)|*.csv',
                        metatype='filepath',
                        info="""CSV text file with workout database.""",
                        ))

        self.pointsfilepath = attrsman.add(cm.AttrConf('pointsfilepath', kwargs.get('pointsfilepath', rootfilepath+'.points.csv'),
                                                       groupnames=['options'],
                                                       perm='rw',
                                                       name='Points file',
                                                       wildcards='CSV file (*.csv)|*.csv',
                                                       metatype='filepath',
                                                       info="CSV text file with GPS point database.",
                                                       ))

        self.year = attrsman.add(cm.AttrConf('year', kwargs.get('year', 2014),
                                             groupnames=['options'],
                                             choices={'2014': 2014, 'from 2015': 2015},
                                             perm='rw',
                                             name='Year of challange',
                                             info='Year of challange is used to identify the correct database format.',
                                             ))

        self.dist_trip_min = attrsman.add(cm.AttrConf('dist_trip_min', kwargs.get('dist_trip_min', 100.0),
                                                      groupnames=['options'],
                                                      perm='rw',
                                                      name='Min. trip distance',
                                                      unit='m',
                                                      info='Minimum distance of one trip. Shorter trips will not be imported.',
                                                      ))

        self.duration_trip_min = attrsman.add(cm.AttrConf('duration_trip_min', kwargs.get('duration_trip_min', 30.0),
                                                          groupnames=['options'],
                                                          perm='rw',
                                                          name='Min. trip duration',
                                                          unit='s',
                                                          info='Minimum duration of one trip. Trips with shorter duration will not be imported.',
                                                          ))

        self.speed_trip_min = attrsman.add(cm.AttrConf('speed_trip_min', kwargs.get('speed_trip_min', 3.0),
                                                       groupnames=['options'],
                                                       perm='rw',
                                                       name='Min. av. trip speed',
                                                       unit='m/s',
                                                       info='Minimum average trip speed. Trips with lower average speed will not be imported.',
                                                       ))

        self.speed_trip_max = attrsman.add(cm.AttrConf('speed_trip_max', kwargs.get('speed_trip_max', 50.0),
                                                       groupnames=['options'],
                                                       perm='rw',
                                                       name='Max. av. trip speed',
                                                       unit='m/s',
                                                       info='Maximum average trip speed. Trips with higher average speed will not be imported.',
                                                       ))

        self.sep_column_workout = attrsman.add(cm.AttrConf('sep_column_workout', kwargs.get('sep_column_workout', ','),
                                                           groupnames=['options'],
                                                           perm='rw',
                                                           name='Workoutdata seperator',
                                                           info='Workout column seperator of CSV file',
                                                           ))

        self.sep_column_points = attrsman.add(cm.AttrConf('sep_column_points', kwargs.get('sep_column_points', ','),
                                                          groupnames=['options'],
                                                          perm='rw',
                                                          name='Point data seperator',
                                                          info='Pointdata column seperator of CSV file',
                                                          ))
예제 #22
0
파일: shapeformat.py 프로젝트: qichaow/sumo
    def __init__(self,
                 ident='shapefileimporter',
                 parent=None,
                 name='Shape file importer',
                 filepath='',
                 coordsattr='',
                 attrnames_to_shapeattrs={},
                 info='Import of shape files in parent datastructure.',
                 logger=None,
                 **kwargs):

        print 'ShapefileImporter.__init__', filepath  # ,projparams_target_default, projparams_shape
        self._init_common(
            ident,
            parent=parent,
            name=name,
            logger=logger,
            info=info,
        )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        self.filepath = attrsman.add(
            cm.AttrConf(
                'filepath',
                filepath,
                groupnames=['options'],
                perm='rw',
                name='Shape file',
                wildcards='Shape file (*.shp)|*.shp|All files (*.*)|*.*',
                metatype='filepath',
                info=
                """File path of shape file. Note that only the file with the extention ".shp" needs to be selected. Attention: all file extensions must be in small letters, for example .shp .dbf, shx, etc""",
            ))

        # print 'self.filepath',self.filepath
        attrsman_parent = parent.get_attrsman()
        self._coordsconfig = attrsman_parent.get_config(coordsattr)

        for attrname, shapeattr_default in attrnames_to_shapeattrs.iteritems():
            config = attrsman_parent.get_config(attrname)
            fieldname = 'fieldname_' + attrname
            setattr(
                self, fieldname,
                attrsman.add(
                    cm.AttrConf(
                        fieldname,
                        shapeattr_default,
                        groupnames=['options', 'field names'],
                        perm='rw',
                        attrname_orig=attrname,
                        name='Field for ' + config.get_name(),
                        info='Field name for the following attribute: ' +
                        config.get_info(),
                    )))

        self.projparams_shape = attrsman.add(
            cm.AttrConf(
                'projparams_shape',
                kwargs.get("projparams_shape", ''),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Shape projection',
                info=
                'Projection4 parameters of shape data. If blank then shape file projection is used or if not present, projection will be guessed from shape coordinates.',
            ))

        # self.projparams_target = attrsman.add(cm.AttrConf(  'projparams_target', kwargs.get("projparams_target",''),
        #                                                groupnames = ['options',],
        #                                                perm='rw',
        #                                                name = 'Target projection',
        #                                                info = 'Projection4 parameters of target, where the coordinates are imported. These are typically the scenario coordinates.',
        #                                                ))

        self._projparams_target = kwargs.get("projparams_target", '')
        self.is_use_shapeproj = attrsman.add(
            cm.AttrConf(
                'is_use_shapeproj',
                kwargs.get("is_use_shapeproj", False),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Use shapefile projection?',
                info=
                'If selected, projection in shape file will be used to interpret projection. If not selected, target projection will be used.',
            ))

        self.is_use_targetproj = attrsman.add(
            cm.AttrConf(
                'is_use_targetproj',
                kwargs.get("is_use_targetproj", True),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Use target projection?',
                info=
                'If selected, target will be used to interpret projection.',
            ))

        self.is_probe_offset = attrsman.add(
            cm.AttrConf(
                'is_probe_offset',
                kwargs.get("is_probe_offset", False),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Probe offset?',
                info=
                """With probe offset, a specific coordinate from the shap-map and the target-map will be used to calculate the offset. 
                                                                  This requires the coordinates of a dedicated point of the shape file and of the target.
                                                                  This method can be used if there is an unknon offset in the shape map coordinate system.
                                                                  """,
            ))

        self.x_probe_shape = attrsman.add(
            cm.AttrConf(
                'x_probe_shape',
                kwargs.get("x_probe_shape", 0.0),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Probed x coord of shape',
                unit='m',
                info='Probed x coord of shape-map.',
            ))

        self.y_probe_shape = attrsman.add(
            cm.AttrConf(
                'y_probe_shape',
                kwargs.get("y_probe_shape", 0.0),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Probed y coord shape',
                unit='m',
                info='Probed y coord of shape-map.',
            ))

        self.x_probe_target = attrsman.add(
            cm.AttrConf(
                'x_probe_target',
                kwargs.get("x_probe_target", 0.0),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Probed x coord of target',
                unit='m',
                info='Probed x coord of target-map.',
            ))

        self.y_probe_target = attrsman.add(
            cm.AttrConf(
                'y_probe_target',
                kwargs.get("y_probe_target", 0.0),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Probed y coord target',
                unit='m',
                info='Probed y coord of target-map.',
            ))

        self.is_autoffset = attrsman.add(
            cm.AttrConf(
                'is_autoffset',
                kwargs.get("is_autoffset", False),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Auto offset?',
                info='If selected, offset will be determined automatically.',
            ))

        # self.offset = attrsman.add(cm.AttrConf(  'offset', kwargs.get("offset",np.array([0.0,0.0,0.0],dtype = np.float32)),
        #                                                groupnames = ['options',],
        #                                                perm='r',
        #                                                name = 'Offset',
        #                                                unit = 'm',
        #                                                info = 'Network offset in WEP coordinates',
        #                                                ))

        self._offset = kwargs.get("offset",
                                  np.array([0.0, 0.0, 0.0], dtype=np.float32))

        self.is_limit_to_boundaries = attrsman.add(
            cm.AttrConf(
                'is_limit_to_boundaries',
                kwargs.get("is_limit_to_boundaries", True),
                groupnames=[
                    'options',
                ],
                perm='rw',
                name='Limit to boundaries?',
                info='Import only shapes that fit into the given boundaries.',
            ))

        # self.boundaries = attrsman.add(cm.AttrConf(  'boundaries',kwargs.get('boundaries',np.array([0.0,0.0,0.0,0.0],dtype = np.float32)) ,
        #                                groupnames = ['options',],
        #                                perm='r',
        #                                name = 'Boundaries',
        #                                unit = 'm',
        #                                info = 'Area limiting boundaries',
        #                                ))
        self.boundaries = kwargs.get(
            'boundaries', np.array([0.0, 0.0, 0.0, 0.0], dtype=np.float32))
예제 #23
0
    def __init__(self, ident, detectors,  logger=None, **kwargs):
        print 'DetectorMatcher.__init__'

        # TODO: let this be independent, link to it or child??

        self._init_common(ident,
                          parent=detectors,
                          name='Detector Matcher',
                          logger=logger,
                          info='Match detectors to lanes.',
                          )

        attrsman = self.set_attrsman(cm.Attrsman(self))

        net = detectors.get_scenario().net

        self.modename = attrsman.add(cm.AttrConf('modename', kwargs.get('modename', 'passenger'),
                                                 groupnames=['options'],
                                                 choices=net.modes.names.get_indexmap().keys(),
                                                 name='Mode name',
                                                 info='Matched lanes must be accessible at least for this mode.',
                                                 ))

        print 'net.modes.names.get_indexmap().keys()', net.modes.names.get_indexmap().keys(),  self.modename

        self.is_edgedetectors = attrsman.add(cm.AttrConf('is_edgedetectors', kwargs.get('is_edgedetectors', False),
                                                         groupnames=['options'],
                                                         name='One detector per edge',
                                                         info="""If True, it is assumed that there is only one detector per edge
                            and detected edge flows will be distributed accross accessible lanes according to some heuristics.
                            If False then each detector is matched to one lane. This is somewhat risky and requires a good 
                            geometrical coincidence between detector position and lane. 
                            """,
                                                         ))

        self.is_check_direction = attrsman.add(cm.AttrConf('is_check_direction', kwargs.get('is_check_direction', False),
                                                           groupnames=['options'],
                                                           name='Use detector direction',
                                                           info="""If True, use director direction information to improve matching.
                            """,
                                                           ))
        self.phidelta_max = attrsman.add(cm.AttrConf('phidelta_max', kwargs.get('phidelta_max', 10.0),
                                                     groupnames=['options'],
                                                     name='Max. angle diff.',
                                                     unit='deg',
                                                     info="""Maximum difference of angels between detector and nearest edge segment.
                            To be used in conjunction with "Use detector direction" """,
                                                     ))

        self.d_max = attrsman.add(cm.AttrConf('d_max', kwargs.get('d_max', 20.0),
                                              groupnames=['options'],
                                              name='Maximum search dist.',
                                              unit='m',
                                              info="""Maximum search distance around detectors.""",
                                              ))

        self.n_targetedge = attrsman.add(cm.AttrConf('n_targetedge', kwargs.get('n_targetedge', 5),
                                                     groupnames=['options'],
                                                     name='Number of target edges',
                                                     info="""Maximum number of considered target edges when searching for the nearest edge.
                            """,
                                                     ))

        self.d_max = attrsman.add(cm.AttrConf('d_max', kwargs.get('d_max', 20.0),
                                              groupnames=['options'],
                                              name='Maximum search dist.',
                                              unit='m',
                                              info="""Maximum search distance around detectors.""",
                                              ))
예제 #24
0
    def __init__(self, ident, demand, logger=None, **kwargs):
        print 'VpCreator.__init__'
        self._init_common(
            ident,
            parent=demand,
            name='Od plots',
            logger=logger,
            info='Plot od data.',
        )
        attrsman = self.set_attrsman(cm.Attrsman(self))

        self.is_plot_reallocation = attrsman.add(
            cm.AttrConf(
                'is_plot_reallocation',
                kwargs.get('is_plot_reallocation', True),
                groupnames=['options'],
                name='Plot re-allocation',
                info='Plot re-allocation.',
            ))
        self.is_plot_trip_density = attrsman.add(
            cm.AttrConf(
                'is_plot_trip_density',
                kwargs.get('is_plot_trip_density', True),
                groupnames=['options'],
                name='Plot trips density',
                info='Plot rtrips density.',
            ))
        self.is_net = attrsman.add(
            cm.AttrConf(
                'is_net',
                kwargs.get('is_net', True),
                groupnames=['options'],
                name='Plot net',
                info='Plot net.',
            ))
        self.is_save = attrsman.add(
            cm.AttrConf(
                'is_save',
                kwargs.get('is_save', False),
                groupnames=['options'],
                name='Save plots',
                info='Save plots.',
            ))
        ##        scenario = self.parent.get_scenario()
        ##        print scenario.demand.odintervals.get_ids()
        self.id_interval = attrsman.add(
            cm.AttrConf(
                'id_interval',
                kwargs.get('interval', 1),
                groupnames=['options'],
                ##                                        choices = scenario.demand.odintervals.ids,
                name='interval',
                info='interval.',
            ))
        ##        vtypes = scenario.demand.vtypes

        self.id_odmode = attrsman.add(
            cm.AttrConf(
                'id_odmode',
                kwargs.get('id_odmodes', 1),
                groupnames=['options'],
                name='id_odmodes',
                ##                                        choices = vtypes.get_modechoices(),
                info='id_odmodes.',
            ))