Пример #1
0
    def set_time(self, start, unit, stepsize, nrTimeSteps):
        """  """
        start_timestep = start.isoformat()
        self._nr_timesteps = nrTimeSteps

        epoch = ldm.Epoch(ldm.Epoch.Kind.common_era, start_timestep,
                          ldm.Calendar.gregorian)
        self._lue_clock = ldm.Clock(epoch, unit.value, stepsize)

        self._lue_time_configuration = ldm.TimeConfiguration(
            ldm.TimeDomainItemType.box)

        self.lue_dataset.add_phenomenon('framework')
        tmp = self.lue_dataset.phenomena['framework']

        self.lue_time_extent = tmp.add_property_set(
            "campo_time_cell", self._lue_time_configuration, self._lue_clock)

        # just a number, TODO sampleNumber?
        simulation_id = 1

        # dynamic...
        time_cell = tmp.property_sets["campo_time_cell"]

        time_boxes = 1

        time_cell.object_tracker.active_set_index.expand(time_boxes)[:] = 0
        time_cell.time_domain.value.expand(time_boxes)[:] = [
            0, self._nr_timesteps
        ]

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #2
0
    def _add_framework(self, nr_objects):
        """      """

        # LUE
        self.lue_dataset.add_phenomenon('framework')
        tmp = self.lue_dataset.phenomena['framework']

        self.lue_time_extent = tmp.add_property_set(
            "fame_time_cell",
            ldm.TimeConfiguration(ldm.TimeDomainItemType.box), self.lue_clock)

        # just a number, TODO sampleNumber?
        simulation_id = 1

        # dynamic...
        time_cell = tmp.property_sets["fame_time_cell"]

        time_boxes = 1

        #time_cell.object_tracker.active_object_id.expand(time_boxes * nr_objects)[:] = np.arange(0, nr_objects, dtype=np.dtype(np.uint64))

        #time_cell.object_tracker.active_object_index.expand(time_boxes * nr_objects)[:] = list(np.zeros(nr_objects, dtype=np.dtype(np.uint64)))

        time_cell.object_tracker.active_set_index.expand(time_boxes)[:] = 0

        #time_domain = point_pset.time_domain
        time_cell.time_domain.value.expand(time_boxes)[:] = [
            0, self._nr_timesteps
        ]

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #3
0
    def _generate_lue_phenomenon(self, phenomenon):
        pset = next(iter(phenomenon.property_sets.values()))

        nr_objects = pset.nr_objects

        self.lue_dataset.add_phenomenon(phenomenon.name)
        tmp = self.lue_dataset.phenomena[phenomenon.name]
        tmp.object_id.expand(nr_objects)[:] = np.arange(nr_objects,
                                                        dtype=ldm.dtype.ID)

        for p in phenomenon.property_sets.values():
            self._generate_lue_property_set(phenomenon.name, p)

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #4
0
    def create_dataset(self, filename, working_dir=os.getcwd()):
        """ """
        fpath = os.path.join(working_dir, filename)

        root, ext = os.path.splitext(fpath)
        if ext == '':
            fpath += '.lue'

        if os.path.exists(filename):
            os.remove(filename)
            #raise FileExistsError("'{}' already exists".format(filename))

        self.lue_filename = fpath

        self.lue_dataset = ldm.create_dataset(self.lue_filename)

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #5
0
    def _lue_write_property(self, phen_name, pset, prop, timestep):

        # todo restructure this method...

        # if possible return without performing disk access
        if not prop.is_dynamic:
            # do not write 'static' data in dynamic section
            if timestep is not None:
                return

        lue_pset = self.lue_dataset.phenomena[phen_name].property_sets[
            pset.name]
        object_ids = self.lue_dataset.phenomena[phen_name].object_id[:]

        if not prop.is_dynamic:
            lue_prop = lue_pset.properties[prop.name]
            if isinstance(prop.space_domain, Points):
                for idx, val in enumerate(prop.values().values):
                    lue_prop.value[idx] = prop.values().values[idx]
            elif isinstance(prop.space_domain, Areas):
                for idx, val in enumerate(prop.values().values):
                    lue_prop.value[
                        object_ids[idx]][:] = prop.values().values[idx]
            else:
                raise NotImplementedError

        else:
            if timestep is not None:
                lue_prop = lue_pset.properties[prop.name]
                if isinstance(prop.space_domain, Points):
                    for idx, val in enumerate(prop.values().values):
                        #lue_prop.value[:][idx, timestep - 1] = prop.values().values[idx]
                        tmp = lue_prop.value[idx]
                        tmp[timestep - 1] = prop.values().values[idx]
                        lue_prop.value[idx] = tmp
                else:
                    for idx, val in enumerate(prop.values().values):
                        lue_prop.value[object_ids[idx]][
                            timestep - 1] = prop.values().values[idx]

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #6
0
    def add_property(self,
                     property_name,
                     dtype=np.float64,
                     time_discretisation=TimeDiscretization.dynamic,
                     rank=None,
                     shape=None):
        assert isinstance(property_name, str)
        assert self._lue_dataset_name is not None

        self.time_discretisation = time_discretisation

        # FAME
        self.shapes = None
        if isinstance(self._domain, Points):
            if rank == None:
                self.shapes = [()] * self._phen
            elif rank != None and shape != None:
                self.shapes = [shape] * self._phen
            else:
                raise NotImplementedError
        elif isinstance(self._domain, Areas):
            self.shapes = [(int(self._domain.row_discr[i]),
                            int(self._domain.col_discr[i]))
                           for i in range(len(self._domain.row_discr))]
        else:
            raise NotImplementedError

        p = Property(self._phen, self.shapes, self._uuid, self._domain,
                     self.time_discretisation)
        p.name = property_name

        p._lue_pset_name = self.__name__

        self._properties.add(p)

        # LUE

        nr_timesteps = int(
            self._lue_dataset.phenomena['framework'].
            property_sets['fame_time_cell'].time_domain.value[0][1])

        pset = self._lue_dataset.phenomena[
            self._lue_phenomenon_name].property_sets[self.__name__]

        if isinstance(p.pset_domain, Points):

            if self.time_discretisation == TimeDiscretization.dynamic:
                p_shape = (nr_timesteps, )
                prop = pset.add_property(
                    property_name,
                    dtype=np.dtype(dtype),
                    shape=p_shape,
                    value_variability=ldm.ValueVariability.variable)
                prop.value.expand(self.nr_objects())  # * nr_timesteps)
            else:
                prop = pset.add_property(property_name, dtype=np.dtype(dtype))
                prop.value.expand(self.nr_objects())

        elif isinstance(p.pset_domain, Areas):

            # all same shape...
            #p_shape = (p.pset_domain.row_discr[0], p.pset_domain.col_discr[0])
            #p_shape = (2,1)
            #prop = pset.add_property(property_name, dtype=np.dtype(dtype), shape=p_shape, value_variability=lue.ValueVariability.variable)

            if self.time_discretisation == TimeDiscretization.dynamic:
                prop = pset.add_property(
                    property_name,
                    dtype=np.dtype(dtype),
                    rank=2,
                    shape_per_object=ldm.ShapePerObject.different,
                    shape_variability=ldm.ShapeVariability.constant)
            else:
                # Same shape
                # prop = pset.add_property(property_name, dtype=np.dtype(dtype), shape=shape)

                # Different shape
                prop = pset.add_property(property_name,
                                         dtype=np.dtype(dtype),
                                         rank=2)  #,

            space_discr = pset.fame_discretization

            for idx, item in enumerate(p.pset_domain):
                space_discr.value[idx] = [item[4], item[5]]
                #prop.value.expand(idx, item, nr_timesteps)

            prop.set_space_discretization(ldm.SpaceDiscretization.regular_grid,
                                          space_discr)
            #prop.value.expand(self.nr_objects())

            rank = 2
            if self.time_discretisation == TimeDiscretization.dynamic:
                for idx, item in enumerate(p.pset_domain):
                    #prop.value.expand(idx, tuple([nr_timesteps, item[4], item[5]]), self.nr_objects())
                    prop.value.expand(idx, tuple([item[4], item[5]]),
                                      nr_timesteps)
            else:
                shapes = np.zeros(self.nr_objects() * rank,
                                  dtype=ldm.dtype.Count).reshape(
                                      self.nr_objects(), rank)

                for idx, item in enumerate(p.pset_domain):
                    shapes[idx][0] = item[4]
                    shapes[idx][1] = item[5]

                prop.value.expand(
                    self._lue_dataset.phenomena[
                        self._lue_phenomenon_name].object_id[:], shapes)

        else:
            raise NotImplementedError

        ldm.assert_is_valid(self._lue_dataset_name)
