celestial_pointing/commands/
clist.rs1use super::{Command, CommandOutput, FitDisplay};
2use crate::error::Result;
3use crate::session::Session;
4
5pub struct Clist;
6
7impl Command for Clist {
8 fn name(&self) -> &str {
9 "CLIST"
10 }
11 fn description(&self) -> &str {
12 "List current coefficients"
13 }
14
15 fn execute(&self, session: &mut Session, _args: &[&str]) -> Result<CommandOutput> {
16 let names = session
17 .model
18 .term_names()
19 .iter()
20 .map(|s| s.to_string())
21 .collect::<Vec<_>>();
22 if names.is_empty() {
23 return Ok(CommandOutput::Text("No terms in model".to_string()));
24 }
25 let coeffs = session.model.coefficients().to_vec();
26 let sigma = session
27 .last_fit
28 .as_ref()
29 .map(|f| f.sigma.clone())
30 .unwrap_or_else(|| vec![0.0; names.len()]);
31 let sky_rms = session.last_fit.as_ref().map(|f| f.sky_rms).unwrap_or(0.0);
32
33 Ok(CommandOutput::FitDisplay(FitDisplay {
34 term_names: names,
35 coefficients: coeffs,
36 sigma,
37 sky_rms,
38 }))
39 }
40}