[docs]@register_api_implementation(core_class=TransientPartialFindCreator)classTransientPartialFindCreatorSetup(PartialFindCreatorSetup):""" Class for handling the querying of transient data tables in load cases To create an instance the following steps may be taken: .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> import numpy as np >>> simulation_setup = ApiGateway(proj=proj).create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup() >>> load_case_setup = lcc_setup.create_load_case_setup(lc_type='Mechanical load case') >>> data_table_setup = simulation_setup \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name_1') >>> var_val, data_val = np.array([0, 0.3, 0.6]), np.array([[0, 1e-3, 2e-3], [1, 2, 3]]) >>> data_table_setup = data_table_setup \\ ... .set_data(var=var_val, data=data_val) >>> print("Available data tables: {}".format(load_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... >>> load_case_setup = load_case_setup \\ ... .set_data_table_by_name(data_table_name='data_table_name_1') \\ ... .set_time_dependent_data_bool(value=True) >>> lc_data_table_query_config = load_case_setup.get_data_table_query_config() In the methods below it is assumed that a lc_data_table_query_config variable contains an object of this class as created above, including the data_table_setup """
[docs]defset_time_dependent_data_column_index(self,index:int)->'TransientPartialFindCreatorSetup':""" Sets the chosen transient data table column to the index provided .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> import numpy as np >>> simulation_setup = ApiGateway(proj=proj).create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup() >>> load_case_setup = lcc_setup.create_load_case_setup(lc_type='Mechanical load case') >>> data_table_setup_1 = simulation_setup \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name_1') >>> var_val, data_val = np.array([0, 0.3, 0.6]), np.array([[0, 1e-3, 2e-3], [1, 2, 3]]) >>> data_table_setup_1 = data_table_setup_1 \\ ... .set_data(var=var_val, data=data_val) >>> data_table_setup_2 = simulation_setup \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name_2') >>> print("Available data tables: {}".format(load_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... >>> load_case_setup = load_case_setup \\ ... .set_data_table_by_name(data_table_name='data_table_name_1') \\ ... .set_time_dependent_data_bool(value=True) >>> lc_data_table_query_config = load_case_setup.get_data_table_query_config() >>> lc_data_table_query_config = lc_data_table_query_config.set_time_dependent_data_column_index(index=1) .. >>> lc_data_table_query_config._initial_partial_find_creator.data_table_column_index == 1 True >>> load_case_setup = load_case_setup.set_data_table_by_name(data_table_name='data_table_name_2') >>> lc_data_table_query_config.set_time_dependent_data_column_index(index=0) Traceback (most recent call last): ... more.api.exceptions.api_exception.StaleReferentError: This query config is stale and no longer valid, most probably the chosen data table changed >>> lc_data_table_query_config = load_case_setup.get_data_table_query_config() >>> lc_data_table_query_config.set_time_dependent_data_column_index(index=1) Traceback (most recent call last): ... more.api.exceptions.api_exception.IndexNotFoundError: Index: "1" is out of bounds, max column index is "0" Parameters ---------- index: int The index of the column to set Returns ------- self This transient query config object Raises ------ StaleReferentError Raised if the data table chosen in the corresponding load case has changed and this query config is no longer valid IndexNotFoundError Raised if the given index is out of bounds TypeError Raised if the given index is not an integer """ifnotisinstance(index,int):raiseTypeError('Only integers can be used as indices for transient data tables')ifindex>=len(self._initial_partial_find_creator.data_table.column_headers[1:]):raiseIndexNotFoundError(f'Index: \"{index}\" is out of bounds, max column index is \"{len(self._initial_partial_find_creator.data_table.column_headers[1:])-1}\"')self._initial_partial_find_creator.data_table_column_index=indexreturnself
[docs]defset_time_dependent_data_column_by_name(self,name:str)->'TransientPartialFindCreatorSetup':""" Sets the chosen transient data table column to the name provided .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> import numpy as np >>> simulation_setup = ApiGateway(proj=proj).create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup() >>> load_case_setup = lcc_setup.create_load_case_setup(lc_type='Mechanical load case') >>> data_table_setup_1 = simulation_setup \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name_1') >>> var_val, data_val = np.array([0, 0.3, 0.6]), np.array([[0, 1e-3, 2e-3], [1, 2, 3]]) >>> data_table_setup_1 = data_table_setup_1 \\ ... .set_data(var=var_val, data=data_val) >>> data_table_setup_2 = simulation_setup \\ ... .create_data_table_setup(data_table_type_name='Transient data table') \\ ... .set_name(name='data_table_name_2') >>> print("Available data tables: {}".format(load_case_setup.available_data_table_names)) # To check which data tables are available Available data tables: ... >>> load_case_setup = load_case_setup \\ ... .set_data_table_by_name(data_table_name='data_table_name_1') \\ ... .set_time_dependent_data_bool(value=True) >>> lc_data_table_query_config = load_case_setup.get_data_table_query_config() >>> data_table_setup = data_table_setup_1 >>> data_table_setup = data_table_setup.set_column_name(index=1, new_name='New column name') >>> lc_data_table_query_config = lc_data_table_query_config.set_time_dependent_data_column_by_name(name='New column name') .. >>> lc_data_table_query_config._initial_partial_find_creator.data_table_column_index == 1 True >>> load_case_setup = load_case_setup.set_data_table_by_name(data_table_name='data_table_name_2') >>> lc_data_table_query_config.set_time_dependent_data_column_index(index=0) Traceback (most recent call last): ... more.api.exceptions.api_exception.StaleReferentError: This query config is stale and no longer valid, most probably the chosen data table changed >>> lc_data_table_query_config = load_case_setup.get_data_table_query_config() >>> lc_data_table_query_config.set_time_dependent_data_column_by_name(name='Non existent name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: Column name: "Non existent name" not found, available names are "['value_0']" Parameters ---------- name: str The name of the column to set Returns ------- self This transient query config object Raises ------ StaleReferentError Raised if the data table chosen in the corresponding load case has changed and this query config is no longer valid NameNotFoundError Raised if the name of the data table column was not found TypeError Raised if the given index is not a string """ifnotisinstance(name,str):raiseTypeError('Only integers can be used as indices for transient data tables')ifnamenotinself._initial_partial_find_creator.data_table.column_headers[1:]:raiseNameNotFoundError(f'Column name: \"{name}\" not found, available names are \"{self._initial_partial_find_creator.data_table.column_headers[1:]}\"')self._initial_partial_find_creator.data_table_column_index=self._initial_partial_find_creator.data_table.column_headers[1:].index(name)returnself