use super::{FieldOfView, PixelScale};
use crate::{Objects, Observer, Photometry, SeeingBuilder, Star};
#[derive(Clone, Debug)]
pub struct FieldBuilder<T: Observer> {
pub(super) pixel_scale: PixelScale,
pub(super) field_of_view: FieldOfView,
pub(super) photometry: Vec<Photometry>,
pub(super) objects: Objects,
pub(super) exposure: f64,
pub(super) poisson_noise: bool,
pub(super) observer: T,
pub(super) seeing: Option<SeeingBuilder>,
pub(super) flux: Option<f64>,
}
impl<T: Observer> FieldBuilder<T> {
pub fn new(observer: T) -> Self {
Self {
pixel_scale: PixelScale::Nyquist(1),
field_of_view: 101.into(),
photometry: vec!["V".into()],
objects: Star::default().into(),
exposure: 1f64,
poisson_noise: false,
observer,
seeing: None,
flux: None,
}
}
pub fn pixel_scale<X: Into<PixelScale>>(self, pixel_scale: X) -> Self {
Self {
pixel_scale: pixel_scale.into(),
..self
}
}
pub fn field_of_view<F: Into<FieldOfView>>(self, field_of_view: F) -> Self {
Self {
field_of_view: field_of_view.into(),
..self
}
}
pub fn photometry<P: Into<Photometry>>(self, photometry: P) -> Self {
Self {
photometry: vec![photometry.into()],
..self
}
}
pub fn polychromatic<P: Into<Photometry>>(self, photometry: Vec<P>) -> Self {
Self {
photometry: photometry.into_iter().map(|p| p.into()).collect(),
..self
}
}
pub fn objects<O: Into<Objects>>(self, objects: O) -> Self {
Self {
objects: objects.into(),
..self
}
}
pub fn flux(self, flux: f64) -> Self {
Self {
flux: Some(flux),
..self
}
}
pub fn exposure(self, exposure: f64) -> Self {
Self { exposure, ..self }
}
pub fn photon_noise(self) -> Self {
Self {
poisson_noise: true,
..self
}
}
pub fn seeing_limited(self, seeing_builder: SeeingBuilder) -> Self {
Self {
seeing: Some(seeing_builder),
..self
}
}
}