Skip to content

Commit

Permalink
Add assert statements to catch undefined components in system functio…
Browse files Browse the repository at this point in the history
…n calls #95
  • Loading branch information
abeerfatima authored Jun 11, 2022
1 parent 2ad3e05 commit 852976b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions payload_designer/components/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __init__(
def get_size(self) -> tuple:
"""Get the size of the sensor face in the (x, y) dimensions of the
cubesat frame."""

assert self.n_px is not None, "n_px must be specified."
assert self.pitch is not None, "Pitch must be specified."

size = (self.n_px * self.pitch, self.n_px * self.pitch)

return size
Expand All @@ -83,28 +85,35 @@ def get_pixel_area(self):
Assumes square pixels.
"""
assert self.pitch is not None, "Pitch must be specified."

pixel_area = self.pitch**2

return pixel_area

def get_dark_noise(self):
"""Get the dark noise of the sensor."""

assert self.i_dark is not None, "i_dark must be specified."
assert self.dt is not None, "dt amplitude must be specified."

dark_noise = self.i_dark * self.dt

return dark_noise

def get_quantization_noise(self):
"""Get the quantization noise of the sensor."""

assert self.n_well is not None, "n_well must be specified."
assert self.n_bit is not None, "n_bit must be specified."

quant_noise = (1 / math.sqrt(12)) * self.n_well / 2**self.n_bit

return quant_noise

def get_noise(self, signal):
"""Get the net noise of the sensor."""

assert self.n_bin is not None, "n_bin must be specified."
assert self.noise_read is not None, "noise_read must be specified."

noise = np.sqrt(
signal
+ self.n_bin * self.get_dark_noise() ** 2
Expand Down

0 comments on commit 852976b

Please sign in to comment.