Beispiel #1
0
    def to_dict(self, extra=(), **kwargs):
        outputs = OrderedDict()
        skip_list = []
        skip_list = ["beams", "columns"]
        # skip_list = ["beams"]
        full_inputs = self.inputs + list(extra)
        for item in full_inputs:
            if item not in skip_list:
                value = self.__getattribute__(item)
                outputs[item] = sf.collect_serial_value(value)

        # # Deal with sections
        # beam_sections = OrderedDict()
        # beam_section_ids = []
        # beam_section_count = 1
        # for ss in range(self.n_storeys):
        #     beam_section_ids.append([])
        #     for bb in range(self.n_bays):
        #         beam_section_ids.append(beam_section_count)
        #         # build a hash string of the section inputs to check uniqueness
        #         parts = []
        #         for item in self.beams[ss][bb].inputs:
        #             parts.append(item)
        #             parts.append(getattr(self.beams[ss][bb], item))
        #         p_str = "-".join(parts)
        #         if p_str not in beam_sections:
        #             beam_sections[p_str] = self.beams[ss][bb].to_dict(extra)
        #             beam_sections[p_str]["id"] = beam_section_count
        #             beam_section_count += 1
        #
        # outputs["beam_section_ids"] = beam_section_ids
        # outputs["beam_sections"] = OrderedDict()
        # for i, p_str in enumerate(beam_sections):
        #     outputs["beam_sections"][beam_sections[p_str]["id"]] = beam_sections[p_str]
        return outputs
Beispiel #2
0
    def to_dict(self, extra=(), **kwargs):
        outputs = OrderedDict()
        skip_list = ["elements"]
        full_inputs = self.inputs + list(extra)
        for item in full_inputs:
            if item not in skip_list:
                value = self.__getattribute__(item)
                outputs[item] = sf.collect_serial_value(value)

        return outputs
Beispiel #3
0
 def to_dict(self, extra=(), **kwargs):
     outputs = OrderedDict()
     skip_list = ["locs"]
     if hasattr(self, "inputs"):
         full_inputs = list(self.inputs) + list(extra)
     else:
         full_inputs = list(extra)
     for item in full_inputs:
         if item not in skip_list:
             value = self.__getattribute__(item)
             outputs[item] = sf.collect_serial_value(value)
     return outputs
Beispiel #4
0
 def to_dict(self, **kwargs):
     outputs = OrderedDict()
     skip_list = []
     for item in self.inputs:
         if item not in skip_list:
             value = self.__getattribute__(item)
             if "_id" in item and value is None:
                 raise ModelError(
                     "Cannot export system with %s set to None" % item)
             if item not in skip_list:
                 value = self.__getattribute__(item)
                 outputs[item] = sf.collect_serial_value(value)
     return outputs
Beispiel #5
0
 def to_dict(self, extra=(), **kwargs):
     outputs = OrderedDict()
     export_none = kwargs.get("export_none", True)
     skip_list = ["cpt", "soil_profile"]
     if hasattr(self, "inputs"):
         full_inputs = list(self.inputs) + list(extra)
     else:
         full_inputs = list(extra)
     for item in full_inputs:
         if item not in skip_list:
             value = self.__getattribute__(item)
             if not export_none and value is None:
                 continue
             outputs[item] = sf.collect_serial_value(
                 value, export_none=export_none)
     return outputs
Beispiel #6
0
 def to_dict(self, extra=(), **kwargs):
     outputs = OrderedDict()
     export_none = kwargs.get("export_none", True)
     if hasattr(self, "inputs"):
         full_inputs = list(self.inputs) + list(extra)
     else:
         full_inputs = list(extra)
     for item in full_inputs:
         if item not in self.skip_list:
             value = self.__getattribute__(item)
             if not export_none and value is None:
                 continue
             outputs[item] = sf.collect_serial_value(value)
     with_hash = kwargs.get('with_hash', True)
     if with_hash:
         outputs['unique_hash'] = self.unique_hash
     return outputs
Beispiel #7
0
    def to_dict(self, extra=(), compression=True, **kwargs):
        outputs = OrderedDict()
        skip_list = ["beams", "columns"]
        full_inputs = self.inputs + list(extra)
        for item in full_inputs:
            if item not in skip_list:
                value = self.__getattribute__(item)
                outputs[item] = sf.collect_serial_value(value)

        # Deal with sections
        column_sections = OrderedDict()
        column_section_ids = []
        column_section_count = 0
        for ss in range(self.n_storeys):
            column_section_ids.append([])
            for cc in range(self.n_cols):

                column_section_ids[ss].append([])
                for sect_i in range(len(self.columns[ss][cc].sections)):
                    if compression:  # build a hash string of the section inputs to check uniqueness
                        parts = []
                        for item in self.columns[ss][cc].sections[
                                sect_i].inputs:
                            if item == "id" or item == "name":
                                continue
                            parts.append(item)
                            parts.append(
                                str(self.columns[ss][cc].get_section_prop(
                                    item, section_i=sect_i)))
                        p_str = "-".join(parts)
                    else:
                        p_str = str(sect_i)
                    if p_str not in column_sections:
                        column_sections[p_str] = self.columns[ss][cc].sections[
                            sect_i].to_dict(extra)
                        column_section_count += 1
                        col_sect_id = column_section_count
                        column_sections[p_str]["id"] = col_sect_id
                    else:
                        col_sect_id = column_sections[p_str]["id"]
                    column_section_ids[ss][cc].append(col_sect_id)

        beam_sections = OrderedDict()
        beam_section_ids = []
        beam_section_count = 0
        for ss in range(self.n_storeys):
            beam_section_ids.append([])
            for bb in range(self.n_bays):
                beam_section_ids[ss].append([])
                for sect_i in range(len(self.beams[ss][bb].sections)):
                    if compression:  # build a hash string of the section inputs to check uniqueness
                        parts = []
                        for item in self.beams[ss][bb].sections[sect_i].inputs:
                            if item == "id" or item == "name":
                                continue
                            parts.append(item)
                            parts.append(
                                str(self.beams[ss][bb].get_section_prop(
                                    item, section_i=sect_i)))
                        p_str = "-".join(parts)
                    else:
                        p_str = str(sect_i)
                    if p_str not in beam_sections:
                        beam_sections[p_str] = self.beams[ss][bb].sections[
                            sect_i].to_dict(extra)
                        beam_section_count += 1
                        beam_sect_id = beam_section_count
                        beam_sections[p_str]["id"] = beam_sect_id
                    else:
                        beam_sect_id = beam_sections[p_str]["id"]
                    beam_section_ids[ss][bb].append(beam_sect_id)

        outputs["column_section_ids"] = column_section_ids
        outputs["beam_section_ids"] = beam_section_ids
        outputs["column_sections"] = OrderedDict()
        outputs["beam_sections"] = OrderedDict()
        for i, p_str in enumerate(column_sections):
            outputs["column_sections"][column_sections[p_str]
                                       ["id"]] = column_sections[p_str]
        for i, p_str in enumerate(beam_sections):
            outputs["beam_sections"][beam_sections[p_str]
                                     ["id"]] = beam_sections[p_str]
        return outputs