The Flexible Image Transport System (FITS) is a powerful and widely adopted means of exchanging Astronomical Data. There are also a great number of tools and libraries available on many platforms to facilitate working with FITS.
We present the FitsLib , A library written to facilitate development of astronomical data analysis tools on the Microsoft.Net Platform. This has been developed as a wrapper over one of the very popular and time tested FITS libraries, CFITSIO. Fits.Net library merges the advantages of speed and ruggedness of CFITSIO with the language independence of the Microsoft.Net technology and a simple Document Object Model (DOM). We believe this library will be intuitive for .NET programmers.
We present the design and usage patterns of the library in C-Sharp. We also discuss performance issues of the library. Finally we present a number of applications and web services, which are currently running on this library.
We wished to use the CFITSIO package in developing image cutout services on the Microsoft's .Net Platform in the C-Sharp language. This is a comprehensive library and we did not feel translation was viable, C-Sharp does allow use of managed C++. We set out to wrap a minimal set of routines in the managed C++ programming environment.
This minimal set, however, grew larger as more functionality was required in C-Sharp. It became apparent that developing code with so many pointers and unmanaged data objects in C-Sharp would prove to be prohibitive, both for development and for maintenance. This led to the design of an object-oriented wrapper that eased the memory and safety issues involved with pointers.
Initially a minimal package was developed which could perform reading operations on FITS files. Slowly more features were added until most of the popular FITS operations are now possible
An undercurrent of a Document Object Model like structure can be seen throughout the package. We felt that it would match closely with the structure of a FITS file and would be easy to associate with for a programmer in an Object Oriented Language such as C-Sharp.
One of the design decisions was to make the library Common Language Runtime compatible (CLR). This would enable the wrapper to be used across different .Net languages such as C-Sharp, Visual Basic and Managed C++.
This resulted in the whole design being done in two stages. In the first stage a CLR compliant interface was designed. In the second stage this interface was implemented by instantiating and operating on the appropriate CFITSIO data structures.
The interface intends to provide an intuitive Document Object Model (DOM) like layout for a FITS file. Features such as indexing, properties and polymorphism are utilized here to give a DOM layout for the classes involved.
The FitsFactory provides methods for creation of new interfaces to FITS files. The Fits interface opens FITS files for read or write operations. There are also specific interfaces for Fits Table and Image units. The FitsHeader interface provides access to header information in every unit. FitsData is the data structure representing a cell of a Table and also the image buffers.
The implementation focuses on issues such as memory management, invoking the underlying CFITSIO routines, error management, implementing object-oriented data structures and maintaining CFITSIO data structures. Specific classes implement each of the interface classes managing the tasks mentioned above (2.1.).
CFitsTable and CFitsImage are the two major implementation classes. The CFitsTable class implements a major portion of the different interfaces to the Fits Table. The CFitsData class implements the FitsData interface by wrapping the fits table vectors and image buffers inside it.
The object oriented and memory managed .Net interface is easy to use but, introduces a small overhead compared with direct CFITSIO usage.
Performance testing of such interfaces is non trivial. It was observed that for some very large FITS files the .NET package appears to outperform the CFITSIO, which seems anomalous. This could be due to host of independent variants such as memory paging, code optimization or garbage collection on the .Net platform.
However, when tested over a range of different operational requirements and loads, some overhead can be observed.
The performance comparisons shown above were done between similar pieces of CFITSIO and FitsLib program code. Additionally, some mathematical operations were done on the data being used in the tables and images. This was done to minimize the effects of code optimization.
Among the information provided are the object unique identifier, its coordinates in the GALEX combined object catalog and in the individual band passes (Far UV and Near UV).
The latest documentation, samples, source and binary downloads are available from http://skyservice.pha.jhu.edu/develop/FitsLib/ .
HEASARC, CFITSIO User's Reference Guide,
NASA/GSFC, A User's Guide for the Flexible Image Transport System,
Erich Gamma et al., Addison-Wesley Pub Co, Design Patterns,
Microsoft Corporation, Microsoft Developer Network,