Modifier#

mrfmsim adds additional modifiers specific to the experimental simulation to the mmodel modifiers. See mmodel.modifier for details.

  • print_inputs: print the inputs of the function with units.

  • print_outputs: print the outputs of the function with units.

  • replace_component: used in the Experiment class definition. The “replace_inputs” adds a modifier to the model.

Note

All the mmodel modifiers are loaded under the mrfmsim namespace. They can be accessed by mrfmsim.modifier.<modifier_name>.

modifier module#

mrfmsim.modifier.numba_jit(**kwargs)[source]#

Numba jit modifier with keyword arguments.

Add metadata to numba.jit. The numba decorator outputs all the parameters make it hard to read. Use the decorator the same way as numba.jit().

mrfmsim.modifier.parse_fields(format_str)[source]#

Parse the field from the format string.

Parameters:

format_str (str) – format string

Returns:

list of fields

The function parses out the field names in the format string. Some field names have slicers or attribute access, such as B0.value, B0[0], B0[0:2]. The function only returns B0 for all these fields. Since there can be duplicated fields after the name split, the function returns unique elements.

mrfmsim.modifier.print_inputs(stdout_format: str, **pargs)[source]#

Print the node input to the console.

Parameters:
  • stdout_format (str) – format string for input and output The format should be keyword only.

  • pargs – keyword arguments for the print function

The names of the parameters are parsed from the format string.

mrfmsim.modifier.print_output(stdout_format: str, **pargs)[source]#

Print the node output to the console.

Parameters:
  • stdout_format (str) – format string for input and output The format should be keyword only. The behavior is for keeping the consistency with other print modifiers.

  • end (str) – end of printout

The names of the parameters are parsed from the format string. The use of the stdout_format is different from the input method, as the modifiers do not know the return name of the node. Only one output field is allowed and the field name is used as the return name.

mrfmsim.modifier.replace_component(replacement: dict)[source]#

Modify the signature with components.

The modifier modifies the internal model function. The wrapper function is keyword-only.

Parameters:

replacement (dict[list | str]) – in the format of {component: [[original, replacement], original …}