2020-05-19 09:39:59 +02:00
|
|
|
from rich.console import Console
|
|
|
|
from rich.table import Table
|
|
|
|
import astropy.units as u
|
|
|
|
|
|
|
|
|
|
|
|
def printSNR(exp_time: u.Quantity, snr: u.Quantity):
|
2020-05-19 09:50:38 +02:00
|
|
|
"""
|
|
|
|
Print the results of the SNR calculation.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
exp_time : Quantity
|
|
|
|
The exposure times for which the SNR was calculated.
|
|
|
|
snr : Quantity
|
|
|
|
The corresponding SNR for the exposure times.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
|
|
|
|
"""
|
2020-05-19 09:39:59 +02:00
|
|
|
table = Table(show_header=True, header_style="bold magenta")
|
|
|
|
table.add_column("#", style="dim", width=4, justify="center")
|
|
|
|
table.add_column("Exposure Time", justify="right")
|
|
|
|
table.add_column("SNR", justify="right")
|
2020-05-19 10:34:10 +02:00
|
|
|
if exp_time.size > 1:
|
|
|
|
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)
|
2020-05-19 09:39:59 +02:00
|
|
|
console = Console()
|
2020-05-29 09:53:01 +02:00
|
|
|
console.print("")
|
2020-05-19 09:39:59 +02:00
|
|
|
console.print(table)
|
|
|
|
|
|
|
|
|
|
|
|
def printExposureTime(exp_time: u.Quantity, snr: u.Quantity):
|
2020-05-19 09:50:38 +02:00
|
|
|
"""
|
|
|
|
Print the results of the exposure time calculation.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
exp_time : Quantity
|
|
|
|
The corresponding exposure time for the SNRs.
|
|
|
|
snr : Quantity
|
|
|
|
The SNRs for which the exposure time was calculated.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
|
|
|
|
"""
|
2020-05-19 09:39:59 +02:00
|
|
|
table = Table(show_header=True, header_style="bold magenta")
|
|
|
|
table.add_column("#", style="dim", width=4, justify="center")
|
|
|
|
table.add_column("SNR", justify="right")
|
|
|
|
table.add_column("Exposure Time", justify="right")
|
2020-05-19 10:34:10 +02:00
|
|
|
if exp_time.size > 1:
|
|
|
|
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)
|
2020-05-19 09:39:59 +02:00
|
|
|
console = Console()
|
2020-05-29 09:53:01 +02:00
|
|
|
console.print("")
|
2020-05-19 09:39:59 +02:00
|
|
|
console.print(table)
|
|
|
|
|
|
|
|
|
|
|
|
def printSensitivity(exp_time: u.Quantity, snr: u.Quantity, sensitivity: u.Quantity):
|
2020-05-19 09:50:38 +02:00
|
|
|
"""
|
|
|
|
Print the results of the sensitivity calculation.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
exp_time : Quantity
|
|
|
|
The exposure times for which the sensitivity was calculated.
|
|
|
|
snr : Quantity
|
|
|
|
The SNRs for which the sensitivity was calculated.
|
|
|
|
sensitivity : Quantity
|
|
|
|
The corresponding sensitivity for the exposure times and SNRs.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
|
|
|
|
"""
|
2020-05-19 09:39:59 +02:00
|
|
|
table = Table(show_header=True, header_style="bold magenta")
|
|
|
|
table.add_column("#", style="dim", width=4, justify="center")
|
|
|
|
table.add_column("Exposure Time", justify="right")
|
|
|
|
table.add_column("SNR", justify="right")
|
|
|
|
table.add_column("Sensitivity", justify="right")
|
2020-05-19 10:34:10 +02:00
|
|
|
if exp_time.size > 1:
|
|
|
|
for i, exp_time_, snr_, sensitivity_ in zip(range(len(exp_time)), exp_time.value, snr.value, sensitivity.value):
|
|
|
|
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)
|
2020-05-19 09:39:59 +02:00
|
|
|
console = Console()
|
2020-05-29 09:53:01 +02:00
|
|
|
console.print("")
|
2020-05-19 09:39:59 +02:00
|
|
|
console.print(table)
|