irfpy.spice.localize
¶
Create some common kernel files.
For some case, one may need to reproduce the kernel files.
- irfpy.spice.localize.make_localized_meta_kernel(original_mk_contents: str, path_values: str) str [source]¶
Return the contents with PATH_VALUES replaced.
- Parameters
original_mk_contents – Original meta kernel file contents.
path_values – The actual value for PATH_VALUES.
- Returns
The contents of the meta_kernel
- irfpy.spice.localize.localize_mkfile(metakernel, local_dir=False, output=None, kernel_path=None)[source]¶
Localize the MK (meta kernel) file, with PATH_VALUE replaced.
Background: The MK file, ending with ‘.tm’, contains the actual kernels to be loaded for a specific project. It frequently contains a “hard-coded” path, “PATH_VALUES”, that points to the parent path (‘..’), while this refers to the parent path of the current directory. Therefore, the PATH_VALUES should be modified manually to load the actual kernels to load.
This function creates a new mk file based on the given metakernel, with PATH_VALUE replaced.
You can use the CLI
irfpy-spice-localize-mk
command.- Parameters
metakernel – The meta kernel (input)
local_dir – If set True, the output file is in the same directory as the given meta kernel, with “_local” added. The
output
is ignored if this is set True.output – The output file name. If None given, stdout is used.
kernel_path – The actual path name where the kernel is stored. If None given (default), the kernel path is deduced from the
metakernel
file.
Example:
Let us localize
/path/to/kernels/mk/mex_ops.tm
.Localize and output to stdout
>>> from irfpy.spice import localize >>> localize_mkfile('/path/to/kernels/mk/mex_ops.tm')
Localize and output to a specific file
>>> localize_mkfile('/path/to/kernels/mk/mex_ops.tm', output="./mex_ops_local.tm")
Localize and output to the original path (
/path/to/kernels/mk/mex_ops_local.tm
is created.)>>> localize_mkfile('/path/to/kernels/mk/mex_ops.tm', local_dir=True)
Localize but with specific path name (but this option is not recommended to use)
>>> localize_mkfile('/path/to/kernels/mk/mex_ops.tm', kernel_path='..')