Example #1
0
 def __init__(self, *args, **kwargs):
     Dataset.__init__(self,
                      dataset_name="test_location",
                      id_name="id",
                      in_table_name=kwargs.get('in_table_name',
                                               'test_locations'),
                      in_storage=kwargs['in_storage'])
    def __init__(self,
            resources=None,
            in_storage=None,
            out_storage=None,
            in_table_name=None,
            out_table_name=None,
            attributes=None,
            id_name=None,
            nchunks=None,
            other_in_table_names=None,
            debuglevel=0
            ):
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating EmploymentSectorGroupDataset object.",2)
        resources = ResourceCreatorEmploymentSectorGroups().get_resources_for_dataset(
            resources = resources,
            in_storage = in_storage,
            out_storage = out_storage,
            in_table_name = in_table_name,
            out_table_name = out_table_name,
            attributes = attributes,
            id_name = id_name,
            id_name_default = self.id_name_default,
            nchunks = nchunks,
            debug = debug,
            )

        Dataset.__init__(self,resources = resources)

        if isinstance(other_in_table_names,list):
            for place_name in other_in_table_names: #load other tables
                ds = Dataset(resources = resources)
                ds.load_dataset(in_table_name=place_name)
                self.connect_datasets(ds)
Example #3
0
    def __init__(self, 
            resources=None, 
            in_storage=None,
            out_storage=None, 
            in_table_name=None, 
            out_table_name=None, 
            attributes=None, 
            id_name=None, 
            nchunks=None, 
            debuglevel=0
            ):
        try: 
            debug = SessionConfiguration().get('debuglevel', 0)
        except:
            debug = 0
        debug = DebugPrinter(debug)
        if debuglevel > debug.flag:
            debug.flag = debuglevel
            
        debug.print_debug("Creating object %s.%s" % (self.__class__.__module__, self.__class__.__name__), 2)
        
        resources = ResourceFactory().get_resources_for_dataset(
            self.dataset_name, 
            resources = resources, 
            in_storage = in_storage,
            in_table_name_pair = (in_table_name,self.in_table_name_default), 
            attributes_pair = (attributes,self.attributes_default),
            out_storage = out_storage,
            out_table_name_pair = (out_table_name, self.out_table_name_default), 
            id_name_pair = (id_name, self.id_name_default), 
            nchunks_pair = (nchunks,self.nchunks_default), 
            debug_pair = (debug,None),
            )

        CoreDataset.__init__(self,resources = resources)
    def __init__(self, resources=None, in_storage=None, out_storage=None,
                  in_table_name=None, attributes=None,
                  out_table_name=None, id_name=None,
                  nchunks=None, other_in_table_names=None,
                  debuglevel=0):
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating DevelopmentGroupDataset object.",2)
        resources = ResourceCreatorDevelopmentGroups().get_resources_for_dataset(
            resources = resources,
            in_storage = in_storage,
            out_storage = out_storage,
            in_table_name = in_table_name,
            out_table_name = out_table_name,
            attributes = attributes,
            id_name = id_name,
            id_name_default = self.id_name_default,
            nchunks = nchunks,
            debug = debug
            )

        Dataset.__init__(self,resources = resources)

        if isinstance(other_in_table_names,list):
            for place_name in other_in_table_names: #load other tables
                ds = Dataset(resources = resources)
                ds.load_dataset(in_table_name=place_name)
                self.connect_datasets(ds)
 def __init__(self, *args, **kwargs):
     Dataset.__init__(
         self,
         dataset_name="test_location",
         id_name="id",
         in_table_name=kwargs.get("in_table_name", "test_locations"),
         in_storage=kwargs["in_storage"],
     )
 def __init__(self, *args, **kwargs):
     Dataset.__init__(
         self, 
         dataset_name="test_agent",
         id_name="id",
         in_table_name=kwargs.get('in_table_name','test_agents'),
         in_storage=kwargs['in_storage']
     )
Example #7
0
 def __init__(self, *args, **kwargs):
     storage = StorageFactory().get_storage('dict_storage')
     
     storage.write_table(table_name='alldata',
         table_data={
             self.id_name:array([1]),
             }
         )
     
     Dataset.__init__(self, in_storage=storage, in_table_name='alldata', id_name=self.id_name, dataset_name="alldata")
