def _init_attributes(self, edges=None): if edges is None: # recover edges from already initialized edges = self.ids_fromedge.get_linktab() if self.get_version() < 0.1: # update attrs from previous # IdsArrayConf not yet modifiable interactively, despite perm = 'rw',!!! self.ids_fromedge.set_perm('rw') self.ids_toedge.set_perm('rw') if hasattr(self, 'func_delete_row'): self.func_make_row._is_returnval = False self.func_delete_row._is_returnval = False self.add_col(am.IdsArrayConf('ids_fromedge', edges, groupnames=['state'], name='Edge ID from', info='Edge ID where turn starts.', xmltag='fromEdge', )) self.add_col(am.IdsArrayConf('ids_toedge', edges, groupnames=['state'], name='Edge ID to', info='Edge ID where turn ends.', xmltag='toEdge', )) self.add_col(am.ArrayConf('flows', 0, dtype=np.int32, groupnames=['state'], perm='rw', name='Flow', info='Absolute number of vehicles which pass from "fromedge" to "toedge" during a certain time interval.', xmltag='number', )) self.add_col(am.ArrayConf('probabilities', 0.0, dtype=np.float32, groupnames=['state'], perm='rw', name='Probab.', info='Probability to make a turn between "Edge ID from" and "Edge ID to" and .', xmltag='probability', )) self.add(cm.FuncConf('func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New turns', info='Add a new turnflow.', is_returnval=False, )) self.add(cm.FuncConf('func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del turns', info='Delete turns.', is_returnval=False, ))
def _init_attributes(self, edges=None): if edges is None: # recover edges from already initialized edges = self.ids_edge.get_linktab() if self.get_version() < 0.1: # update attrs from previous # IdsArrayConf not yet modifiable interactively, despite perm = 'rw',!!! self.ids_edge.set_perm('rw') if hasattr(self, 'func_delete_row'): self.func_make_row._is_returnval = False self.func_delete_row._is_returnval = False self.add_col( am.IdsArrayConf( 'ids_edge', edges, groupnames=['state'], name='Edge ID', perm='rw', info='Edge ID of flow.', xmltag='from', )) self.add_col( am.ArrayConf( 'flows', 0, dtype=np.int32, groupnames=['state'], perm='rw', name='Flow', info= 'Absolute number of vehicles which start on the given edge during a certain time interval.', xmltag='number', )) self.add( cm.FuncConf( 'func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New flow.', info='Add a new flow.', is_returnval=False, )) self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del flow', info='Delete flow.', is_returnval=False, ))
def __init__(self, odintervals): # print 'AddOdWizzard',odintervals#,odintervals.times_start # print ' dir(odintervals)',dir(odintervals) zones = odintervals.get_zones() self._init_objman('odm_adder', parent=odintervals, name='ODM Wizzard', info='Wizzard to add origin zone to destination zone demand informations.', ) self.add_odoptions_common(odintervals.parent.get_scenario().net.modes, odintervals.parent.activitytypes) self.add_col(am.ArrayConf('names_orig', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Orig zone', info='Name of traffic assignment zone of origin of trip.', )) self.add_col(am.ArrayConf('names_dest', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Dest zone', info='Name of traffic assignment zone of destination of trip.', )) self.add_col(am.ArrayConf('tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info='Number of trips from zone of origin to zone of destination.', xmltag='tripnumber', )) self.add(cm.FuncConf('func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New OD flow.', info='Add a new OD flow.', )) self.add(cm.FuncConf('func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del OD flow', info='Delete OD flow.', ))
def _init_attributes(self, zones=None): # print '_init_attributes',self.ident if not self.has_attrname('zones'): self.add(cm.ObjConf(zones, is_child=False, groups=['_private'])) else: # zones is already an attribute zones = self.zones.get_value() if self.get_version() < 0.1: # update attrs from previous # IdsArrayConf not yet modifiable interactively, despite perm = 'rw',!!! self.ids_orig.set_perm('rw') self.ids_dest.set_perm('rw') if hasattr(self, 'func_delete_row'): self.func_make_row._is_returnval = False self.func_delete_row._is_returnval = False self.add_col( am.IdsArrayConf( 'ids_orig', zones, groupnames=['state'], perm='rw', name='Orig.', #choices = zones.ids_sumo.get_indexmap(), info='traffic assignment zone of origin of trip.', xmltag='id_orig', )) self.add_col( am.IdsArrayConf( 'ids_dest', zones, groupnames=['state'], perm='rw', name='Dest.', #choices = zones.ids_sumo.get_indexmap(), info='ID of traffic assignment zone of destination of trip.', xmltag='id_dest', )) self.add_col( am.ArrayConf( 'tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info= 'Number of trips from zone with ID Orig to zone with ID Dest.', xmltag='tripnumber', )) # print ' pre add func_make_row' self.add( cm.FuncConf( 'func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New OD flow.', info='Add a new OD flow.', is_returnval=False, )) # print ' post add func_make_row' self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del OD flow', info='Delete OD flow.', is_returnval=False, ))
def __init__(self, odintervals): # print 'AddOdWizzard',odintervals#,odintervals.times_start # print ' ',dir(odintervals) zones = odintervals.get_zones() self._init_objman('odm_adder', parent=odintervals, name='ODM Wizzard', info='Wizzard to add origin zone to destination zone demand informations.', ) self.add(am.AttrConf('t_start', 0, groupnames=['state'], perm='rw', name='Start time', unit='s', info='Start time of interval', )) self.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 self.add(am.AttrConf('id_mode', MODES['passenger'], groupnames=['state'], choices=odintervals.parent.vtypes.get_modechoices(), name='ID mode', info='ID of transport mode.', )) self.add(cm.AttrConf('scale', 1.0, groupnames=['options'], perm='rw', name='Scale', info='Scale demand by this factor before adding. Value od 1.0 means no scaling.' )) self.add_col(am.ArrayConf('names_orig', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Orig zone', info='Name of traffic assignment zone of origin of trip.', )) self.add_col(am.ArrayConf('names_dest', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Dest zone', info='Name of traffic assignment zone of destination of trip.', )) self.add_col(am.ArrayConf('tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info='Number of trips from zone with ID Orig to zone with ID Dest.', xmltag='tripnumber', )) self.add(cm.FuncConf('func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New row', info='Add a new row.', )) self.add(cm.FuncConf('func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del row', info='Delete a row.', ))
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.', ))
def _init_attributes(self): # attrsman = self # = self.get_attrsman() demand = self.parent net = self.get_net() self.add(cm.ObjConf(PtLinks('ptlinks', self))) self.add_col( am.ArrayConf( 'linenames', default='', dtype='object', perm='rw', name='Line name', info= 'This is the official name or number of the line. Note that the same line may have several line services for different service periods.', xmltag='line', )) self.add_col( am.ArrayConf( 'times_begin', 0, name='Begin time', unit='s', perm='rw', info='Time when service begins.', xmltag='begin', )) self.add_col( am.ArrayConf( 'times_end', 0, name='End time', perm='rw', unit='s', info='Time when service ends.', xmltag='end', )) self.add_col( am.ArrayConf( 'periods', 0, name='Interval', perm='rw', unit='s', info='Time interval between consecutive vehicles.', xmltag='period', )) self.add_col( am.ArrayConf( 'times_dwell', 20, groupnames=['options'], perm='rw', name='Dwell time', untit='s', info= 'Dwell time in a stop while passengers are boarding/alighting.', xmltag='duration', )) self.add_col( am.IdlistsArrayConf( 'ids_stops', net.ptstops, groupnames=['parameters'], name='PT stop IDs', info= 'Sequence of IDs of stops or stations of a public transort line.', )) self.add_col( am.IdlistsArrayConf( 'ids_edges', net.edges, name='Edge IDs', info= 'Sequence of edge IDs constituting this public transport line.', xmltag='edges', )) self.add_col( am.IdsArrayConf( 'ids_vtype', demand.vtypes, id_default=0, groupnames=['state'], name='Veh. type ID', info='Vehicle type used to derve this line.', xmltag='type', )) self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del line', info='Delete line service.', is_returnval=False, )) if self.get_version() < 0.2: if hasattr(self, 'period'): self.delete('period') self.linenames.set_xmltag('line') self.ids_vtype.set_xmltag('type') self.times_dwell.set_xmltag('duration') self.periods.set_xmltag('period') self.times_end.set_xmltag('end') self.times_begin.set_xmltag('begin')
def __init__(self, odintervals, **kwargs): # print 'AddOdWizzard',odintervals#,odintervals.times_start # print ' dir(odintervals)',dir(odintervals) zones = odintervals.get_zones() self._init_objman( 'odm_adder', parent=odintervals, name='ODM Wizzard', info= 'Wizzard to add origin zone to destination zone demand informations.', ) self.add_odoptions_common(odintervals.parent.get_scenario().net.modes, odintervals.parent.activitytypes, **kwargs) ids_zone = zones.get_ids() zonechoices = {} for id_zone, name_zone in zip(ids_zone, zones.ids_sumo[ids_zone]): zonechoices[name_zone] = id_zone # print ' zonechoices',zonechoices # make for each possible pattern a field for prob # if len(zonechoices) > 0: self.add( cm.ListConf( 'ids_zone_orig_filter', kwargs.get('ids_zone_orig_filter', []), groupnames=['options'], choices=zonechoices, name='Filter zones of origin', info= """Filters flows if its origin is in one of these zones. If no zone is given, then no filtering takes place.""", )) self.add( cm.ListConf( 'ids_zone_dest_filter', kwargs.get('ids_zone_dest_filter', []), groupnames=['options'], choices=zonechoices, name='Filter zones of destination', info= """Filters flows if its destination is in one of these zones. If no zone is given, then no filtering takes place.""", )) self.add( cm.ListConf( 'ids_zone_cross_filter', kwargs.get('ids_zone_cross_filter', []), groupnames=['options'], choices=zonechoices, name='Filter zones to cross', info= """Filters flows if a straight line between origin and destination crosses at least one of these zones. If no zone is given, then no filtering takes place.""", )) self.add( cm.AttrConf( 'dist_min', kwargs.get('dist_min', -1.0), groupnames=['options'], name='Filter zones with min. dist.', unit='m', info= """Filters flows if the straight line between origin and destination is greater than the given minimum distance. If negative, then no filtering takes place.""", )) self.add( cm.AttrConf( 'dist_max', kwargs.get('dist_max', -1.0), groupnames=['options'], name='Filter zones with max. dist.', unit='m', info= """Filters flows if the straight line between origin and destination is less than the given minimum distance. If negative, then no filtering takes place.""", )) self.add_col( am.ArrayConf( 'names_orig', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Orig zone', info='Name of traffic assignment zone of origin of trip.', )) self.add_col( am.ArrayConf( 'names_dest', '', dtype='object', groupnames=['state'], choices=list(zones.ids_sumo.get_value()), name='Dest zone', info='Name of traffic assignment zone of destination of trip.', )) self.add_col( am.ArrayConf( 'tripnumbers', 0, groupnames=['state'], perm='rw', name='Trips', info= 'Number of trips from zone of origin to zone of destination.', xmltag='tripnumber', )) self.add( cm.FuncConf( 'func_make_row', 'on_add_row', None, groupnames=['rowfunctions', '_private'], name='New OD flow.', info='Add a new OD flow.', )) self.add( cm.FuncConf( 'func_delete_row', 'on_del_row', None, groupnames=['rowfunctions', '_private'], name='Del OD flow', info='Delete OD flow.', ))