Пример #7
0
    def setUpClass(self):
        nr_areas = 3
        rank = 2
        time_boxes = 1
        timesteps = 3

        dataset = ldm.create_dataset("test_dyn_diff.lue")
        area = dataset.add_phenomenon("phenomenon")

        id = [2, 5, 4]
        area.object_id.expand(nr_areas)[:] = id

        # Time
        time_configuration = ldm.TimeConfiguration(ldm.TimeDomainItemType.box)
        epoch = ldm.Epoch(ldm.Epoch.Kind.common_era, "2000-02-03",
                          ldm.Calendar.gregorian)
        clock = ldm.Clock(epoch, ldm.Unit.year, 2)

        # Space
        space_configuration = ldm.SpaceConfiguration(
            ldm.Mobility.stationary, ldm.SpaceDomainItemType.box)

        prop_set = area.add_property_set("prop_set",
                                         time_configuration,
                                         clock,
                                         space_configuration,
                                         space_coordinate_dtype=np.dtype(
                                             np.float32),
                                         rank=rank)

        prop_set.object_tracker.active_object_id.expand(time_boxes *
                                                        nr_areas)[:] = id

        prop_set.object_tracker.active_object_index.expand(
            time_boxes * nr_areas)[:] = [0, 0, 0]

        prop_set.object_tracker.active_set_index.expand(time_boxes)[:] = 0

        time_domain = prop_set.time_domain
        time_domain.value.expand(time_boxes)[:] = [0, 2]

        box = np.arange(nr_areas * rank * 2, dtype=np.float32).reshape(
            nr_areas, rank * 2) + 1
        box = np.array([[1, 2, 3, 4], [5, 6, 11, 12], [13, 14, 20, 21]],
                       dtype=np.float32)

        prop_set.space_domain.value.expand(nr_areas)[:] = box

        # Property with differently shaped 2D object arrays
        property1_datatype = np.dtype(np.float32)
        property1 = prop_set.add_property(
            "property1",
            dtype=property1_datatype,
            rank=rank,
            shape_per_object=ldm.ShapePerObject.different,
            shape_variability=ldm.ShapeVariability.constant)
        count_datatype = ldm.dtype.Count
        shape = 2 + np.arange(  # Dummy data
            nr_areas * rank, dtype=count_datatype).reshape(nr_areas, rank)

        property2_datatype = np.dtype(np.int32)
        property2 = prop_set.add_property(
            "property2",
            dtype=property2_datatype,
            rank=rank,
            shape_per_object=ldm.ShapePerObject.different,
            shape_variability=ldm.ShapeVariability.constant)

        for idx, obj in enumerate(id):
            property1.value.expand(obj, tuple(shape[idx]), timesteps)
            property2.value.expand(obj, tuple(shape[idx]), timesteps)

        # Dummy values
        for idx, obj_id in enumerate(id):
            for t in range(timesteps):
                np.random.seed(t + 2)
                v1 = (10 *
                      np.random.rand(*shape[idx])).astype(property1_datatype)
                np.random.seed(t + 2)
                v2 = (20 *
                      np.random.rand(*shape[idx])).astype(property2_datatype)
                property1.value[obj_id][t] = v1
                property2.value[obj_id][t] = v2

        # Discretization property with 1D object arrays containing the shape of
        # each object's elevation array: nr_rows and nr_cols
        discretization = prop_set.add_property("discretization",
                                               dtype=count_datatype,
                                               shape=(rank, ))
        discretization.value.expand(nr_areas)[:] = shape

        property1.set_space_discretization(
            ldm.SpaceDiscretization.regular_grid, discretization)

        property2.set_space_discretization(
            ldm.SpaceDiscretization.regular_grid, discretization)

        ldm.assert_is_valid(dataset)
