spinifex.h5parm_tools ===================== .. py:module:: spinifex.h5parm_tools Functions --------- .. autoapisummary:: spinifex.h5parm_tools._get_station_metadata spinifex.h5parm_tools._zero_terminated_string spinifex.h5parm_tools.add_antenna_info spinifex.h5parm_tools.add_soltab spinifex.h5parm_tools.add_source_info spinifex.h5parm_tools.check_h5parm spinifex.h5parm_tools.create_empty_h5parm spinifex.h5parm_tools.create_solset spinifex.h5parm_tools.get_minimal_solset_name spinifex.h5parm_tools.get_minimal_soltab_name spinifex.h5parm_tools.write_rm_to_h5parm spinifex.h5parm_tools.write_tec_to_h5parm Module Contents --------------- .. py:function:: _get_station_metadata(rms: dict[str, Any]) -> tuple[list[Any], list[Any]] helper function to generate arrays of station names and positions Parameters ---------- rms : dict[RM|DTEC] dictionary with RM object per station Returns ------- tuple station_names and station_positions (ITRF xyz) .. py:function:: _zero_terminated_string(size: int = 10) -> h5py.Datatype .. py:function:: add_antenna_info(solset: h5py.Dataset, antenna_names: numpy.typing.NDArray[numpy.floating[Any]], antenna_pos: numpy.typing.NDArray[numpy.floating[Any]]) -> None Add antenna metadata to a solset Parameters ---------- solset : h5py.Dataset A solset in an h5parm antenna_names : NDArray[np.floating[Any]] array with antenna names antenna_pos : NDArray[np.floating[Any]] array ant x 3 with ITRF antenna positions .. py:function:: add_soltab(solset: h5py.Dataset, soltab_type: str, val: numpy.typing.NDArray[numpy.floating[Any]], weight: numpy.typing.NDArray[numpy.floating[Any]], soltab_axes: list[Any], axes_values: dict[str, Any], soltab_name: str | None = None) -> h5py.Dataset Add asolution table to an existing solset Parameters ---------- solset : h5py.Dataset solset soltab_type : str type of the solutions val : NDArray[np.floating[Any]] array with solutions values, must match the shape of the axes weight : NDArray[np.floating[Any]] array of weights, must match the shape of val soltab_axes : list ordered list of axes as they are defined for val/wegiht axes_values : dict[Any] dictionary with the values for each axis in soltab_axes soltab_name : str|None, optional name of the solution table, if None or existing will default to ###, by default None Returns ------- h5py.Dataset the solution table .. py:function:: add_source_info(solset: h5py.Dataset, source_names: numpy.typing.NDArray[numpy.str_], source_dirs: numpy.typing.NDArray[numpy.floating[Any]]) -> None Add source metadata to a solset Parameters ---------- solset : h5py.Dataset A solset in an h5parm source_names : NDArray[np.str_] array with source names source_dirs : NDArray[np.floating[Any]] array source x 2 with Ra,DEC directions of the sources .. py:function:: check_h5parm(h5file: h5py.File) -> bool Check if given h5file is suitable as h5parm Parameters ---------- h5file : h5py.File possible h5parm file Returns ------- bool True if the file is conform h5parm definition .. py:function:: create_empty_h5parm(h5parm_name: str) -> None create an empty h5parm file Parameters ---------- h5parm_name : str name of the file Raises ------ TypeError error if h5parm_name is existing and not a valid h5parm .. py:function:: create_solset(h5file: h5py.File, solset_name: str | None = None) -> h5py.Dataset Create new empty solset in your h5parm file. A solset has an antenna and source table. Default name is sol###" Parameters ---------- h5file : h5py.File the h5parm file, must be writable solset_name : str, optional name of the solset, if None the first available from sol### will be used, by default None Returns ------- h5py.Dataset pointer to the new solset .. py:function:: get_minimal_solset_name(h5file: h5py.File) -> str Find the best name for your new solset in an h5parm file. Default name is sol### Parameters ---------- h5file : h5py.File the h5parm file Returns ------- str frst available name for the solset .. py:function:: get_minimal_soltab_name(solset: h5py.Dataset, soltab_type: str) -> str Find the best name for your new soltab in an h5parm file. Default name is [soltab_type]### Parameters ---------- solset : h5py.Dataset the solset in an h5parm soltab_type : str type of the solution table Returns ------- str frst available name for the soltab .. py:function:: write_rm_to_h5parm(rms: dict[str, spinifex.get_rm.RM], h5parm_name: str, solset_name: str | None = None, soltab_name: str | None = None, add_to_existing_solset: bool = False) -> None writes a dictionary of RM values per station to a new or existing h5parm file Parameters ---------- rms : dict[RM] rm values per station h5parm_name : str name of the h5parm file solset_name : str | None, optional name of the solset if None it will default to sol###, by default None soltab_name : str | None, optional name of the soltab if None it will default to 'rotationmeasure###' add_to_existing_solset : bool = False whether to append to an existing solset, if it exists. If True, the user is responsible for having consistent antennas and sources. Raises ------ TypeError error if h5parm_name is existing and not a valid h5parm .. py:function:: write_tec_to_h5parm(dtec: dict[str, spinifex.get_dtec.DTEC], h5parm_name: str, solset_name: str | None = None, soltab_name: str | None = None, add_to_existing_solset: bool = False) -> None writes a dictionary of RM values per station to a new or existing h5parm file Parameters ---------- dtec : dict[DTEC] electron density profiles per station h5parm_name : str name of the h5parm file solset_name : str | None, optional name of the solset if None it will default to sol###, by default None soltab_name : str | None, optional name of the soltab if None it will default to 'rotationmeasure###' add_to_existing_solset : bool = False whether to append to an existing solset, if it exists. If True, the user is responsible for having consistent antennas and sources. Raises ------ TypeError error if h5parm_name is existing and not a valid h5parm