Example #8
0
    def __init__(self,
                 categories=array([
                     1,
                 ]),
                 resources=None,
                 what=None,
                 attribute_name=None,
                 data=None,
                 names=None,
                 in_storage=None,
                 out_storage=None,
                 in_table_name=None,
                 attributes=None,
                 out_table_name=None,
                 id_name=None,
                 nchunks=None,
                 debuglevel=0):
        """
        'what' must be a string, such as 'residential' or 'commercial'.
        """
        debug = DebugPrinter(debuglevel)
        debug.print_debug(
            "Creating DevelopmentProjectDataset object for %s projects." %
            what, 2)

        self.categories = categories
        self.what = what
        self.attribute_name = attribute_name
        attributes_default = AttributeType.PRIMARY
        dataset_name = "development_project"
        nchunks_default = 1

        if data <> None:
            in_storage = StorageFactory().get_storage('dict_storage')

            in_storage.write_table(table_name='development_projects',
                                   table_data=data)
            in_table_name = 'development_projects'

        resources = ResourceFactory().get_resources_for_dataset(
            dataset_name,
            resources=resources,
            in_storage=in_storage,
            out_storage=out_storage,
            in_table_name_pair=(in_table_name, None),
            out_table_name_pair=(out_table_name, None),
            attributes_pair=(attributes, attributes_default),
            id_name_pair=(id_name, self.id_name_default),
            nchunks_pair=(nchunks, nchunks_default),
            debug_pair=(debug, None))

        self.category_variable_name = resources.get(
            "category_variable_name", self.category_variable_name_default)
        Dataset.__init__(self, resources=resources)
 def __init__(self, **kwargs):
     self.constants_dict = Constants(**kwargs)
     data = {}
     for attr, value in self.constants_dict.iteritems():
         if isscalar(value):
             new_value = array([value])
             data[attr] = new_value
     storage = StorageFactory().get_storage("dict_storage")
     storage.write_table(table_name="urbansim_constants", table_data=data)  # whatever name
     Dataset.__init__(
         self, in_storage=storage, in_table_name="urbansim_constants", id_name=[], dataset_name="urbansim_constant"
     )
    def __init__(
        self,
        categories=array([1]),
        resources=None,
        what=None,
        attribute_name=None,
        data=None,
        names=None,
        in_storage=None,
        out_storage=None,
        in_table_name=None,
        attributes=None,
        out_table_name=None,
        id_name=None,
        nchunks=None,
        debuglevel=0,
    ):
        """
        'what' must be a string, such as 'residential' or 'commercial'.
        """
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating DevelopmentProjectDataset object for %s projects." % what, 2)

        self.categories = categories
        self.what = what
        self.attribute_name = attribute_name
        attributes_default = AttributeType.PRIMARY
        dataset_name = "development_project"
        nchunks_default = 1

        if data <> None:
            in_storage = StorageFactory().get_storage("dict_storage")

            in_storage.write_table(table_name="development_projects", table_data=data)
            in_table_name = "development_projects"

        resources = ResourceFactory().get_resources_for_dataset(
            dataset_name,
            resources=resources,
            in_storage=in_storage,
            out_storage=out_storage,
            in_table_name_pair=(in_table_name, None),
            out_table_name_pair=(out_table_name, None),
            attributes_pair=(attributes, attributes_default),
            id_name_pair=(id_name, self.id_name_default),
            nchunks_pair=(nchunks, nchunks_default),
            debug_pair=(debug, None),
        )

        self.category_variable_name = resources.get("category_variable_name", self.category_variable_name_default)
        Dataset.__init__(self, resources=resources)
Example #11
0
    def __init__(self,
            resources=None,
            other_in_table_names=None,
            use_groups=True,
            ):

        Dataset.__init__(self,resources = resources)

        if isinstance(other_in_table_names,list):
            for place_name in other_in_table_names: #load other tables
                ds = Dataset(resources = resources)
                ds.load_dataset(in_table_name=place_name)
                self.connect_datasets(ds)

        if use_groups:
            self.groups = self._get_groups()
 def __init__(self, **kwargs):
     self.constants_dict = Constants(**kwargs)
     data = {}
     for attr, value in self.constants_dict.iteritems():
         if isscalar(value):
             new_value = array([value])
             data[attr] = new_value
     storage = StorageFactory().get_storage('dict_storage')
     storage.write_table(
         table_name='urbansim_constants',  # whatever name
         table_data=data)
     Dataset.__init__(self,
                      in_storage=storage,
                      in_table_name='urbansim_constants',
                      id_name=[],
                      dataset_name='urbansim_constant')
