[docs]@register_api_implementation(core_class=RailProfile)classRailProfileSetup(LoadSetup):""" The API handler for rail profiles The following example shows how to create a rail profile using the API, it is assumed that these steps were performed in each of the examples for other methods in this class. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup().set_name(name='Example LCC') >>> lc_setup = lcc_setup.create_load_case_setup(lc_type='Mechanical load case').set_name(name='Example LC') >>> rail_profile_setup = lc_setup.create_load_setup(load_type='Rail profile') .. >>> isinstance(rail_profile_setup, RailProfileSetup) True >>> isinstance(rail_profile_setup._load, RailProfile) True The next example shows how to get an API object for an already existing load. .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> simulation_setup = api.create_simulation_setup() >>> lcc_setup = simulation_setup.create_load_case_container_setup().set_name(name='Example LCC') >>> lc_setup = lcc_setup.create_load_case_setup(lc_type='Mechanical load case').set_name(name='Example LC') .. >>> rail_profile_setup = lc_setup.create_load_setup(load_type='Rail profile') >>> rail_profile_setup = lc_setup.get_load_setup(index=0) # The load under this index must already exist .. >>> isinstance(rail_profile_setup, RailProfileSetup) True >>> isinstance(rail_profile_setup._load, RailProfile) True """
[docs]defset_component_by_name(self,component_name:str)->'RailProfileSetup':""" Sets the component for the associated rail profile See example at the top for how to create a rail profile setup object .. admonition:: Example :class: note .. >>> import more.project >>> proj = more.project.Project() >>> from more.api import ApiGateway >>> api = ApiGateway(proj=proj) >>> rail_profile_setup = _rail_profile_api_setup(api) >>> component = proj.comp.add_component() >>> component.name = 'example component' >>> rail_profile_setup = rail_profile_setup.set_component_by_name(component_name='example component') # The component with this name must already exist .. >>> rail_profile_setup._load.component_selector.selected_entity == component True >>> rail_profile_setup = rail_profile_setup.set_component_by_name(component_name='nonexistent name') Traceback (most recent call last): ... more.api.exceptions.api_exception.NameNotFoundError: ... Returns ------- self: RailProfile Raises ------ NameNotFoundError Raised if the supplied name is not recognized """self._load.component_selector.select_entity_by_name(name=component_name)returnself
[docs]defset_rail_interface_by_name(self,rail_interface_name)->'RailProfileSetup':""" Sets the rail interface for the associated rail profile Returns ------- self: RailProfile Raises ------ NameNotFoundError Raised if the supplied name is not recognized """try:self._load.selected_rail_interface=self._available_rail_interfaces_dict[rail_interface_name]exceptKeyError:raiseNameNotFoundError('Rail interface with name: {} not found, available names are: {}'.format(rail_interface_name,self._available_rail_interfaces_dict.keys()))returnself
defset_profile_car_length_averaging_option(self,value:bool)->'RailProfileSetup':self._load.profile_car_length_averaging_option=valuereturnselfdefset_profile_normal_dir(self,value)->'RailProfileSetup':self._load.profile_normal_dir=valuereturnself@propertydefavailable_links_dict(self):returnself._available_links_dict@propertydef_available_links_dict(self)->typing.Dict[str,typing.Any]:return{cv.name:cvforcvinself._load.available_links}defset_links_by_names(self,link_names)->'RailProfileSetup':try:iter(link_names)exceptTypeError:raiseTypeError('Link names must be an iterable of names of links to choose')selected_links=[]forlink_nameinlink_names:iflink_nameinself._available_links_dict.keys():selected_links.append(self._available_links_dict[link_name])else:raiseNameNotFoundError('Link with name: {} is not in the list of available links: {}'.format(link_name,self._available_links_dict.keys()))self._load.selected_links=selected_linksreturnselfdefset_data(self,var,data)->'RailProfileSetup':self._load.profile_data.set_table_data(var,data)returnself@propertydefavailable_interpolation_methods(self)->typing.List[str]:returnlist(self._load.profile_data.trait('interpolation').trait_type.values)defset_interpolation_method(self,method_name:str)->'RailProfileSetup':try:self._load.profile_data.interpolation=method_nameexceptTraitError:raiseNameNotFoundError('Interpolation method: {} not found, available interpolation methods are: {}'.format(method_name,self.available_interpolation_methods))returnselfdefimport_data(self,path)->'RailProfileSetup':self._load.profile_data.import_data(path)returnself
[docs]defset_component(self,component)->'RailProfileSetup':""" Deprecated method .. admonition:: Deprecated :class: warning `set_component` will be removed in a future MORe release, it is replaced by :meth:`~.set_component_by_name` """logger.warning('Deprecation: \"set_component\" will be removed in a future MORe release, it is replaced by \"set_component_by_name\"')self.set_component_by_name(component_name=component.name)returnself
[docs]defset_rail_interface(self,rail_interface)->'RailProfileSetup':""" Deprecated method .. admonition:: Deprecated :class: warning `set_component` will be removed in a future MORe release, it is replaced by :meth:`~.set_component_by_name` """logger.warning('Deprecation: \"set_component\" will be removed in a future MORe release, it is replaced by \"set_component_by_name\"')self.set_rail_interface_by_name(rail_interface_name=rail_interface.name)returnself
@propertydefavailable_rail_interfaces_dict(self):""" Deprecated method .. admonition:: Deprecated :class: warning `available_rail_interfaces_dict` will be removed in a future MORe release, it is replaced by :meth:`~.available_rail_interfaces_names` """logger.warning('Deprecation: \"available_rail_interfaces_dict\" will be removed in a future MORe release, it is replaced by \"available_rail_interfaces_names\"')returnself._available_rail_interfaces_dict
[docs]defset_links(self,links):""" Deprecated method .. admonition:: Deprecated :class: warning `set_links` will be removed in a future MORe release, it is replaced by :meth:`~.set_links_by_names` """logger.warning('Deprecation: \"set_links\" will be removed in a future MORe release, it is replaced by \"set_links_by_names\"')returnself._available_rail_interfaces_dict
[docs]defset_profile_data(self,profile_data):""" Deprecated method .. admonition:: Deprecated :class: warning `set_profile_data` will be removed in a future MORe release, it is replaced by :meth:`~.set_data` """logger.warning('Deprecation: \"set_profile_data\" will be removed in a future MORe release, it is replaced by \"set_data\"')returnself.set_data(var=profile_data.var,data=profile_data.data)