Пример #8
0
    def setUpClass(self):
        nr_areas = 3
        rank = 2

        dataset = ldm.create_dataset("catchments.lue")
        area = dataset.add_phenomenon("catchment")

        id = [2, 5, 4]
        area.object_id.expand(nr_areas)[:] = id

        space_configuration = ldm.SpaceConfiguration(
            ldm.Mobility.stationary, ldm.SpaceDomainItemType.box)
        constant = area.add_property_set("static",
                                         space_configuration,
                                         space_coordinate_dtype=np.dtype(
                                             np.float32),
                                         rank=rank)

        box = np.arange(nr_areas * rank * 2, dtype=np.float32).reshape(
            nr_areas, rank * 2) + 1
        box = np.array([[1, 2, 3, 4], [5, 6, 11, 12], [13, 14, 20, 21]],
                       dtype=np.float32)

        constant.space_domain.value.expand(nr_areas)[:] = box

        # Property with differently shaped 2D object arrays
        property1_datatype = np.dtype(np.float32)
        property1 = constant.add_property("property1",
                                          dtype=property1_datatype,
                                          rank=rank)
        count_datatype = ldm.dtype.Count
        shape = 2 + np.arange(  # Dummy data
            nr_areas * rank, dtype=count_datatype).reshape(nr_areas, rank)
        value = property1.value.expand(id, shape)

        property2_datatype = np.dtype(np.int32)
        property2 = constant.add_property("property2",
                                          dtype=property2_datatype,
                                          rank=rank)
        count_datatype = ldm.dtype.Count
        value2 = property2.value.expand(id, shape)

        for a in range(nr_areas):
            v = (  # Dummy data
                10 * np.random.rand(*shape[a])).astype(property1_datatype)
            value[id[a]][:] = v
            value2[id[a]][:] = (  # Dummy data
                20 * np.random.rand(*shape[a])).astype(property2_datatype)

        # Discretization property with 1D object arrays containing the shape of
        # each object's elevation array: nr_rows and nr_cols
        discretization = constant.add_property("discretization",
                                               dtype=count_datatype,
                                               shape=(rank, ))
        discretization.value.expand(nr_areas)[:] = shape

        property1.set_space_discretization(
            ldm.SpaceDiscretization.regular_grid, discretization)

        property2.set_space_discretization(
            ldm.SpaceDiscretization.regular_grid, discretization)

        ldm.assert_is_valid(dataset)
