Skip to content

Commit

Permalink
implement fits srclist writing
Browse files Browse the repository at this point in the history
test convert yaml to fits
  • Loading branch information
d3v-null committed Jul 7, 2024
1 parent 0624d6c commit 1a1d6d0
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 23 deletions.
5 changes: 4 additions & 1 deletion src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ impl From<WriteSourceListError> for HyperdriveError {
| WriteSourceListError::InvalidHyperdriveFormat(_)
| WriteSourceListError::Sexagesimal(_) => Self::Srclist(s),
WriteSourceListError::IO(e) => Self::from(e),
WriteSourceListError::Yaml(_) | WriteSourceListError::Json(_) => Self::Generic(s),
WriteSourceListError::Yaml(_)
| WriteSourceListError::Json(_)
| WriteSourceListError::Fitsio(_)
| WriteSourceListError::Fits(_) => Self::Generic(s),

Check warning on line 374 in src/cli/error.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/error.rs#L374

Added line #L374 was not covered by tests
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/srclist/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ pub(crate) enum WriteSourceListError {
#[error(transparent)]
Sexagesimal(#[from] marlu::sexagesimal::SexagesimalError),

#[error(transparent)]
Fitsio(#[from] fitsio::errors::Error),

#[error(transparent)]
Fits(#[from] crate::io::read::fits::FitsError),

/// An IO error.
#[error(transparent)]
IO(#[from] std::io::Error),
Expand Down
7 changes: 5 additions & 2 deletions src/srclist/fits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

//! Code to handle FITS source list files.

// The reference frequency of the power laws.
const REF_FREQ_HZ: f64 = 200e6;

mod read;
// mod write;
mod write;

// Re-exports.
pub(crate) use read::parse_source_list;
// pub(crate) use write::write_source_list;
pub(crate) use write::write_source_list_jack;
16 changes: 6 additions & 10 deletions src/srclist/fits/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use log::debug;
use marlu::RADec;
use vec1::Vec1;

// The reference frequency of the power laws and curved power laws.
use super::REF_FREQ_HZ;
use crate::{
io::read::fits::{fits_open, fits_open_hdu, FitsError},
srclist::{
Expand Down Expand Up @@ -361,9 +363,6 @@ fn parse_lobes_source_list(
hdu: FitsHdu,
col_names: Vec<String>,
) -> Result<SourceList, FitsError> {
// The reference frequency of the power laws and curved power laws.
const REF_FREQ_HZ: f64 = 200e6;

let CommonCols {
unq_source_id: _,
names,
Expand Down Expand Up @@ -512,9 +511,6 @@ fn parse_jack_source_list(
hdu: FitsHdu,
col_names: Vec<String>,
) -> Result<SourceList, FitsError> {
// The reference frequency of the power laws and curved power laws.
const REF_FREQ_HZ: f64 = 200e6;

let CommonCols {
unq_source_id: src_names,
names: comp_names,
Expand Down Expand Up @@ -557,7 +553,10 @@ fn parse_jack_source_list(
)
.enumerate()
{
let prefix = comp_name.rsplit_once("_C").expect("contains '_C'").0;
let prefix = comp_name
.rsplit_once("_C")
.unwrap_or_else(|| panic!("{comp_name:?} does not contain '_C'"))
.0;
let src_comps = map.get_mut(prefix).unwrap_or_else(|| {
panic!("Component '{comp_name}' couldn't be matched against any of the UNQ_SOURCE_ID")

Check warning on line 561 in src/srclist/fits/read.rs

View check run for this annotation

Codecov / codecov/patch

src/srclist/fits/read.rs#L561

Added line #L561 was not covered by tests
});
Expand Down Expand Up @@ -706,9 +705,6 @@ fn parse_gleam_x_source_list(
hdu: FitsHdu,
col_names: Vec<String>,
) -> Result<SourceList, FitsError> {
// The reference frequency of the power laws.
const REF_FREQ_HZ: f64 = 200e6;

let CommonCols {
unq_source_id: _,
names: src_names,
Expand Down
Loading

0 comments on commit 1a1d6d0

Please sign in to comment.