<commit_before>//! `fitsio` - a thin wrapper around the [`cfitsio`][1] C library.
//!
//! * [HDU access](#hdu-access)
//! * [Creating new HDUs](#creating-new-hdus)
//! * [Header keys](#header-keys)
//! * [Reading file data](#reading-file-data)
//!     * [Images](#images)
//!     * [Tables](#tables)
//! * [Writing file data](#writing-file-data)
//!     * [Images](#images)
//!     * [Tables](#tables)
//!
//! This library wraps the low level `cfitsio` bindings: [`fitsio-sys`][2] and provides a more
//! native experience for rust users.
//!
//! The main interface to a fits file is [`FitsFile`](struct.FitsFile.html). All file manipulation
//! and reading starts with this class.
//!
//! Opening a file:
//!
//! ```rust
//! # fn main() {
//! # let filename = "../testdata/full_example.fits";
//! use fitsio::FitsFile;
//!
//! // let filename = ...;
//! let fptr = FitsFile::open(filename).unwrap();
//! # }
//! ```
//!
//! Alternatively a new file can be created on disk with the companion method
//! [`create`](struct.FitsFile.html#method.create):
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::FitsFile;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let _filename = tdir_path.join("test.fits");
//! # let filename = _filename.to_str().unwrap();
//! use fitsio::FitsFile;
//!
//! // let filename = ...;
//! let fptr = FitsFile::create(filename).unwrap();
//! # }
//! ```
//!
//! From this point, the current HDU can be queried and changed, or fits header cards can be read
//! or file contents can be read.
//!
//! To open a fits file in read/write mode (to allow changes to the file), the
//! [`edit`](struct.FitsFile.html#method.edit) must be used. This opens a file which already exists
//! on disk for editing.
//!
//! ## HDU access
//!
//! HDU information belongs to the [`FitsHdu`](struct.FitsHdu.html) object. HDUs can be fetched by
//! `String`/`str` or integer (0-indexed).
//! The `HduInfo` object contains information about the current HDU:
//!
//! ```rust
//! # extern crate fitsio;
//! # extern crate fitsio_sys;
//! # use fitsio::{FitsFile, HduInfo};
//! #
//! # fn main() {
//! # let filename = "../testdata/full_example.fits";
//! # let fptr = FitsFile::open(filename).unwrap();
//! let hdu = fptr.hdu(0).unwrap();
//! // image HDU
//! if let HduInfo::ImageInfo { shape } = hdu.info {
//!    println!("Image is {}-dimensional", shape.len());
//!    println!("Found image with shape {:?}", shape);
//! }
//! # let hdu = fptr.hdu("TESTEXT").unwrap();
//!
//! // tables
//! if let HduInfo::TableInfo { column_descriptions, num_rows, .. } = hdu.info {
//!     println!("Table contains {} rows", num_rows);
//!     println!("Table has {} columns", column_descriptions.len());
//! }
//! # }
//! ```
//!
//! ## Creating new HDUs
//!
//! ### Images
//!
//! New fits images are created with the [`create_image`](struct.FitsFile.html#method.create_image)
//! method. This method requires the extension name, and an
//! [`ImageDescription`](struct.ImageDescription.html) object, which defines the shape and type of
//! the desired image:
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::fitsfile::ImageDescription;
//! # use fitsio::types::ImageType;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let filename = tdir_path.join("test.fits");
//! # let fptr = fitsio::FitsFile::create(filename.to_str().unwrap()).unwrap();
//! let image_description = ImageDescription {
//!     data_type: ImageType::FLOAT_IMG,
//!     dimensions: &[100, 100],
//! };
//! let mut hdu = fptr.create_image("EXTNAME".to_string(), &image_description).unwrap();
//! # }
//! ```
//!
//! ### Tables
//!
//! Similar to creating new images, new tables are created with the
//! [`create_table`](struct.FitsFile.html#method.create_table) method. This requires an extension
//! name, and a slice of [`ColumnDescription`](columndescription/struct.ColumnDescription.html)s:
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::columndescription::*;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let filename = tdir_path.join("test.fits");
//! # let fptr = fitsio::FitsFile::create(filename.to_str().unwrap()).unwrap();
//! let first_description = ConcreteColumnDescription {
//!     name: "A".to_string(),
//!     data_type: ColumnDataDescription::scalar(ColumnDataType::Int),
//! };
//! let second_description = ConcreteColumnDescription {
//!     name: "B".to_string(),
//!     data_type: ColumnDataDescription::scalar(ColumnDataType::Long),
//! };
//! let descriptions = [first_description, second_description];
//! let mut hdu = fptr.create_table("EXTNAME".to_string(), &descriptions).unwrap();
//! # }
//! ```
//!
//! #### Column descriptions
//!
//! Columns are described with the
//! [`ColumnDescription`](columndescription/struct.ColumnDescription.html) struct. This
//! encapsulates: the name of the column, and the data format.
//!
//! The fits specification allows scalar or vector columns, and the data format is described the
//! [`ColumnDataDescription`](columndescription/struct.ColumnDataDescription.html) struct, which in
//! turn encapsulates the number of elements per row element (typically 1), the width of the
//! column (for strings), and the data type, which is one of the
//! [`ColumnDataType`](columndescription/enum.ColumnDataType.html) members
//!
//! For the common case of a scalar column, a `ColumnDataDescription` object can be constructed
//! with the `scalar` method:
//!
//! ```rust
//! # extern crate fitsio;
//! # use fitsio::columndescription::*;<commit_msg>Update documentation for new column creation<commit_after>//! `fitsio` - a thin wrapper around the [`cfitsio`][1] C library.
//!
//! * [HDU access](#hdu-access)
//! * [Creating new HDUs](#creating-new-hdus)
//! * [Header keys](#header-keys)
//! * [Reading file data](#reading-file-data)
//!     * [Images](#images)
//!     * [Tables](#tables)
//! * [Writing file data](#writing-file-data)
//!     * [Images](#images)
//!     * [Tables](#tables)
//!
//! This library wraps the low level `cfitsio` bindings: [`fitsio-sys`][2] and provides a more
//! native experience for rust users.
//!
//! The main interface to a fits file is [`FitsFile`](struct.FitsFile.html). All file manipulation
//! and reading starts with this class.
//!
//! Opening a file:
//!
//! ```rust
//! # fn main() {
//! # let filename = "../testdata/full_example.fits";
//! use fitsio::FitsFile;
//!
//! // let filename = ...;
//! let fptr = FitsFile::open(filename).unwrap();
//! # }
//! ```
//!
//! Alternatively a new file can be created on disk with the companion method
//! [`create`](struct.FitsFile.html#method.create):
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::FitsFile;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let _filename = tdir_path.join("test.fits");
//! # let filename = _filename.to_str().unwrap();
//! use fitsio::FitsFile;
//!
//! // let filename = ...;
//! let fptr = FitsFile::create(filename).unwrap();
//! # }
//! ```
//!
//! From this point, the current HDU can be queried and changed, or fits header cards can be read
//! or file contents can be read.
//!
//! To open a fits file in read/write mode (to allow changes to the file), the
//! [`edit`](struct.FitsFile.html#method.edit) must be used. This opens a file which already exists
//! on disk for editing.
//!
//! ## HDU access
//!
//! HDU information belongs to the [`FitsHdu`](struct.FitsHdu.html) object. HDUs can be fetched by
//! `String`/`str` or integer (0-indexed).
//! The `HduInfo` object contains information about the current HDU:
//!
//! ```rust
//! # extern crate fitsio;
//! # extern crate fitsio_sys;
//! # use fitsio::{FitsFile, HduInfo};
//! #
//! # fn main() {
//! # let filename = "../testdata/full_example.fits";
//! # let fptr = FitsFile::open(filename).unwrap();
//! let hdu = fptr.hdu(0).unwrap();
//! // image HDU
//! if let HduInfo::ImageInfo { shape } = hdu.info {
//!    println!("Image is {}-dimensional", shape.len());
//!    println!("Found image with shape {:?}", shape);
//! }
//! # let hdu = fptr.hdu("TESTEXT").unwrap();
//!
//! // tables
//! if let HduInfo::TableInfo { column_descriptions, num_rows, .. } = hdu.info {
//!     println!("Table contains {} rows", num_rows);
//!     println!("Table has {} columns", column_descriptions.len());
//! }
//! # }
//! ```
//!
//! ## Creating new HDUs
//!
//! ### Images
//!
//! New fits images are created with the [`create_image`](struct.FitsFile.html#method.create_image)
//! method. This method requires the extension name, and an
//! [`ImageDescription`](struct.ImageDescription.html) object, which defines the shape and type of
//! the desired image:
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::fitsfile::ImageDescription;
//! # use fitsio::types::ImageType;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let filename = tdir_path.join("test.fits");
//! # let fptr = fitsio::FitsFile::create(filename.to_str().unwrap()).unwrap();
//! let image_description = ImageDescription {
//!     data_type: ImageType::FLOAT_IMG,
//!     dimensions: &[100, 100],
//! };
//! let mut hdu = fptr.create_image("EXTNAME".to_string(), &image_description).unwrap();
//! # }
//! ```
//!
//! ### Tables
//!
//! Similar to creating new images, new tables are created with the
//! [`create_table`](struct.FitsFile.html#method.create_table) method. This requires an extension
//! name, and a slice of [`ColumnDescription`](columndescription/struct.ColumnDescription.html)s:
//!
//! ```rust
//! # extern crate tempdir;
//! # extern crate fitsio;
//! # use fitsio::columndescription::*;
//! # fn main() {
//! # let tdir = tempdir::TempDir::new("fitsio-").unwrap();
//! # let tdir_path = tdir.path();
//! # let filename = tdir_path.join("test.fits");
//! # let fptr = fitsio::FitsFile::create(filename.to_str().unwrap()).unwrap();
//! let first_description = ColumnDescription::new("A")
//!     .with_type(ColumnDataType::Int)
//!     .create().unwrap();
//! let second_description = ColumnDescription::new("B")
//!     .with_type(ColumnDataType::Long)
//!     .create().unwrap();
//! let descriptions = [first_description, second_description];
//! let mut hdu = fptr.create_table("EXTNAME".to_string(), &descriptions).unwrap();
//! # }
//! ```
//!
//! #### Column descriptions
//!
//! Columns are described with the
//! [`ColumnDescription`](columndescription/struct.ColumnDescription.html) struct. This
//! encapsulates: the name of the column, and the data format.
//!
//! The fits specification allows scalar or vector columns, and the data format is described the
//! [`ColumnDataDescription`](columndescription/struct.ColumnDataDescription.html) struct, which in
//! turn encapsulates the number of elements per row element (typically 1), the width of the
//! column (for strings), and the data type, which is one of the
//! [`ColumnDataType`](columndescription/enum.ColumnDataType.html) members
//!
//! For the common case of a scalar column, a `ColumnDataDescription` object can be constructed
//! with the `scalar` method:
//!
//! ```rust
//! # extern crate fitsio;
//! # use fitsio::columndescription::*;
{'fraction_non_alphanumeric': 0.21167315175097276, 'fraction_numerical': 0.0019022913964548205, 'mean_word_length': 3.557131599684791, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '184489', 'n_tokens_mistral': 3892, 'n_tokens_neox': 3563, 'n_words': 984}