Example #13
0
    def __init__(
        self,
        resources=None,
        other_in_table_names=None,
        use_groups=True,
    ):

        Dataset.__init__(self, resources=resources)

        if isinstance(other_in_table_names, list):
            for place_name in other_in_table_names:  #load other tables
                ds = Dataset(resources=resources)
                ds.load_dataset(in_table_name=place_name)
                self.connect_datasets(ds)

        if use_groups:
            self.groups = self._get_groups()
    def __init__(self, resources=None, what="household", in_storage=None,
                 in_table_name=None, out_storage=None, out_table_name=None, 
                 id_name=None, nchunks=None, debuglevel=0):
        ## TODO remove "what" arguement
        
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating ControlTotalDataset object for "+what+".",2)
        
        if not self.in_table_name_default:
            self.in_table_name_default = "annual_" + what + "_control_totals"
        if not self.out_table_name_default:         
            self.out_table_name_default = "annual_" + what + "_control_totals"
            
        attributes_default = AttributeType.PRIMARY
        #dataset_name = "control_total"
        nchunks_default = 1

        resources = ResourceFactory().get_resources_for_dataset(
            self.dataset_name,
            resources=resources,
            in_storage=in_storage,
            out_storage=out_storage,
            in_table_name_pair=(in_table_name,self.in_table_name_default),
            attributes_pair=(None, attributes_default),
            out_table_name_pair=(out_table_name, self.out_table_name_default),
            id_name_pair=(id_name,self.id_name_default),
            nchunks_pair=(nchunks,nchunks_default),
            debug_pair=(debug,None)
            )
        
        table_name = resources["in_table_name"]
        if resources['id_name'] is None or len(resources['id_name'])== 0:
            #if both self.id_name_default and id_name argument in __init__ is unspecified, 
            #ControlTotalDataset would use all attributes not beginning with "total"
            #as id_name
            id_names = []
            column_names = resources["in_storage"].get_column_names(table_name)
            for column_name in column_names:
                if not re.search('^total', column_name):
                    id_names.append(column_name)
            resources.merge({"id_name":resources["id_name"] + id_names})

        Dataset.__init__(self, resources = resources)
Example #15
0
 def __init__(self, 
         resources=None, 
         data=None, 
         names=None, 
         in_storage=None, 
         out_storage=None,
         in_table_name=None, 
         out_table_name=None,
         attributes=None, 
         id_name=None,
         nchunks=None, 
         debuglevel=0
         ):
     debug = DebugPrinter(debuglevel)
     debug.print_debug("Creating LandUseDevelopmentDataset object.", 2 )
     
     dataset_name = "landuse_development"
     nchunks_default = 1
     
     if data <> None:
         in_storage = StorageFactory().get_storage('dict_storage')
         
         in_storage.write_table(table_name='landuse_developments', table_data=data)
         in_table_name='landuse_developments'
     
     resources = ResourceFactory().get_resources_for_dataset(
             dataset_name, 
             in_storage=in_storage, 
             out_storage=out_storage,
             resources=resources, 
             in_table_name_pair=(in_table_name,None), 
             out_table_name_pair=(out_table_name, None), 
             id_name_pair=(id_name,self.id_name_default), 
             nchunks_pair=(nchunks,nchunks_default), 
             debug_pair=(debug,None)
             )
         
     Dataset.__init__(self, resources = resources)
    def __init__(self,
                 resources=None,
                 data=None,
                 names=None,
                 in_storage=None,
                 out_storage=None,
                 in_table_name=None,
                 out_table_name=None,
                 attributes=None,
                 id_name=None,
                 nchunks=None,
                 debuglevel=0):
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating LandUseDevelopmentDataset object.", 2)

        dataset_name = "landuse_development"
        nchunks_default = 1

        if data <> None:
            in_storage = StorageFactory().get_storage('dict_storage')

            in_storage.write_table(table_name='landuse_developments',
                                   table_data=data)
            in_table_name = 'landuse_developments'

        resources = ResourceFactory().get_resources_for_dataset(
            dataset_name,
            in_storage=in_storage,
            out_storage=out_storage,
            resources=resources,
            in_table_name_pair=(in_table_name, None),
            out_table_name_pair=(out_table_name, None),
            id_name_pair=(id_name, self.id_name_default),
            nchunks_pair=(nchunks, nchunks_default),
            debug_pair=(debug, None))

        Dataset.__init__(self, resources=resources)
Example #17
0
    def __init__(self,
                 resources=None,
                 in_storage=None,
                 out_storage=None,
                 in_table_name=None,
                 out_table_name=None,
                 attributes=None,
                 id_name=None,
                 nchunks=None,
                 debuglevel=0):
        try:
            debug = SessionConfiguration().get('debuglevel', 0)
        except:
            debug = 0
        debug = DebugPrinter(debug)
        if debuglevel > debug.flag:
            debug.flag = debuglevel

        debug.print_debug(
            "Creating object %s.%s" %
            (self.__class__.__module__, self.__class__.__name__), 2)

        resources = ResourceFactory().get_resources_for_dataset(
            self.dataset_name,
            resources=resources,
            in_storage=in_storage,
            in_table_name_pair=(in_table_name, self.in_table_name_default),
            attributes_pair=(attributes, self.attributes_default),
            out_storage=out_storage,
            out_table_name_pair=(out_table_name, self.out_table_name_default),
            id_name_pair=(id_name, self.id_name_default),
            nchunks_pair=(nchunks, self.nchunks_default),
            debug_pair=(debug, None),
        )

        CoreDataset.__init__(self, resources=resources)