Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(self):
# data specifics
sigma_bkg = 0.05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 10 # cutout pixel size
deltaPix = 0.1 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**kwargs_data)
kwargs_psf_gaussian = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'pixel_size': deltaPix}
psf = PSF(**kwargs_psf_gaussian)
kwargs_psf = {'psf_type': 'PIXEL', 'kernel_point_source': psf.kernel_point_source}
psf_class = PSF(**kwargs_psf)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': 0.1, 'e2': 0.1}
lens_model_list = ['SPEP']
self.kwargs_lens = [kwargs_spemd]
lens_model_class = LensModel(lens_model_list=lens_model_list)
kwargs_sersic = {'amp': 1., 'R_sersic': 0.1, 'n_sersic': 2, 'center_x': 0, 'center_y': 0}
# 'SERSIC_ELLIPSE': elliptical Sersic profile
kwargs_sersic_ellipse = {'amp': 1., 'R_sersic': .6, 'n_sersic': 3, 'center_x': 0, 'center_y': 0,
'e1': 0.1, 'e2': 0.1}
lens_light_model_list = ['SERSIC']
def setup(self):
# data specifics
sigma_bkg = 0.05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 10 # cutout pixel size
deltaPix = 0.5 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
self.kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**self.kwargs_data)
kwargs_psf_gaussian = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'truncation': 5, 'pixel_size': deltaPix}
psf_gaussian = PSF(**kwargs_psf_gaussian)
self.kwargs_psf = {'psf_type': 'PIXEL', 'kernel_point_source': psf_gaussian.kernel_point_source}
psf_class = PSF(**self.kwargs_psf)
# 'EXERNAL_SHEAR': external shear
kwargs_shear = {'gamma1': 0.01, 'gamma2': 0.01} # gamma_ext: shear strength, psi_ext: shear angel (in radian)
e1, e2 = param_util.phi_q2_ellipticity(0.2, 0.8)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': e1, 'e2': e2}
lens_model_list = ['SPEP', 'SHEAR']
self.kwargs_lens = [kwargs_spemd, kwargs_shear]
lens_model_class = LensModel(lens_model_list=lens_model_list)
self.LensModel = lens_model_class
# list of light profiles (for lens and source)
kwargs_sersic = {'amp': 1., 'R_sersic': 0.1, 'n_sersic': 2, 'center_x': 0, 'center_y': 0}
# 'SERSIC_ELLIPSE': elliptical Sersic profile
kwargs_sersic_ellipse = {'amp': 1., 'R_sersic': .6, 'n_sersic': 3, 'center_x': 0, 'center_y': 0,
'e1': 0.1, 'e2': 0.1}
lens_light_model_list = ['SERSIC']
self.kwargs_lens_light = [kwargs_sersic]
lens_light_model_class = LightModel(light_model_list=lens_light_model_list)
source_model_list = ['SERSIC_ELLIPSE']
self.kwargs_source = [kwargs_sersic_ellipse]
source_model_class = LightModel(light_model_list=source_model_list)
kwargs_numerics = {'supersampling_factor': 1, 'supersampling_convolution': False, 'compute_mode': 'regular'}
imageModel = ImageModel(data_class, psf_class, lens_model_class, source_model_class,
lens_light_model_class, kwargs_numerics=kwargs_numerics)
image_sim = sim_util.simulate_simple(imageModel, self.kwargs_lens, self.kwargs_source,
self.kwargs_lens_light)
data_class.update_data(image_sim)
kwargs_data['image_data'] = image_sim
kwargs_data_joint = {'multi_band_list': [[kwargs_data, kwargs_psf, kwargs_numerics]], 'multi_band_type': 'single-band'}
self.data_class = data_class
self.psf_class = psf_class
kwargs_model = {'lens_model_list': lens_model_list,
'source_light_model_list': source_model_list,
'lens_light_model_list': lens_light_model_list,
'fixed_magnification_list': [False],
}
self.kwargs_numerics = {
'subgrid_res': 1,
'psf_subgrid': False}
def setup(self):
# data specifics
sigma_bkg = 0.05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 10 # cutout pixel size
deltaPix = 0.1 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**kwargs_data)
kwargs_psf_gaussian = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'pixel_size': deltaPix}
psf = PSF(**kwargs_psf_gaussian)
kwargs_psf = {'psf_type': 'PIXEL', 'kernel_point_source': psf.kernel_point_source}
psf_class = PSF(**kwargs_psf)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': 0.1, 'e2': 0.1}
lens_model_list = ['SPEP']
self.kwargs_lens = [kwargs_spemd]
lens_model_class = LensModel(lens_model_list=lens_model_list)
kwargs_sersic = {'amp': 1., 'R_sersic': 0.1, 'n_sersic': 2, 'center_x': 0, 'center_y': 0}
# 'SERSIC_ELLIPSE': elliptical Sersic profile
kwargs_sersic_ellipse = {'amp': 1., 'R_sersic': .6, 'n_sersic': 3, 'center_x': 0, 'center_y': 0,
'e1': 0.1, 'e2': 0.1}
lens_light_model_list = ['SERSIC']
def test_data_configure_simple(self):
# data specifics
sigma_bkg = 1. # background noise per pixel
exp_time = 10 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 100 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = Data(kwargs_data)
assert data_class.deltaPix == deltaPix
def setup(self):
# data specifics
sigma_bkg = 0.05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 10 # cutout pixel size
deltaPix = 0.1 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**kwargs_data)
kwargs_psf_gaussian = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'pixel_size': deltaPix}
psf = PSF(**kwargs_psf_gaussian)
kwargs_psf = {'psf_type': 'PIXEL', 'kernel_point_source': psf.kernel_point_source}
psf_class = PSF(**kwargs_psf)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': 0.1, 'e2': 0.1}
lens_model_list = ['SPEP']
self.kwargs_lens = [kwargs_spemd]
lens_model_class = LensModel(lens_model_list=lens_model_list)
kwargs_sersic = {'amp': 1., 'R_sersic': 0.1, 'n_sersic': 2, 'center_x': 0, 'center_y': 0}
# 'SERSIC_ELLIPSE': elliptical Sersic profile
kwargs_sersic_ellipse = {'amp': 1., 'R_sersic': .6, 'n_sersic': 3, 'center_x': 0, 'center_y': 0,
'e1': 0.1, 'e2': 0.1}
lens_light_model_list = ['SERSIC']
def setup(self):
# data specifics
sigma_bkg = .05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 100 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**kwargs_data)
kwargs_psf = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'truncation': 5}
psf_class = PSF(**kwargs_psf)
# 'EXERNAL_SHEAR': external shear
kwargs_shear = {'gamma1': 0.01, 'gamma2': 0.01} # gamma_ext: shear strength, psi_ext: shear angel (in radian)
phi, q = 0.2, 0.8
e1, e2 = param_util.phi_q2_ellipticity(phi, q)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': e1, 'e2': e2}
lens_model_list = ['SPEP', 'SHEAR']
self.kwargs_lens = [kwargs_spemd, kwargs_shear]
lens_model_class = LensModel(lens_model_list=lens_model_list)
# list of light profiles (for lens and source)
# 'SERSIC': spherical Sersic profile
kwargs_sersic = {'amp': 1., 'R_sersic': 0.1, 'n_sersic': 2, 'center_x': 0, 'center_y': 0}
# 'SERSIC_ELLIPSE': elliptical Sersic profile
lens_light_model_list = ['SERSIC']
self.kwargs_lens_light = [kwargs_sersic]
lens_light_model_class = LightModel(light_model_list=lens_light_model_list)
source_model_list = ['SERSIC_ELLIPSE']
self.kwargs_source = [kwargs_sersic_ellipse]
source_model_class = LightModel(light_model_list=source_model_list)
self.kwargs_ps = [{'ra_source': 0.0, 'dec_source': 0.0,
'source_amp': 1.}] # quasar point source position in the source plane and intrinsic brightness
point_source_list = ['SOURCE_POSITION']
point_source_class = PointSource(point_source_type_list=point_source_list, fixed_magnification_list=[True])
kwargs_numerics = {'supersampling_factor': 1, 'supersampling_convolution': False, 'compute_mode': 'regular',
'point_source_supersampling_factor': 1}
imageModel = ImageModel(data_class, psf_class, lens_model_class, source_model_class,
lens_light_model_class,
point_source_class, kwargs_numerics=kwargs_numerics)
image_sim = sim_util.simulate_simple(imageModel, self.kwargs_lens, self.kwargs_source,
self.kwargs_lens_light, self.kwargs_ps)
data_class.update_data(image_sim)
self.data_class = data_class
self.psf_class = psf_class
self.kwargs_data['image_data'] = image_sim
self.kwargs_model = {'lens_model_list': lens_model_list,
'source_light_model_list': source_model_list,
'lens_light_model_list': lens_light_model_list,
'point_source_model_list': point_source_list,
'fixed_magnification_list': [False],
'index_lens_model_list': [[0, 1]],
}
self.kwargs_numerics = kwargs_numerics
num_source_model = len(source_model_list)
def setup(self):
# data specifics
sigma_bkg = .05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 100 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg)
data_class = ImageData(**kwargs_data)
kwargs_psf = sim_util.psf_configure_simple(psf_type='GAUSSIAN', fwhm=fwhm, kernelsize=31, deltaPix=deltaPix,
truncate=5)
psf_class = PSF(kwargs_psf)
# 'EXERNAL_SHEAR': external shear
kwargs_shear = {'e1': 0.01, 'e2': 0.01} # gamma_ext: shear strength, psi_ext: shear angel (in radian)
phi, q = 0.2, 0.8
e1, e2 = param_util.phi_q2_ellipticity(phi, q)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': e1, 'e2': e2}
lens_model_list = ['SPEP', 'SHEAR']
self.kwargs_lens = [kwargs_spemd, kwargs_shear]
lens_model_class = LensModel(lens_model_list=lens_model_list)
# list of light profiles (for lens and source)
# 'SERSIC': spherical Sersic profile
def setup(self):
# data specifics
sigma_bkg = .05 # background noise per pixel
exp_time = 100 # exposure time (arbitrary units, flux per pixel is in units #photons/exp_time unit)
numPix = 100 # cutout pixel size
deltaPix = 0.05 # pixel size in arcsec (area per pixel = deltaPix**2)
fwhm = 0.5 # full width half max of PSF
# PSF specification
kwargs_data = sim_util.data_configure_simple(numPix, deltaPix, exp_time, sigma_bkg, inverse=True)
data_class = ImageData(**kwargs_data)
kwargs_psf = {'psf_type': 'GAUSSIAN', 'fwhm': fwhm, 'truncation': 5, 'pixel_size': deltaPix}
psf_class = PSF(**kwargs_psf)
kernel = psf_class.kernel_point_source
kwargs_psf = {'psf_type': 'PIXEL', 'kernel_point_source': kernel, 'psf_error_map': np.ones_like(kernel) * 0.001}
psf_class = PSF(**kwargs_psf)
# 'EXERNAL_SHEAR': external shear
kwargs_shear = {'gamma1': 0.01, 'gamma2': 0.01} # gamma_ext: shear strength, psi_ext: shear angel (in radian)
phi, q = 0.2, 0.8
e1, e2 = param_util.phi_q2_ellipticity(phi, q)
kwargs_spemd = {'theta_E': 1., 'gamma': 1.8, 'center_x': 0, 'center_y': 0, 'e1': e1, 'e2': e2}
lens_model_list = ['SPEP', 'SHEAR']
self.kwargs_lens = [kwargs_spemd, kwargs_shear]
lens_model_class = LensModel(lens_model_list=lens_model_list)