Skip to content

Commit

Permalink
Merge pull request #136 from deepskies/paper-edits
Browse files Browse the repository at this point in the history
Paper edits
  • Loading branch information
voetberg authored Feb 26, 2024
2 parents 1c3a954 + 489cb62 commit 2d05e3c
Show file tree
Hide file tree
Showing 16 changed files with 945 additions and 260 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
![GitHub Workflow Status](https://github.com/deepskies/DeepBench/actions/workflows/test-bench.yml/badge.svg?label=test)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![PyPI version](https://badge.fury.io/py/deepbench.svg)](https://badge.fury.io/py/deepbench)

[![Documentation Status](https://readthedocs.org/projects/deepbench/badge/?version=latest)](https://deepbench.readthedocs.io/en/latest/?badge=latest)

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



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

## Documentation

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

#### To build
#### To build from source
```
pip install sphinx
cd docs
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added paper/figures/DeepBench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions paper/figures/code/example_objects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
from deepbench.image import SkyImage, ShapeImage
from deepbench.physics_object import HamiltonianPendulum, Pendulum
import matplotlib.pyplot as plt
import numpy as np


# Each image is 480,480
image_shape = (480, 480)

# Total images N and figure size
fig, subplots = plt.subplots(2, 4, figsize=(12, 6))

# Center of all images is at 480/2, 480/2
center = image_shape[0] / 2


# Parameters for each ellipse
ellipse_params = {
"center": (center, center),
"width": 100,
"height": 200,
"fill": True,
"angle": 30,
}
shape_single = ShapeImage(image_shape, object_noise_level=0.0)
single_shape_noiseless = shape_single.combine_objects(
["ellipse"], object_params=[ellipse_params]
)

subplots[0, 0].imshow(single_shape_noiseless)

# Use the same parameters to make an ellipse with noise
shape_single = ShapeImage(image_shape, object_noise_level=0.4)
shape_single_noisy = shape_single.combine_objects(
["ellipse"], object_params=[ellipse_params]
)

subplots[0, 1].imshow(shape_single_noisy)

# Produce a rectangle with specified line widths
line_params = {
"center": (center + int(center / 2), center),
"width": 120,
"height": 200,
"line_width": 20,
}
shape_two = ShapeImage(image_shape, object_noise_level=0)
# Use the combine objects method to make ellipses and rectangles with the above prameters
shape_two_noiseless = shape_two.combine_objects(
["ellipse", "rectangle"], object_params=[ellipse_params, line_params]
)

subplots[0, 2].imshow(shape_two_noiseless)

# Do it with a noise argument now
shape_two = ShapeImage(image_shape, object_noise_level=0.2)
shape_two_noisy = shape_single.combine_objects(
["ellipse", "rectangle"], object_params=[ellipse_params, line_params]
)

subplots[0, 3].imshow(shape_two_noisy)

# Read the process with specifiations for astronomy objects
star_instance = {"radius": 100.0, "amplitude": 100.0}
star_params = {"center_x": center - int(center / 2), "center_y": center}

galaxy_instance = {"radius": 30.0, "amplitude": 200.0, "ellipse": 0.8, "theta": 0.2}
galaxy_params = {"center_x": center, "center_y": center + int(center / 2)}
subplots[1, 0].set_ylabel("Astronomy", labelpad=8.0)

one_image_sky = SkyImage(image_shape)
one_sky = one_image_sky.combine_objects(
["star"], instance_params=[star_instance], object_params=[star_params]
)

subplots[1, 0].imshow(one_sky)


one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
one_image_sky_noise = one_sky_noise.combine_objects(
["star"], instance_params=[star_instance], object_params=[star_params]
)

subplots[1, 1].imshow(one_image_sky_noise)

one_image_sky = SkyImage(image_shape)
one_sky = one_image_sky.combine_objects(
["star", "galaxy"],
instance_params=[star_instance, galaxy_instance],
object_params=[star_params, galaxy_params],
)

subplots[1, 2].imshow(one_sky)


one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
one_image_sky_noise = one_sky_noise.combine_objects(
["star", "galaxy"],
instance_params=[star_instance, galaxy_instance],
object_params=[star_params, galaxy_params],
)

subplots[1, 3].imshow(one_image_sky_noise)


one_sky_noise = SkyImage(image_shape, object_noise_level=0.4)
one_image_sky_noise = one_sky_noise.combine_objects(
["star", "galaxy"],
instance_params=[star_instance, galaxy_instance],
object_params=[star_params, galaxy_params],
)

subplots[1, 3].imshow(one_image_sky_noise)

# Y axis labels for each row
subplots[0, 0].set_ylabel("Geometry", labelpad=10.0)

# Remove unnecessary ticks, only put them on the 100 pixel marks
# Flip the images so it starts at 0.,0.
ticks = np.linspace(0, image_shape[0], int(image_shape[0] / 100))
for plot in subplots.ravel():
plot.autoscale(tight=True)
plot.set_yticks(ticks.tolist()[::-1])
plot.invert_yaxis()
plot.set_xticks(ticks)

# All object titles
subplots[0, 0].set_title("Noiseless Single Object")
subplots[0, 2].set_title("Noiseless Multi-Object")
subplots[0, 1].set_title("Noisy Single Object")
subplots[0, 3].set_title("Noisy Multi-Object")

# Scale information
fig.supxlabel("pixel")
fig.supylabel("pixel")

plt.savefig("../example_objects.png")
89 changes: 89 additions & 0 deletions paper/figures/code/example_pendulums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from deepbench.physics_object import HamiltonianPendulum, Pendulum
import matplotlib.pyplot as plt
import numpy as np


# Define the number of objects in the plot and the total figure size
fig, subplots = plt.subplots(1, 2, figsize=(int(19 * (3 / 4)), int(7 * 3 / 4)))

# Set the times to calculate the pendulum position over
# 1 point every second, for 0 to 25 seconds
time = np.array(np.linspace(0, 25, 25))

# Produce pendulum object
pendulum = Pendulum(
pendulum_arm_length=10.0,
starting_angle_radians=np.pi / 4,
acceleration_due_to_gravity=9.8,
noise_std_percent={
"pendulum_arm_length": 0.0,
"starting_angle_radians": 0.1,
"acceleration_due_to_gravity": 0.1,
},
)

# Use the noiseless argument to make the pendulum w/o noise
# Plot that against the time and with scatter and line options
pendulum_noiseless = pendulum.create_object(time, noiseless=True)
subplots[0].plot(time, pendulum_noiseless, color="black")
subplots[0].scatter(time, pendulum_noiseless, color="black", label="Noiseless")

# Use the noiseless=False to do the same with a noiseless pendulum
pendulum_noisy = pendulum.create_object(time, noiseless=False)
subplots[0].plot(time, pendulum_noisy, color="red")
subplots[0].scatter(time, pendulum_noisy, color="red", label="Noisy")


# Produce noiseless pendulum object for the H
pendulum = HamiltonianPendulum(
pendulum_arm_length=10.0,
starting_angle_radians=np.pi / 4,
acceleration_due_to_gravity=9.8,
noise_std_percent={
"pendulum_arm_length": 0.0,
"starting_angle_radians": 0.0,
"acceleration_due_to_gravity": 0.0,
},
)

# Cacluate the pendulum positions and engeries
pendulum_data = pendulum.create_object(time)

# Plot the line and scatterplot versions of the position wrt time
subplots[1].plot(pendulum_data[4], pendulum_data[0], color="black")
subplots[1].scatter(
pendulum_data[4], pendulum_data[0], color="black", label="Noiseless"
)

# Repeat the process with the noisely pendulum
pendulum = HamiltonianPendulum(
pendulum_arm_length=10.0,
starting_angle_radians=np.pi / 4,
acceleration_due_to_gravity=9.8,
noise_std_percent={
"pendulum_arm_length": 0.2,
"starting_angle_radians": 0.0,
"acceleration_due_to_gravity": 0.0,
},
)

pendulum_data = pendulum.create_object(time)

subplots[1].plot(pendulum_data[4], pendulum_data[0], color="red")
subplots[1].scatter(pendulum_data[4], pendulum_data[0], color="red", label="Noisy")

# Set plot labels
subplots[0].set_title("Newtonian")
subplots[1].set_title("Hamiltonian")

# Set axices labels
for plot in subplots.ravel():
# plot.set(xticks=[], yticks=[])

plot.set_xlabel("Time (s)")
plot.set_ylabel("X Position")

# Assign legend location
subplots[1].legend(loc="center left", bbox_to_anchor=(1.02, 1))

plt.savefig("../pendulums.png")
Binary file added paper/figures/example_objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed paper/figures/overview_diagram.png
Binary file not shown.
Binary file added paper/figures/pendulums.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2d05e3c

Please sign in to comment.