Struct rubbl_casatables::TableDesc
source · pub struct TableDesc { /* private fields */ }
Expand description
Information about the structure of a CASA table.
From the casacore documentation: “A TableDesc object contains the description, or structure, of a table. This description is required for the creation of a new table. Descriptions are subsequently associated with every table and embedded in them.”“
Examples
Create a description of a table named “TYPE”, with a scalar string column
named “A” with comment “string”, a column of unsigned integer arrays of no
fixed size named “B” with comment “uint array”, and a column of double
precision complex number arrays of shape [4]
named “C” with comment “fixed
complex vector”
use rubbl_casatables::{GlueDataType, TableDescCreateMode, TableDesc};
let mut table_desc = TableDesc::new("TYPE", TableDescCreateMode::TDM_SCRATCH).unwrap();
table_desc
.add_scalar_column(GlueDataType::TpString, "A", Some("string"), false, false).unwrap();
table_desc
.add_array_column(GlueDataType::TpUInt, "B", Some("uint array"), None, false, false).unwrap();
table_desc
.add_array_column(GlueDataType::TpDComplex, "C", Some("fixed complex vector"), Some(&[4]), false, false).unwrap();
Implementations§
source§impl TableDesc
impl TableDesc
sourcepub fn new(name: &str, mode: TableDescCreateMode) -> Result<Self, TableError>
pub fn new(name: &str, mode: TableDescCreateMode) -> Result<Self, TableError>
Create a new TableDesc.
name
- The name of the table description. From casacore:
This name can be seen as the table type in the same way as a
class name is the data type of an object.
mode
- The mode in which to create the table description.
For compatibility with casacore, multiple options are provided,
however you most likely want to go with Scratch, as this avoids
writing a .tabdsc file to disk.
sourcepub fn add_scalar_column(
&mut self,
data_type: GlueDataType,
col_name: &str,
comment: Option<&str>,
direct: bool,
undefined: bool
) -> Result<(), TableError>
pub fn add_scalar_column(
&mut self,
data_type: GlueDataType,
col_name: &str,
comment: Option<&str>,
direct: bool,
undefined: bool
) -> Result<(), TableError>
Add a scalar column to the TableDesc
sourcepub fn add_array_column(
&mut self,
data_type: GlueDataType,
col_name: &str,
comment: Option<&str>,
dims: Option<&[u64]>,
direct: bool,
undefined: bool
) -> Result<(), TableError>
pub fn add_array_column(
&mut self,
data_type: GlueDataType,
col_name: &str,
comment: Option<&str>,
dims: Option<&[u64]>,
direct: bool,
undefined: bool
) -> Result<(), TableError>
Add an array column to the TableDesc
If dimensions (dims
) are provided, then the column has fixed dimensions,
other wise the column is not fixed.
sourcepub fn set_ndims(&mut self, col_name: &str, ndims: u64) -> Result<(), TableError>
pub fn set_ndims(&mut self, col_name: &str, ndims: u64) -> Result<(), TableError>
Set the number of dimensions of a column
sourcepub fn get_keyword_record(&mut self) -> Result<TableRecord, CasacoreError>
pub fn get_keyword_record(&mut self) -> Result<TableRecord, CasacoreError>
Return a copy of the keyword TableRecord
sourcepub fn get_column_keyword_record(
&mut self,
col_name: &str
) -> Result<TableRecord, CasacoreError>
pub fn get_column_keyword_record(
&mut self,
col_name: &str
) -> Result<TableRecord, CasacoreError>
Return a copy of the keyword TableRecord for a given column.
sourcepub fn put_column_keyword<T: CasaDataType>(
&mut self,
col_name: &str,
kw_name: &str,
value: &T
) -> Result<(), CasacoreError>
pub fn put_column_keyword<T: CasaDataType>(
&mut self,
col_name: &str,
kw_name: &str,
value: &T
) -> Result<(), CasacoreError>
Add a “keyword” to be associated with a particular column in this table description.
col_name
- The name of the affected column.
kw_name
- The name of the keyword to apply to the column.
value
- The value to associate with the keyword.