Пример #9
0
  def setUpClass(self):
    nr_objects = 3

    dataset = ldm.create_dataset("test_const_same.lue")
    phen = dataset.add_phenomenon("catchment")

    id = [2, 5, 4]
    phen.object_id.expand(nr_objects)[:] = id


    point_space_configuration = ldm.SpaceConfiguration(
        ldm.Mobility.stationary,
        ldm.SpaceDomainItemType.point
    )


    point_rank = 2
    point_pset = phen.add_property_set(
        "static_point", point_space_configuration,
        space_coordinate_dtype=np.dtype(np.float32), rank=point_rank)

    box = np.arange(nr_objects * point_rank, dtype=np.float32).reshape(
        nr_objects, point_rank)

    point_pset.space_domain.value.expand(nr_objects)[:] = box

    property1 = point_pset.add_property("property1", dtype=np.dtype(np.float32))
    np.random.seed(2)
    v1 = np.random.rand(nr_objects).astype(np.float32)
    property1.value.expand(nr_objects)[:] = v1

    property2 = point_pset.add_property("property2", dtype=np.dtype(np.int32))
    np.random.seed(2)
    v2 = (20 * np.random.rand(nr_objects)).astype(np.int32)
    property2.value.expand(nr_objects)[:] = v2

    area_space_configuration = ldm.SpaceConfiguration(
        ldm.Mobility.stationary,
        ldm.SpaceDomainItemType.box
    )
    space_rank = 2
    area_pset = phen.add_property_set(
        "static_area", area_space_configuration,
        space_coordinate_dtype=np.dtype(np.float32), rank=space_rank)

    box = np.arange(nr_objects * space_rank * 2, dtype=np.float32).reshape(
        nr_objects, space_rank * 2)
    area_pset.space_domain.value.expand(nr_objects)[:] = box

    shape = (2, 4)
    count_datatype = ldm.dtype.Count

    ## Property with same shaped 2D object arrays
    property1_datatype = np.dtype(np.float32)
    property1 = area_pset.add_property(
        "property1", dtype=property1_datatype, shape=shape)
    np.random.seed(2)
    values = np.random.rand(nr_objects * shape[0] * shape[1]).astype(property1_datatype).reshape(nr_objects, shape[0], shape[1])
    property1.value.expand(nr_objects)[:] = values

    property2_datatype = np.dtype(np.int32)
    property2 = area_pset.add_property(
        "property2", dtype=property2_datatype, shape=shape)
    np.random.seed(2)
    values2 = (20 * np.random.rand(nr_objects * shape[0] * shape[1])).astype(property2_datatype).reshape(nr_objects, shape[0], shape[1])

    property2.value.expand(nr_objects)[:] = values2

    # Discretization property
    space_globals = phen.add_collection_property_set("globals")

    discretization = space_globals.add_property(
        "discretization", dtype=count_datatype, shape=(space_rank,))

    discretization.value.expand(1)[:] = np.array([shape[0],shape[1]],
            dtype=count_datatype).reshape(1, space_rank)

    property1.set_space_discretization(
        ldm.SpaceDiscretization.regular_grid, discretization)

    property2.set_space_discretization(
        ldm.SpaceDiscretization.regular_grid, discretization)

    ldm.assert_is_valid(dataset, fail_on_warning=False)
