suncasa.casa_compat
casa_compat.py
Provides a uniform interface for importing CASA (Common Astronomy Software Applications) tools across different versions and Python environments. It supports both the monolithic (CASA 4/5/6) and modular (CASA 6+) installations.
This script dynamically imports CASA components, addressing the architectural changes between versions. In monolithic installations, components are available as instantiated objects. In modular installations, components are accessed through casatools and casatasks.
Function: - get_casa_tools(alias_list): Returns a dictionary of requested CASA tool instances. It accepts a list of tool aliases and handles dynamic import or built-in object access, ensuring compatibility across CASA versions.
Parameters: - alias_list (list of str): Aliases for CASA tools to import. Defaults to a common set of tools.
Returns: - dict: Mapping of tool aliases to their instances or objects.
- Usage example:
casa_tools = get_casa_tools([‘tbtool’, ‘mstool’, ‘qatool’, ‘iatool’, ‘rgtool’, ‘msmdtool’, ‘smtool’, ‘metool’]) for alias, instance in casa_tools.items():
print(f”{alias}: {instance}”)
The function uses importlib for CASA 6+ and falls back to direct access in earlier versions or interactive sessions.
Attributes
Functions
|
Dynamically imports and returns CASA tools specified by their aliases. |
|
Dynamically imports specified CASA tasks from the casatasks module. This is designed to uniformly import CASA tasks |
Module Contents
- suncasa.casa_compat.import_casatools(alias_list=['tbtool', 'mstool', 'qatool', 'iatool', 'rgtool', 'msmdtool', 'smtool', 'metool'])[source]
Dynamically imports and returns CASA tools specified by their aliases.
Parameters: alias_list (list of str): Aliases of the CASA tools to be imported and returned.
Returns: dict: A dictionary with keys as tool aliases and values as the imported modules or objects.
- suncasa.casa_compat.import_casatasks(*task_names)[source]
Dynamically imports specified CASA tasks from the casatasks module. This is designed to uniformly import CASA tasks for both monolithic and modular CASA installations, addressing the issue where direct task import is not supported in monolithic CASA versions.
Intended for modular CASA 6+ installations where tasks are accessed via casatasks. For monolithic CASA (versions 4/5/6), this function provides a unified interface, though direct imports are handled via the global namespace.
Parameters: - task_names (str): Names of CASA tasks to import.
Returns: - dict: Mapping of task names to their corresponding functions.
Raises: - ImportError: If a task is not found in casatasks.