Module: fake_data_creator#
A class for creating fake data sets.
The FakeDataSet class allows the user to create fake data sets for testing, including generating images with random noise and adding artificial objects. The fake data can be saved to files or used directly.
- class kbmod.fake_data.fake_data_creator.FakeDataSet(width, height, times, *, mask_fraction=0.0, noise_level=2.0, psf_val=0.5, psfs=None, artifacts_fraction=0.0, artifacts_mean=0.0, artifacts_std=2.0, use_seed=-1)[source]#
This class creates fake data sets for testing and demo notebooks.
Methods
get_work_unit
([config])Create a WorkUnit from the fake data.
insert_object
(trj)Insert a fake object given the trajectory.
insert_random_artifacts
(fraction, mean, std)Insert noise artifacts into the images that are brighter than the background noise.
insert_random_object
(flux[, vx, vy])Create a fake object that will be within the image bounds in all images.
Insert a number of random objects based on a given TrajectorGenerator.
reset
()Regenerate the image stack and clear the inserted objects.
save_fake_data_to_work_unit
(filename[, config])Create the fake data in a WorkUnit file.
set_wcs
(new_wcs)Set a new fake WCS to be used for this data.
Check if the trajectory is within the image bounds for all times.
- get_work_unit(config=None)[source]#
Create a WorkUnit from the fake data.
- Parameters:
- filenamestr
The name of the resulting WorkUnit file.
- configSearchConfiguration, optional
The configuration parameters to use. If None then uses default values.
- insert_object(trj)[source]#
Insert a fake object given the trajectory.
- Parameters:
- trjTrajectory
The trajectory of the fake object to insert.
- insert_random_artifacts(fraction, mean, std)[source]#
Insert noise artifacts into the images that are brighter than the background noise.
- Parameters:
- fractionfloat
The fraction of pixels to modify [0.0, 1.0]
- meanfloat
The mean value of the artifacts in units of flux.
- stdfloat
The standard deviation of the artifacts.
- insert_random_object(flux, vx=None, vy=None)[source]#
Create a fake object that will be within the image bounds in all images.
- Parameters:
- fluxfloat
The flux of the object.
- vxfloat or list of float, optional
The x-velocity or list of allowable x-velocities (in pixels per day). If None, a random x-velocity is generated.
- vyfloat or list of float, optional
The y-velocity or list of allowable y-velocities (in pixels per day). If None, a random y-velocity is generated.
- Returns:
- trjTrajectory
The trajectory of the inserted object.
- insert_random_objects_from_generator(num_trj, generator, flux)[source]#
Insert a number of random objects based on a given TrajectorGenerator. This ensures that the inserted objects can be recovered by the search.
- Parameters:
- num_trjint
The number of trajectories to insert.
- generatorTrajectoryGenerator
The generator to use for creating the trajectories.
- fluxfloat
The flux of the object.
- Returns:
- trjsList of Trajectory
The list of all the trajectories inserted.
- save_fake_data_to_work_unit(filename, config=None)[source]#
Create the fake data in a WorkUnit file.
- Parameters:
- filenamestr
The name of the resulting WorkUnit file.
- configSearchConfiguration, optional
The configuration parameters to use. If None then uses default values.
- kbmod.fake_data.fake_data_creator.create_fake_times(num_times, t0=0.0, obs_per_day=1, intra_night_gap=0.01, inter_night_gap=1)[source]#
Create a list of times based on a cluster of
obs_per_day
observations each night spaced outintra_night_gap
within a night andinter_night_gap
data between observing nights.- Parameters:
- num_timesint
The number of time steps (number of images).
- t0float
The time stamp of the first observation [default=0.0]
- obs_per_dayint
The number of observations on the same night [default=1]
- intra_night_gapfloat
The time (in days) between observations in the same night [default=0.01]
- inter_night_gapint
The number of days between observing runs [default=1]
- Returns:
- result_timeslist
A list of
num_times
floats indicating the different time stamps.
- kbmod.fake_data.fake_data_creator.image_stack_add_fake_object(stack, x, y, vx, vy, *, ax=0.0, ay=0.0, flux=100.0)[source]#
Insert a fake object given the trajectory.
- Parameters:
- stackImageStackPy
The image stack to modify.
- xint
The x-coordinate of the object at the first time (in pixels).
- yint
The y-coordinate of the object at the first time (in pixels).
- vxfloat
The x-velocity of the object (in pixels per day).
- vyfloat
The y-velocity of the object (in pixels per day).
- axfloat, optional
The x-acceleration of the object (in pixels per day^2). This is only used to test non-linear trajectories and defaults to 0.0.
- ayfloat, optional
The y-acceleration of the object (in pixels per day^2). This is only used to test non-linear trajectories and defaults to 0.0.
- fluxfloat, optional
The flux of the object. Default: 100.0
- kbmod.fake_data.fake_data_creator.image_stack_add_random_masks(stack, mask_fraction, rng=None)[source]#
Add random masks to the image stack.
- Parameters:
- stackImageStackPy
The image stack to modify.
- mask_fractionfloat
The fraction of pixels to mask in each image [0.0, 1.0].
- rngnp.random.Generator, optional
The random number generator to use. If None creates a new random generator. Default: None
- kbmod.fake_data.fake_data_creator.make_fake_image_stack(height, width, times, noise_level=2.0, psf_val=0.5, psfs=None, rng=None)[source]#
Create a fake ImageStackPy for testing.
- Parameters:
- widthint
The width of the images in pixels.
- heightint
The height of the images in pixels.
- timeslist
A list of time stamps.
- noise_levelfloat
The level of the background noise. Default: 2.0
- psf_valfloat
The value of the default PSF. Used if individual psfs are not specified. Default: 0.5
- psfslist of numpy.ndarray, optional
A list of PSF kernels. If none, Gaussian PSFs from with std=psf_val are used.
- rngnp.random.Generator
The random number generator to use. If None creates a new random generator. Default: None