Interactive System for the Display and Analysis of Data Cubes Observed with Herschel D. Hurtado, E. Sánchez, and Jesús Martı́n-Pintado. Departamento de Astrofı́sica Molecular e Infrarroja, Instituto de Estructura de la Materia, Consejo Superior de Investigaciones Cientı́ficas, c/Serrano, 121. 28006 Madrid. eduardo@damir.iem.csic.es Summary. This paper summarizes the software developments carried out by the Department of Molecular and Infrared Astrophysics (DAMIR) at the Institute of Structure of Matter as the Spanish contribution to the Instrument Control Center (ICC) of the Heterodyne Instrument for the Far Infrared (HIFI) on board of the Herschel mission of the European Space Agency. The developed tools can also be used to visualize and reduce data from integral field units producing 2D imaging spectroscopy. 1 Rationale, framework for the software development at DAMIR 1.1 The Herschel Project During the year 2008, the European Space Agency will launch the Herschel observatory [1], a space mission that will operate in the Far Infrared. Its 3,5 meters telescope will have an angular resolution between 600 and 4300 for the frequency range covered by Herschel from 490 to 5000 GHz (or 60 to 600 µm). It will be equipped with three instruments: PACS, SPIRE and HIFI. The Heterodine Instrument for the Far-IR (HIFI) consists of SIS mixers and hot electron bolometers covering a wide range of frequencies: from 490 to 2000 GHz (or 150 to 600 µm) and operating at cryogenic temperatures of 4 K. These frontends are connected to wide band spectrometers which provides high spectral resolution of λ/∆λ ≈ 106 . The DAMIR department is actively involved in the Herschel project. The Spanish National Plan for Space Research funds the DAMIR’s contribution to the HIFI ICC and the scientific research programme. The DAMIR is leading the software development for the reduction of data obtained using the On The Fly (OTF) mapping observing mode with HIFI. In addition, the 2 D. Hurtado, E. Sánchez, and Jesús Martı́n-Pintado. DAMIR is collaborating in the development of other components of the Herschel Common Software System (HCSS) to be used by the whole mission. These contributions range from the calibration and data reduction pipelines for the low level products to the framework for automatically generating the documentation for the whole project. At the same time, the DAMIR profits from its development effort and the expertise acquired, developing its own software tools for generic purpose for Radioastronomy. These tools serve to visualize/analyze individual single spectra as well as sets of spectra collected by using the OTF mapping technique, generating the final image cubes. This project seeks the usage of advanced software engineering techniques and methodologies, including an spiral development model, thorough testing harnesses and a quality assurance policy. Java was chosen as the programming language, taking into account its platform independency and cross platform interoperability, and its remarkable object oriented nature, that eases noticeably the development of highly structured and reusable software components. Other strong point in this project lies in the usage of an Integrated Development Environment for the development of scripts written in the Pyhon interpreted language, very appropriate for the fast development of “high level” scripts for data reduction and analysis. Other advantage of the Herschel software will be the fact that it will be public to the astronomical community, differently from other commercial software tools such as the widespread IDL. However, the software developments for the Herschel project convey also certain disadvantages, such as their complexity, wide scope, and the large number of institutes and groups involved, which causes very long development cycles until the components are stable enough to enable their use by the remainder groups. Another important inconvenient resides in the difficulty of training astronomers for developing software in sophisticate OO languages such as Java, which usually requires a long learning period. 1.2 DAMIR’s Tools: MASSA and MADCUBA The Herschel project is developing a number of software libraries which can be used by the DAMIR for the development of its own, general purpose, software tools. Moreover, the fact of having these basic developments provided by the HCSS has reduced dramatically the number of persons required, within the DAMIR, to develop this kind of graphic tools for cubes and spectra analysis. These developments would be much more expensive, if not impossible, without this modular, well structured software platform, which allows a fast reuse of its different components. The software tools developed by the DAMIR are called MASSA (MAdrid Single Spectrum Analysis) and MADCUBA (MAdrid Data CUbe Analysis). We have conceived their architectures so that their core components can be reused within the Herschel project, for the OTF data reduction that the DAMIR must deliver to the HIFI ICC. The image reconstruction for the Interactive System for the Display and Analysis of Data Cubes 3 Fig. 1. Sketch of the On The Fly mapping observing mode. While the telescope is scanning, it takes spectroscopic data on the source which are combined with the data from an off source reference On The Fly maps requires to perform a series of operations on the spectra gathered during the observation, such as calibration, baseline fitting, FFT for ripple removal, etc. Once the spectra have been analyzed, it is necessary to apply a gridding algorithm to compute the spectra corresponding to a regular spatial distribution. The MASSA application comprises this group of functions. Once the cube is generated, the MADCUBA application can be used to analyze it and perform several operations, such as smoothing or resampling in the frequency and/or space domains. 2 Spectral Analysis, OTF Image Reconstruction MASSA MASSA is a graphical application developed in Java to analyze simple spectra and OTF observations. MASSA’s main characteristics are: the use of a Graphical User Interface (GUI), the reuse of HCSS software components, and support for several data formats. 2.1 Features Spectral analysis MASSA offers a number of functionalities in order to work with several spectra, both single and OTF. These functionalities are integrated in a powerful application visual interface, allowing the manipulation of spectra in a simple way, like modern computer applications. The tools that MASSA offers are: single or OTF spectra display, visual spectra selection based on their spatial coordinates, baseline computation by graphically displaying the spectra and graphically choosing the windows for the windows, interacting with the pointing device (mouse, touchpad), bad channels edition, smoothing (based on different algorithms), ripples removal, regridding in the frequencies or velocities axis and gaussian fitting. 4 D. Hurtado, E. Sánchez, and Jesús Martı́n-Pintado. Fig. 2. Example snapshot: Baseline computation with MASSA Gridding for OTF data reduction: Image Cube generation There are a number of methods to make the spatial gridding. MASSA implements one based on averaging neighbour points: it lies in a bidimensional normalized convolution between a filter or convolution kernel and a plane with irregular arranged data, which has been provided with a regular grid in which calculate the value. The algorithm developed for MASSA involves these steps: First a rectangular and regular grid (in the space dimensions) must be computed. MASSA automatically calculates this grid based on the antenna beam width an the spectra positions. It is also flexible enough to allow the user to define the regular grid. • Select the convolution filter that will be used in the interpolation process, with the optimum parameters to carry out efficient calculations. Currently, MASSA implements several filters: gaussian, box, sinc. These have the characteristic that are created based on separable functions, which allows to carry out independent axis operations, increasing the algorithm speed. • Compute the interpolation, i.e., the bidimensional convolution, between every plane in the spatial dimensions and the selected convolution kernel. • Calculate the parameters for the resulting cube, both the coordinates (world coordinate system) and spectra common data. • Interactive System for the Display and Analysis of Data Cubes 5 2.2 Data formats The following astronomic data formats can be imported/stored: FITS files: the FITS format is one of the most used in astronomy. Massa allows to read spectra FITS files and write FITS cube files after gridding. • The format used within the Herschel Common Software System (HCSS), used when importing HCSS specific FITS files or when reading serialized data products got from the Herschel’s pipelines. • CLASS 30 meter format: due to its wide usage in our department, Massa is also able to import this format used in the files coming from the Granada’s IRAM telescope. • VO (Virtual Observatory) currently, the posibility to read/write future VO’s standards is being considered, by collaborating with the Andalucian Institute for Astrophysics (IAA). • 3 Cube Analsys - MADCUBA MADCUBA (Madrid Data Cube Analysis) is a graphical tool for the analysis of image cubes, such as those generated by MASSA from observations performed in OTF mapping mode. It is able to read image cubes stored in FITS and LMV formats, and it will also be able to read data cubes from the object oriented database from the Herschel telescope. By means of this tool the astronomer can visualize the image corresponding to a cube for each of the channels that it comprises, i.e., it can be used to display an area of the sky (cube slices) for each of the frequencies that the cube covers in the frequency domain. Its graphical display offers also the average image obtained by integrating the whole set of channels (frequencies) for the given cube. In addition, other display plots the spectrum corresponding to certain coordinates in the sky (chosen by pointing to them in the image display for a given channel). The tool dynamically updates the spectrum corresponding to the pixel pointed within the image display. A fourth graphical component is a plot of the spectrum obtained by integrating the spectra for the whole map. The tool can also draw a line over the image under analysis, obtaining the corresponding velocity-position diagram for the given “cut” in the cube. The tool allows to zoom in and out both in the channel images (and the average image) and in the spectra plots, and the user can switch between the units used in the x-axis to display the spectra using either frequencies, velocities or channel numbers. It can also show two x-axes with two different units at the same time, such as velocity and rest frequency. In the image display the user can select the cut levels to display intensities, as well as the color palette for those intensities, and it is possible also to add text annotations to the images, and to print the images. 6 D. Hurtado, E. Sánchez, and Jesús Martı́n-Pintado. The image display for a given channel provides the user with all its characteristic information (channel number, rest frequency, wavelength, RMS), and the coordinates of the pixel under the pointer focus and its corresponding spatial coordinates. One can also switch between various spatial coordinates, epochs and either galactic or equatorial coordinates. Fig. 3. Snapshot of a Madcuba sesssion Madcuba provides also with operations like smoothing and resampling a cube both in the frequency and in the space domain, storing the result in a new FITS file. It is also possible to crop the cube in order to work with a smaller “subcube” or to store one or several selected spectra to be further analyzed using MASSA. The smoothing and resampling operation can be configured, choosing the filter type (Gaussian, BoxCar, Hanning) and its parameters (e.g. size of the filter in freqs, channels, pixels, or arc seconds). Acknowledgements We acknowledge the support by the research grant ESP2004-00665 funded by the Spanish Plan Nacional del Espacio. References 1. Pilbratt, G. L., Cernicharo, J., Heras, A. M., Prusti, T., Harris, R.: SP-460 The Promise of the Herschel Space Observatory, (ESA Publications Division, Noordwijk, The Netherlands, 2001).