pub struct Field { /* private fields */ }Expand description
The angular extent of a frame.
Feed a Field to Constraint::within (circular
membership sized by a RadiusPolicy) or
Constraint::frame (rectangular membership) to
build a search Constraint.
§Example
use target_match::{Field, Optics, RadiusPolicy};
let field = Field::from_optics(Optics {
focal_mm: 800.0,
pixel_um: (3.76, 3.76),
binning: (1, 1),
pixels: (6248, 4176),
})
.unwrap();
assert!(field.width().degrees() > 0.0);
assert!(field.height().degrees() > 0.0);
assert!(field.diagonal().degrees() > field.width().degrees());
assert!(field.pixel_scale().is_some(), "derived from optics, so plate scale is known");
let _radius = field.radius(RadiusPolicy::Circumscribed);Implementations§
Source§impl Field
impl Field
Sourcepub fn from_optics(o: Optics) -> Result<Self>
pub fn from_optics(o: Optics) -> Result<Self>
Derive a field from full optics.
Effective pixel size = pixel size × binning (per axis); pixel scale (arcsec/px) = effective pixel size (mm) / focal length (mm) × arcsec/radian; field extent = pixel scale × pixel count.
§Example
use target_match::{Field, Optics};
let field = Field::from_optics(Optics {
focal_mm: 800.0,
pixel_um: (3.76, 3.76),
binning: (1, 1),
pixels: (6248, 4176),
})
.unwrap();
let (sx, _) = field.pixel_scale().unwrap();
assert!((sx - 0.969).abs() < 1e-2, "≈0.969 arcsec/px");§Errors
Error::InvalidOptics if any input is non-positive or non-finite.
Sourcepub fn from_pixel_scale(
scale_arcsec_px: (f64, f64),
pixels: (u32, u32),
) -> Result<Self>
pub fn from_pixel_scale( scale_arcsec_px: (f64, f64), pixels: (u32, u32), ) -> Result<Self>
Build a field from a directly supplied pixel scale (arcsec/px, per axis) and sensor pixel counts.
§Example
use target_match::Field;
let field = Field::from_pixel_scale((0.9694, 0.9694), (6248, 4176)).unwrap();
assert_eq!(field.pixel_scale(), Some((0.9694, 0.9694)));
assert!((field.width().degrees() - 1.683).abs() < 1e-2);§Errors
Error::InvalidOptics if any input is non-positive or non-finite.
Sourcepub fn from_fov(width: Angle, height: Angle) -> Result<Self>
pub fn from_fov(width: Angle, height: Angle) -> Result<Self>
Build a field directly from its angular width and height (no optics; pixel scale is unknown).
§Example
use skymath::Angle;
use target_match::Field;
let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert_eq!(field.width().degrees(), 2.0);
assert!(field.pixel_scale().is_none(), "no optics, so no plate scale");§Errors
Error::InvalidOptics if width or height is non-positive or non-finite.
Sourcepub fn diagonal(self) -> Angle
pub fn diagonal(self) -> Angle
Diagonal field of view — hypot(width,
height). Halved, this is the
RadiusPolicy::Circumscribed search radius.
§Example
use skymath::Angle;
use target_match::Field;
let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert!((field.diagonal().degrees() - 2.0_f64.hypot(1.0)).abs() < 1e-9);Sourcepub fn pixel_scale(self) -> Option<(f64, f64)>
pub fn pixel_scale(self) -> Option<(f64, f64)>
Per-axis pixel scale (arcsec/px), if this field was built with a scale
(via from_optics or
from_pixel_scale) — None for
from_fov.
§Example
use target_match::{Field, Optics};
let field = Field::from_optics(Optics {
focal_mm: 800.0, pixel_um: (3.76, 3.76), binning: (1, 1), pixels: (6248, 4176),
})
.unwrap();
let (sx, sy) = field.pixel_scale().unwrap();
assert!((sx - 0.969).abs() < 1e-2);
assert_eq!(sx, sy);Sourcepub fn radius(self, policy: RadiusPolicy) -> Angle
pub fn radius(self, policy: RadiusPolicy) -> Angle
Compute a search radius from this field under policy. Feeds
Constraint::within, which calls this
internally.
§Example
use skymath::Angle;
use target_match::{Field, RadiusPolicy};
let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
let r = field.radius(RadiusPolicy::Explicit(Angle::from_degrees(3.0)));
assert!((r.degrees() - 3.0).abs() < 1e-9);