Пример #10
0
    def _generate_lue_property_set(self, phen_name, property_set):

        rank = -1
        space_type = None
        space_configuration = None
        static = False
        if self._lue_time_configuration is None:
            static = True

        if isinstance(property_set.space_domain, Points):
            space_type = ldm.SpaceDomainItemType.point
            rank = 2
        else:
            space_type = ldm.SpaceDomainItemType.box
            rank = 2

        #if not space_domain.mobile:
        space_configuration = ldm.SpaceConfiguration(ldm.Mobility.stationary,
                                                     space_type)
        #else:
        #  raise NotImplementedError

        if static:
            tmp_pset = self.lue_dataset.phenomena[phen_name].add_property_set(
                property_set.name,
                space_configuration,
                np.dtype(np.float64),
                rank=rank)
        else:
            tmp_pset = self.lue_dataset.phenomena[phen_name].add_property_set(
                property_set.name,
                self._lue_time_configuration,
                self._lue_clock,
                space_configuration,
                np.dtype(np.float64),
                rank=rank)

        tmp_pset = self.lue_dataset.phenomena[phen_name].property_sets[
            property_set.name]

        # Assign coordinates
        if space_type == ldm.SpaceDomainItemType.point:

            space_coordinate_dtype = tmp_pset.space_domain.value.dtype

            tmp_values = np.ones((property_set.nr_objects, 2),
                                 dtype=tmp_pset.space_domain.value.dtype)

            for idx, item in enumerate(property_set.space_domain):
                tmp_values[idx, 0] = item[0]
                tmp_values[idx, 1] = item[1]
            tmp_pset.space_domain.value.expand(
                property_set.nr_objects
            )[-property_set.nr_objects:] = tmp_values

        elif space_type == ldm.SpaceDomainItemType.box:

            space_coordinate_dtype = tmp_pset.space_domain.value.dtype

            tmp_values = np.zeros((property_set.nr_objects, 4),
                                  dtype=tmp_pset.space_domain.value.dtype)

            for idx, item in enumerate(property_set.space_domain):
                tmp_values[idx, 0] = item[0]
                tmp_values[idx, 1] = item[1]
                tmp_values[idx, 2] = item[2]
                tmp_values[idx, 3] = item[3]

            tmp_pset.space_domain.value.expand(
                property_set.nr_objects
            )[-property_set.nr_objects:] = tmp_values

            # For fields we also add a discretisation property
            # tmp_prop = tmp_location.add_property('fame_discretization', dtype=np.dtype(np.int64), shape=(1,2), value_variability=lue.ValueVariability.constant)
            # tmp_prop.value.expand(self._nr_objects)
            # for idx, item in enumerate(space_domain):
            #   tmp_prop.value[idx]= [item[4], item[5]]

            tmp_prop = tmp_pset.add_property('campo_discretization',
                                             dtype=ldm.dtype.Count,
                                             shape=(2, ))
            tmp_prop.value.expand(property_set.nr_objects)

        else:
            raise NotImplementedError

        for prop in property_set.properties.values():
            self._generate_lue_property(phen_name, property_set, prop)

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #11
0
    def _generate_lue_property(self, phen_name, property_set, prop):

        pset = self.lue_dataset.phenomena[phen_name].property_sets[
            property_set.name]

        dtype = prop.values().values[0].dtype

        nr_objects = prop.nr_objects

        if isinstance(property_set.space_domain, Points):

            if prop.is_dynamic:
                time_boxes = 1
                p_shape = (self._nr_timesteps, )
                lue_prop = pset.add_property(
                    prop.name,
                    dtype=np.dtype(dtype),
                    shape=p_shape,
                    value_variability=ldm.ValueVariability.variable)
                lue_prop.value.expand(nr_objects)

                # Just create these once...
                if pset.object_tracker.active_object_id.nr_ids == 0:
                    pset.object_tracker.active_object_id.expand(
                        time_boxes * nr_objects
                    )[:] = self.lue_dataset.phenomena[phen_name].object_id[:]
                    pset.object_tracker.active_set_index.expand(
                        time_boxes)[:] = 0

                    time_domain = pset.time_domain
                    time_domain.value.expand(time_boxes)[:] = [
                        0, self._nr_timesteps
                    ]

            else:
                lue_prop = pset.add_property(prop.name, dtype=np.dtype(dtype))
                lue_prop.value.expand(nr_objects)

        elif isinstance(property_set.space_domain, Areas):

            if prop.is_dynamic:
                lue_prop = pset.add_property(
                    prop.name,
                    dtype=np.dtype(dtype),
                    rank=2,
                    shape_per_object=ldm.ShapePerObject.different,
                    shape_variability=ldm.ShapeVariability.constant)
            else:
                # Same shape
                # prop = pset.add_property(property_name, dtype=np.dtype(dtype), shape=shape)

                # Different shape
                lue_prop = pset.add_property(prop.name,
                                             dtype=np.dtype(dtype),
                                             rank=2)

            space_discr = pset.campo_discretization

            for idx, item in enumerate(property_set.space_domain):
                space_discr.value[idx] = [item[4], item[5]]

            lue_prop.set_space_discretization(
                ldm.SpaceDiscretization.regular_grid, space_discr)

            rank = 2
            if prop.is_dynamic:
                for idx, item in enumerate(property_set.space_domain):
                    prop.value.expand(idx, tuple([item[4], item[5]]),
                                      nr_timesteps)
            else:
                shapes = np.zeros(nr_objects * rank,
                                  dtype=ldm.dtype.Count).reshape(
                                      nr_objects, rank)

                for idx, item in enumerate(property_set.space_domain):
                    shapes[idx][0] = item[4]
                    shapes[idx][1] = item[5]

                lue_prop.value.expand(
                    self.lue_dataset.phenomena[phen_name].object_id[:], shapes)

        else:
            raise NotImplementedError

        if self._debug:
            ldm.assert_is_valid(self.lue_filename)
