// FitsLib.h /** A library for reading and manipulating FITS files. haridas@jhu.edu Vivek Haridas Johns Hopkins University Department of Physics and Astronomy FITS stands for flexible image transport system. FitsLib aims to provide an interface to the FITS file on the Dot Net Platform. It is built as an object oriented wrapper around the CFITSIO library's interface to the FITS files. Even though this library should be accessible in all the Dot Net Languages, the main focus is on making it available for C-Sharp. The documentation given here also tends to do the same. This library is intended to assist astronomers in writing webservices utilizing the immense amount of data available in the FITS files. The library provides an interface to the FITS files using a set of active and passive objects. Active Objects access the file and passive objects contain the data accessed from the file. The FitsLib namespace provides all the neccessary interfaces to access the FITS files. Look below in List of articles and samples for a brief tour of how to use the library and to access some of the samples. List of articles and samples FITS data format CFITSIO First documentation release. Examples and articles still left to be documented. First articles added on basic FITS file operation. String Access of FitsTable cells revised. Now you can access them directly as an ArrayList. No need to worry about unicode conversions. Added new methods to read and write rectangular sections of image buffer. Make sure you use the new createImageSectionBuffer to create a buffer for writing rectangular sections. A bug fix for WriteSectionOfPixels. New examples for reading images, reading header key values, writing new fits tables and images. Instructions for usage of the library in a WebService is also available. Support for types LongLong (int64) , complex and double complex added. Bug fix in column insertion routines. Source code split into many files. Corrected memory leaks in FitsData and FitsImagePoint. The String property of FitsData now returns an array of strings. Added a new SafeArray property to FitsData. This means that you can access the data without an unsafe block. Added internal support to read and write long string header keywords. Also includes memory leak fixes in FitsTable. Added CreateColumnCells method in FitsTable interface. This can be used in writing columns of data into newly created tables. **/ #pragma once using namespace System; extern "C" { #include "fitsio.h" #include "stdlib.h" } // Gets a non unicode char* from a string //Used for internal purpose only char* getcharfromString(String* str); namespace FitsLib { /** Contains all the neccessary entities to access a FITS file. The library provides a set of active and a set of passive objects. The operations on an active object would be reflected on the FITS file being accessed. The passive objects are holders of data extracted from the file. The active objects are Fits, FitsUnit, FitsImage, FitsTable, FitsUnitHeader, FitsColumnCollection and FitsTableElementCollection. Changes made on these objects would be reflected in the corresponding FITS file. Changes made in passive objects such as FitsData would be reflected in the file only after they are explicitly written to the active objects. Look below for a code snippet of using the FitsLib library. List of articles and samples **/ __value public enum DataType { /** The different Fits data types supported in the library. An enumeration of the data types supported for the operations on the fits files. All the data holding objects used in the Fitslib library essentianly have a DataType property. This property reflects the type of data the object holds. Bit, Complex and DoubleComplex data types are not yet supported. FitsData interface FitsData interface FitsKeyValue interface **/ Bit = TBIT,/// ///Not implemented Byte = TBYTE,/// Logical = TLOGICAL,/// String = TSTRING,/// Ushort = TUSHORT,/// Short = TSHORT,/// Uint = TUINT,/// Int = TINT,/// Ulong = TULONG,/// Long = TLONG,/// Int32 = TINT32BIT,/// Float = TFLOAT,/// Double = TDOUBLE,/// Complex = TCOMPLEX,/// ///Not implemented DoubleComplex = TDBLCOMPLEX,/// ///Not implemented LongLong = TLONGLONG/// ///Not implemented /// }; __value public enum FitsError { /** The different Fits errors reported in the library. An enumeration of the errors reported during the operations on the fits files. FitsException is thrown when an error occurs. FitsException has an Error property which reflects the error in terms of these enumerations. The ExtendedError property of FitsException gives a more precise reason for the error. FitsException class **/ Success = 1,/// Unknown,/// FileAlreadyOpen,/// FileOpen,/// FileNotOpen,/// FileCreate,/// NotATable,/// InvalidDataType,/// ///The ExtendedError gives the actual underlying data type FileChangedAfterLoading,/// CFitsIOError,/// ///The ExtendedError gives the actual error reported by CFITSIO FitsInconsistancy,/// OperationNotSupported,/// OutOfRange,/// NotImplemented/// ///The ExtendedError gives the unimplemented data type /// }; __value public enum HduType { /** The different types of Fits data units. An enumeration of the different type of fits data units. Every FitsUnit has a Type property. This helps in identifying whether it is a table or an image. FitsUnit interface **/ Image = IMAGE_HDU,/// AsciiTable = ASCII_TBL,/// BinaryTable = BINARY_TBL,/// Any = ANY_HDU /* Not documenting, as this is not supposed to be used.*/ /// }; __value public enum ImageType { /** The different formats in which a Fits Image is stored in file. An enumeration of the different formats of Fits Images. FitsImageInfo has a Type property, which reflects this. This helps in identifying the format of the image in the corresponding FitsImage. Note that although the values look similar to the DataType values, they are inherently different and are small in number when compared to them. DataType enum FitsImage interface FitsImageInfo interface **/ Byte = BYTE_IMG,/// Short = SHORT_IMG,/// Float = FLOAT_IMG,/// Double = DOUBLE_IMG,/// Long = LONG_IMG,/// // FitsIO.h comments /* The following 2 codes are not true FITS */ /* datatypes; these codes are only used internally */ /* within cfitsio to make it easier for users */ /* to deal with unsigned integers. */ Ushort = USHORT_IMG,/// Ulong = ULONG_IMG/// /// }; __value public enum FileMode { /** The different modes of opening a Fits file. These are the different modes in which a FITS file can be opened. A Fits interface is used to open a FITS file. Fits interface **/ Read = 1,/// ReadWrite,/// Create,/// CreateOverWrite/// /// }; /*All Interfaces */ /* Level 1 */ /* Level 2 */ public __gc __interface FitsDataInfo {/** Provides Information about the content of a fits data holder. FitsDataInfo interface provides a way of accessing all the neccessary information about data contained in a table cell, table column or an image buffer. FitsData interface FitsColumnInfo interface **/ public: __property FitsLib::DataType get_Type(); /** Gets the data type of the contained data. This indicates the actual property of the data holder which contains data. The data type of the contained data. Make sure of accessing the relavent member of FitsData. For example, If this property returned Byte then access FitsData.Byte for data. Accessing any other field inside the FitsData object would raise a null exception. FitsData interface **/ __property long get_Length(); /** Get the length of the contents. Length of the contents of the FitsData object. The contents of the FitsData object are arranged in an one dimensional vector. This property gives the length of this vector. This is mainly used to access the length of a FitsImage's buffer after or before reading the image data. Note that this is equivalent to the Repeat property, which is used to find the repeat count of a table cell's data vector. Repeat property FitsImage interface FitsTable interface FitsData interface **/ __property long get_Repeat(); /** Get the repeat of the contents. Repeat count of the contents of the FitsData object. The contents of the FitsData object are arranged in an one dimensional vector. This property gives the repeat count of the elements in this vector. This is mainly used to find the repeat count of a table cell's data vector. Note that this is equivalent to the Length property, which is used to access the length of a FitsImage's buffer. Length property FitsImage interface FitsTable interface FitsData interface **/ __property long get_UnitSize(); /** Get the unit size of a single element in the contents. Unit size of an element in the contents of the FitsData object. The contents of the FitsData object are arranged in an one dimensional vector. This property gives the size of one elements in this vector. This is mainly used to find the size of one element a Image buffer's data vector. Note that this is equivalent to the Width property, which is used to access the width of an element in the FitsTable element's vector. Width property FitsImage interface FitsTable interface FitsData interface **/ __property long get_Width();/* Same as UnitSize, but for Cells */ /** Get the width of a single element in the contents. Width of an element in the contents of the FitsData object. The contents of the FitsData object are arranged in an one dimensional vector. This property gives the width of one element in this vector. This is mainly used to find the width of one element a Table element's data vector. Note that this is equivalent to the UnitSize property, which is used to access the size of an element in the FitsImage's buffer. UnitSize property FitsImage interface FitsTable interface FitsData interface **/ /// }; [System::Reflection::DefaultMemberAttribute("KeyNameAt")] public __gc __interface FitsKeyNameCollection { /** Collection of key names in a FitsUnit. This provides a way of accessing the names of all the keys in a fits unit header. Use it like an array of key names. The indexer helps in providing array like access. FitsUnitHeader interface **/ public: __property System::String* get_KeyNameAt(int Index); /** Get the name of a key. This provides a way of accessing the key name collection as an array. The key index whose name is to be retreived. The Key name. Note that the index starts from 1 and not from 0. **/ /// }; public __gc __interface FitsKeyValue { /** Value stored in a key of a FitsUnit Header. This provides a way of accessing the value of a header key. It also provides a way to access the comments and history of a key. Fires an exception if the inherent type is different from the accesed value's type. One such case is when the Type of the data is DataType.Int and an access is made to the Float property. FitsUnitHeader interface **/ public: __property System::String* get_Comments(); /** Get the comments of the key. Comments of the key. **/ __property DataType get_Type(); /** Get the data type of the value. The data type of the underlying value. Accessing a data value other than that corresponding to stored type fires an exception. **/ __property System::String* get_String(); __property void set_String(System::String* value); /** Get or set the value for a key. The key value. **/ __property unsigned __int8 get_Byte(); __property void set_Byte(unsigned __int8 value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property short get_Short(); __property void set_Short(short value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property unsigned short get_Ushort(); __property void set_Ushort(unsigned short value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property int get_Int(); __property void set_Int(int value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property unsigned int get_Uint(); __property void set_Uint(unsigned int value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property long get_Long(); __property void set_Long(long value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property unsigned long get_Ulong(); __property void set_Ulong(unsigned long value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property float get_Float(); __property void set_Float(float value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property double get_Double(); __property void set_Double(double value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ __property bool get_Logical(); __property void set_Logical(bool value); /** Get or set the value for a key. The key value. Fires an exception if the inherent type is different. Type property **/ /// }; [System::Reflection::DefaultMemberAttribute("Coordinate")] public __gc __interface FitsImagePoint { /** A multi-dimensional co-ordinate inside a FitsImage. This provides a way of accessing the location of a point in terms of it's co-ordinates along each axis. Use it like an array of axes. The indexer helps in providing array like access. It is used in various activities such an image creation, image buffer access and image information extraction. FitsImage interface FitsImageInfo interface Fits interface FitsFactory class **/ public: __property long get_Coordinate(int Dim); __property void set_Coordinate(int Dim, long Value); /** Get or set the coordinate of a requested dimension of the point. This provides a way of accessing the Point as an array of axes. The zero based index of the dimension or the axes of the coordinate whose value is needed. The value of the coordinate. Consider a 3 dimensional point P(x,y,z), access x with P[0], y with P[1] and so on. **/ __property int get_Dimensions(); /** Get the number of dimensions of a point. The number of dimensions of the point. If a point can be represented as P(x,y) then it returns 2. **/ /// }; /* Level 3*/ public __gc __interface FitsData { /** The main data container for all fits objects. This is one of the main objects in the context of data manipulations or extraction on a FITS file. A FitsTable cell is represented by a FitsData object as well as a FitsImage buffer. By their nature both are actually just vectors which hold data of one the fits supported data types. While accessing data, any access to a type that is not stored internaly will raise an exception. If the Info.Type property indicates a Float but you access an Int, you are expected to get an exception fired. FitsImage interface FitsTable interface **/ public: __property FitsDataInfo* get_Info(); /** Get the information about the contents. This gives some important information about the data to be accessed. In case of unknown data being accesed, it is advised to check the type and size information of the data content before proceeding to read or write it. The object having information about the data content. **/ __property unsigned __int8* get_Byte(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property short* get_Short(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property unsigned short* get_Ushort(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property int* get_Int(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property unsigned int* get_Uint(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property long* get_Long(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property unsigned long* get_Ulong(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property float* get_Float(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property double* get_Double(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property System::String* get_String() __gc[];//Added Mar 13,2003, updated July 29,2003 /** Get the internal data vector. Gets access to a live copy of the data vector as strings. Any change made here will be recorded. Later the same can be used to write back to a table. An array of strings. Fires an exception if the inherent type is different. Info.Type property **/ __property __int64* get_LongLong(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. Fires an exception if the inherent type is different. Info.Type property **/ __property float* get_Complex(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. The vector is of twice the size as given by the Length property of the Info property. Consider the array to be made of the real followed by the imaginary part of the same complex number. Say you have 5 complex numbers in a FitsData object d. Then d.complex will have 2 X d.Info.Length elements. The elements d.complex[0], d.complex[2] .... d.complex[8] correspond to the real parts of the five complex numbers and the elements d.complex[1], d.complex[3].... d.complex[9] correspond to the imaginary parts of the five complex numbers. Also this property Fires an exception if the inherent type is different. Info.Type property Info.Length property **/ __property double* get_DoubleComplex(); /** Get the internal data vector. Gets access to a live copy of the data vector. Any change made here will be recorded. Later the same can be used to write back to an image or table. The data vector. The vector is of twice the size as given by the Length property of the Info property. Consider the array to be made of the real followed by the imaginary part of the same complex number. Say you have 5 complex numbers in a FitsData object d. Then d.doublecomplex will have 2 X d.Info.Length elements. The elements d.doublecomplex[0], d.doublecomplex[2] .... d.doublecomplex[8] correspond to the real parts of the five complex numbers and the elements d.doublecomplex[1], d.doublecomplex[3].... d.doublecomplex[9] correspond to the imaginary parts of the five complex numbers. Also this property Fires an exception if the inherent type is different. Info.Type property Info.Length property **/ __property System::Array* get_SafeArray();//Added July 30,2003 /** Get the internal data vector. Gets access to a live copy of the data vector as an Array of objects.
Any change made here will be recorded. Later the same can be used to write back to a table.
Cast the returned data according to its data type.
For example, If the actual data type of an element in the cell's vector is an integer, then just cast it to (int[]) .
Here is a small line of code :-
An array of objects. Fires an exception if the inherent type is different. Info.Type property
**/ ///
}; [System::Reflection::DefaultMemberAttribute("get_Key")] public __gc __interface FitsUnitHeader { /** The header of a FitsUnit. This provides a way of accesing the header keys of FitsUnit. It also behaves as a collection of keys. The indexer property helps in providing an array like access to the Header Keys. FitsUnit interface **/ public: __property FitsKeyNameCollection* get_KeyName(); /** Get the names of keys in the FitsUnit header. Access the names of all the keys in the header of a FitsUnit. The collection of keynames. **/ __property int get_Count(); /** Get the count of the number of keys in the FitsUnit header. The count of the number of keys in the header. **/ /** Get the key value at a given index in the FitsUnit Header. **/ __property FitsKeyValue* get_Key(int Index); /** This provides a way of accessing the Header as an array of keys. The zero based index of the key whose value is needed. The value of the key. Index is zero based. **/ __property FitsKeyValue* get_Key(System::String* KeyName); // Assume String,as the user does not know /** This provides a way of accessing the Header as an array of keys. The name of the key whose value is needed. The value of the key. The key value is assumed to be a string as the user didnot request a specific type. **/ __property FitsKeyValue* get_Key(System::String* KeyName,DataType type); __property void set_Key(System::String* KeyName,FitsKeyValue* Value); // Writing the datatype as in Value /** This provides a way of accessing the Header as an array of keys. The name of the key whose value is needed. The data type in which the value is expected to be. The value of the key. While assigning a value, a null value will delete the key. If type of the key value is not known in advance, it is safe to access it as a string. **/ /** **/ // If the Value is NULL, it deletes the key void Copy(FitsUnitHeader* Src); /** Copy the header keys from another FitsUnit This provides a way of duplicating header keys into different FitsUnits. The Source FitsUnit header which has to be copied onto self. Even though, it can be done by manually inserting each key from one header to other, this method is more efficient. **/ /// }; public __gc __interface FitsImageInfo { /** The Image's information. This provides access to the image's information such as the size of the image and the Type of the underlying image buffer elements. FitsImage interface **/ public: __property FitsImagePoint* get_Size(); /** Gets the size of the Image. The size of the image is represented in terms of a point on the image. This is the farthest point from the origin in all dimensions. Thus it would contain the size of each dimension. The size of the image as the farthest point from the origin. **/ __property ImageType get_Type(); /** Gets the type of the Image. The type of the image informs us about the format in which it is stored in the FITS file. Note that the image's data buffer can be extracted in a different type than the actual type of the image. The type of the image as stored in the FITS file. **/ /// }; public __gc __interface FitsColumnInfo { /** The FitsColumns's information. This provides access to the column's information such as the name of of the column and the information about the underlying data elements. FitsColumn interface **/ public: __property int get_Index(); /** Gets the column number. The column number as stored in the table of the FITS file. **/ __property System::String* get_Name(); /** Gets the column name. The column name as stored in the table of the FITS file. **/ __property FitsDataInfo* get_Data(); /** Gets the information about data content. The information about the data content of the column. This information can be different from the information in the FITS file. This could happen when the user has forced the column to loaded as a different type than the underlying type. **/ /// }; // Level 4 public __gc __interface FitsUnit { /** A Fits Data unit. This provides access to a particular data unit in a FITS file. This can be casted into a FitsTable or a FitsImage depending on it's type. FitsImage interface FitsTable interface Fits interface **/ public: __property HduType get_Type(); /** Gets the type of the Data unit. The type of the data unit informs us whether it is an image or a table. This information can be used to decide whether to cast a given FitsUnit to FitsImage or FitsTable. The type of the header data unit as stored in the FITS file. **/ __property int get_Index(); /** Gets the Data unit number. The data unit number as stored in the FITS file. **/ __property FitsUnitHeader* get_Header(); /** Gets the header of the FitsUnit. The header gives a way of accessing the keys stored in a FitsUnit. The header of the data unit as stored in the FITS file. **/ /// }; public __gc __interface FitsImage { /** A Fits Image. This provides access to a particular image in a FITS file. Operations supported on an image include reading and writing of the buffers. New buffers compatible with a given image can also be created. FitsUnit interface **/ public: __property FitsImageInfo* get_Info(); /** Get the information about the contents. This gives some important information about the image to be accessed. In case of unknown image being accesed, it is advised to check the type and size information of the image content before proceeding to read or write it. The object having information about the image's content. **/ FitsData* ReadStrechOfPixels(FitsImagePoint* Start,FitsImagePoint* End,DataType BufferType); /** Read a portion of the image's buffer This provides a way to extract the data buffer of a FitsImage. The object containing the portion of image buffer requested. The starting point for the buffer to be extracted. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the buffer to be extracted. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. The data type of the elements for the buffer to be extracted. **/ void WriteStrechOfPixels(FitsImagePoint* Start,FitsImagePoint* End,FitsData* Buffer); /** Write a portion of the image's buffer This provides a way to write into a FitsImage. The starting point of the image buffer to be written. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the image buffer to be written. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. The buffer to be written. **/ FitsData* ReadSectionOfPixels(FitsImagePoint* Start,FitsImagePoint* End,DataType BufferType); /** Read a rectangular section of the image's buffer This provides a way to extract the data buffer of a FitsImage. The object containing the portion of image buffer requested. The starting point for the buffer to be extracted. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the buffer to be extracted. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. The data type of the elements for the buffer to be extracted. **/ void WriteSectionOfPixels(FitsImagePoint* Start,FitsImagePoint* End,FitsData* Buffer); /** Write a rectangular section of the image's buffer This provides a way to write into a FitsImage. The contents of the buffer provided will be written into a rectangular section of the image. The rectangle is defined by the Start and End points. The starting point of the image buffer to be written. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the image buffer to be written. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. The buffer to be written. **/ // Clean Buffer big enough to hold data from Start to End of this image /** Create a clean image buffer **/ FitsData* CreateImageBuffer(DataType Type,FitsImagePoint* Start,FitsImagePoint* End); /** This provides a way of creating image buffer compatible with the image. The buffer created will be clean. The object containing a clean image buffer requested. The data type of the elements in the buffer. The starting point of the image buffer. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the image buffer. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. **/ FitsData* CreateImageBuffer(DataType Type,long Length); /** This provides a way of creating image buffer compatible with the image. The buffer created will be clean. The object containing a clean image buffer requested. The data type of the elements in the buffer. The length of the image buffer. **/ FitsData* CreateImageSectionBuffer(DataType Type,FitsImagePoint* Start,FitsImagePoint* End); /** Create a clean rectangular image buffer This provides a way of creating a rectangular image buffer compatible with the image. The buffer created will be clean and big enough to hold the rectangular section. The object containing a clean image buffer requested. The data type of the elements in the buffer. The starting point of the image buffer. For this to be same as starting point of the image, specify the point to be (1,1,..) as coordinates are 1 based. The ending point for the image buffer. For this to be same as ending point of the image, just pass a copy of the image's size, which is the most extreme point from the origin. **/ /// }; [System::Reflection::DefaultMemberAttribute("CellAt")] public __gc __interface FitsTableElementCollection { /** Collection of elements in a FitsTable. This provides a way of accessing the elements of a FitsTable. Use it like an two dimensional array of elements. The indexer helps in providing array like access. FitsTable interface **/ public: /** Get the table element at a given location. **/ __property FitsData* get_CellAt(int Row,int Column); __property void set_CellAt(int Row,int Column,FitsData* Cell); /** This provides a way of accessing the table element as an array of rows and columns of cells. The one based index of the row whose element is needed. The one based index of the column whose element is needed. The requested element of the table. Index is one based. **/ __property FitsData* get_CellAt(int Row,System::String* Column); __property void set_CellAt(int Row,System::String* Column,FitsData* Cell); /** This provides a way of accessing the table element as an array of rows and columns of cells. The one based index of the row whose element is needed. The name of the column whose element is needed. The requested element of the table. Index is one based. **/ __property FitsData* get_CellAt(int Row,int Column,DataType type); /** This provides a way of accessing the table element as an array of rows and columns of cells. The one based index of the row whose element is needed. The one based index of the column whose element is needed. The data type in which the element is needed. The requested element of the table. Index is one based. **/ __property FitsData* get_CellAt(int Row,System::String* Column,DataType type); /** This provides a way of accessing the table element as an array of rows and columns of cells. The one based index of the row whose element is needed. The name of the column whose element is needed. The data type in which the element is needed. The requested element of the table. Index is one based. **/ /// }; [System::Reflection::DefaultMemberAttribute("ColumnInfoAt")] public __gc __interface FitsColumnInfoCollection { /** Collection of information of all columns in a FitsTable. This provides a way of accessing the information of the contents of any column in a FitsTable. Use it like an array of column informations. The indexer helps in providing array like access. This is a faster way of accessing information of more than one column. FitsTable interface **/ /// ///Gets the information for a given column. __property FitsColumnInfo* get_ColumnInfoAt(System::String* Name); /** This provides a way of accessing the column informations as an array of columns. The name of the column whose information is needed. The requested column's information. **/ __property FitsColumnInfo* get_ColumnInfoAt(int Index); /** This provides a way of accessing the column informations as an array of columns. The index of the column whose information is needed. The requested column's information. **/ /// /// }; [System::Reflection::DefaultMemberAttribute("Cell")] public __gc __interface FitsColumnCells { /** Collection of all cells in a column of the FitsTable. This provides a way of accessing the cells of a given column in a FitsTable. Use it like an array of cells. The indexer helps in providing array like access. This is a faster way of accessing information of more than one cell of the same column. FitsTable interface **/ public: __property FitsData* get_Cell(long Row); __property void set_Cell(long Row,FitsData* Cell); /** Gets a cell in the column. This provides a way of accessing the column as an array of cells. The row index of the cell. The table element. Note that the index starts from 1 and not from 0. **/ __property long get_Count(); /** Get the count of the number of Cells in the Column. The count of the cells in the Column. **/ /// }; // Level 5 [System::Reflection::DefaultMemberAttribute("Unit")] public __gc __interface FitsUnitCollection { /** Collection of all the tables and images in a FITS file. This provides a way of accessing a table or an image at a given location in a FITS file. Use it like an array of data units. The indexer helps in providing array like access. The unit retrieved can be later casted to a FitsImage or FitsTable according to it's type. Fits interface FitsTable interface FitsImage interface **/ public: __property FitsUnit* get_Unit(int Index); /** Gets a data unit in the file. This provides a way of accessing the file as an array of data units. The index of the data unit. The data unit. Note that the index starts from 1 and not from 0. **/ __property int get_Count(void); /** Get the count of the number of data units in the file. The count of the data units in the file. **/ /// }; [System::Reflection::DefaultMemberAttribute("ColumnCells")] __gc public __interface FitsColumnCollection { /** Collection of all the columns in a FitsTable. This provides a way of accessing an entire column in a table. Use it like an array of columns. The indexer helps in providing array like access. This provides a faster approach to retrieve multiple cells from the same column than individual cell access through FitsUnitCollection. FitsTable interface FitsUnitCollection interface **/ public: /** Gets the entire column. **/ __property FitsColumnCells* get_ColumnCells(int Column); __property void set_ColumnCells(int Column,FitsColumnCells* ColumnCells); /** This provides a way of accessing the tables as array of columns of cells. The one based index of the column to be accessed. The requested column of the table. Index is one based. **/ __property FitsColumnCells* get_ColumnCells(System::String* Column); __property void set_ColumnCells(System::String* Column,FitsColumnCells* ColumnCells); /** This provides a way of accessing the tables as array of columns of cells. The name of the column to be accessed. The requested column of the table. **/ __property FitsColumnCells* get_ColumnCells(int Column,DataType type); /** This provides a way of accessing the tables as array of columns of cells. The one based index of the column to be accessed. The expected data type of the column elements. The requested column of the table. Index is one based. **/ __property FitsColumnCells* get_ColumnCells(System::String* Column,DataType type); /** This provides a way of accessing the tables as array of columns of cells. The name of the column to be accessed. The expected data type of the column elements. The requested column of the table. Index is one based. **/ /// }; // Level 6 public __gc __interface FitsTable { /** A Fits Table. This provides access to a particular table in a FITS file. Operations supported on an table include accessing cells or columns of cells, insertion of new columns or rows and accessing information about any column. New cells compatible with a given column can also be created. FitsUnit interface **/ public: __property long get_NumberOfRows(); /** Gets the number of rows in the table. The number of rows in the table. **/ __property int get_NumberOfColumns(); /** Gets the number of columns in the table. The number of columns in the table. **/ __property FitsColumnInfoCollection* get_ColumnInfo(); /** Gets the collection of information of columns in the table. The collection of information of columns in the table. **/ __property FitsColumnCollection* get_Column(); /** Gets the collection of columns in the table. The collection of columns in the table. **/ __property FitsTableElementCollection* get_Cell(); /** Gets the collection of all cells in the table. The collection of all cells in the table. **/ void InsertColumn(int At, System::String* Name, DataType type, int Repeat); /** Insert a new column This provides a way of inserting a new column of required configuration into the table. The column after which the new column has to be inserted. The name of the new column. The data type of elements in a cell of the column. The repeat count of elements in a cell of the column. When DataType is String, the Repeat is the maximum number of charchters in the string. **/ void InsertRows(long At, long Count); /** Insert new rows This provides a way of inserting new rows into the table. The row after which the new row has to be inserted. The number of rows to be inserted. **/ int GetColumnIndex(System::String* Name); /** Get the index of a column This provides a way of accessing the index of a column in the table. 1 based index of the column. The name of the column. **/ /** Create a table cell. **/ FitsData* CreateFitsCell(int Column); /** The cell created. The index of the column for which the cell is being created. **/ FitsData* CreateFitsCell(System::String* Column); /** The cell created. The name of the column for which the cell is being created. **/ FitsData* CreateFitsCell(int Column,DataType type); /** The cell created. The index of the column for which the cell is being created. The data type of the cell being created. **/ FitsData* CreateFitsCell(System::String* Column,DataType type); /** The cell created. The name of the column for which the cell is being created. The data type of the cell being created. **/ /// FitsColumnCells* CreateColumnCells(int Column); /** Create a new holder for writing All Rows in a Column. The index of column for which the cells holder is required. The holder for all cells in a column. **/ /// }; // Level 7 public __gc __interface Fits // For Outside World { /** A FITS file object. This provides access to a operate on a FITS file. Operations supported include accessing tables, images, headers and addition of new tables and images. FitsFactory class **/ public: // File IO operations void Open(System::String* FileName,FileMode Mode); // should load Brief info on all units too /** Opens a FITS file The name of the file. The mode of opening the file. **/ void Close(); /** Close a FITS file **/ // Adding new Units FitsImage* AddNewImage(ImageType type,FitsImagePoint* Size); /** Add a new image to a fits file The new image added into the file. The type of the image to be inserted. The size of the image expressed as the extreme point in all dimensions. **/ FitsTable* AddNewTable(HduType TableType); /** Add a new table to a fits file The new table added into the file. The type of the table to be inserted. Creation of new Ascii table is not supported. **/ FitsUnit* CopyUnit(FitsUnit* Src);// Should check case where src and desst are same file /** Copy a table or image from another file The new unit copied into the file. The source image or table. **/ __property FitsUnitCollection* get_Units(); /** Gets the collection of all tables and images in the file. The collection of all tables and images. **/ /// }; /*All Classes*/ /* Level 1*/ // // Exception thrown on invalid or failed operations on Fits files // // public __gc class FitsException : public System::Exception { /** Exceptions raised in FitsLib operations. These are exceptions thrown on invalid or failed operations on Fits files. FitsError enum. **/ public: // constructor FitsException(FitsError Err,int exErr); /** Class Constructor. The error code. The extended error code, which makes it more precise to locate the error. **/ // Get the String representing the error System::String* ToString(); /** The error represented as a string. The error string. This includes full details of the error. **/ // Get the errorcode // __property FitsError get_Error(); /** Gets the error code. The error code. **/ // Get the extended errorcode __property int get_ExtendedError(); /** Gets the extended error code. The extended error code. **/ static bool IsFitsException(System::Exception* e); /** Verifies whether a given exception is FitsException. True for FitsException and False otherwise. This is an useful function in checking for a FitsException whenever an exception is fired. **/ protected: int m_nExtendedError; FitsError m_obError; /// }; public __gc class FitsFactory { /** A factory for creating new interface objects. The factory helps in creating new interface to a fits file. It also provides methods to create an Image Point, a header key value. It also provides a method to convert unicode strings to Fits Strings. This is useful in writing back string data into the FITS files. **/ public: static Fits* CreateFits(); /** Create a new interface to a FITS File. An interface to access FITS files. **/ static FitsImagePoint* CreateImagePoint(int Dimensions); /** Create a new Fits Image point. The dimensions of the image for which the point is being created. An image point. **/ static FitsKeyValue* CreateKeyValue(DataType type); /** Create a new Fits Unit Header's key value. The data type of the key value being created. The key value created. **/ /// }; ///
} /**
**/