Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 24, 2024
1 parent dbf9d45 commit c444a1e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"from slsim.image_simulation import lens_image_series, sharp_rgb_image\n",
"from slsim.Plots.plot_functions import create_image_montage_from_image_list\n",
"from slsim.image_simulation import point_source_coordinate_properties\n",
"from slsim.LsstSciencePipeline import lsst_science_pipeline, opsim_pipeline\n"
"from slsim.LsstSciencePipeline import lsst_science_pipeline, opsim_pipeline"
]
},
{
Expand Down Expand Up @@ -115,8 +115,7 @@
")\n",
"\n",
"path = (\n",
" os.path.dirname(slsim.__file__)\n",
" + \"/Sources/SupernovaeCatalog/supernovae_data.pkl\"\n",
" os.path.dirname(slsim.__file__) + \"/Sources/SupernovaeCatalog/supernovae_data.pkl\"\n",
")\n",
"with open(path, \"rb\") as f:\n",
" supernovae_data = pickle.load(f)\n",
Expand Down Expand Up @@ -435,7 +434,7 @@
"ra_points = coord.Angle(np.random.uniform(low=0, high=360, size=N) * u.degree)\n",
"ra_points = ra_points.wrap_at(180 * u.degree)\n",
"dec_points = np.arcsin(2 * np.random.uniform(size=N) - 1) / np.pi * 180\n",
"dec_points = coord.Angle(dec_points * u.degree)\n"
"dec_points = coord.Angle(dec_points * u.degree)"
]
},
{
Expand Down
60 changes: 41 additions & 19 deletions tests/test_LsstSciencePipeline/test_opsim_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest
import pickle


@pytest.fixture
def pes_lens_instance():
path = os.path.dirname(__file__)
Expand Down Expand Up @@ -50,33 +51,54 @@ def test_opsim_time_series_images_data():
obs_strategy="baseline_v3.0_10yrs",
MJD_min=60000,
MJD_max=60500,
print_warning=False)
print_warning=False,
)

assert isinstance(opsim_data, list) # is opsim_data a list?
assert len(opsim_data) == len(dec_points) # does it have the same length as number of points given?
assert opsim_data[0].keys() == ['bkg_noise', # does it contain the right data columns?
'psf_kernel',
'obs_time',
'expo_time',
'zero_point',
'calexp_center',
'band']
assert isinstance(opsim_data[0]['bkg_noise'][0], float) # are entries from bkg_noise floats?
assert opsim_data[0]['psf_kernel'][0].ndim == 2 # is psf_kernel a 2 dimensional array?
assert isinstance(opsim_data[0]['obs_time'][0], float) # are entries from obs_time floats?
assert isinstance(opsim_data[0]['expo_time'][0], float) # are entries from expo_time floats?
assert isinstance(opsim_data[0]['zero_point'][0], float) # are entries from zero_point floats?
assert isinstance(opsim_data[0]['calexp_center'][0], np.ndarray) # is calexp_center an array?
assert opsim_data[0]['calexp_center'][0].shape == (2,) # is calexp_center an array of length 2?
assert all(isinstance(item, float) for item in opsim_data[0]['calexp_center'][0]) # are entries floats?
assert isinstance(opsim_data[0]['band'][0], str) # are entries from band strings?
assert len(opsim_data) == len(
dec_points
) # does it have the same length as number of points given?
assert opsim_data[0].keys() == [
"bkg_noise", # does it contain the right data columns?
"psf_kernel",
"obs_time",
"expo_time",
"zero_point",
"calexp_center",
"band",
]
assert isinstance(
opsim_data[0]["bkg_noise"][0], float
) # are entries from bkg_noise floats?
assert (
opsim_data[0]["psf_kernel"][0].ndim == 2
) # is psf_kernel a 2 dimensional array?
assert isinstance(
opsim_data[0]["obs_time"][0], float
) # are entries from obs_time floats?
assert isinstance(
opsim_data[0]["expo_time"][0], float
) # are entries from expo_time floats?
assert isinstance(
opsim_data[0]["zero_point"][0], float
) # are entries from zero_point floats?
assert isinstance(
opsim_data[0]["calexp_center"][0], np.ndarray
) # is calexp_center an array?
assert opsim_data[0]["calexp_center"][0].shape == (
2,
) # is calexp_center an array of length 2?
assert all(
isinstance(item, float) for item in opsim_data[0]["calexp_center"][0]
) # are entries floats?
assert isinstance(opsim_data[0]["band"][0], str) # are entries from band strings?


def test_opsim_variable_lens_injection(pes_lens_instance):
lens_class = pes_lens_instance

# Load example opsim data format
expo_data = Table.read('../TestData/expo_data_opsim.hdf5', path='data')
expo_data = Table.read("../TestData/expo_data_opsim.hdf5", path="data")

transform_pix2angle = np.array([[0.2, 0], [0, 0.2]])
bands = ["g", "r", "i"]
Expand Down

0 comments on commit c444a1e

Please sign in to comment.