:py:mod:`rubin_lc_simulator.simulator` ====================================== .. py:module:: rubin_lc_simulator.simulator .. autoapi-nested-parse:: Created on Thu Jun 28 20:30:11 2018 @author: danielgodinez Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: rubin_lc_simulator.simulator.LSSTSimulator Functions ~~~~~~~~~ .. autoapisummary:: rubin_lc_simulator.simulator.draw_random_baseline rubin_lc_simulator.simulator.draw_random_coord .. py:class:: LSSTSimulator(ra: float = 0.0, dec: float = 0.0, band: str = 'i', out_dir: str = '_metric_results_rubin_sim_') Interface for simulating light curves using Rubin Observatory / LSST cadence and noise models. This class extracts the Rubin/LSST observational cadence at a specified sky position (RA, Dec) using the `rubin_sim` framework. It supports simulating photometric light curves by injecting user-defined models and applying realistic per-epoch noise based on the five sigma depth at each visit. :param ra: Right Ascension (in decimal degrees) of the simulated source. Default is 0.0. :type ra: float :param dec: Declination (in decimal degrees) of the simulated source. Default is 0.0. :type dec: float :param band: LSST photometric filter to use ('u', 'g', 'r', 'i', 'z', or 'y'). Default is 'i'. :type band: str, optional :param out_dir: Output directory for storing cached metric results from `rubin_sim`. Default is '_metric_results_rubin_sim_'. :type out_dir: str, optional .. attribute:: mjd_min Minimum MJD (time) for the simulation window. :type: float .. attribute:: mjd_max Maximum MJD for the simulation window. :type: float .. attribute:: photParams LSST photometric configuration (e.g., exposure time, number of exposures). :type: PhotometricParameters .. attribute:: bandpasses Dictionary of Rubin LSST bandpass filters from `rubin_sim.phot_utils`. :type: dict .. attribute:: opsim Handle to the baseline LSST OpSim cadence simulation database. :type: Database .. attribute:: metric `rubin_sim` metric used to extract cadence and 5σ depth per observation. :type: Metric .. attribute:: mjd Simulated time values for the generated light curve. :type: np.ndarray or None .. attribute:: mag Simulated magnitudes (with noise) of the light curve. :type: np.ndarray or None .. attribute:: magerr Corresponding per-epoch magnitude uncertainties. :type: np.ndarray or None .. py:method:: __repr__() -> str Return a string representation of the class instance. :returns: Human-readable summary of the object. :rtype: str .. py:method:: _slice_sky() -> rubin_sim.maf.slicers.UserPointsSlicer Slice the sky at the specified RA/DEC location. :returns: The spatial slicer used by the `rubin_sim` API to evaluate the sky at the specified position. :rtype: rubin_sim.maf.slicers.UserPointsSlicer .. py:method:: _retrieve_metrics() -> numpy.ndarray Query OpSim and return the raw metric data for the target position. :returns: Array containing the raw simulation metrics for the specified sky position. :rtype: np.ndarray .. py:method:: LSST_metrics() -> Optional[numpy.ndarray] Public wrapper to obtain the visit table without any filtering and check if the slice is valid. This method must be called by the user immediately after initialization. The returned `dataSlice` is not stored as a class attribute—by design, it must be handled externally by the user. :returns: The `dataSlice` containing simulation metrics for a single sky position, representing all overlapping visits. :rtype: np.ndarray .. rubric:: Notes The returned `dataSlice` is never stored internally. It should be assigned to a local variable and passed manually to downstream methods as needed. .. py:method:: _filter_band_time(data: numpy.ndarray) -> numpy.ndarray Restrict a data slice to the configured band and MJD range. :param data: Array containing observation metadata, including filter, start MJD, and five-sigma depth. :type data: np.ndarray :returns: Filtered data slice containing only entries within the configured band and MJD range. :rtype: np.ndarray .. py:method:: _generate_light_curve(data: numpy.ndarray, lc: Optional[numpy.ndarray] = None) -> Tuple[numpy.ndarray, Ellipsis] Generate a light curve with Rubin cadence and LSST noise model. This method operates locally and does not assign instance attributes. Use `lsst_real_lc()` if you want the outputs stored as class attributes. :param data: The `dataSlice` containing cadence metrics for a single sky position. :type data: np.ndarray :param lc: Ideal (noise-free) light curve to which LSST noise will be added. If None, the method returns only the observation timestamps. :type lc: np.ndarray, optional :returns: If `lc` is None, returns an array of observation MJDs. If `lc` is provided, returns a tuple of arrays: (mjd, mag, magerr), representing the light curve with simulated LSST noise. :rtype: np.ndarray or tuple of np.ndarray .. rubric:: Notes This method is designed to be called twice. The first call retrieves the cadence (MJD array), allowing the user to simulate their own light curve. The second call takes the simulated magnitudes and returns the full light curve with LSST noise. .. py:method:: lsst_real_lc(data_slice: numpy.ndarray, lc: Optional[numpy.ndarray] = None) -> Optional[numpy.ndarray] Filter `data_slice` to the requested band and either return the cadence (MJD) or attach a full noisy light curve to the instance. :param data_slice: Output from `LSST_metrics()`, containing observation metadata. :type data_slice: np.ndarray :param lc: Ideal (noise-free) magnitudes to which LSST noise will be added. If provided, the method assigns light curve attributes to the instance. :type lc: np.ndarray, optional :returns: Returns an array of observation MJDs if `lc` is None. If `lc` is provided, the function modifies the instance in-place by setting the `mjd`, `mag`, and `magerr` attributes, and returns None. :rtype: np.ndarray or None .. py:function:: draw_random_baseline(band: str) -> float Draw a random baseline magnitude within the allowed dynamic range. :param band: LSST photometric filter to use ('u', 'g', 'r', 'i', 'z', or 'y'). :type band: str, optional :returns: A baseline magnitude uniformly sampled between the saturation limit and 5σ depth for the specified band. :rtype: float .. py:function:: draw_random_coord(ra_range: tuple = (0, 360), dec_range: tuple = (-75, 15)) -> list Draw a random sky coordinate within the specified RA and DEC range. :param ra_range: Right ascension range to sample from, in degrees. Default is (0, 360). :type ra_range: tuple of float, optional :param dec_range: Declination range to sample from, in degrees. Default is (-75, 15), covering most of the Southern sky observed by LSST. :type dec_range: tuple of float, optional :returns: A list containing two values: right ascension and declination in decimal degrees. :rtype: list of float