Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated paper with example images #116

Merged
merged 14 commits into from
Jan 30, 2024
Merged
23 changes: 23 additions & 0 deletions .github/workflows/make_pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: [push]

jobs:
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
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
Loading