flint.sky_model =============== .. py:module:: flint.sky_model Attributes ---------- .. autoapisummary:: flint.sky_model.KNOWN_1934_FILES flint.sky_model.KNOWN_CATAS flint.sky_model.KNOWN_PB_TYPES flint.sky_model.NORM_COLS Classes ------- .. autoapisummary:: flint.sky_model.AiryResponse flint.sky_model.CurvedPL flint.sky_model.GaussianResponse flint.sky_model.SincSquaredResponse flint.sky_model.SkyModel flint.sky_model.SkyModelOptions flint.sky_model.SkyModelOutputPaths Functions --------- .. autoapisummary:: flint.sky_model._jinc flint.sky_model.cli flint.sky_model.create_sky_model flint.sky_model.curved_power_law flint.sky_model.evaluate_src_model flint.sky_model.fit_curved_pl flint.sky_model.generate_airy_pb flint.sky_model.generate_gaussian_pb flint.sky_model.generate_pb flint.sky_model.generate_sinc_squared_pb flint.sky_model.get_1934_model flint.sky_model.get_known_catalogue flint.sky_model.get_parser flint.sky_model.get_sky_model_output_paths flint.sky_model.load_catalogue flint.sky_model.make_calibrate_model flint.sky_model.make_ds9_region flint.sky_model.make_hyperdrive_model flint.sky_model.preprocess_catalogue Module Contents --------------- .. py:class:: AiryResponse Bases: :py:obj:`NamedTuple` Container describing a airy disc response .. py:attribute:: atten :type: numpy.ndarray The attenuation of the response .. py:attribute:: freqs :type: numpy.ndarray The frequencies the beam is evaluated at .. py:attribute:: fwhms :type: numpy.ndarray The full-width at half-maximum corresponding to freqs .. py:attribute:: offset :type: float Angular offset of the source .. py:class:: CurvedPL Bases: :py:obj:`NamedTuple` Container for results of a Curved Power Law, >>> S_nu = S_nu_0 * (nu/nu_0)**alpha * exp(q*ln(nu/nu_0)**2.) Note that in the case of q=0. the model reduces to a normal power-law. .. py:attribute:: alpha :type: float The fitted spectral index .. py:attribute:: norm :type: float The fitted normalisation of the fitted model .. py:attribute:: q :type: float The fitted curvature of the spectral index .. py:attribute:: ref_nu :type: float The nominated reference frequency .. py:class:: GaussianResponse Bases: :py:obj:`NamedTuple` Container describing a simple Gaussian taper .. py:attribute:: atten :type: numpy.ndarray The attenuation of the response .. py:attribute:: freqs :type: numpy.ndarray The frequencies the beam is evaluated at .. py:attribute:: fwhms :type: numpy.ndarray The full-width at half-maximum corresponding to freqs .. py:attribute:: offset :type: float Angular offset of the source .. py:class:: SincSquaredResponse Bases: :py:obj:`NamedTuple` Container describing a sinc-squared response .. py:attribute:: atten :type: numpy.ndarray The attenuation of the response .. py:attribute:: freqs :type: numpy.ndarray The frequencies the beam is evaluated at .. py:attribute:: fwhms :type: numpy.ndarray The full-width at half-maximum corresponding to freqs .. py:attribute:: offset :type: float Angular offset of the source .. py:class:: SkyModel Bases: :py:obj:`NamedTuple` Description of the derived sky-model .. py:attribute:: apparent :type: bool :value: True Whether the sources and model are absolute of apparent fluxes .. py:attribute:: calibrate_model :type: pathlib.Path | None :value: None Path to the sky-model file created to use with calibrate .. py:attribute:: ds9_region :type: pathlib.Path | None :value: None Path to the DS9 region file representing the sky-model .. py:attribute:: flux_jy :type: float Total flux in Jansky .. py:attribute:: hyperdrive_model :type: pathlib.Path | None :value: None Path to the sky-model file created to use with hyperdrive .. py:attribute:: no_sources :type: int Number of source that are included in the sky-model .. py:class:: SkyModelOptions(/, **data: Any) Bases: :py:obj:`flint.options.BaseOptions` Options that describe how to build a local sky-model, including where reference catalogues are stored, the preferred catalogue, the types of models to produce, and filtering criteria .. py:attribute:: assumed_alpha :type: float :value: -0.83 Assume this to be the typical spectral index if it is not recorded in the reference catalogue .. py:attribute:: assumed_q :type: float :value: 0.0 Assume this to be the typical amount of spectral curvature should they not be in the reference catalogue .. py:attribute:: flux_cutoff :type: float :value: 0.02 The intrinsic brightness a source needs to be for it to be included in the sky model .. py:attribute:: fwhm_scale_cutoff :type: float :value: 1 A source needs to be within this many FWHM units from the direction of interest for it to be included .. py:attribute:: reference_catalogue_directory :type: pathlib.Path The reference catalogue directory that contains the known flint reference catalogues .. py:attribute:: reference_name :type: str | None :value: None .. py:attribute:: write_calibrate_model :type: bool :value: False Should the model for calibrate be created. The output will have .calibrate.txt suffix appended to the MS path. .. py:attribute:: write_ds9_region :type: bool :value: False Should a DS9 region file be created. The output will have .ds9.reg suffix appended to the MS path. .. py:attribute:: write_hyperdrive_model :type: bool :value: False Should the model for hyperdrive be created. The output will have .hypderdrive.yaml suffix appended to the MS path. .. py:class:: SkyModelOutputPaths Bases: :py:obj:`NamedTuple` Holds the expected names for different type of sky model outputs .. py:attribute:: calibrate_path :type: pathlib.Path Path of the calibrate style sky catalogue .. py:attribute:: hyperdrive_path :type: pathlib.Path Path of the hyperdrive style sky catalogue .. py:attribute:: region_path :type: pathlib.Path Path of the ds9 region file .. py:function:: _jinc(x) .. py:function:: cli() -> None .. py:function:: create_sky_model(ms_path: pathlib.Path, sky_model_options: SkyModelOptions) -> SkyModel | None Create a sky-model to calibrate RACS based measurement sets. If no sources were selected then None is returned. :param ms_path: Measurement set to create sky-model for :type ms_path: Path :param sky_model_options: Options to use to construct the sky model :type sky_model_options: SkyModelOptions :returns: SkyModel | None -- Basic informattion concerning the sky-model derived and the output files. If no sources were selected then None is returned. .. py:function:: curved_power_law(nu: numpy.ndarray, norm: float, alpha: float, beta: float, ref_nu: float) -> numpy.ndarray A curved power law model. >>> S_nu = S_nu_0 * (nu/nu_0)**alpha * exp(q*ln(nu/nu_0)**2.) Note that in the case of q=0. the model reduces to a normal power-law. :param nu: Frequency array. :type nu: np.ndarray :param norm: Reference flux. :type norm: float :param alpha: Spectral index. :type alpha: float :param beta: Spectral curvature. :type beta: float :param ref_nu: Reference frequency. :type ref_nu: float :returns: Model flux. :rtype: np.ndarray .. py:function:: evaluate_src_model(freqs: astropy.units.Quantity, src_row: astropy.table.row.Row, ref_nu: astropy.units.Quantity) -> astropy.units.Jy Evaluate a SED of an object using its recordded Normalisation, alpha and q components. :param freqs: Frequencies to evaluate :type freqs: u.Quantity :param src_row: Source propertieis from which the parameters are extracted :type src_row: Row :param ref_nu: Reference frequency of the model parameterization :type ref_nu: u.Quantity :returns: Brightness of model evaluated across frequency :rtype: u.Jy .. py:function:: fit_curved_pl(freqs: astropy.units.Quantity, flux: astropy.units.Quantity, ref_nu: astropy.units.Quantity) -> CurvedPL Fit some specified set of datapoints with a generic curved powerlaw. This is _not_ meant for real data, ratther as a way of representing the functional form of a model after it has been perturbed by some assumed primary beam. :param freqs: Frequencies corresponding to each brightness :type freqs: np.ndarray :param flux: Brightness corresponding to each frequency :type flux: np.ndarray :param ref_nu: Reference frequency that the model is set to :type ref_nu: float :returns: The fitted parameter results :rtype: CurvedPL .. py:function:: generate_airy_pb(freqs: astropy.units.Quantity, aperture: astropy.units.Quantity, offset: astropy.units.Quantity) -> AiryResponse Calculate the theoretical airy response of an aperture of a known size. :param reqs: Frequencies to evaluate the beam at :type reqs: u.Quantity :param aperture: Size of the dish :type aperture: u.Quantity :param offset: Offset from the centre of the beam :type offset: u.Quantity :returns: Numerical results of the theoretical sinc-squared primary beam :rtype: AiryResponse .. py:function:: generate_gaussian_pb(freqs: astropy.units.Quantity, aperture: astropy.units.Quantity, offset: astropy.units.Quantity) -> GaussianResponse Calculate the theoretical Gaussian taper for an aperture of known size :param freqs: Frequencies to evaluate the beam at :type freqs: u.Quantity :param aperture: Size of the dish :type aperture: u.Quantity :param offset: Offset from the centre of the beam :type offset: u.Quantity :returns: Numerical results of the theoretical gaussian primary beam :rtype: GaussianResponse .. py:function:: generate_pb(pb_type: str, freqs: astropy.units.Quantity, aperture: astropy.units.Quantity, offset: astropy.units.Quantity) -> GaussianResponse | SincSquaredResponse | AiryResponse Generate the primary beam response using a set of physical quantities. Each is assumed to be rotationally invariant, so a 1-D slice can be evaluated. Known approximations are: * gaussian * sincsquared * airy :param pb_type: The type of approximation to use :type pb_type: str :param freqs: The frequency to valuate at. :type freqs: u.Quantity :param aperture: The size of the dish :type aperture: u.Quantity :param offset: The distance to measure out to :type offset: u.Quantity :raises ValueError: Raised if `pb_type` is not known :returns: Constructed primary beam responses :rtype: Union[GaussianResponse, SincSquaredResponse, AiryResponse] .. py:function:: generate_sinc_squared_pb(freqs: astropy.units.Quantity, aperture: astropy.units.Quantity, offset: astropy.units.Quantity) -> SincSquaredResponse Calculate the theoretical sinc-squared response of an aperture of a known size. See Equation 3.78 and 3.79 from: https://www.cv.nrao.edu/~sransom/web/Ch3.html :param reqs: Frequencies to evaluate the beam at :type reqs: u.Quantity :param aperture: Size of the dish :type aperture: u.Quantity :param offset: Offset from the centre of the beam :type offset: u.Quantity :returns: Numerical results of the theoretical sinc-squared primary beam :rtype: SincSquaredResponse .. py:function:: get_1934_model(mode: str = 'calibrate') -> pathlib.Path Construct the path to a 1934-638 model. This is intended to calibrate the bandpass. :param mode: Calibration software intended to be used. This will determine model file to load. Supported modes are 'calibrate'. Defaults to 'calibrate'. :type mode: str, optional :raises ValueError: When supplied 'mode' is not known. :returns: Path to 1934-638 calibration model. :rtype: Path .. py:function:: get_known_catalogue(cata: str) -> flint.catalogue.Catalogue Get the parameters of a known catalogue TODO: Replace with configuration based method to load known cata :param cata: The lookup name of the catalogue :type cata: str :returns: properties of known catalogue :rtype: Catalogue .. py:function:: get_parser() .. py:function:: get_sky_model_output_paths(ms_path: pathlib.Path) -> SkyModelOutputPaths Create a set of expected sky model output file paths :param ms_path: The base name to construct the names against :type ms_path: Path :raises ValueError: If it appears `ms_path` does not point to a measurement set :returns: The set of paths to use when creating models :rtype: SkyModelOutputPaths .. py:function:: load_catalogue(catalogue_dir: pathlib.Path, catalogue: str | None = None, ms_pointing: astropy.coordinates.SkyCoord | None = None, assumed_alpha: float = -0.83, assumed_q: float = 0.0) -> tuple[flint.catalogue.Catalogue, astropy.table.Table] Load in a catalogue table given a name or measurement set declinattion. :param catalogue_dir: Directory containing known catalogues :type catalogue_dir: Path :param catalogue: Catalogue name to look up from known catalogues. Defaults to None. :type catalogue: Optional[str], optional :param ms_pointing: Pointing direction of the measurement set. Defaults to None. :type ms_pointing: Optional[SkyCoord], optional :param assumed_alpha: The assumed spectral index to use if there is no spectral index column known in model catalogue. Defaults to -0.83. :type assumed_alpha: float, optional :param assumed_q: The assumed curvature to use if there is no curvature column known in model catalogue. Defaults to 0.0. :type assumed_q: float, optional :raises FileNotFoundError: Raised when a catalogue can not be resolved. :returns: The `Catalogue` information and `Table` of components loaded :rtype: Tuple[Catalogue,Table] .. py:function:: make_calibrate_model(out_path: pathlib.Path, sources: list[tuple[astropy.table.row.Row, CurvedPL]]) -> pathlib.Path Create a sky-model file that is compatible with the AO Calibrate software :param out_path: Output path of the model file :type out_path: Path :param sources: The sources and their (apparent) SED to write :type sources: List[Tuple[Row,CurvedPL]] :returns: Output path of the model file :rtype: Path .. py:function:: make_ds9_region(out_path: pathlib.Path, sources: list[astropy.table.row.Row]) -> pathlib.Path Create a DS9 region file of the sky-model derived :param out_path: Output path to of the region file to write :type out_path: Path :param sources: Collection of Row objects (with normalised column names) :type sources: List[Row] :returns: Path to the region file created :rtype: Path .. py:function:: make_hyperdrive_model(out_path: pathlib.Path, sources: list[tuple[astropy.table.row.Row, CurvedPL]]) -> pathlib.Path Writes a Hyperdrive sky-model to a yaml file. :param out_path: The output path that the sky-model would be written to :type out_path: Path :param sources: Collection of sources to write, including the :type sources: List[Tuple[Row,CurvedPL]] :param normalized row and the results of fitting to the estimated apparent SED: :returns: The path of the file created :rtype: Path .. py:function:: preprocess_catalogue(cata_info: flint.catalogue.Catalogue, cata_tab: astropy.table.Table, ms_pointing: astropy.coordinates.SkyCoord, flux_cut: float = 0.02, radial_cut: astropy.units.deg = 1.0 * u.deg) -> astropy.table.QTable Apply the flux and separation cuts to a loaded table, and transform input column names to an expected set of column names. :param cata_info: Description of the catalogue from known catalogues :type cata_info: Catalogue :param cata_tab: The loaded catalogue table :type cata_tab: Table :param ms_pointing: Pointing of the measurement set :type ms_pointing: SkyCoord :param flux_cut: Flux cut in Jy. Defaults to 0.02. :type flux_cut: float, optional :param radial_cut: Radial separation cut in deg. Defaults to 1.. :type radial_cut: u.deg, optional :returns: _description_ :rtype: QTable .. py:data:: KNOWN_1934_FILES Known models of PKS B1934-638 in different formats .. py:data:: KNOWN_CATAS :type: dict[str, flint.catalogue.Catalogue] Known sky-model catalogues that have had some pre-processing operations applied. Discuss with maintainers for access, .. py:data:: KNOWN_PB_TYPES :value: ('gaussian', 'sincsquared', 'airy') .. py:data:: NORM_COLS Normalised column names and their corresponding astropy units.