Skip to content

Commit

Permalink
Merge pull request #467 from dirac-institute/fake_data_reorg
Browse files Browse the repository at this point in the history
Reorganize the fake data creators
  • Loading branch information
jeremykubica authored Feb 12, 2024
2 parents 825087d + 13734c3 commit 74d56f2
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 98 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import numpy as np
psf = kb.PSF(1.5)

# Create fake data with ten 512x512 pixel images and starting at MJD of 57130.2.
from kbmod.fake_data_creator import *
from kbmod.fake_data.fake_data_creator import *
fake_times = create_fake_times(10, t0=57130.2)
ds = FakeDataSet(512, 512, fake_times)
imgs = ds.stack.get_images()
Expand Down
2 changes: 1 addition & 1 deletion notebooks/create_fake_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"source": [
"import os\n",
"\n",
"from kbmod.fake_data_creator import *\n",
"from kbmod.fake_data.fake_data_creator import *\n",
"from kbmod.search import *"
]
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/manual_test_fake_orbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import kbmod.search as kb

from kbmod.configuration import SearchConfiguration
from kbmod.fake_orbits.insert_fake_orbit import insert_fake_orbit_into_work_unit
from kbmod.fake_orbits.pyoorb_helper import PyoorbOrbit
from kbmod.fake_data.insert_fake_orbit import insert_fake_orbit_into_work_unit
from kbmod.fake_data.pyoorb_helper import PyoorbOrbit
from kbmod.work_unit import WorkUnit

# Set the image parameters.
Expand Down
48 changes: 19 additions & 29 deletions tests/test_analysis_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from kbmod.analysis_utils import *
from kbmod.fake_data_creator import add_fake_object
from kbmod.fake_data.fake_data_creator import FakeDataSet
from kbmod.result_list import *
from kbmod.search import *
from kbmod.trajectory_utils import make_trajectory
Expand Down Expand Up @@ -85,21 +85,20 @@ def setUp(self):

# image properties
self.img_count = 10
self.dim_x = 15
self.dim_y = 20
self.noise_level = 1.0
self.variance = self.noise_level**2
self.p = PSF(0.5)

# create image set with single moving object
self.imlist = []
self.time_list = []
for i in range(self.img_count):
time = i / self.img_count
self.time_list.append(time)
im = LayeredImage(self.dim_x, self.dim_y, self.noise_level, self.variance, time, self.p, i)
self.imlist.append(im)
self.stack = ImageStack(self.imlist)
self.dim_x = 100
self.dim_y = 100

# Create fake images.
self.time_list = [i / self.img_count for i in range(self.img_count)]
self.fake_ds = FakeDataSet(
self.dim_x,
self.dim_y,
self.time_list,
noise_level=1.0,
psf_val=0.5,
use_seed=True,
)
self.stack = self.fake_ds.stack

# Set up old_results object for analysis_utils.PostProcess
self.num_curves = 4
Expand Down Expand Up @@ -179,21 +178,12 @@ def test_load_and_filter_results_lh(self):
make_trajectory(60, 60, 0, 0, 1.0, 1.0, self.img_count),
]

# Create fake images with the objects in them.
imlist = []
for i in range(self.img_count):
t = self.time_list[i]
im = LayeredImage(100, 100, self.noise_level, self.variance, t, self.p, i)

# Add the objects.
for j, trj in enumerate(trjs):
add_fake_object(im, trj.x, trj.y, trj.flux, self.p)

# Append the image.
imlist.append(im)
# Add a fake object to the fake images.
for trj in trjs:
self.fake_ds.insert_object(trj)

# Create the stack search and insert the fake results.
search = StackSearch(ImageStack(imlist))
search = StackSearch(self.fake_ds.stack)
search.set_results(trjs)

# Do the filtering.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bilinear_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from kbmod.fake_data_creator import add_fake_object
from kbmod.fake_data.fake_data_creator import add_fake_object
import kbmod.search as kb


Expand Down
2 changes: 1 addition & 1 deletion tests/test_data_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
load_input_from_file,
load_input_from_individual_files,
)
from kbmod.fake_data_creator import create_fake_times, FakeDataSet
from kbmod.fake_data.fake_data_creator import create_fake_times, FakeDataSet
from kbmod.search import *
from kbmod.work_unit import WorkUnit
from utils.utils_for_tests import get_absolute_data_path
Expand Down
2 changes: 1 addition & 1 deletion tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tempfile
import unittest

from kbmod.fake_data_creator import *
from kbmod.fake_data.fake_data_creator import *
from kbmod.run_search import *
from kbmod.search import *
from kbmod.trajectory_utils import make_trajectory
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fake_data_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tempfile
import unittest

from kbmod.fake_data_creator import *
from kbmod.fake_data.fake_data_creator import *
from kbmod.file_utils import *
from kbmod.search import *
from kbmod.work_unit import WorkUnit
Expand Down
2 changes: 1 addition & 1 deletion tests/test_image_stack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tempfile
import unittest

from kbmod.fake_data_creator import add_fake_object
from kbmod.fake_data.fake_data_creator import add_fake_object
from kbmod.search import *


Expand Down
2 changes: 1 addition & 1 deletion tests/test_layered_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from astropy.io import fits

from kbmod.fake_data_creator import add_fake_object
from kbmod.fake_data.fake_data_creator import add_fake_object
from kbmod.search import *


Expand Down
2 changes: 1 addition & 1 deletion tests/test_readme_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

import kbmod.search as kb
from kbmod.fake_data_creator import *
from kbmod.fake_data.fake_data_creator import *


class test_readme_example(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from astropy.io import fits

from kbmod.fake_data_creator import add_fake_object
from kbmod.fake_data.fake_data_creator import add_fake_object
from kbmod.file_utils import *
from kbmod.result_list import ResultList
from kbmod.run_search import SearchRunner
Expand Down
Loading

0 comments on commit 74d56f2

Please sign in to comment.