0809.2465/ms.tex
1: %\documentclass[traditabstract,referee]{aa}  
2: %\documentclass[traditabstract]{aa}  
3: \documentclass[oldversion]{aa}  
4: 
5: \pdfoutput=1
6: \usepackage{amsmath}
7: \usepackage{graphicx}
8: \usepackage{txfonts}
9: \usepackage{url}
10: \newcommand{\releasedate}{Feb 8, 2008}
11: \newcommand{\nspectra}{2470}
12: \newcommand{\ntargets}{1923}
13: \newcommand{\nassociations}{520}
14: \usepackage[authoryear]{natbib}
15: 
16: \usepackage{color}
17: \newcommand{\new}[1]{{#1}}
18: 
19: \begin{document}
20: 
21: \title{The Hubble Legacy Archive NICMOS Grism Data}
22: 
23: 
24: \titlerunning{HLA NICMOS Grism Data}
25: 
26: \author{Wolfram Freudling, 
27: Martin K\"ummel, 
28: Jonas Haase, 
29: Richard Hook, 
30: Harald Kuntschner, 
31: Marco Lombardi,
32: Alberto Micol, 
33: Felix Stoehr, 
34: \and
35: Jeremy Walsh}
36: \authorrunning{Freudling et al.}
37: 
38: \institute{Space Telescope -- European  Coordinating Facility}
39: \date{submitted May 29, 2008; accepted Sep 3, 2008}
40: 
41: \abstract{ {The Hubble Legacy Archive (HLA) aims to create calibrated science
42: data from the Hubble Space Telescope archive and make them accessible via
43: user-friendly and Virtual Observatory (VO) compatible interfaces.  It is a
44: collaboration between the Space Telescope Science Institute (STScI), the
45: Canadian Astronomy Data Centre (CADC) and the Space Telescope - European
46: Coordinating Facility (ST-ECF). Data produced by the Hubble Space Telescope
47: (HST) instruments with slitless spectroscopy modes are among the most difficult
48: to extract and exploit. } {As part of the HLA project, the ST-ECF aims to
49: provide calibrated spectra for objects observed with these HST slitless modes.
50: } {In this paper, we present the HLA NICMOS G141 grism spectra.  We describe in
51: detail the calibration, data reduction and spectrum extraction methods used to
52: produce the extracted spectra.  The quality of the extracted spectra and
53: associated direct images is  demonstrated through comparison with near-IR
54: imaging catalogues and existing near-IR spectroscopy.} { The output data
55: products and their associated metadata are publicly available
56: (\url{http://hla.stecf.org/}) through a web form, as well as  a VO-compatible
57: interface that enables flexible querying of the archive of the \nspectra\
58: NICMOS G141 spectra. \new{In total, spectra of \ntargets\  unique targets
59: are included.}} \keywords{NICMOS -- infrared spectroscopy -- Hubble Space
60: Telescope, Calibration} }
61: 
62: \maketitle
63: 
64: 
65: \section{Introduction}
66: 
67: Three of the current Hubble Space Telescope instruments include built-in
68: slitless spectroscopic modes: the Space Telescope Imaging Spectrograph
69: (STIS), the Near Infrared Camera and Multi-Object Spectrometer (NICMOS), and the
70: Advanced Camera for Surveys (ACS).  The main advantage of slitless spectroscopy
71: is that spectra can in principle be obtained from all objects within the field
72: of view of an instrument. The main disadvantages are that the size of the
73: object limits the achievable spectral resolution, that spectra might overlap,
74: and that the background is relatively high because no slit mask prevents the
75: full sky background from illuminating every pixel of the detector. In addition,
76: extracting one-dimensional spectra from such data is a complex process and is
77: often achieved using highly interactive procedures.  
78: 
79: A fraction of the slitless data in the HST archive has been collected to obtain
80: spectra of specific objects, but spectra of objects other than the primary
81: targets have in most cases not been extracted or analysed.  The goal of the
82: ST-ECF HLA project is to extract spectra of all objects that have been
83: observed with HST slitless spectroscopy modes and to serve these spectra
84: through an archive with associated descriptions of the spectra, such as how
85: much one spectrum is contaminated by those of nearby objects. 
86: 
87: Each of the HST slitless spectrograph modes provides a different capability to
88: HST.  STIS and the ACS prisms cover the UV part of the spectrum that is not
89: accessible from the ground. The NICMOS grisms cover IR wavelengths that can
90: partially be observed from the ground, but where the background is much lower
91: in space. The ACS optical channels covering the optical wavelength range also
92: benefit from a combination of lower background and higher spatial resolution
93: from space. \new{The STIS grating provides the highest  resolving power among
94: the HST instruments with slitless spectroscopy modes. }
95: 
96: The data analysis for each of the spectrographs presents a significant
97: challenge, and specialised, mostly interactive tools are available for
98: individual instruments such as NICMOS \citep{nicmoslook}. For ACS a set of
99: non-interactive software tools, called aXe, has been developed which, on the
100: basis of a catalogue of the objects on the associated direct image, extracts
101: one and two-dimensional spectra \citep{axe1}. This software package was, for
102: example, extensively used for extracting ACS Wide Field Camera slitless spectra
103: in the Hubble Ultra Deep Field (HUDF) \citep{axe2}.  For the HLA project, we
104: have produced a pipeline that is designed to extract spectra from large numbers
105: of datasets in an unsupervised manner and can be tailored to particular
106: instruments.
107: 
108: We chose to start the slitless spectroscopy HLA project with the NICMOS
109: G141 grism dataset. After a brief description of the available data in the
110: archive (Sect.~\ref{sec:data}), the basic reduction steps applied to the NICMOS
111: images are described in Sect.~\ref{sec:images}, followed by a detailed
112: discussion of the spectrum extraction procedure (Sec~\ref{sec:extract}). In
113: Sec~\ref{sec:cal}, we show a new set of NICMOS spectrum calibration data.
114: 
115: Our extraction pipeline, PHLAG, is described in (Sect.~\ref{sec:phlag}).  The
116: extensive set of metadata that allows the archive of spectra to be served
117: through Virtual Observatory (VO) interfaces is summarised in
118: Sect.~\ref{sec:metadata}.  The calibrated spectra were subject to quality
119: assessment in terms of their astrometric and spectrophotometric properties and
120: shown by internal and external comparisons to be well-calibrated (see
121: Sect.~\ref{sec:qc}).  
122: 
123: \begin{figure}[t]
124: \includegraphics[scale=0.48]{grismexample}
125: \caption{Example of one matching pair of a F160W image (left, image n4k6j1a4q)
126: and the corresponding G141 grism image (right, image n4k6j1zyq)  from HLA
127: dataset N4K6IZZCQ }\label{fig:grismexample}
128: \end{figure}
129: 
130: \section{NICMOS Grism Data}\label{sec:data}
131: 
132: NICMOS, a second generation HST instrument, was installed in 1997. One of the
133: three NICMOS cameras, NIC3 includes three grisms for slitless spectroscopy. A
134: grism combines a grating and a prism in such a manner that it  produces a
135: dispersed spectrum at the position of the undispersed image when the grism is
136: removed. At the nominal grism wavelength, the image through a grism will be, to
137: first order, identical to an image without a dispersive element.
138: 
139: In NICMOS, the grisms are mounted on a filter wheel that can switch between any
140: of the filters and grisms. Since there are no slit masks, spectra of all
141: objects in the fields are produced. Depending on the location of the object,
142: the zeroth, first or the second order spectra may be visible. The mode of
143: operation is to first take an image with a filter that matches the bandpass of
144: the grism followed by one or more exposures with the grism. To avoid image
145: defects, a small or large scale dither pattern is used in a well designed
146: observing run. Fig.~\ref{fig:grismexample} shows a typical pair of exposures of
147: a filter image with a matched grism image.
148: 
149: The most widely used of the NICMOS grisms is G141, which covers the wavelength
150: range from 1.10 to 1.95$\,\mu$m. This wavelength range is not easily accessible
151: from the ground, and the dark background in space makes G141 a sensitive mode
152: to obtain spectra of all objects within the 51 $\times$ 51 arcsec$^2$ field of
153: view of the camera. The dispersion  for the first order spectrum is about 8.0
154: nm per pixel, which results in spectra about 105 pixels long. 
155: 
156: In March 2002, the NICMOS Cryocooler System (NCS) was installed. With the NCS,
157: the NICMOS detectors operate at a higher temperature and this changed the dark
158: current as well as the quantum efficiency as a function of wavelength for each
159: pixel. Therefore, all calibrations have to be derived separately for data taken
160: with and without the NCS \citep{ncscal}.
161: 
162: In July 2007, the HST archive contained  about 9000 NICMOS G141 observations.
163: \new{These data include both pointed observations towards specific targets and
164: programmes which used NICMOS in parallel to other HST instruments.  More than
165: 50\% of the NICMOS data presented in this paper are from four different HST
166: programmes,  namely HST proposal IDs 9707 \citep{john1}, 9865 \citep{mal1},
167: 8082 \citep{john2} and 10226 \citep{mal2}.} The pointing positions are almost
168: randomly distributed on the sky and are shown in Fig.~\ref{fig:sky}.
169: 
170: \begin{figure}[t]
171: \includegraphics[scale=0.4]{sky}
172: \caption{Distribution of NICMOS G141 grism images on the sky.}\label{fig:sky}
173: \end{figure}
174: 
175: 
176: 
177: \section{Image Processing and Target Selection}\label{sec:images}
178: 
179: \subsection{Associations}
180: 
181: Each spectrum in this work is based on a collection of images, which includes
182: both grism images and undispersed images.  The images in each of these {\em
183: associations} overlap and were treated collectively. The undispersed images
184: were co-added for the creation of target lists, and the two-dimensional spectra
185: on the grism images were rectified and co-added before the extraction of
186: one-dimensional spectra. These steps are described in detail in this section.
187: 
188: The grouping of NICMOS datasets into associations was performed using the World
189: Coordinate System (WCS) in the image header to compute relative pointings. To
190: ensure accurate relative coordinates among the images in any given association,
191: only datasets obtained with the same set of guide stars were included.
192: 
193: The spectral dispersion of NICMOS grism images is along the x-axis of the
194: detector.  The orientation of the grism images on the sky determines which of
195: the spectra overlap. We therefore chose to co-add only grism images that differ
196: in orientation by less than one degree, whereas the orientation of undispersed
197: images was not restricted. \new{The result of this procedure is that, for some
198: targets, several spectra are extracted and not co-added. The reason for this
199: decision was that different orientations of the spectra result in different
200: contamination. Indeed, the very reason that many programmes have observed the
201: same field with different roll angles is that it is likely that at least one of
202: the spectra for each target is free of contamination. We leave it up to the
203: user to pick the best of the spectra for each target.   }
204: 
205: In total 962 NICMOS G141 associations were created from 9262 grism members (up
206: to June 2007).  The grouping efficiency is therefore more than 9.5 exposures
207: per association.
208: 
209: 
210: \subsection{Preprossessing of NICMOS Images}
211: 
212: To produce one-dimensional spectra of individual targets, we extracted the flux
213: and wavelength information from NICMOS grism images and associated undispersed
214: images that have been reduced with STScI's CALNICA reduction pipeline version
215: 4.1.1 \citep{nicmoshandbook}.  NICMOS supports non-destructive multiple
216: readouts, and virtually all NICMOS data are taken in this mode.  The STSDAS
217: program CALNICA \citep{calnica} produces calibrated images from these raw data,
218: the processing steps include bias correction, dark current subtraction, and
219: computation of the count rate for each pixel using all readouts. The NICMOS
220: images suffered from a number of peculiar anomalies, some of them are treated
221: by CALNICA, for others separate STSDAS tasks are available.  The default
222: parameters of CALNICA and some of the algorithms used in the auxilliary task
223: are optimised for use with undispersed images. In the rest of the section, we
224: describe the parameters and procedures we used for the NICMOS Grism HLA.
225: 
226: \subsubsection{Bars Correction}
227: 
228: Some NICMOS images suffer from pairs of bright and dark columns or rows,
229: so-called ``bars''.  \new{These bars are bias-related artefacts in the form of
230: noiseless offsets} of a few DNs along a pair of columns or rows, with the
231: pattern replicated exactly in all four image quadrants. CALNICA has a built-in
232: procedure to detect and remove such bars.  Unfortunately, the central two rows
233: of NICMOS spectra contain more than 80\% of the flux of point sources and the
234: spectra are therefore of similar width to the bars. As a result, in crowded
235: grism images when the spectra are well aligned with the rows of the detector,
236: CALNICA often mistakes the peak of the spectra for bars and tries to remove
237: them.  To avoid this problem, a value of 4$\sigma$ was used for the threshold
238: in CALNICA which controls the bar detection. This compares to a default value
239: of 3$\sigma$.  It was found that this selection removes the described problem
240: in virtually all cases.
241: 
242: 
243: \subsubsection{Bad Pixels}
244: 
245: Images reduced with CALNICA typically contain between 20 and 100 unflagged bad
246: pixels, which contain significantly higher flux than their neighbours. These
247: ``hot'' pixels can produce spurious emission lines in extracted spectra.  The
248: pixel spacing of the NICMOS NIC3 camera is 0.2$\,$arcsec which undersamples the
249: Point Spread Function (PSF).  Commonly used methods to distinguish between
250: point sources and hot or cold pixels, based on the sharpness of features on the
251: calibrated image, are therefore not very effective with NICMOS.  On the other
252: hand, the multiple readouts provide information that can be used to recognise
253: unreliable pixels. The following procedure was implemented to identify bad
254: pixels. For each pixel the accumulated count rate at each readout, which is one
255: of the outputs of CALNICA, was fitted by a line. A pixel was flagged as ``bad''
256: when either the slope of the line was different from zero by at least four
257: times the uncertainty of the slope, or the reduced $\chi^2$ of the fit was
258: greater than four.  Flagged pixels were ignored in the subsequent analysis.
259: 
260: \subsubsection{Cosmic Rays}
261: 
262: Because of the multiple readouts, the count rate of a pixel can be measured
263: even if that pixel is hit by a cosmic ray (CR). The extra charge deposited by
264: the CR between two readouts produces a sudden discontinuity in the count rate.
265: CALNICA includes a procedure to identify and remove such jumps from the data.
266: This procedure is effective for more than 90\% of all CR hits. \new{ CALNICA
267: version 4.1.1. sometimes fails and produces a bright pixel in the output
268: images, even though it correctly recognised that this pixel is affected by a
269: CR. A future release of CALNICA will fix this problem \citep{newcalnica} but is
270: currently not yet available. } Because of the undersampling of the NICMOS
271: images, distinguishing between stars and cosmic rays cannot be easily done on
272: the basis of the sharpness of a flux peak alone. We therefore adopted a
273: procedure to use both the charge built up and the sharpness to minimize the
274: number of false detections of CR hits.  Each pixel identified by CALNICA as
275: affected by CR was checked to determine whether this pixel had an unusually
276: high flux in the output images.  Specifically, such a pixel was flagged as bad
277: if its flux was more than 4$\sigma$ above the mean of its neighbouring pixels.
278: 
279: 
280: \subsubsection{Pedestal}
281: 
282: NICMOS images suffer from random DC offsets in the bias level, which may be
283: different in each of the four quadrants. The offsets are constant within each
284: quadrant. If not removed, these offsets imprint the structure of the flatfields
285: on the calibrated images during the flatfielding step. Since grism images are
286: not flatfielded as images, the pedestal is visible as different constant
287: offsets of the  quadrants. There are two STSDAS tasks, pedsky and pedsub,
288: available to remove the pedestal from the calibrated images.  Neither of them
289: works well with grism images. We therefore used the following approach to
290: improve the pedestal in the grism images. First, for each pixel of a quadrant
291: we normalised the count rates of the multiple readouts to the mean of the last
292: three reads. We then computed the median count rate for each readout of all the
293: pixels in a quadrant. We then computed the value of the DC offsets for each
294: quadrant that results in constant median count rate. These values were then
295: subtracted from all the pixels in the corresponding quadrant.
296: 
297: 
298: \subsection{Co-addition of Undispersed Images}\label{sec:coadd}
299: 
300: In order to create a deeper and cleaner direct image, to be used to prepare the
301: input object catalogue needed as input to the spectral extraction, the direct
302: images in each association were first combined.  The MultiDrizzle software
303: \citep{drizzle,Fruchter} was used to register each input image, based on its
304: header WCS, and to remove the small NICMOS geometric distortion using the
305: standard cubic polynomial coefficient set. Standard default settings were used.
306: The data quality arrays were also aligned by this step and registered output
307: weight images created. MultiDrizzle is not yet well optimised for NICMOS and
308: experiments revealed that a combination of inadequately precise alignment and
309: the strong undersampling of the NIC3 camera resulted in the cores of compact
310: objects being incorrectly flagged as cosmic rays during the ``driz\_cr''
311: MultiDrizzle step. This led to significant photometric errors. To avoid this
312: \new{ we used MultiDrizzle only up to the image combination step. } The
313: preparation of image bad pixel masks and the final image combination were
314: performed using the {\it imcombine} task in IRAF. 
315: 
316: 
317: \subsection{Target Catalogue}
318: \label{sec:undisp-image-catal}
319: 
320: The first step in the extraction of slitless spectra is to find objects  on the
321: undispersed image.  Object parameters relevant for the extraction are the
322: coordinates, the position angle, the object sizes, and the magnitude in a
323: reference spectral band.
324: 
325: \begin{table*}
326:   \caption{Relevant parameters used for the source extraction in the direct images.}
327:   \centering
328:   \begin{tabular}{lcl}
329:   \hline
330:     Parameter & Value & Description \\
331:     \hline
332:     \texttt{DETECT\_MINAREA} & $4$ & Minimum number of pixels above
333:     threshold \\
334:     \texttt{DETECT\_THRESH} & $3.0$ & Minimum threshold for detection
335:     \\
336:     \texttt{ANALYSIS\_THRESH} & $3.0$ & Minimum threshold for analysis
337:     \\
338:     \texttt{DEBLEND\_NTHRESH} & $8$ & Number of deblending sub-thresholds
339:     \\
340:     \texttt{DEBLEND\_MINCONT} & $0.03$ & Minimum contrast parameter for
341:     deblending \\
342:     \texttt{SEEING\_FWHM} & $0.26$ & Stellar FWHM in arcsec \\
343:     \texttt{BACK\_SIZE} & $64$ & Background mesh size \\
344:     \texttt{BACK\_FILTERSIZE} & $1$ & Background filter size \\
345:   \hline
346:   \end{tabular}
347:   \label{tab:sex}
348: \end{table*}
349: 
350: We used the SExtractor program \citep{ba} to generate the object catalogues.
351: The output exposure time image generated in the co-addition step was used as a
352: weight map, which significantly  reduces the number of spurious detections and
353: improves the accuracy of the photometry.
354: 
355: The relevant parameters used for the extraction are given in
356: Tab.~\ref{tab:sex}.  We used the ``windowed'' centroid (\texttt{XWIN},
357: \texttt{YWIN}) as the target coordinates, which is the  iteratively computed
358: first moment of  the object's surface brightness after convolution with a
359: Gaussian function with size matched to the object.  This leads to very accurate
360: centroid measurement, especially for point sources (the large majority of
361: sources in our sample).  In addition, we also measured ``un-windowed''
362: morphological major axes \texttt{A}, \texttt{B}, position angle \texttt{THETA},
363: and  magnitudes (\texttt{MAG\_AUTO}.  Finally, we kept track of the success of
364: these measurements by retaining the SExtractor \texttt{FLAGS} parameters (see
365: below).
366: 
367: The original SExtractor catalogue was then further filtered in order to remove
368: spurious detections:
369: 
370: \begin{itemize}
371: 
372: \item We removed all objects with $\mathtt{FLAGS} \ge 64$: that effectively
373: removes all objects for which a severe memory overflow occurred either during
374: deblending or during the extraction;
375: 
376: \item We removed faint objects for which we do not expect to be able to extract
377: a spectrum from the dispersed images ($\mathtt{MAG\_AUTO} \ge 23.5$), or
378: extremely elongated ones ($\mathtt{A} / \mathtt{B} > 4$), which are often
379: simply detector artifacts or cosmic rays;
380: 
381: \item We took objects with sizes smaller than one pixel ($\sqrt{\mathtt{A}
382: \mathrm{B}} < 1 \mbox{ pixel}$) as point-like sources, and set both their axes
383: to $1 \mbox{ pixel}$;
384: 
385: \item For extended objects, we computed the extension and orientation of the
386: virtual slits from the parameters \texttt{A}, \texttt{B}, and \texttt{THETA}
387: (see Appendix~A);
388: 
389: \item We discarded associations that suffered from significant crowding ($>140
390: \mbox{ sources arcmin}^{-2}$) \new{since such a high source density leaves too
391: little  sky background to allow the estimation of the local background levels.}
392: 
393: 
394: \item We included external 2MASS sources in the final catalogue, as described
395: in Sect.~\ref{sec:extern-2mass-sourc}.
396: 
397: \end{itemize}
398: 
399: 
400: \subsection{Astrometric calibration}
401: \label{sec:astr-calibr}
402: 
403: The astrometric coordinate system  of the raw NICMOS images is specified in the
404: WCS keyswords in the image headers.  Its accuracy  is ultimately  limited by
405: the accuracy of the catalogue used for pointing the telescope. For earlier
406: data,   the Guide Star Catalog~I \citep{1990AJ.....99.2019L} was used, and
407: since 2000 the Guide Star Catalog II \citep{gsc2} is used.  Both catalogues are
408: based on scans of the photographic Sky Survey plates at various epochs and
409: bandpasses.  The absolute accuracy reaches $\sim 0.3''$ over a large fraction
410: of the sky, but  errors can be as high as several arcsecs towards the edges of
411: the scanned plates.  A comparison of the astrometry in undispersed NICMOS
412: images with more accurate data showed such large offsets in some cases.
413: 
414: Accurate coordinates are not only important for the final astrometric fidelity
415: of our spectra, but also to identify potentially contaminating objects outside
416: of the NICMOS images (see Sect.~\ref{sec:contam}). We therefore decided to
417: carry out an independent astrometric calibration of all our undispersed images.
418: For that purpose, we first generated  preliminary versions of the  catalogues
419: described in Sect.~\ref{sec:undisp-image-catal} with coordinates based on the
420: WCS and used them to compute offsets to the WCS.
421: 
422: 
423: \begin{table*}
424: \caption[]{Reference Catalogues used for Astrometric Calibration.}\label{tab:refcats}
425: \centering
426: \begin{tabular}{lccc}
427: \hline
428: Catalogue & Acronym & Reference & Accuracy \\
429: \hline
430: USNO CCD Astrograph Catalog& UCAC2 & \cite{2004AJ....127.3043Z} & 0.06
431: arcsec\\
432: Two Micron All Sky Survey& 2MASS  &\cite{2006AJ....131.1163S} & 0.10 arcsec\\
433: Sloan Digital Sky Survey& SDSS-DR5  &\cite{2007ApJS..172..634A} & 0.15
434: arcsec \\
435: USNO-B1.0 catalog & USN0& \cite{2003AJ....125..984M} & 0.20 arcsec\\
436: Guide Star Catalog II & GSC2.3.2 & \cite{gsc2} & 0.30 arcsec\\
437: \hline
438: \end{tabular}
439: \end{table*} 
440: 
441: The offset correction applied to the WCS is the mean offset of the WCS
442: catalogue coordinates and a global astrometric reference catalogue obtained by
443: merging the five catalogues listed in Tab.~\ref{tab:refcats}.  The merged
444: astrometric catalogue includes sources from all reference catalogues and
445: assigns to each object  the coordinates of  the most accurate catalogue in
446: which it was detected.  The mean offset was then calculated using a weighted
447: average, with weights proportional to the inverse of the square intrinsic
448: astrometric errors associated with each source.
449: 
450: The most critical part of the whole procedure is the matching of the sources in
451: the astrometric catalogue with our object catalogue.  This step is challenging
452: because of the small field of view of the NIC3 camera and the relatively large
453: number of artefacts present in the NICMOS images.  The basic approach of our
454: adopted procedure is to first use the WCS coordinates and identify the nearest
455: neighbours in the merged reference catalogues, compute offsets to the WCS, and
456: iterate. The scatter in the offsets of different stars is then used as an
457: estimate of the astrometric accuracy.
458: 
459: Our method, however, differs in a number of ways from the simple scheme
460: outlined above.  Firstly, the initial astrometric solution assumed is not the
461: original HST astrometry, but rather the HST astrometry corrected for the median
462: offset computed among all the pre- or post-NCS observations. This median offset
463: is $\sim 1.1''$ for pre-NCS observations, and $\sim 0.3''$ for the post-NCS
464: observations (see Fig.~\ref{fig:astro_offsets}).
465: 
466: Secondly, we used the \textit{median\/} offset between the astrometric
467: catalogue and the NICMOS object catalogue in the first two iterations, and a
468: $\sigma$-clipped weighted average for subsequent iterations.  This ensures that
469: the initial, highly uncertain offset does not introduce any strong bias because
470: of wrongly matched pairs.
471: 
472: Thirdly, if during any iteration we found more than three matched pairs, we
473: uses a clustering analysis to remove spurious matches.  Specifically, we
474: identified clusters in the offset plane $(\mathrm{d}x, \mathrm{d}y)$.  We then
475: removed from each cluster those matches that increase the standard deviation of
476: the offsets by more than a factor of two.  This technique is more robust in
477: removing badly matched pairs than $\sigma$-clipping.
478: 
479: \begin{figure}[t]
480: \includegraphics[width=\hsize]{fig03}
481: \caption{Cumulative distribution of number of astrometric calibration stars
482: used in each field.}\label{fig:21}
483: \end{figure}
484: 
485: \begin{figure}[t]
486: \includegraphics[width=\hsize]{fig05}
487: \caption{Difference between objects coordinates computed from  the WCS in the
488: image header and coordinates listed in astrometric reference catalogues. The
489: crosses mark the mean of the distributions before and after the installation of
490: the NCS, and the circles make the 1$\sigma$ scatter around the mean. The
491: systematic error in the WCS coordinates is significant larger for the pre-NCS
492: data.  }\label{fig:astro_offsets} 
493: \end{figure}
494: 
495: \begin{figure}[t]
496: \includegraphics[width=\hsize]{fig04}
497: \caption{ Cumulative distribution of estimated astrometric accuracies of the
498: object coordinates before and after the astrometric correction.
499: }\label{fig:22}
500: \end{figure}
501: 
502: Finally, in the case of the 2MASS catalogue, we also compared H-band magnitudes
503: measured on the NICMOS images with those in the 2MASS catalogue and removed bad
504: matches.
505: 
506: At the end of the whole process the algorithm returned the following quantities:
507: 
508: \begin{itemize}
509: 
510: \item the estimated offset;
511: 
512: \item the theoretical statistical error on the offset, derived from a simple
513: error propagation of the intrinsic catalogue accuracies listed in
514: Tab.~\ref{tab:refcats};
515: 
516: \item in cases where at least two objects are matched, the sample variance of
517: the offsets of the matched objects was also calculated;
518: 
519: \item finally, the full list of matches was retained for inclusion in the
520: metadata.
521: 
522: \end{itemize}
523: 
524: In total, about 96\% of our released spectra have corrected coordinates, and
525: for 91\% of these we were able to match two or more astrometric sources The
526: distribution of the number of matches is shown in Fig.~\ref{fig:21} The
527: computed offsets are shown in Fig.~\ref{fig:astro_offsets}.  In
528: Fig.~\ref{fig:22} we compare the  distributions of the estimated astrometric
529: uncertainty (i.e.\ the square root of the sample variance of offsets) before
530: and after applying these offsets. The median  accuracy of the astrometry
531: improves from about 1.24 arcsec to about 0.27 arcsec.
532: 
533: 
534: \subsection{External 2MASS sources}
535: \label{sec:extern-2mass-sourc}
536: 
537: NICMOS grism images can include partial spectra of bright objects that are
538: located outside of the field of view (FOV) but close enough to the edge of the
539: image so that the grism still deflects part of the first order spectrum onto
540: the detector.  The zeroth order spectra of such objects can be fully included
541: in the grism image without a corresponding counterpart on the undispersed
542: image.  Such partial spectra might contaminate other spectra, and the zeroth
543: order spectra might be mistaken for bright emission lines.  We used the 2MASS
544: catalogue to identify bright sources close to each grism image that might
545: create such spurious spectra.  After the astrometric correction described in
546: Sect.~\ref{sec:astr-calibr}, the coordinates of the images are known well
547: enough to predict the location of such spectra accurately enough to take them
548: into account for contamination estimation.  By visual inspection of  the images
549: we determined that the maximum distance of sources from the image edges that
550: still produces a spectrum is 13 arcsec at the left image edge, and 3 arcsec at
551: the right image edge.
552: 
553: Although it is in principle possible to extract spectra of the external
554: sources, in the current release we did not attempt to do so, but only used the
555: external sources for the estimate of the contamination see
556: Sect.~\ref{sec:contam}.
557: 
558: \section{Extraction of NICMOS Spectra}\label{sec:extract}
559: 
560: \subsection{Methods}
561: 
562: One-dimensional integrated \new{first order} spectra of objects were extracted
563: from grism data with the help of the target catalogues. \new{Whilst second
564: order spectra are visible on NICMOS grism images for bright targets, in most
565: cases only small parts of these spectra are usable because they are not
566: completely contained within the NICMOS detector and usually suffer from
567: significant contamination.} We therefore chose to limit our project to the
568: first order spectra.
569: 
570: \new{The essential extraction steps} were to remove the local background close
571: to the spectrum, use the position of the object on the undispersed image to
572: obtain a wavelength scale, and then add up the flux values for each wavelength
573: bin. The wavelength dependent response of  each pixel was taken into account
574: during this extraction.
575: 
576: We used a modified version of the extraction software aXe \citep{axe1} version
577: 3.7 for that purpose.  aXe was designed to treat slitless spectroscopic data
578: and includes the transfer of source positions derived on undispersed images
579: onto the slitless images; the application of wavelength dependent  flat fields,
580: the co-addition and extraction of spectra and the  estimation of the
581: contamination. We now describe the modifications and additions that were made
582: to the basic aXe package, most of them address NICMOS specific properties of
583: the data. 
584: 
585: \subsection{Tracing of spectra} \label{sec:spectraces}
586: 
587: Spectra on G141 grism images are closely aligned with the rows of the detector.
588: The angle between the dispersion direction  and the detector rows depends on
589: the exact orientation of the grisms.  The grism is mounted on a rotating filter
590: wheel, which lead to slight differences in the positioning of the grisms each
591: time it is rotated into place. Typical values for the angle between the
592: dispersion direction and the x-axis of the detector ranged from 0 to 2$^\circ$.
593: We therefore determined this angle separately for each grism observation.
594: 
595: To ensure an identical extraction around the variable traces for the entire
596: data set, the spectral trace was measured on each grism image individually.
597: This was done by selecting the brightest three point-like objects on each image
598: and determining the trace solution for each object individually. The individual
599: solutions were then combined using the signal-to-noise ratio of the spectrum as
600: weight to determine the single trace solution for that grism image. 
601: 
602: 
603: \subsection{Background Subtraction}
604: 
605: The NICMOS grism images are  not flatfielded in the standard pipeline, because
606: the local quantum efficiency is wavelength dependent. Spatial variations in the
607: throughput were therefore taken into account during the extraction process for
608: each target spectrum, after the wavelength calibration. An imprint of the
609: flatfield convolved with the spectrum of the sky background in the grism
610: passband is therefore visible in calibrated grism images. This background has
611: to be {\em subtracted} before the flux in each wavelength bin is summed. In
612: addition to the imprint of the flatfield, a region of enhanced dark current was
613: visible in the lower right-hand part of all NICMOS images. This enhanced dark
614: current, which varies depending on the positioning of the field offset mirror
615: (FOM), is also an additive component that has to be subtracted.
616: 
617: G141 background images were constructed from grism images that contained no or
618: few visible spectra, using about twenty different images for each prepared
619: background.  The median of the scaled images was subtracted from each
620: individual image to isolate the contribution of the FOM to the background.  In
621: this manner, two different background images were prepared for different time
622: periods, one presenting the flatfield imprint on the background, and the other
623: the enhanced dark current.  Scaled versions of these backgrounds were
624: subtracted from each grism image.
625: 
626: The scaling of the subtracted background was a crucial parameter for the
627: flatness of the resulting image and therefore the quality of the extracted
628: spectra. Because of the uncertainties in the overall bias level and dark
629: current and the changing sky brightness, the measured background level was not
630: a good predictor of the structure seen in the background. The scaling for the
631: subtraction was therefore determined by finding the least-squares solution for
632: a line fit to  the pixel values in the background versus the ones in the grism
633: images. Only pixels that do not contain any spectrum were used in this
634: procedure.
635: 
636: For most data sets, this procedure succeeded in removing most variations in the
637: background. To further improve the quality of the extraction, a local
638: background was subtracted  for each extracted spectrum. This local background
639: is a linear fit to the region around each spectrum. 
640: 
641: 
642: \subsection{Virtual Slits}
643: 
644: The slit in a longslit spectrograph selects a part of the sky, and light from
645: that area is then dispersed and binned in wavelength.  In slitless
646: spectrographs, the light that reaches the final wavelength bins is only limited
647: by the extent of the targets.  The light distribution of target objects
648: therefore  defines the lines of constant wavelength on the dispersed image, and
649: the effective resolving power. The size, position and orientation of the lines
650: of constant wavelength are used to extract one-dimensional spectra from the
651: two-dimensional image. 
652: 
653: Target  objects can be of  an arbitrary shape that may depend on wavelength.
654: For the extraction of spectra, we made two approximations.  Firstly, we
655: neglected any wavelength dependence of the object shape and derived all shape
656: parameters from the undispersed image. Secondly, we treated all objects as
657: ellipses, i.e.  assumed that the isophotes were elliptical.  The spectral
658: resolution of the spectra extracted with these approximation was slightly lower
659: than an optimal extraction that uses knowledge of the exact shape of objects as
660: a function of wavelength. For these approximations, we computed the extraction
661: direction that optimizes the spectral resolution of the spectra. The details
662: are given in Appendix~A.
663: 
664: 
665: \subsection{Adjustment of Wavelength Scale}
666: 
667: As a result of the filter wheel non-repeatability, the spectra on any given
668: exposure can be shifted by up to a few pixels relative to the expected
669: wavelength zero point derived from the undispersed image.  The wavelength
670: zeropoint was therefore re-adjusted for each exposure by extracting the
671: brightest few ($\sim$4) spectra and cross-correlating the characteristic
672: spectral feature (i.e. the drop of sensitivity) at the red end of all spectra
673: with a fiducial template. This template was prepared from the sensitivity
674: curves shown in Fig.~\ref{fig:throughput}. In this way any wavelength
675: zero-point shifts introduced by the non-repeatability of the positioning of the
676: grism wheel were taken out with a precision of about $\pm$0.2 pixel or $\pm$16
677: \AA. Potential wavelength calibration changes as a function of position within
678: the field of view were not taken into account.
679: 
680: \begin{table*}[t]
681: \begin{center}
682: \caption{Tabulated values for the linearity correction $b$}
683: \label{tab:nonlin}
684: \begin{tabular}{ccccccccccccc}
685: \hline
686: 
687: $\lambda [\mu]$ m&.825&.875&.925&.975& 1.1&1.2&1.3&1.4&1.5&1.6&1.7&1.8\\
688: b &.069&.057&.052&.050&.049&.048&.041&.023&.013&.008&.004& 0\\
689: \hline
690: \end{tabular}
691: \end{center}
692: \end{table*}
693: 
694: \subsection{Pixel Response Function}\label{sec:prf}
695: 
696: The NICMOS detectors show significant sensitivity variations across individual
697: pixels \citep{sto99,xu03}. These variations, together with the large pixel size
698: and the small trace angles (see Sec~\ref{sec:spectraces}), result in a
699: modulation of the extracted spectrum with a wave-like pattern for point-like
700: objects. The amplitude of this pattern is about 4\%. To correct for this effect
701: the exact location of the trace must be known to a fraction of the pixel size. 
702: 
703: The subpixel accuracy for the trace location  within a spectrum cannot be
704: achieved with the fits described in Sec~\ref{sec:spectraces}. A sensitive
705: estimator of the trace location is the quantity $f = v_{1}/ v_{2}$ with  the
706: brightest pixel value $v_{1}$ and the second brightest pixel value $v_{2}$,
707: respectively. For each point-like object, the values $f$ along the spectrum
708: were determined. The position where this function peaks marks the wavelength
709: value at which the spectrum is located at the centre of a row.  For raw spectra
710: with sufficient signal-to-noise to determine the peaks were multiplied by a
711: correction function~$f_{\rm pr}$:
712: 
713: \begin{equation}
714: f_{\rm pr} = 1 + 0.04  \sin (2 \pi  y) ,
715: \end{equation}
716: where $y$ is the position of the spectrum on the detector determined with
717: subpixel accuracy as described above.
718: 
719: 
720: \subsection{Non-Linearity Correction}
721: 
722: The NICMOS detector responds to different infalling photon count rates in a
723: non-linear manner. Even if the total number of photons is identical, the
724: detector will report a different flux if the number of photons per unit time
725: differs.  This effect was described  in \cite{bohlinI}. Following
726: \cite{bohlinII}, we corrected point-like objects for the detected photon count
727: rates $c$ according to
728: 
729: \begin{equation}
730: c = c_{\rm obs} / [ 1 - 2 b(\lambda)  + b(\lambda)  \log_{10}(c_{\rm obs})], 
731: \end{equation}
732: where $c_{\mathrm obs}$ is the count rate derived from the grism image, and
733: the values $b(\lambda)$ are given in Table \ref{tab:nonlin}.
734: 
735: 
736: \subsection{Flux Calibration} \label{sec:flux}
737: 
738: Flux calibration of point sources was done by multiplying the count rate of
739: extracted spectra by the sensitivity curve (see Fig.~\ref{fig:throughput})
740: derived from flux standards.  Flux standards are stars and thus point-like
741: sources, and the spectral resolution is determined by the instrument setup. For
742: extended objects, however, the spectral resolution is degraded by the extent of
743: the object in the dispersion direction.  This smoothing of the spectra reduces
744: the amplitude of structure in the sensitivity curve and has to be taken into
745: account for the flux calibration of extended objects.
746: 
747: The flux calibration of extended sources was carried out by multiplying the
748: count rate by a smoothed version of the point source sensitivity function.
749: The width of the Gaussian smoothing kernel was
750: \begin{equation}
751: \sigma = f r\sqrt{s^{2} - p^{2}}  , 
752: \end{equation}
753: where $s$ is the FWHM of the object in the dispersion direction, $p$ is the
754: FWHM of the point spread function, and $r$ is the dispersion in $\AA$ per
755: pixel. The quantity $f$ is a correction factor that was found empirically by
756: experiment using extended source spectra; the adopted value was 0.65.
757: 
758: The procedure was tested both on  simulations of Gaussian objects using the aXe
759: simulation package aXeSIM \citep{axesim}, and on real extracted NICMOS spectra.
760: The tests showed that, in most cases, the procedure successfully removed the
761: imprinted structure resulting from the changes in sensitivity with wavelength
762: that is visible in spectra calibrated with the nominal point source sensitivity
763: curve. 
764: 
765: 
766: \subsection{Contamination}
767: \label{sec:contam}
768: 
769: One of the disadvantages of slitless spectroscopy is that spectra of science
770: targets may overlap with the spectra of random objects in the field that are
771: not masked by any slit mechanism. Only isolated objects are not affected by
772: this sort of contamination. The level of contamination depends on the
773: separation and relative flux level of the objects. Spectra that are
774: contaminated may still be useful if the expected flux from the contaminator is
775: significantly smaller than the flux in the spectrum of interest. Estimating the
776: contamination level for all spectra is essential to exploit them
777: scientifically.
778: 
779: \new{Contamination levels were estimated by aXe assuming flat contaminating
780: spectra \citep{axe1}. We used this feature to estimate the contamination both
781: from objects in the source catalogue and from bright 2MASS sources (see
782: Sect.~\ref{sec:extern-2mass-sourc}) that were close enough to the target object
783: so that their spectra might overlap.  The contamination level was estimated in
784: the following manner: The shape of spectra in the cross dispersion direction
785: was assumed to be Gaussian with a dispersion $\sigma$ equal to the object size
786: listed in the target catalogue.  The spectrum of each potential contaminator
787: was assumed to be flat in $f_{\lambda}$ with an integrated magnitude identical
788: to the one measured on the undispersed image.  With these assumptions,
789: two-dimensional spectra for all potentially contaminating objects were
790: produced. Finally, a spectrum at the position of the target was extracted in
791: exactly the same manner as the spectrum from the original grism image.  The
792: resulting spectrum was then used as an estimate of the contaminating flux.}
793: 
794: \new{
795: \subsection{Co-addition of Spectra}
796: 
797: The final step in the extraction of spectra is to sum up all flux contributions
798: for a given wavelength bin. The approach used by aXe is to rectify the two
799: dimensional spectra onto a predefined grid using the drizzle approach
800: \citep{drizzle}. In }\new{ our modified version of aXe, each spectrum of a
801: target is first drizzled to the same grid. We then use the IRAF task {\it
802: imcombine} with 4$\sigma$ rejection to combine the two-dimensional spectra.
803: One-dimensional spectra are finally produced by summing up all pixels that
804: correspond to the same wavelength. }
805: 
806: 
807: \section{The Pipeline for the Hubble Legacy Archive Grism data
808: (PHLAG)}\label{sec:phlag}
809: 
810: The whole extraction procedure from the retrieval of the input data to the
811: extraction of the calibrated spectra was carried out in a single Python script,
812: called {\bf P}ipeline for the {\bf H}ubble {\bf L}egacy {\bf A}rchive {\bf
813: G}rism data (PHLAG).  PHLAG works with the NICMOS calibrated images and  calls
814: the necessary external packages in a series of processing steps.  The steps
815: carried out are as follows:
816: 
817: \begin{enumerate}
818: 
819: \item {\bf Data preparation:} The data are prepared for the pipeline reduction.
820: The direct images are grouped according to the filter.  Pairs, consisting of
821: one direct image and one slitless image with small positional offsets, are
822: composed.
823: 
824: \item {\bf Image combination:} The direct images are rectified and co-added as
825: described in Sect.~\ref{sec:coadd}.
826: 
827: \item {\bf Object detection:} The object catalogues are extracted from the
828: undispersed image (Sect.~\ref{sec:undisp-image-catal}).
829: 
830: \item {\bf Spectral extraction:} The extraction of one  and two-dimensional
831: spectra is performed using the aXe software package with the modifications
832: described in Sect.~\ref{sec:extract}.
833: 
834: \item {\bf Metadata:} The spectra are prepared for ingestion into the database.
835: The metadata are collected or derived (see Sect.~\ref{sec:metadata}).
836: Associated products such as stamps and cutout-images are created. 
837: 
838: 
839: \end{enumerate}
840: 
841: 
842: \section{Calibration of NICMOS Spectra}\label{sec:cal}
843: 
844: \subsection{Flatfield Cube}
845: 
846: The quantum efficiency of each pixel on the detector is a function of
847: wavelength, and this function is different for each pixel. For slitless
848: spectroscopic images, the usual step of correcting the quantum efficiency
849: variations by flatfielding has to be replaced by a wavelength  dependent
850: correction. Such a correction requires a three-dimensional flatfield cube with
851: detector coordinates and wavelength as the three axis.  
852: 
853: The flatfield cube was derived from the NICMOS narrow band flat fields,
854: separately for the pre-NCS and post-NCS periods.  Tab. \ref{Table_flat} lists
855: the narrow band flats that were used.  For each pixel, we fitted a 5th order
856: polynomial  to the value of the pixel in each flatfield.  Fig.~\ref{Fig_flat}
857: illustrates the zeroth order (wavelength independent) and first order
858: (wavelength dependent) terms of the flat field cube. The mean value of the rms
859: on the polynomial fit for the post-NCS flat field cube is 0.15\%.
860: 
861: \begin{table*}[t]
862: \begin{center}
863: \caption[]{Flat field cube fitting for Pre- and Post-NCS flat fields.}
864: \vskip 0.1cm
865: \label{Table_flat}
866: \begin{tabular}{lll} 
867: \hline
868: Filter & Pre-NCS Flat & Post-NCS Flat \\
869: \hline
870: F108N & i191346kn\_flt.fits & 3\_F108N\_STEP16\_1On-AllOff\_sflt.fits \\
871: F113N & i191346mn\_flt.fits & 3\_F113N\_STEP16\_1On-AllOff\_sflt.fits \\
872: F164N & i191346pn\_flt.fits & 3\_F164N\_STEP16\_1On-AllOff\_sflt.fits \\
873: F166N & i191346qn\_flt.fits & 3\_F166N\_STEP16\_1On-AllOff\_sflt.fits \\
874: F187N & i191346sn\_flt.fits & 3\_F187N\_STEP16\_1On-AllOff\_sflt.fits \\
875: F190N & i191346tn\_flt.fits & 3\_F190N\_STEP16\_1On-AllOff\_sflt.fits \\
876: F196N & i1913470n\_flt.fits & 3\_F196N\_STEP16\_1On-AllOff\_sflt.fits \\
877: F200N & i1913471n\_flt.fits & 3\_F200N\_STEP16\_1On-AllOff\_sflt.fits \\
878: F212N & i1913472n\_flt.fits & 3\_F212N\_STEP16\_1On-AllOff\_sflt.fits \\
879: F215N & i1913473n\_flt.fits & 3\_F215N\_STEP16\_1On-AllOff\_sflt.fits \\
880: F240M & i1913475n\_flt.fits & 3\_F240M\_STEP2\_1On-AllOff\_sflt.fits  \\
881: \hline
882: \end{tabular}
883: \end{center}
884: \end{table*}
885:  
886: \begin{figure}
887: \includegraphics[bb=76 20 461 403,clip,width=0.47\hsize]{Fig_Flat_1}
888: \hfill
889: \includegraphics[bb=76 20 461 403,clip,width=0.47\hsize]{Fig_Flat_2}
890: \caption{The zeroth order (wavelength independent) plane of the 
891: post-NCS flat field cube (left) and the first order (wavelength
892: dependent) plane (right).  }
893: \label{Fig_flat}
894: \end{figure}
895: 
896: 
897: 
898: \subsection{Wavelength Calibration}
899: 
900: In-orbit wavelength calibration for G141 spectra was established by
901: observations of spectra of planetary nebulae (PNe). Two compact PNe were
902: observed -- Hubble 12 (Hb~12) and Vy2-2, although both are resolved by NIC3.
903: Fig.~\ref{Fig_Hb12} shows the one-dimensional extracted spectrum of Hb~12 with
904: the identified emission lines indicated. By matching the observed positions of
905: the lines, fitted by Gaussians, with known wavelengths, the G141 dispersion
906: solution was established. Vy2-2 was observed in 1997 as part of the early
907: calibration programme and Hb~12 in 2002 in the post-NCS era. For Hb~12 fifteen
908: spectra were analysed for first order dispersion solution and eight for the
909: second order spectrum; for Vy2-2 only three spectra were available to analyse,
910: and were only used to verify the solution derived from Hb~12. Within the errors
911: no difference was found between the wavelength solutions for both targets,
912: indicating no measurable change of the dispersion pre- and post-NCS. 
913: 
914: Up to fifteen emission lines were detectable in the first order spectra and
915: seven for the second order; the lines and their identifications are listed in
916: Tab.~\ref{Table_lines}. First and second order polynomial fits were made to the
917: variations of the pixel position with wavelength. The second order terms are
918: very small, typically $2 \times 10^{4}$ times smaller than the first order fit
919: coefficient; they were neglected and only a linear solution adopted. The
920: sampling of any spatial dependence of the wavelength solutions was poor and
921: single average values for the fit coefficients were adopted for the whole
922: detector. Tab.~\ref{Table_disps} lists the first and second spectral order
923: dispersion solutions in the form $ \lambda ({\rm \AA}) = A_0 + A_1  x_0$, where
924: $x_0$ is the pixel offset along the trace from the position of the direct
925: object.
926:  
927: \begin{table}
928: \caption[]{Nebular emission lines used for wavelength calibration.}
929: \label{Table_lines}
930: \centering 
931: \begin{tabular}{ll} 
932: \hline
933: ~~~$\lambda({\rm\AA})$ & Species \\
934: \hline
935: 10830.290 & HeI \\
936: 10938.095 & HI \\
937: 11164.403 & [Fe II] \\
938: 11305.854 & [SI] \\
939: 11969.059 & HeI \\
940: 12527.506 & HeI \\
941: 12818.08  & HI \\
942: 14072.70  & [Fe II] \\
943: 14706.272 & [Fe II] \\
944: 16109.313 & HI \\
945: 16407.192 & HI \\
946: 16806.520 & HI \\
947: 17362.108 & HI \\
948: 18174.121 & HI \\
949: 18751.01  & HI \\
950: \hline
951: \end{tabular}
952: \end{table}
953: 
954: \begin{table}
955: \caption[]{Dispersion solutions for G141 spectra.}
956: \vskip0.1cm
957: \label{Table_disps}
958: \centering 
959: \begin{tabular}{lrl} 
960: \hline
961: Spectrum & $A_0 ({\rm\AA})$ & $A_1 ({\rm\AA/pix})$ \\
962: order    &             &  \\
963: \hline
964:  1 & 13962.8 & 80.19 \\
965:  2 &  7141.7 & 40.54 \\
966: \hline
967: \end{tabular}
968: \end{table}
969: 
970:  
971: \begin{figure}
972: \includegraphics[width=\hsize]{wavecal}
973: \caption{NICMOS G141 spectrum of the planetary nebula Hb~12
974: showing the emission line identifications. The upper axis
975: shows the offset in pixels from the position of the direct image.
976: }
977: \label{Fig_Hb12}
978: \end{figure}
979: 
980: 
981: \subsection{Sensitivity Calibration}
982: \label{sec:fluxcal}
983: 
984: The sensitivity curve needed for the flux calibration of the spectra
985: (Sect.~\ref{sec:flux}) was derived from observations of the flux standards
986: GD153, G191B2B, and P330E.  Tab.~\ref{Table_fluxstd} lists the observations
987: used to derive the final sensitivity calibration.  Spectra were extracted from
988: those observations and co-added for each star separately for pre-NCS and
989: post-NCS observations. The sensitivity curve was then computed by dividing the
990: count rates of these spectra  by  tabulated standard fluxes for each star. The
991: standard fluxes were taken from the  HST CALSPEC library and are based on
992: Hubeny NLTE  models \citep{fluxcala}  in the case of G191B2B and GD153
993: (g191b2b\_mod\_004.fits,  gd153\_mod\_004.fits) and a combined STIS, NICMOS
994: spectrum in the case of P330E \citep[p330e\_stisnic\_001.fits,][]{fluxcalb}.
995: 
996: The average flux calibrations agreed to about 3\% between the three standard
997: stars and we did not detect significant variations as a function of time of
998: observation. However, variations as a function of  position within the field of
999: view indicated a scatter of about 8\%. The field of view coverage with  flux
1000: standard stars was not sufficient to allow a field-dependent  sensitivity
1001: calibration. Overall the absolute flux calibration for post-NCS observations
1002: was expected to be accurate to better than 10\%, while  for pre-NCS data it was
1003: difficult to assess the overall reliability due  to a lack of suitable standard
1004: star observations. The sensitivity files used in the pipeline reduction carry a
1005: random error of only 1-3\% that was propagated into the final spectra.  In
1006: addition, there was an uncertainty of about $\sim$10\% in the overall
1007: normalisation of the flux.  The final sensitivity curves derived for pre- and
1008: post-NCS periods  are shown in Fig.~\ref{fig:throughput}.
1009: 
1010: 
1011: \begin{table*}
1012: \caption[]{List of flux standard stars}
1013: \vskip0.1cm
1014: \label{Table_fluxstd}
1015: \centering
1016: \begin{tabular}{llrll}
1017: \hline
1018: Star    & Association & PROP ID & PROP PI & pre/post NCS \\
1019: \hline
1020: GD153   & N94A02E6Q & 10385 & Bohlin   & post NCS \\
1021: GD153   & N8U402MVQ &  9998 & Bohlin   & post NCS \\
1022: GD153   & N9U203NOQ & 11064 & Bohlin   & post NCS \\
1023: G191B2B & N9U201M3Q & 11064 & Bohlin   & post NCS \\
1024: G191B2B & N8U405TWQ &  9998 & Bohlin   & post NCS \\
1025: G191B2B & N94A03GDQ & 10385 & Bohlin   & post NCS \\
1026: P330E   & N8U406VZQ &  9998 & Bohlin   & post NCS \\
1027: P330E   & N8BR01ICQ &  8991 & Thompson & post NCS \\
1028: P330E   & N9U212P8Q & 11064 & Bohlin   & post NCS \\
1029: \hline
1030: G191B2B & N4IT01NUQ &  7696 & Calzetti & pre NCS  \\
1031: P330E   & N4VD01OYQ &  7959 & Calzetti & pre NCS  \\
1032: \hline
1033: \end{tabular}
1034: \end{table*}
1035: 
1036: \begin{figure}[h]
1037: \includegraphics[width=\hsize]{fig08}
1038: \caption{NICMOS sensitivity curves as a function of wavelength for the
1039:   G141 grism for pre-NCS and post-NCS data sets.}\label{fig:throughput}
1040: \end{figure}
1041: 
1042: 
1043: \section{Data Products and Distribution}
1044: 
1045: \subsection{HLA Portal}
1046: 
1047: 
1048: HLA data are distributed by both ST-ECF and STScI.  There are three main ways
1049: to search, browse, and access the NICMOS spectra:
1050: 
1051: \begin{enumerate}
1052: 
1053: \item{Archive Query Interface.} The HLA archive can be searched
1054: online (\url{http://archive.eso.org/wdb/wdb/hla/product_science/form}) and
1055: constraints on the target (e.g. the target name), the data properties (e.g.
1056: effective exposure time), the source properties (e.g. the magnitude) and the
1057: data quality (e.g. the signal-to-noise ratio) can be placed. The detailed
1058: result pages show the preview of the data as well as all available metadata.
1059: 
1060: \item{HLA archive at STScI.} The ST-ECF HLA data has been also integrated into
1061: the HLA interface of the Space Telescope Science
1062: Institute (\url{http://hla.stsci.edu}). A subset of the parameters of the
1063: ST-ECF HLA interface are shown and can be queried.
1064: 
1065: \item{Virtual Observatory.} We provide fully automated access to the HLA
1066: metadata and data via Virtual Observatory (VO) standards. A Simple Spectrum
1067: Access Protocol (SSAP) server has been established
1068: (\url{http://www.stecf.org/hla-vo}).  It serves VOTables in V1.1 format, which
1069: contain, in addition to the standard metadata, information about the footprints
1070: of the equivalent slits of the grism spectra. Our SSAP server has been tested
1071: with ESO's archive browser VirGO (\url{http://archive.eso.org/cms/virgo/}) as
1072: well as with SPLAT (\url{http://star-www.dur.ac.uk/~pdraper/splat/splat-vo/}, 
1073: also available at \url{http://starlink.jach.hawaii.edu/})
1074: and VOSpec (\url{http://esavo.esa.int/vospecapp}). 
1075: 
1076: \end{enumerate}
1077: 
1078: 
1079: \subsection{Distributed Files} \label{sec:metadata}
1080: 
1081: The spectra are distributed as sets of FITS files, which include two
1082: dimensional cutouts of each target from the rectified and calibrated  grism
1083: images, a cutout of the target from the undispersed filter image and  a
1084: one-dimensional extracted spectrum.
1085: 
1086: The two-dimensional grism stamp images and the direct image cutouts are
1087: multi-extension FITS files.  The one-dimensional spectrum follows the data
1088: formatting specified for FITS serialisation by the IVOA Spectral Data Model
1089: version 1.01 \citep{mcd}.  Each data point contains the wavelength in \AA, the
1090: count rate in electrons per second and the flux expressed in physical units
1091: along with associated errors and an estimate of the contaminating flux.
1092: Additional metadata include keywords to describe the contamination, the
1093: orientation of the dispersion direction on the sky and footprints.  
1094: 
1095: 
1096: 
1097: \begin{figure}
1098: \includegraphics[width=\hsize]{fig09}
1099: \caption{Distribution of the number of extracted spectra from HLA
1100:   datasets.}\label{fig:datasets}
1101: \end{figure}
1102: 
1103: 
1104: \begin{figure}
1105: \includegraphics[width=\hsize]{fig10}
1106: \caption{Magnitude distribution of the targets with spectra in the HLA release. The blue
1107: histogram are the extended sources. }\label{fig:maghist}
1108: \end{figure}
1109: 
1110: \begin{figure}
1111: \includegraphics[width=\hsize]{fig11}
1112: \caption{Measured signal-to-noise of the HLA spectra as a function of magnitude.}\label{fig:snmags}
1113: \end{figure}
1114: 
1115: \section{Results}\label{sec:qc}
1116: 
1117: \subsection{Data Release 1}
1118: 
1119: Data were released on \releasedate. This Data Release 1 (DR1) includes a total
1120: of \nspectra\ extracted from  \nassociations\ associations. 
1121: 
1122: The H-band magnitudes computed from the undispersed images of the targets range
1123: from 7 to 23.5  for point sources, and from 16 to 23.5 for extended sources as
1124: identified by the SExtractor program (see Fig.~\ref{fig:maghist}).  Only
1125: spectra with measured signal-to-noise ratios larger than three were included in
1126: the release, and  typical measured signal-to-noise ratios are about 50 for
1127: objects brighter than H$\approx$17 (see Fig.~\ref{fig:snmags}).
1128: 
1129: \subsection{Completeness}
1130: 
1131: Whether the spectrum of a particular target is extracted depends, among other
1132: things, on the detection of the target on the undispersed image, the  relative
1133: location and flux levels of other spectra on the grism image, the location of
1134: residual image defects and  the location of the spectrum  relative to the image
1135: edges.  The number of spectra extracted at each pointing therefore varies
1136: widely, and was typically about five.  The distribution of the number of
1137: spectra extracted from each association is shown in Fig.~\ref{fig:datasets}.
1138: 
1139: \new{To assess the completeness of the sample quantitatively, we have compared
1140: the DR1 catalogue with the survey by \citet{pat}. These authors searched
1141: two-dimensional NICMOS grism images for emission line objects and found a total
1142: of 33 candidates. Most of the emission lines are H$\alpha$ at redshifts between
1143: 0.75 and 1.9. Such a sample of galaxies is dominated by closely interacting
1144: systems and, because of contamination issues, our procedure selects against
1145: such objects. We found that a total of 6 of the \citeauthor{pat} candidates are
1146: included in DR1. We therefore consider 20\% to be a lower limit for the
1147: completeness of our catalogue.  }
1148: 
1149: The HLA includes any spectrum suitable for extraction, no attempt has been made
1150: to classify or match the targets with any catalogue. Some of the fields  have
1151: been observed several times with different roll angle. These spectra were not
1152: co-added and therefore several spectra might be available for one target.  In
1153: total, the number of unique targets in the release is \ntargets.
1154: 
1155: 
1156: \subsection{Photometric accuracy of the undispersed images}
1157: \label{sec:phot-accur-undisp}
1158: 
1159: The photometric accuracy of the undispersed direct images was assessed by
1160: comparing the magnitudes obtained in the F160W and F110W bands with the 2MASS H
1161: and J band magnitudes of matched objects.  When doing this comparison, we used
1162: aperture photometry with an aperture of 11 pixels, and applied a
1163: finite-aperture correction as provided by the NICMOS Data Handbook
1164: \citep{nicmoshandbook}; in addition, we converted the 2MASS magnitudes into the
1165: AB magnitude system.  
1166: 
1167: \begin{figure}[h]
1168:   \centering
1169:   \includegraphics[width=\hsize]{fig12}
1170:   \caption{\textbf{Top.} Direct image F160W magnitude, as a function
1171:     of the 2MASS $H$ magnitude.  \textbf{Bottom.}  Difference of the
1172:     two magnitudes as a function of the 2MASS magnitude .}
1173:   \label{fig:7}
1174: \end{figure}
1175: 
1176: The results obtained are shown in Fig.~\ref{fig:7}: a good agreement is
1177: obtained over the whole magnitude range, with negligible bias; the relatively
1178: large scatter observed, $\sim0.16 \mbox{ mag}$, is probably due to the
1179: photometric uncertainties present in the 2MASS catalogue for faint sources.
1180: Similar results were obtained for the F110W magnitudes.
1181: 
1182: 
1183: \subsection{Photometric accuracy of the spectra}
1184: 
1185: \begin{figure}[t]
1186:   \centering
1187:   \includegraphics[width=\hsize]{fig13}
1188:   \caption{Total throughput of the F160W filter for the NICMOS/NIC3 camera.}
1189:   \label{fig:4}
1190: \end{figure}
1191: 
1192: Quality control of the photometric calibration of the one-dimensional spectra
1193: was performed by comparing the integrated flux, as measured from the
1194: end-product spectra, with the magnitude derived from the direct images.  The
1195: following procedure was applied: 
1196: 
1197: \begin{itemize} 
1198: 
1199: \item all spectra  that had associated direct images in the F160W filter were
1200: selected; 
1201: 
1202: \item for the selected objects, only spectra which were considered complete up
1203: to the boundary of the total throughput of the F160W/NIC3 configuration (see
1204: Fig.~\ref{fig:4}), were selected.  In particular, all spectra that did not
1205: contain data within the wavelength range defined by $\mathrm{throughput} >
1206: 0.005$ were discarded; 
1207: 
1208: \item the flux of these objects was then integrated and compared with either
1209: the direct image magnitudes or, when available, with the 2MASS $H$ band
1210: magnitudes.  At the same time, the error on the magnitude due to flux
1211: contamination from other sources was also evaluated using data provided in the
1212: output products.  
1213: 
1214: \end{itemize}
1215: 
1216: \begin{figure}
1217:   \centering
1218:   \includegraphics[width=\hsize]{fig14}
1219:   \caption{\textbf{Top.} The ``spectroscopic'' magnitude, i.e.\ the
1220:     magnitude derived from the spectrum of the object, is shown as a
1221:     function of the direct image F160W magnitude.   \textbf{Bottom.}
1222:     The difference of the two magnitudes is plotted as a function of
1223:     the direct image magnitude.  \new{For both plots, the colour
1224:     of the points indicates the level of contamination, 
1225: coded according to the difference $\Delta m$ in the magnitude  of the target
1226: and that of the contaminator. The colour codes are as follows:
1227:  green:              $\Delta m > 8^{\sl mag}$,
1228:  yellow: $4^{\sl mag}<\Delta m < 8^{\sl mag}$,
1229:  orange: $2^{\sl mag}<\Delta m < 4^{\sl mag}$
1230: and  red: $0^{\sl mag}<\Delta m < 2^{\sl mag}$.
1231:  }
1232: }
1233:   \label{fig:5}
1234: \end{figure}
1235: 
1236: \begin{figure}[h]
1237:   \includegraphics[height=0.32\hsize]{fig15a}
1238:   \hfill
1239:   \includegraphics[height=0.32\hsize]{fig15b}
1240:   \hfill
1241:   \includegraphics[height=0.32\hsize]{fig15c}
1242: \newline
1243:   \includegraphics[width=0.31\hsize]{fig15aspec}
1244:   \hfill
1245:   \includegraphics[width=0.32\hsize]{fig15bspec}
1246:   \hfill
1247:   \includegraphics[width=0.31\hsize]{fig15cspec}
1248:   \caption{Examples of catastrophic discrepancies selected from the
1249:     outliers of Fig.~\ref{fig:5}.  Each panel shows
1250:     the direct image associated to the source for which an inaccurate
1251:     spectroscopic magnitude was obtained (marked in red); other
1252:     objects in the field used for the contamination calculation are
1253:     marked with blue ellipses. \new{The corresponding cutouts from
1254:     the grism image are shown below the undispersed images.}
1255:     \textbf{Left.} Source in a crowded
1256:     field, close to an undetected source to the
1257:     right. \textbf{Middle.} Source close to bright star on the
1258:     boundary. \textbf{Right.} Source contaminated by a bright star
1259:     outside the field (note the spike on the centre-left of the
1260:     image).}
1261:   \label{fig:6}
1262: \end{figure}
1263: 
1264: The results obtained for the comparison with the F160W direct images are shown
1265: in Fig.~\ref{fig:5}.  A very good linear response is obtained over a large
1266: range of magnitudes for both pre- and post-NCS data.  The effects of spectrum
1267: contamination are visible in the lower-right part of the graph, which is
1268: occupied mainly by \new{sources with  high levels of contamination, as directly
1269: evaluated from the spectra}.  Overall the agreement is good, with a median
1270: offset of 0.16 magnitudes for pre-NCS data, and 0.23 for the post-NCS case.
1271: The scatter is in both cases $\sim0.5$ magnitudes.
1272: 
1273: A few ``catastrophic'' cases of sources with apparent no-contamination but
1274: still large magnitude difference are however evident in this plot.  These cases
1275: were investigated further and simple explanations could be found for almost all
1276: of them.  In general, it was found that large discrepancies were associated
1277: with: (i) crowded fields, for which the contamination model might be
1278: inaccurate; (ii) objects close to bright sources not included in the analysis;
1279: (iii) objects close to extended, diffuse sources; or (iv) objects contaminated
1280: by sources outside the field of view of the direct image. \new{ Three examples
1281: of such cases are shown in Fig.~\ref{fig:6}. For each case, the undispersed
1282: image  with the marked problematic target is shown along with the corresponding
1283: spectrum cutout. In the left and centre panels, a bright undetected source
1284: produces significant  contamination in the extracted spectra.  In both cases,
1285: the contaminating source dominates the flux. In the right panel, the zeroth
1286: order of a very bright source outside the field produces a bright region  in
1287: the extracted spectrum.}
1288: 
1289: 
1290: \subsection{Noise}\label{sec:sn}
1291: 
1292: All extracted spectra include a predicted flux uncertainty  in each wavelength
1293: bin based on error propagation from the error array in the NICMOS images
1294: through to the final spectra.  Fig.~\ref{fig:signaltonoise} compares these
1295: predicted uncertainties with noise measurements on the final spectra using the
1296: DER\_SNR algorithm \citep{2007STECF..42....4S}. 
1297: 
1298: \begin{figure}[ht]
1299:   \centering
1300:   \includegraphics[width=\hsize]{fig16}
1301:   \caption{Noise measurements from the spectrum using the DER\_SNR
1302:     algorithm as a function the noise estimate obtained from the
1303:     NICMOS error array using error propagation.}
1304:   \label{fig:signaltonoise}
1305: \end{figure}
1306: 
1307: The SNR values are in good agreement with quite small scatter at the high flux
1308: end. At the faint end the scatter is larger and there is a slight but
1309: systematic trend for the DER\_SNR values to be higher than their predicted
1310: value. This might be due to a component, e.g. the noise in the background,
1311: which was not included in our noise model, or reflect some bias in the
1312: measurement of the noise. 
1313: 
1314: 
1315: \subsection{\new{Comparison of Spectra with NICMOSlook Extractions}}
1316: 
1317: \new{Most previous extractions of NICMOS grism spectra have used interactive
1318: tools, such as the NICMOSlook program \citep{nicmoslook}. NICMOSlook is a
1319: highly specialised tool that provides a large number of options and parameters
1320: that can be varied to optimise the extraction.  The main advantages of using an
1321: interactive program is that the background region can be adjusted for each
1322: individual spectrum and that the subpixel accuracy of the trace necessary for
1323: the pixel-response correction} \new{can be visually checked and fitting
1324: parameters can be modified.  In addition, NICMOSlook's optional deblending of
1325: overlapping spectra results in a more reliable estimate of contamination
1326: levels, and is accurate enough to recover heavily contaminated spectra.  The
1327: combination of optimising the background regions and deblending of overlapping
1328: spectra allows NICMOSlook to extract more spectra in crowded regions than is
1329: possible  with the automatic procedure used in this work. For example,
1330: \cite{pat} used NICMOSlook to extract the larger sample of H$\alpha$ emitters
1331: mentioned above.
1332: 
1333: For those spectra that are included in DR1, the main uncertainty is the
1334: background level. The impact is most visible in low signal-to-noise spectra.
1335: In Fig.~\ref{fig:nicmoslook}, we compare  the NICMOSlook extraction of three
1336: spectra  of the \citeauthor{pat} targets with the one from DR1, all of them are
1337: low signal-to-noise spectra.  The good agreement of the spectra suggests that
1338: both the relative and absolute flux calibration in DR1 is reliable.
1339: 
1340: To summarise, the accuracy of the completely unsupervised extractions of NICMOS
1341: spectra in HLA DR1 is close to what can be achieved with an interactive tool.
1342: In addition, we have taken into account contamination by sources outside the
1343: field of view of NICMOS, which is not possible using currently available
1344: interactive tools.  }
1345: 
1346: \begin{figure}
1347: \includegraphics[width=\hsize]{nicmoslook}
1348: \caption{\new{Comparison of HLA spectra  with extractions using 
1349: the NICMOSlook program. All three spectra are H$\alpha$ emitting galaxies
1350:  discovered by \cite{pat}. The blue curves are NICMOSlook extractions, whereas the
1351: red curves are the HLA extractions. The blue labels are the \citeauthor{pat}'s names.
1352: } }\label{fig:nicmoslook}
1353: \end{figure}
1354: 
1355: 
1356: \subsection{Comparison of Spectra with Published Data}
1357: 
1358: As a quality check, we compared some extracted spectra to spectra of the same
1359: objects taken from the ground, as well as previously published extractions of
1360: spectra from the same NICMOS data. Because of strong atmospheric lines, H-band
1361: IR spectroscopy is difficult to calibrate from the ground. In particular, the
1362: region around $\lambda=1.4-1.5\,\mu$ m is not accessible from the ground. 
1363: 
1364: In Figs.~\ref{fig:comp1} and~\ref{fig:1044}, we compare spectra of two high
1365: redshift QSOs to spectra from Gemini \citep{comp1} and the Italian Telescopio
1366: Nazionale Galileo  \citep[TNG,][]{maio}. In both cases, the shape of the line
1367: and continuum around the  CIII line at $\lambda\sim1.3\,\mu$m is well
1368: reproduced. The continuum at wavelengths longer than 1.5$\,\mu$m agrees to
1369: within about 5\% with the Gemini data, but differs by almost a factor of two
1370: from the TNG data. We attribute this discrepancy to the uncertain calibration
1371: of the data from the ground. 
1372: 
1373: Finally, in Fig.~\ref{fig:asr24}, we compare HLA spectra of the brown dwarf
1374: ASR~24 with the spectra extracted  from the same data set by \cite{asr24}.
1375: ASR~24 has been observed three times with NICMOS G141 with three different roll
1376: angles. The HLA therefore contains three separate spectra of this source,
1377: namely HNG\_J032911.32+311717.5\_N8VM06BEQ, HNG\_J032911.32+311717.5\_N8VM09G5Q
1378: and HNG\_J032911.32+311717.6\_N8VM16S3Q. \cite{asr24} did not derive a flux
1379: scale for their spectrum, this spectrum is therefore scaled to matched the HLA
1380: extraction. It can be seen that the absolute and relative flux calibration of
1381: the three HLA extractions agree to within 10\%.  We therefore conclude that the
1382: quality of the HLA NICMOS G141 spectra is comparable to the best extractions
1383: previously obtained from the data.
1384: 
1385: 
1386: \begin{figure}
1387: \includegraphics[width=\hsize]{fig17}
1388: \caption{Comparison of an HLA spectrum with a Gemini spectrum of the same
1389: source.  The blue curve is the heavily smoothed spectrum of SDSS
1390: J083643.85+005453.3 from \cite{comp1}, the red curve is
1391: HNG\_J083643.82+005453.4\_N6LE01ULQ.}\label{fig:comp1}
1392: \end{figure}
1393: 
1394: \begin{figure}
1395: \includegraphics[width=\hsize]{fig18}
1396: \caption{Comparison of an HLA spectrum with a TNG NICS spectrum of the same
1397: source.  The blue curve is the spectrum of SDSS 104433.04+012502.2 from
1398: \cite{maio}, the red curve is
1399: HNG\_J104433.08-012501.6\_N6LE03C7Q.}\label{fig:1044} 
1400: \end{figure}
1401: 
1402: \begin{figure}
1403: \includegraphics[width=\hsize]{fig19}
1404: \caption{Comparison of an HLA spectra of brown dwarf ASR~24 (red curves and
1405: error bars) with the spectrum published by \cite{asr24} (blue curve).  The
1406: latter has been scaled to match the mean flux level of the HLA
1407: data}\label{fig:asr24}
1408: \end{figure}
1409: 
1410: 
1411: \section{Summary and Conclusion}
1412: 
1413: The HLA NICMOS grism project provides a database of low resolution H-band IR
1414: spectra. Most of the spectra have never been previously extracted from the HST
1415: NICMOS grism data. The database is useful for work on cool stars and emission
1416: line galaxies at $z$ between 1.1 and 1.9, which are readily detected with the
1417: NICMOS grism. The calibration of the spectra is based on a new analysis of
1418: available calibration data and extraction of the spectra for isolated point
1419: source should be close to optimum.  Confused spectra and spectra of extended
1420: objects are identified in the data release and are also of high quality.  The
1421: absolute and relative flux calibration of the spectra is better than 10\%, and
1422: the wavelength calibration better than 5 nm.  The data release is accompanied
1423: by a wide range of auxiliary data and is available through several interfaces.
1424: We anticipate a revised data release based on a new version of the STScI
1425: CALNICA pipeline in early 2009.
1426: 
1427: \begin{acknowledgements}
1428: 
1429: This paper is based on observations made with the NASA/ESA Hubble Space
1430: Telescope, obtained from the data archive at the Space Telescope -- European
1431: Coordinating Facility.  We thank our HLA collaborators Brad Whitmore and  the
1432: STScI and CADC HLA teams.
1433: 
1434: \end{acknowledgements}
1435: 
1436: \clearpage
1437: 
1438: \appendix
1439: \newcommand{\diff}{\mathrm{d}}
1440: 
1441: 
1442: \section{Extraction of Slitless Spectra}
1443: \label{sec:slitl-meas}
1444: 
1445: 
1446: A crucial difference between longslit and slitless spectroscopy is the
1447: selection of the light to be dispersed. For slitless spetroscopy, the light
1448: that enters the spectrograph is only limited by the  object shape and the point
1449: spread function.  For the extraction, we neglected the fact that the shape, as
1450: well as the point spread function, can change with wavelength. For the
1451: following discussion, we also neglect the impact of the sensitivity curves on
1452: the spectrum. A more rigorous discussion of the parameters will be presented by
1453: \citet{theorypaper}. With the above  approximations, the specific intensity of
1454: the object $I(\vec x, \lambda)$ at the angular position $\vec x$ can be
1455: expressed as the product of two functions
1456: 
1457: \begin{equation} \label{eq:1} I(\vec x, \lambda) = I(\vec x) F(\lambda) \; ,
1458: \end{equation}
1459: where $I(\vec x)$, is the integrated intensity of the object as revealed by the
1460: direct image, and $F(\lambda)$ is the spectral energy distribution.
1461: $F(\lambda)$ is independent of the position $\vec x$.
1462: The image $\tilde I(\vec x)$ generated by the slitless spectrograph
1463: is then
1464: \begin{equation}
1465:   \label{eq:2}
1466:   \tilde I(\vec x) = \int I \bigl( \vec x - \vec r (\lambda -
1467:   \lambda_0), \lambda \bigr) \, \diff \lambda = \int I \bigl( \vec x -
1468:   \vec r (\lambda - \lambda_0) \bigr) F(\lambda) \, \diff \lambda \; ,
1469: \end{equation}
1470: where $\vec r$ is the dispersion vector and $\lambda_0$ a pivot
1471: wavelength.  The second equality shows that the result can be written
1472: as a simple convolution, carried out along the dispersion direction,
1473: of the original image with the object spectrum.
1474: 
1475: The goal of the spectral extraction is to add all flux values of pixels that
1476: represent the same wavelength. For slitless spectroscopy, the monochromatic
1477: light from a single wavelength covers a region  with the same shape as the
1478: target object on the detector. For simplicity, we assign all pixels on a
1479: straight line on the two-dimensional grism image to the same wavelength bin in
1480: the one-dimensional spectrum.  The size of the objects along the dispersion
1481: direction limits the spectra resolution of slitless spectra and has the same
1482: effect as the width of the slit in a longslit spectrograph.  In the following,
1483: we will refer to the box defined by the above straight line of constant
1484: wavelength and the size of the object along the dispersion direction  as the
1485: ``virtual slit''.
1486: 
1487: For complex objects, it is unavoidable that a straight line includes pixels
1488: with flux originating from different wavelengths. The goal of the extraction
1489: procedure is to choose the direction of the virtual slit so that variations of
1490: wavelength are minimised.  Our algorithm is designed to work exactly for the
1491: case of elliptical objects, i.e.  in that case each wavelength bin of the
1492: one-dimensional spectrum includes only pixels with flux from a single
1493: wavelength.
1494: 
1495: 
1496: 
1497: \begin{figure}
1498:   \centering
1499:   \includegraphics[scale=0.75]{angles}
1500:   \caption{Schematic drawing of a slitless spectrum measurement.}
1501:   \label{fig:angles}
1502: \end{figure}
1503: 
1504: 
1505: As shown above in Eq.~\eqref{eq:2}, the two-dimensional spectrum is a
1506: convolution of the object image with the one-dimensional spectrum.  Spectral
1507: features will be smoothed by the object intensity profile corresponding to each
1508: line of dispersion.  For example, for an object with a single emission line at
1509: $\lambda_\mathrm{e}$ so that $F(\lambda) \propto \delta(\lambda -
1510: \lambda_\mathrm{e})$,  the resultant image $\tilde I(\vec x)$ will be identical
1511: to $I(\vec x)$ except for a shift along $\vec r$. 
1512: 
1513: A natural choice for the orientation of the virtual slit is the direction of
1514: the line defined by the  ``centre of light'' of the intensity profile along the
1515: dispersion direction.  In this case,   the position $\vec x_\mathrm{e}$
1516: satisfies the equation
1517: 
1518: \begin{equation}
1519:   \label{eq:3}
1520:   \int \tilde I(\vec x_\mathrm{e} + \vec r \ell) \ell \, \diff \ell =
1521:   0 \; .
1522: \end{equation}
1523: 
1524: 
1525: For elliptical isophotes, the image of the object can be written as a function
1526: of the elliptical radius $\rho^2 \equiv \vec x^\mathrm{T} A \vec x$, 
1527: \begin{equation}
1528:   \label{eq:4}
1529:   I(\vec x) = f \bigl( \vec x^\mathrm{T} A \vec x\bigr) \; ,
1530: \end{equation}
1531: where $A$ is a $2 \times 2$ symmetric matrix, and where, for simplicity,
1532: we have chosen the origin of our coordinates at the centre of the
1533: elliptical object.  In the following, without loss of generality, we
1534: will also assume that the dispersion direction is along the horizontal
1535: axis $x_1$, so that $\vec r = (r, 0)$.
1536: For convenience, we convert to  a \textit{slanted\/}
1537: coordinate system $\vec x'$ defined by the linear
1538: transformation
1539: \begin{align}
1540:   \label{eq:5}
1541:   x_1 \mapsto x'_1 = {} & x_1 + k x_2 \; , &
1542:   x_2 \mapsto x'_2 = {} & x_2 \; . \\
1543:   \vec x \mapsto \vec x' = {} & T \vec x \; , & 
1544:   T = {} & \begin{pmatrix}
1545:     1 & k \\
1546:     0 & 1
1547:   \end{pmatrix} \; .
1548: \end{align}
1549: In this new coordinate system we then define the slanted direct image
1550: $I'(\vec x')$ as a simple remapping of $I(\vec x)$:
1551: \begin{equation}
1552:   \label{eq:6}
1553:   I'(\vec x') = I(\vec x) = I(T^{-1} \vec x') \; .
1554: \end{equation}
1555: Along a line parallel to the dispersion direction, the transformation
1556: $T$ is a simple translation: in other words, for fixed $x_2$, $x'_1$
1557: is a simple shift of $x_1$ by $k x_2$. 
1558: 
1559: To compute the orientation of the virtual slit, we choose the 
1560: value of $k$ in the  transformation $T$
1561: in such a manner that the image of the galaxy in the slanted coordinate
1562: system appears as an ellipse with one of the axes oriented along the
1563: dispersion direction.  This requirement is equivalent to choosing the
1564: matrix $T^{-\mathrm{T}} A T^{-1}$ to be  diagonal, which is guaranteed if
1565: $k = A_{12} / A_{11}$.  With this choice, we find
1566: \begin{equation}
1567:   \label{eq:7}
1568:   T^{-\mathrm{T}} A T^{-1} =
1569:   \begin{pmatrix}
1570:     A_{11} & 0 \\
1571:     0 & \det (A) / A_{11}
1572:   \end{pmatrix} \; .
1573: \end{equation}
1574: 
1575: In this new coordinate system  the virtual slits  are perpendicularly to the
1576: dispersion direction, because the object is now symmetric along the axis
1577: $x'_2$.  The corresponding lines in the original coordinate system can be
1578: obtained by transforming back the vertical lines, and as graphically
1579: illustrated in Fig.~\ref{fig:angles}, these lines can be obtained by joining
1580: the two tangent points of the ellipse describing the direct object with lines
1581: parallel to the dispersion direction.  
1582: 
1583: Note that the direction of the virtual slits is never along one of the axes of
1584: the elliptical isophotes except in the trivial case where the object is already
1585: oriented along the dispersion direction ($A_{12} = k = 0$).  The angle with
1586: respect to the vertical formed by the lines of constant wavelength is given by
1587: $\tan \beta = k = A_{12} / A_{11}$, and thus for highly elongated objects it
1588: can approach $\pm \pi/2$.
1589: 
1590: \def\aap{A\& A}
1591: \def\pasp{Proc.Astr.Soc.Pacific}
1592: \def\mnras{MNRAS}
1593: \def\apj{ApJ}
1594: \def\aj{AJ}
1595: \def\apjl{ApJL}
1596: \def\apjs{ApJS}
1597: \def\procspie{Proc. SPIE}
1598: 
1599: 
1600: \clearpage
1601: \begin{thebibliography}{}
1602: \bibliography{}
1603: 
1604: 
1605: \bibitem[Adelman-McCarthy et al.(2007)]{2007ApJS..172..634A} 
1606: Adelman-McCarthy, J.~K., et al.\ 2007, \apjs, 172, 634 
1607: 
1608: \bibitem[Bertin \& Arnouts(1996)]{ba} Bertin, E. \& Arnouts, S.\ 1996, \aap,
1609: 117, 393
1610: 
1611: \bibitem[Bohlin(2003)]{fluxcala}Bohlin, R. 2003, 2002 HST Calibration Workshop,
1612: ed. S. Arribas, A.  Koekemoer, \& B. Whitmore, (Baltimore:STScI),  115
1613: 
1614: \bibitem[Bohlin(2007)]{fluxcalb}Bohlin, R. C. 2007, in The Future of
1615: Photometric, Spectrophotometric,  and Polarimetric Standardization, ASP Conf.
1616: Series, Vol. 364, p. 315  ed. C. Sterken; astro-Ph 0608715
1617: 
1618: \bibitem[Bohlin, Riess \& de Jong(2006)]{bohlinI} Bohlin, R.C., Riess, A.  \&
1619: de Jong, R. 2006, Instrument Science Report, NICMOS, 2006-002
1620: 
1621: \bibitem[Bohlin, Lindler \& Riess(2005)]{bohlinII} Bohlin, R.C., Lindler, D.
1622: \& Riess, A. 2005, Instrument Science Report, NICMOS, 2005-002
1623: 
1624: \bibitem[Bushouse(1997)]{calnica} Bushouse, H. 1997, The 1997 HST Calibration
1625: Workshop with a New Generation of Instruments, 223, 223 
1626: 
1627: \bibitem[Dahlen et al.(2008))]{newcalnica} Dahlen, T., et al. 2008,
1628: Instrument Science Report, NICMOS, 2008-002
1629: 
1630: 
1631: \bibitem[Freudling(1997)]{nicmoslook} Freudling, W.\ 1997, Space Telescope
1632: European Coordinating Facility Newsletter, Volume 24, 7, 24, 7 
1633: 
1634: \bibitem[Fruchter \& Hook(2002)]{Fruchter} Fruchter, A. S., Hook, R. N. 2002,
1635: PASP, 114, 144
1636: 
1637: \bibitem[Greissl et al.(2007)]{asr24} Greissl, J., Meyer, 
1638: M.~R., Wilking, B.~A., Fanetti, T., Schneider, G., Greene, T.~P., \& Young, 
1639: E.\ 2007, \aj, 133, 1321 
1640: 
1641: \bibitem[Horne(1986)]{horne} Horne, K.\ 1986, \pasp, 98, 609 
1642: 
1643: \bibitem[Koekemoer et al.(2002)]{drizzle} 
1644: Koekemoer, A.M., Fruchter, A.S., Hook, R.N. \& Hack,W. 2002, 
1645:  Proceedings of the 2002 HST Calibration Workshop, 
1646: STScI, 337
1647: 
1648: \bibitem[Koekemoer et al.(2006)]{koe06} Koekemoer, A.M.,   Fruchter, A.S.,
1649: Hook, R.N., Hack W.,  \& Hanley, C. 2006, The 2005 Calibration Workshop, eds.
1650: A.\ Koekemoer, P.\ Goudfrooij, \& L.\ Dressel, L., 423 
1651: 
1652: \bibitem[K\"ummel et al.(2008)]{axe1} K\"ummel, M.,  
1653: Walsh, J.R., Pirzkal, N., Kuntschner, H., \& Pasquali, A., 2008, PASP, submitted
1654: 
1655: \bibitem[K\"{u}mmel, Kuntschner \& Walsh(2007)]{axesim}K\"{u}mmel, M.,
1656: Kuntschner, H., \& Walsh, J. R. 2007 , Space Telescope -- European Coordinating Facility Newsletter, 43, 8
1657: 
1658: \bibitem[Lasker et al.(1990)]{1990AJ.....99.2019L} Lasker, B.~M., Sturch, 
1659: C.~R., McLean, B.~J., Russell, J.~L., Jenkner, H., 
1660: \& Shara, M.~M.\ 1990, \aj, 99, 2019 
1661: 
1662: \bibitem[Lombardi et al.(2008)]{theorypaper} 
1663: Lombardi et al., 2008, in preparation
1664: 
1665: \bibitem[MacKenty(1997a)]{john2} MacKenty, J.\ 1997a, HST Proposal, 7907
1666: 
1667: \bibitem[MacKenty(1997b)]{john1} MacKenty, J.\ 1997b, HST Proposal, 8082
1668: 
1669: \bibitem[Malkan(2003)]{mal2} Malkan, M.\ 2003, HST Proposal, 9865
1670: 
1671: \bibitem[Malkan(2004)]{mal1} Malkan, M.\ 2004, HST Proposal, 10226
1672: 
1673: \bibitem[Maiolino et al.(2004)]{maio} Maiolino, R., Oliva, E., Ghinassi, F.,
1674: Pedani, M., Mannucci, F., Mujica, R., \& Juarez, Y.\ 2004, \aap, 420, 889 
1675: 
1676: \bibitem[McCarthy et al.(1999)]{pat} McCarthy, P.~J., et 
1677: al.\ 1999, \apj, 520, 548 
1678: 
1679: \bibitem[McDowell \& Tody(2007)]{mcd}  McDowell, J. \& Tody, D. (eds.) 2007,
1680: IVOA Spectral Data Model Version 1.01,
1681: http://www.ivoa.net/Documents/PR/DM/SpectrumDM-20070515.html
1682: 
1683: \bibitem[McLean et al.(2000)]{gsc2} McLean, B.~J., Greene, G.~R., Lattanzi,
1684: M.~G., \& Pirenne, B.\ 2000, Astronomical Data Analysis Software and Systems
1685: IX, 216, 145 
1686: 
1687: \bibitem[Mobasher \& Roye(2004)]{nicmoshandbook} Mobasher, B. \& Roye, E. eds.
1688: 2004, HST Data Handbook for NICMOS  V.6
1689: 
1690: \bibitem[Monet et al.(2003)]{2003AJ....125..984M} Monet, D.~G., et al.\ 
1691: 2003, \aj, 125, 984 
1692: 
1693: \bibitem[Pirzkal et al.(2004)]{axe2} Pirzkal, N., Xu, C., Malhotra, S., et al.
1694: 2004, \apjs, 154 501
1695: 
1696: \bibitem[Schultz et al.(2003)]{ncscal} Schultz, A.~B., et al.\ 2003, \procspie,
1697: 4850, 858 
1698: 
1699: \bibitem[Stern et al.(2003)]{comp1} Stern, D., Hall, P.~B., Barrientos, L.~F.,
1700: Bunker, A.~J., Elston, R., Ledlow, M.~J., Raines, S.~N., \& Willis, J.\ 2003,
1701: \apjl, 596, L39 
1702: 
1703: \bibitem[Storrs et al.(1999)]{sto99} Storrs, R., Hook, R., Stiavelli, M.,
1704: Hanley, C., \& Freudling, W., 1999,  Instrument Science Report, NICMOS, 99-005
1705: 
1706: \bibitem[Stoehr et al.(2007)]{2007STECF..42....4S} Stoehr, F., et al.\ 2007,
1707: Space Telescope European Coordinating Facility Newsletter, 42, 4
1708: 
1709: \bibitem[Thompson \& Freudling(2002)]{rodger} Thompson, R.~I., \& Freudling,
1710: W.\ 2002, HST Calibration Workshop: Hubble after the Installation of the ACS
1711: and the NICMOS Cooling System, 240
1712: 
1713: \bibitem[Skrutskie et al.(2006)]{2006AJ....131.1163S} Skrutskie, M.~F., et al.\
1714: 2006, \aj, 131, 1163 
1715: 
1716: \bibitem[Xu \& Mobasher(2003)]{xu03} Xu, C., \& Mobasher, B. 2003, Instrument
1717: Science Report, NICMOS, 2003-009
1718: 
1719: \bibitem[Zacharias et al.(2004)]{2004AJ....127.3043Z} Zacharias, N., Urban,
1720: S.~E., Zacharias, M.~I., Wycoff, G.~L., Hall, D.~M., Monet, D.~G., \& Rafferty,
1721: T.~J.\ 2004, \aj, 127, 3043 
1722: 
1723: \end{thebibliography}
1724: 
1725: 
1726: \end{document}
1727: 
1728: