arrakis.init_database ===================== .. py:module:: arrakis.init_database .. autoapi-nested-parse:: Create the Arrakis database .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: arrakis.init_database.TQDM_OUT Functions --------- .. autoapisummary:: arrakis.init_database.beam_database arrakis.init_database.beam_inf arrakis.init_database.cat2beams arrakis.init_database.cli arrakis.init_database.field_database arrakis.init_database.get_beams arrakis.init_database.get_catalogue arrakis.init_database.main arrakis.init_database.ndix_unique arrakis.init_database.read_racs_database arrakis.init_database.source2beams arrakis.init_database.source_database Module Contents --------------- .. py:function:: beam_database(database_path: pathlib.Path, islandcat: astropy.table.Table, host: str, epoch: int, username: str | None = None, password: str | None = None) -> pymongo.results.InsertManyResult Insert beams into the database :Parameters: * **islandcat** (*Table*) -- Island catalogue table. * **host** (*str*) -- MongoDB host IP. * **username** (*str, optional*) -- Mongo username. Defaults to None. * **password** (*str, optional*) -- Mongo host. Defaults to None. * **epoch** (*int, optional*) -- RACS epoch to use. Defaults to 0. :returns: Result of the insert. :rtype: InsertManyResult .. !! processed by numpydoc !! .. py:function:: beam_inf(database: astropy.table.Table, survey_dir: pathlib.Path, host: str, epoch: int, username: str | None = None, password: str | None = None) -> pymongo.results.InsertManyResult Get the beam information .. !! processed by numpydoc !! .. py:function:: cat2beams(mastercat: astropy.table.Table, database: astropy.table.Table, max_sep: float = 1) -> tuple[numpy.ndarray, numpy.ndarray, astropy.coordinates.Angle] Find the separations between sources in the master catalogue and the RACS beams :Parameters: * **mastercat** (*Table*) -- Master catalogue table. * **database** (*Table*) -- RACS database table. * **max_sep** (*float, optional*) -- Maximum source separation in degrees. Defaults to 1. :returns: Output of astropy.coordinates.search_around_sky :rtype: Tuple[np.ndarray, np.ndarray, Angle] .. !! processed by numpydoc !! .. py:function:: cli() Command-line interface .. !! processed by numpydoc !! .. py:function:: field_database(survey_dir: pathlib.Path, host: str, epoch: int, username: str | None = None, password: str | None = None) -> tuple[pymongo.results.InsertManyResult, pymongo.results.InsertManyResult] Reset and load the field database :Parameters: * **survey_dir** (*Path*) -- Path to RACS database (i.e. 'askap_surveys/racs' repo). * **host** (*str*) -- Mongo host * **epoch** (*int, optional*) -- RACS epoch number. * **username** (*Union[str, None]*) -- Mongo username * **password** (*Union[str, None]*) -- Mongo password :returns: Field and beam info insert object. :rtype: Tuple[InsertManyResult, InsertManyResult] .. !! processed by numpydoc !! .. py:function:: get_beams(mastercat: astropy.table.Table, database: astropy.table.Table, epoch: int = 0) -> list[dict] Get beams from the master catalogue :Parameters: * **mastercat** (*Table*) -- Master catalogue table. * **database** (*Table*) -- RACS database table. :returns: List of beam dictionaries. :rtype: List[Dict] .. !! processed by numpydoc !! .. py:function:: get_catalogue(survey_dir: pathlib.Path, epoch: int = 0) -> astropy.table.Table Get the RACS catalogue for a given epoch :Parameters: **epoch** (*int, optional*) -- Epoch number. Defaults to 0. :returns: RACS catalogue table. :rtype: Table .. !! processed by numpydoc !! .. py:function:: main(load: bool = False, islandcat: str | None = None, compcat: str | None = None, database_path: pathlib.Path | None = None, host: str = 'localhost', username: str | None = None, password: str | None = None, field: bool = False, epochs: list[int] = [0], force: bool = False) -> None Main script :Parameters: * **load** (*bool, optional*) -- Load the database. Defaults to False. * **islandcat** (*Union[str, None], optional*) -- Island catalogue. Defaults to None. * **compcat** (*Union[str, None], optional*) -- Component catalogue. Defaults to None. * **host** (*str, optional*) -- Mongo host. Defaults to "localhost". * **username** (*Union[str, None], optional*) -- Mongo username. Defaults to None. * **password** (*Union[str, None], optional*) -- Mongo password. Defaults to None. * **field** (*bool, optional*) -- Load the field database. Defaults to False. * **epochs** (*List[int], optional*) -- Epochs to load. Defaults to [0]. * **force** (*bool, optional*) -- Force overwrite of database. Defaults to False. :raises ValueError: If load is True and islandcat or compcat are None. .. !! processed by numpydoc !! .. py:function:: ndix_unique(x: numpy.ndarray) -> tuple[numpy.ndarray, list[numpy.ndarray]] Find the N-dimensional array of indices of the unique values in x From https://stackoverflow.com/questions/54734545/indices-of-unique-values-in-array :Parameters: **x** (*np.ndarray*) -- Array of values. :returns: - 1D-array of sorted unique values - Array of arrays. Each array contains the indices where a given value in x is found :rtype: Tuple[np.ndarray, np.ndarray] .. !! processed by numpydoc !! .. py:function:: read_racs_database(survey_dir: pathlib.Path, epoch: int, table: str) -> astropy.table.Table Read the RACS database from CSVs or postgresql :Parameters: * **survey_dir** (*Path*) -- Path to RACS database (i.e. 'askap_surveys/racs' repo). * **epoch** (*int*) -- RACS epoch number. * **table** (*str*) -- Table name. :returns: RACS database table. :rtype: Table .. !! processed by numpydoc !! .. py:function:: source2beams(ra: float, dec: float, database: astropy.table.Table, max_sep: float = 1) -> astropy.table.Table Find RACS beams that contain a given source position :Parameters: * **ra** (*float*) -- RA of source in degrees. * **dec** (*float*) -- DEC of source in degrees. * **database** (*dict*) -- RACS database table. * **max_sep** (*float, optional*) -- Maximum separation of source to beam centre in degrees. Defaults to 1. :returns: Subset of RACS database table containing beams that contain the source. :rtype: Table .. !! processed by numpydoc !! .. py:function:: source_database(islandcat: astropy.table.Table, compcat: astropy.table.Table, host: str, epoch: int, username: str | None = None, password: str | None = None) -> tuple[pymongo.results.InsertManyResult, pymongo.results.InsertManyResult] Insert sources into the database Following https://medium.com/analytics-vidhya/how-to-upload-a-pandas-dataframe-to-mongodb-ffa18c0953c1 :Parameters: * **islandcat** (*Table*) -- Island catalogue table. * **compcat** (*Table*) -- Component catalogue table. * **host** (*str*) -- MongoDB host IP. * **username** (*str, optional*) -- Mongo username. Defaults to None. * **password** (*str, optional*) -- Mongo host. Defaults to None. :returns: Results for the islands and components inserts. :rtype: Tuple[InsertManyResult, InsertManyResult] .. !! processed by numpydoc !! .. py:data:: TQDM_OUT