Пример #12
0
  def setUpClass(self):
    nr_objects = 3
    rank = 2
    time_boxes = 1
    timesteps = 4

    dataset = ldm.create_dataset("test_dyn_same.lue")
    phen = dataset.add_phenomenon("catchment")

    id = [2, 5, 4]
    phen.object_id.expand(nr_objects)[:] = id

    # Time
    time_configuration = ldm.TimeConfiguration(
        ldm.TimeDomainItemType.box
    )
    epoch = ldm.Epoch(ldm.Epoch.Kind.common_era, "2000-02-03", ldm.Calendar.gregorian)
    clock = ldm.Clock(epoch, ldm.Unit.year, 2)

    # Space
    point_space_configuration = ldm.SpaceConfiguration(
        ldm.Mobility.stationary,
        ldm.SpaceDomainItemType.point #box
    )

    point_rank = 1
    point_pset = phen.add_property_set(
        "dynamic_point",
        time_configuration, clock,
        point_space_configuration,
        space_coordinate_dtype=np.dtype(np.float32), rank=point_rank)

    box = np.arange(nr_objects * 2, dtype=np.float32).reshape(
        nr_objects, 2)

    print(box)
    #print(point_pset.space_domain.value[:])

    point_pset.space_domain.value.expand(nr_objects)[:] = box

    point_pset.object_tracker.active_object_id.expand(time_boxes * nr_objects)[:] = id

    point_pset.object_tracker.active_object_index.expand(time_boxes * nr_objects)[:] = [0, 0, 0]

    point_pset.object_tracker.active_set_index.expand(time_boxes)[:] = 0

    time_domain = point_pset.time_domain
    time_domain.value.expand(time_boxes)[:] = [0, 3]

    property1 = point_pset.add_property("property1", dtype=np.dtype(np.float32), shape=(timesteps,),
        value_variability=ldm.ValueVariability.variable)
    np.random.seed(2)
    v1 = np.random.rand(timesteps * nr_objects).astype(np.float32).reshape(nr_objects, timesteps)
    property1.value.expand(nr_objects)[:] = v1


    property2 = point_pset.add_property("property2", dtype=np.dtype(np.int32), shape=(timesteps,),
        value_variability=ldm.ValueVariability.variable)
    np.random.seed(2)
    v2 = (20 * np.random.rand(timesteps * nr_objects)).astype(np.int32).reshape(nr_objects, timesteps)
    property2.value.expand(nr_objects)[:] = v2


    area_space_configuration = ldm.SpaceConfiguration(
        ldm.Mobility.stationary,
        ldm.SpaceDomainItemType.box
    )

    space_rank = 2
    area_pset = phen.add_property_set(
        "dynamic_area",
        time_configuration, clock,
        area_space_configuration,
        space_coordinate_dtype=np.dtype(np.float32), rank=space_rank)

    box = np.arange(nr_objects * space_rank * 2, dtype=np.float32).reshape(
        nr_objects, space_rank * 2)
    area_pset.space_domain.value.expand(nr_objects)[:] = box

    area_pset.object_tracker.active_object_id.expand(time_boxes * nr_objects)[:] = id

    area_pset.object_tracker.active_object_index.expand(time_boxes * nr_objects)[:] = [0, 0, 0]

    area_pset.object_tracker.active_set_index.expand(time_boxes)[:] = 0

    time_domain = area_pset.time_domain
    time_domain.value.expand(time_boxes)[:] = [0, 3]

    shape = (timesteps, 2, 4)
    count_datatype = ldm.dtype.Count

    ## Property with same shaped 2D object arrays
    property1_datatype = np.dtype(np.float32)
    property1 = area_pset.add_property(
        "property1", dtype=property1_datatype, shape=shape,
        value_variability=ldm.ValueVariability.variable)
    values = np.random.rand(timesteps * nr_objects * shape[0] * shape[1]).astype(property1_datatype).reshape(nr_objects, timesteps, shape[1], shape[2])
    property1.value.expand(nr_objects)[:] = values

    property2_datatype = np.dtype(np.int32)
    property2 = area_pset.add_property(
        "property2", dtype=property2_datatype, shape=shape,
        value_variability=ldm.ValueVariability.variable)
    values2 = (20 * np.random.rand(timesteps * nr_objects * shape[0] * shape[1])).astype(property2_datatype).reshape(nr_objects, timesteps, shape[1], shape[2])
    property2.value.expand(nr_objects)[:] = values2

    # Discretization property
    space_globals = phen.add_collection_property_set("globals")

    discretization = space_globals.add_property(
        "discretization", dtype=count_datatype, shape=(space_rank,))

    discretization.value.expand(1)[:] = np.array([shape[0],shape[1]],
            dtype=count_datatype).reshape(1, space_rank)

    property1.set_space_discretization(
        ldm.SpaceDiscretization.regular_grid, discretization)

    property2.set_space_discretization(
        ldm.SpaceDiscretization.regular_grid, discretization)


    ldm.assert_is_valid(dataset)