/* @(#)lnapdisp.c 17.1.1.1 (ES0-DMD) 01/25/02 17:53:59 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, MA 02139, USA. Corresponding concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* .COPYRIGHT (C) 1993 European Southern Observatory */ /* .IDENT .prg */ /* .AUTHORS Pascal Ballester (ESO/Garching) */ /* Cristian Levin (ESO/La Silla) */ /* .KEYWORDS Spectroscopy, Long-Slit */ /* .PURPOSE Wavelength Calibration for 1D, Long and MOS*/ /* .VERSION 1.0 Package Creation 15-JAN-1993 */ /* ------------------------------------------------------- */ #include #include #include #include #define ipos(col,row,siz) row * siz + col main() { char inframe[60], coerbr[60], outtab[60]; /* Table names */ int status, iav, knull, actvals, null; /* Std Interfaces variables */ int naxis, npix[2], imno, ypix, kunit; double start[2], step[2], pixel, y_pos[2], y_world; double *x_world, *lambda, *bin; char ident[80], cunit[64]; double *image; int colw, colb, colf, pix, tid; int debug = FALSE; if (!debug) { SCSPRO("lnapdisp"); status = SCKGETC("IN_A", 1, 60, &actvals, inframe); if (status) SCTPUT("Error while reading IN_A"); status = SCKGETC("IN_B", 1, 60, &actvals, coerbr); if (status) SCTPUT("Error while reading IN_B"); status = SCKGETC("OUT_A", 1, 60, &actvals, outtab); if (status) SCTPUT("Error while reading OUT_A"); } else { SCSPRO("-1"); strcpy(inframe,"arc0001"); strcpy(outtab,"reb1"); strcpy(coerbr,"coerbr"); } SCKRDD("INPUTD", 1, 2, &actvals, y_pos, &kunit, &null); strcpy(ident," "); strcpy(cunit, " "); SCIGET(inframe, D_R8_FORMAT, F_I_MODE, F_IMA_TYPE, 2, &naxis, npix, start, step, ident, cunit, (char**)&image, &imno); if (TCTINI(outtab, F_TRANS, F_O_MODE, 5, npix[0], &tid)) SCTPUT("**** Error while creating output table"); TCCINI(tid, D_R8_FORMAT, 1, "F8.2", "Lambda", "LAMBDA", &colw); TCCINI(tid, D_R8_FORMAT, 1, "F8.2", "Bin size","BIN", &colb); TCCINI(tid, D_R8_FORMAT, 1, "F8.2", "Flux", "FLUX", &colf); if (naxis == 1) {npix[1] = 1; start[1] = 1.; step[1] = 1.;} x_world = (double *) osmmget(npix[0]*sizeof(double)); lambda = (double *) osmmget(npix[0]*sizeof(double)); bin = (double *) osmmget(npix[0]*sizeof(double)); /* Do the job */ if (y_pos[0] < 0) ypix = y_pos[1]; else ypix = (int) ((y_pos[1] - start[1])/step[1] + 0.5); rebin(coerbr, x_world, lambda, bin, start, step, npix, ypix); /* For 1D images, the value ypix is considered as the position where dispersion coefficients are read. y values are decremented by 1 because arrays start at 0 */ if (naxis == 1) ypix = 1; ypix -= 1; /* All results are written to the output table */ write_dcol (tid, npix[0], colw, lambda, 0); write_dcol (tid, npix[0], colb, bin, 0); write_dcol (tid, npix[0], colf, image, ipos(0,ypix,npix[0])); /* Close everything and good bye */ osmmfree((char *)x_world), osmmfree((char *)lambda), osmmfree((char *)bin); TCTCLO(tid), SCFCLO(imno), SCSEPI(); } write_dcol(tid, nb, colnb, col, start) int tid, nb, colnb, start; double col[]; { int i; for (i=0; i