Skip to content

Commit 2d05e3c

Browse files
authored
Merge pull request #136 from deepskies/paper-edits
Paper edits
2 parents 1c3a954 + 489cb62 commit 2d05e3c

16 files changed

+945
-260
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
![GitHub Workflow Status](https://github.com/deepskies/DeepBench/actions/workflows/test-bench.yml/badge.svg?label=test)
22
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
33
[![PyPI version](https://badge.fury.io/py/deepbench.svg)](https://badge.fury.io/py/deepbench)
4-
4+
[![Documentation Status](https://readthedocs.org/projects/deepbench/badge/?version=latest)](https://deepbench.readthedocs.io/en/latest/?badge=latest)
55

66
### What is it?
77
Simulation library for very simple simulations to *benchmark* machine learning algorithms.
88

9-
10-
119
### Why do we need it? Why is it useful?
1210
1. There are very universally recognized scientifically meaningful benchmark data sets, or methods with which to generate them.
1311
2. A very simple data set will have objects, patterns, and signals that are intuitively quanitifiable and will be fast to generate.
1412
3. A very simple data set will be a great testing ground for new networks and for newcomers to practice with the technology.
1513

1614
## Documentation
1715

18-
#### Readthedocs link coming soon!!
16+
#### [ReadTheDocs](https://deepbench.readthedocs.io/en/latest/)
1917

20-
#### To build
18+
#### To build from source
2119
```
2220
pip install sphinx
2321
cd docs
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

paper/figures/DeepBench.png

111 KB
Loading

paper/figures/code/example_objects.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
from deepbench.image import SkyImage, ShapeImage
2+
from deepbench.physics_object import HamiltonianPendulum, Pendulum
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
6+
7+
# Each image is 480,480
8+
image_shape = (480, 480)
9+
10+
# Total images N and figure size
11+
fig, subplots = plt.subplots(2, 4, figsize=(12, 6))
12+
13+
# Center of all images is at 480/2, 480/2
14+
center = image_shape[0] / 2
15+
16+
17+
# Parameters for each ellipse
18+
ellipse_params = {
19+
"center": (center, center),
20+
"width": 100,
21+
"height": 200,
22+
"fill": True,
23+
"angle": 30,
24+
}
25+
shape_single = ShapeImage(image_shape, object_noise_level=0.0)
26+
single_shape_noiseless = shape_single.combine_objects(
27+
["ellipse"], object_params=[ellipse_params]
28+
)
29+
30+
subplots[0, 0].imshow(single_shape_noiseless)
31+
32+
# Use the same parameters to make an ellipse with noise
33+
shape_single = ShapeImage(image_shape, object_noise_level=0.4)
34+
shape_single_noisy = shape_single.combine_objects(
35+
["ellipse"], object_params=[ellipse_params]
36+
)
37+
38+
subplots[0, 1].imshow(shape_single_noisy)
39+
40+
# Produce a rectangle with specified line widths
41+
line_params = {
42+
"center": (center + int(center / 2), center),
43+
"width": 120,
44+
"height": 200,
45+
"line_width": 20,
46+
}
47+
shape_two = ShapeImage(image_shape, object_noise_level=0)
48+
# Use the combine objects method to make ellipses and rectangles with the above prameters
49+
shape_two_noiseless = shape_two.combine_objects(
50+
["ellipse", "rectangle"], object_params=[ellipse_params, line_params]
51+
)
52+
53+
subplots[0, 2].imshow(shape_two_noiseless)
54+
55+
# Do it with a noise argument now
56+
shape_two = ShapeImage(image_shape, object_noise_level=0.2)
57+
shape_two_noisy = shape_single.combine_objects(
58+
["ellipse", "rectangle"], object_params=[ellipse_params, line_params]
59+
)
60+
61+
subplots[0, 3].imshow(shape_two_noisy)
62+
63+
# Read the process with specifiations for astronomy objects
64+
star_instance = {"radius": 100.0, "amplitude": 100.0}
65+
star_params = {"center_x": center - int(center / 2), "center_y": center}
66+
67+
galaxy_instance = {"radius": 30.0, "amplitude": 200.0, "ellipse": 0.8, "theta": 0.2}
68+
galaxy_params = {"center_x": center, "center_y": center + int(center / 2)}
69+
subplots[1, 0].set_ylabel("Astronomy", labelpad=8.0)
70+
71+
one_image_sky = SkyImage(image_shape)
72+
one_sky = one_image_sky.combine_objects(
73+
["star"], instance_params=[star_instance], object_params=[star_params]
74+
)
75+
76+
subplots[1, 0].imshow(one_sky)
77+
78+
79+
one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
80+
one_image_sky_noise = one_sky_noise.combine_objects(
81+
["star"], instance_params=[star_instance], object_params=[star_params]
82+
)
83+
84+
subplots[1, 1].imshow(one_image_sky_noise)
85+
86+
one_image_sky = SkyImage(image_shape)
87+
one_sky = one_image_sky.combine_objects(
88+
["star", "galaxy"],
89+
instance_params=[star_instance, galaxy_instance],
90+
object_params=[star_params, galaxy_params],
91+
)
92+
93+
subplots[1, 2].imshow(one_sky)
94+
95+
96+
one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
97+
one_image_sky_noise = one_sky_noise.combine_objects(
98+
["star", "galaxy"],
99+
instance_params=[star_instance, galaxy_instance],
100+
object_params=[star_params, galaxy_params],
101+
)
102+
103+
subplots[1, 3].imshow(one_image_sky_noise)
104+
105+
106+
one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
107+
one_image_sky_noise = one_sky_noise.combine_objects(
108+
["star", "galaxy"],
109+
instance_params=[star_instance, galaxy_instance],
110+
object_params=[star_params, galaxy_params],
111+
)
112+
113+
subplots[1, 3].imshow(one_image_sky_noise)
114+
115+
# Y axis labels for each row
116+
subplots[0, 0].set_ylabel("Geometry", labelpad=10.0)
117+
118+
# Remove unnecessary ticks, only put them on the 100 pixel marks
119+
# Flip the images so it starts at 0.,0.
120+
ticks = np.linspace(0, image_shape[0], int(image_shape[0] / 100))
121+
for plot in subplots.ravel():
122+
plot.autoscale(tight=True)
123+
plot.set_yticks(ticks.tolist()[::-1])
124+
plot.invert_yaxis()
125+
plot.set_xticks(ticks)
126+
127+
# All object titles
128+
subplots[0, 0].set_title("Noiseless Single Object")
129+
subplots[0, 2].set_title("Noiseless Multi-Object")
130+
subplots[0, 1].set_title("Noisy Single Object")
131+
subplots[0, 3].set_title("Noisy Multi-Object")
132+
133+
# Scale information
134+
fig.supxlabel("pixel")
135+
fig.supylabel("pixel")
136+
137+
plt.savefig("../example_objects.png")
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from deepbench.physics_object import HamiltonianPendulum, Pendulum
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
6+
# Define the number of objects in the plot and the total figure size
7+
fig, subplots = plt.subplots(1, 2, figsize=(int(19 * (3 / 4)), int(7 * 3 / 4)))
8+
9+
# Set the times to calculate the pendulum position over
10+
# 1 point every second, for 0 to 25 seconds
11+
time = np.array(np.linspace(0, 25, 25))
12+
13+
# Produce pendulum object
14+
pendulum = Pendulum(
15+
pendulum_arm_length=10.0,
16+
starting_angle_radians=np.pi / 4,
17+
acceleration_due_to_gravity=9.8,
18+
noise_std_percent={
19+
"pendulum_arm_length": 0.0,
20+
"starting_angle_radians": 0.1,
21+
"acceleration_due_to_gravity": 0.1,
22+
},
23+
)
24+
25+
# Use the noiseless argument to make the pendulum w/o noise
26+
# Plot that against the time and with scatter and line options
27+
pendulum_noiseless = pendulum.create_object(time, noiseless=True)
28+
subplots[0].plot(time, pendulum_noiseless, color="black")
29+
subplots[0].scatter(time, pendulum_noiseless, color="black", label="Noiseless")
30+
31+
# Use the noiseless=False to do the same with a noiseless pendulum
32+
pendulum_noisy = pendulum.create_object(time, noiseless=False)
33+
subplots[0].plot(time, pendulum_noisy, color="red")
34+
subplots[0].scatter(time, pendulum_noisy, color="red", label="Noisy")
35+
36+
37+
# Produce noiseless pendulum object for the H
38+
pendulum = HamiltonianPendulum(
39+
pendulum_arm_length=10.0,
40+
starting_angle_radians=np.pi / 4,
41+
acceleration_due_to_gravity=9.8,
42+
noise_std_percent={
43+
"pendulum_arm_length": 0.0,
44+
"starting_angle_radians": 0.0,
45+
"acceleration_due_to_gravity": 0.0,
46+
},
47+
)
48+
49+
# Cacluate the pendulum positions and engeries
50+
pendulum_data = pendulum.create_object(time)
51+
52+
# Plot the line and scatterplot versions of the position wrt time
53+
subplots[1].plot(pendulum_data[4], pendulum_data[0], color="black")
54+
subplots[1].scatter(
55+
pendulum_data[4], pendulum_data[0], color="black", label="Noiseless"
56+
)
57+
58+
# Repeat the process with the noisely pendulum
59+
pendulum = HamiltonianPendulum(
60+
pendulum_arm_length=10.0,
61+
starting_angle_radians=np.pi / 4,
62+
acceleration_due_to_gravity=9.8,
63+
noise_std_percent={
64+
"pendulum_arm_length": 0.2,
65+
"starting_angle_radians": 0.0,
66+
"acceleration_due_to_gravity": 0.0,
67+
},
68+
)
69+
70+
pendulum_data = pendulum.create_object(time)
71+
72+
subplots[1].plot(pendulum_data[4], pendulum_data[0], color="red")
73+
subplots[1].scatter(pendulum_data[4], pendulum_data[0], color="red", label="Noisy")
74+
75+
# Set plot labels
76+
subplots[0].set_title("Newtonian")
77+
subplots[1].set_title("Hamiltonian")
78+
79+
# Set axices labels
80+
for plot in subplots.ravel():
81+
# plot.set(xticks=[], yticks=[])
82+
83+
plot.set_xlabel("Time (s)")
84+
plot.set_ylabel("X Position")
85+
86+
# Assign legend location
87+
subplots[1].legend(loc="center left", bbox_to_anchor=(1.02, 1))
88+
89+
plt.savefig("../pendulums.png")

0 commit comments

Comments
 (0)