Bugfix: print information
This commit is contained in:
parent
970cdd543b
commit
a2fbbfc49d
@ -113,11 +113,15 @@ class Imager(ASensor):
|
|||||||
getLogger("root").info("Calculating the SNR...", extra={"user_waiting": True})
|
getLogger("root").info("Calculating the SNR...", extra={"user_waiting": True})
|
||||||
snr = signal_current.sum() * exp_time / np.sqrt(
|
snr = signal_current.sum() * exp_time / np.sqrt(
|
||||||
(signal_current + background_current + dark_current).sum() * exp_time + (read_noise ** 2).sum())
|
(signal_current + background_current + dark_current).sum() * exp_time + (read_noise ** 2).sum())
|
||||||
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='SNR', unit='configurations'))
|
# Print information
|
||||||
for exp_time_ in pbar(exp_time):
|
if exp_time.size > 1:
|
||||||
# Print information
|
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='SNR', unit='configurations'))
|
||||||
self.__printDetails(signal_current * exp_time_, background_current * exp_time_, read_noise,
|
for exp_time_ in pbar(exp_time):
|
||||||
dark_current * exp_time_, "t_exp=%.2f s: " % exp_time_.value)
|
self.__printDetails(signal_current * exp_time_, background_current * exp_time_, read_noise,
|
||||||
|
dark_current * exp_time_, "t_exp=%.2f s: " % exp_time_.value)
|
||||||
|
else:
|
||||||
|
self.__printDetails(signal_current * exp_time, background_current * exp_time, read_noise,
|
||||||
|
dark_current * exp_time, "t_exp=%.2f s: " % exp_time.value)
|
||||||
# Return the value of the SNR, ignoring the physical units (electrons^0.5)
|
# Return the value of the SNR, ignoring the physical units (electrons^0.5)
|
||||||
return snr.value * u.dimensionless_unscaled
|
return snr.value * u.dimensionless_unscaled
|
||||||
|
|
||||||
@ -152,11 +156,16 @@ class Imager(ASensor):
|
|||||||
exp_time = snr ** 2 * (
|
exp_time = snr ** 2 * (
|
||||||
1 + current_ratio + np.sqrt((1 + current_ratio) ** 2 + 4 * read_noise_tot ** 2 / snr ** 2)) / (
|
1 + current_ratio + np.sqrt((1 + current_ratio) ** 2 + 4 * read_noise_tot ** 2 / snr ** 2)) / (
|
||||||
2 * signal_current_tot)
|
2 * signal_current_tot)
|
||||||
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='Exposure Time', unit='configurations'))
|
# Print information
|
||||||
for snr_, exp_time_ in pbar(zip(snr, exp_time)):
|
if exp_time.size > 1:
|
||||||
# Print information
|
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='Exposure Time',
|
||||||
self.__printDetails(signal_current * exp_time_, background_current * exp_time_, read_noise,
|
unit='configurations'))
|
||||||
dark_current * exp_time_, "SNR=%.2f: " % snr_.value)
|
for snr_, exp_time_ in pbar(zip(snr, exp_time)):
|
||||||
|
self.__printDetails(signal_current * exp_time_, background_current * exp_time_, read_noise,
|
||||||
|
dark_current * exp_time_, "SNR=%.2f: " % snr_.value)
|
||||||
|
else:
|
||||||
|
self.__printDetails(signal_current * exp_time, background_current * exp_time, read_noise,
|
||||||
|
dark_current * exp_time, "SNR=%.2f: " % snr.value)
|
||||||
return exp_time
|
return exp_time
|
||||||
|
|
||||||
@u.quantity_input(exp_time="time", snr=u.dimensionless_unscaled, target_brightness=u.mag)
|
@u.quantity_input(exp_time="time", snr=u.dimensionless_unscaled, target_brightness=u.mag)
|
||||||
@ -185,12 +194,18 @@ class Imager(ASensor):
|
|||||||
signal_current_lim = snr * (snr + np.sqrt(
|
signal_current_lim = snr * (snr + np.sqrt(
|
||||||
snr ** 2 + 4 * (exp_time * (background_current.sum() + dark_current.sum()) +
|
snr ** 2 + 4 * (exp_time * (background_current.sum() + dark_current.sum()) +
|
||||||
(read_noise ** 2).sum()))) / (2 * exp_time)
|
(read_noise ** 2).sum()))) / (2 * exp_time)
|
||||||
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='Sensitivity', unit='configurations'))
|
# Print information
|
||||||
for snr_, exp_time_, signal_current_lim_ in pbar(zip(snr, exp_time, signal_current_lim)):
|
if exp_time.size > 1:
|
||||||
# Print information
|
pbar = enlighten.get_manager().counter(**dict(total=len(exp_time), desc='Sensitivity',
|
||||||
self.__printDetails(signal_current_lim_ * exp_time_, background_current * exp_time_, read_noise,
|
unit='configurations'))
|
||||||
dark_current * exp_time_,
|
for snr_, exp_time_, signal_current_lim_ in pbar(zip(snr, exp_time, signal_current_lim)):
|
||||||
"SNR=%.2f t_exp=%.2f s: " % (snr_.value, exp_time_.value))
|
self.__printDetails(signal_current_lim_ * exp_time_, background_current * exp_time_, read_noise,
|
||||||
|
dark_current * exp_time_,
|
||||||
|
"SNR=%.2f t_exp=%.2f s: " % (snr_.value, exp_time_.value))
|
||||||
|
else:
|
||||||
|
self.__printDetails(signal_current_lim * exp_time, background_current * exp_time, read_noise,
|
||||||
|
dark_current * exp_time,
|
||||||
|
"SNR=%.2f t_exp=%.2f s: " % (snr.value, exp_time.value))
|
||||||
return target_brightness - 2.5 * np.log10(signal_current_lim / signal_current.sum()) * u.mag
|
return target_brightness - 2.5 * np.log10(signal_current_lim / signal_current.sum()) * u.mag
|
||||||
|
|
||||||
@u.quantity_input(signal=u.electron, background=u.electron, read_noise=u.electron ** 0.5, dark=u.electron)
|
@u.quantity_input(signal=u.electron, background=u.electron, read_noise=u.electron ** 0.5, dark=u.electron)
|
||||||
|
@ -22,8 +22,11 @@ def printSNR(exp_time: u.Quantity, snr: u.Quantity):
|
|||||||
table.add_column("#", style="dim", width=4, justify="center")
|
table.add_column("#", style="dim", width=4, justify="center")
|
||||||
table.add_column("Exposure Time", justify="right")
|
table.add_column("Exposure Time", justify="right")
|
||||||
table.add_column("SNR", justify="right")
|
table.add_column("SNR", justify="right")
|
||||||
for i, exp_time_, snr_ in zip(range(len(exp_time)), exp_time.value, snr.value):
|
if exp_time.size > 1:
|
||||||
table.add_row(str(i), ("%1.4e " + exp_time.unit.to_string()) % exp_time_, "%1.4e" % snr_)
|
for i, exp_time_, snr_ in zip(range(len(exp_time)), exp_time.value, snr.value):
|
||||||
|
table.add_row(str(i), ("%1.4e " + exp_time.unit.to_string()) % exp_time_, "%1.4e" % snr_)
|
||||||
|
else:
|
||||||
|
table.add_row("1", ("%1.4e " + exp_time.unit.to_string()) % exp_time.value, "%1.4e" % snr.value)
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
||||||
@ -47,8 +50,11 @@ def printExposureTime(exp_time: u.Quantity, snr: u.Quantity):
|
|||||||
table.add_column("#", style="dim", width=4, justify="center")
|
table.add_column("#", style="dim", width=4, justify="center")
|
||||||
table.add_column("SNR", justify="right")
|
table.add_column("SNR", justify="right")
|
||||||
table.add_column("Exposure Time", justify="right")
|
table.add_column("Exposure Time", justify="right")
|
||||||
for i, exp_time_, snr_ in zip(range(len(exp_time)), exp_time.value, snr.value):
|
if exp_time.size > 1:
|
||||||
table.add_row(str(i), "%1.4e" % snr_, ("%1.4e " + exp_time.unit.to_string()) % exp_time_)
|
for i, exp_time_, snr_ in zip(range(len(exp_time)), exp_time.value, snr.value):
|
||||||
|
table.add_row(str(i), "%1.4e" % snr_, ("%1.4e " + exp_time.unit.to_string()) % exp_time_)
|
||||||
|
else:
|
||||||
|
table.add_row("1", "%1.4e" % snr.value, ("%1.4e " + exp_time.unit.to_string()) % exp_time.value)
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
||||||
@ -75,8 +81,12 @@ def printSensitivity(exp_time: u.Quantity, snr: u.Quantity, sensitivity: u.Quant
|
|||||||
table.add_column("Exposure Time", justify="right")
|
table.add_column("Exposure Time", justify="right")
|
||||||
table.add_column("SNR", justify="right")
|
table.add_column("SNR", justify="right")
|
||||||
table.add_column("Sensitivity", justify="right")
|
table.add_column("Sensitivity", justify="right")
|
||||||
for i, exp_time_, snr_, sensitivity_ in zip(range(len(exp_time)), exp_time.value, snr.value, sensitivity.value):
|
if exp_time.size > 1:
|
||||||
table.add_row(str(i), ("%1.4e " + exp_time.unit.to_string()) % exp_time_, "%1.4e" % snr_,
|
for i, exp_time_, snr_, sensitivity_ in zip(range(len(exp_time)), exp_time.value, snr.value, sensitivity.value):
|
||||||
("%1.4e " + sensitivity.unit.to_string()) % sensitivity_)
|
table.add_row(str(i), ("%1.4e " + exp_time.unit.to_string()) % exp_time_, "%1.4e" % snr_,
|
||||||
|
("%1.4e " + sensitivity.unit.to_string()) % sensitivity_)
|
||||||
|
else:
|
||||||
|
table.add_row("1", ("%1.4e " + exp_time.unit.to_string()) % exp_time.value, "%1.4e" % snr.value,
|
||||||
|
("%1.4e " + sensitivity.unit.to_string()) % sensitivity.value)
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
Loading…
Reference in New Issue
Block a user