| 1 |
/* @(#)filtlib.c 19.1 (ESO-DMD) 02/25/03 13:18:59 */ |
| 2 |
/*=========================================================================== |
| 3 |
Copyright (C) 1995 European Southern Observatory (ESO) |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU General Public License as |
| 7 |
published by the Free Software Foundation; either version 2 of |
| 8 |
the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public |
| 16 |
License along with this program; if not, write to the Free |
| 17 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 18 |
MA 02139, USA. |
| 19 |
|
| 20 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 21 |
Internet e-mail: [email protected] |
| 22 |
Postal address: European Southern Observatory |
| 23 |
Data Management Division |
| 24 |
Karl-Schwarzschild-Strasse 2 |
| 25 |
D 85748 Garching bei Muenchen |
| 26 |
GERMANY |
| 27 |
===========================================================================*/ |
| 28 |
|
| 29 |
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 30 |
.COPYRIGHT: Copyright (c) 1987 European Southern Observatory, |
| 31 |
all rights reserved |
| 32 |
.IDENTIFIER module filtlib |
| 33 |
.LANGUAGE C |
| 34 |
.AUTHOR K. Banse IPG-ESO Garching |
| 35 |
.KEYWORDS |
| 36 |
.COMMENTS holds fits interfaces (based on Midas std. intf.) |
| 37 |
needed for the different modules of T.B.Georgiev |
| 38 |
|
| 39 |
|
| 40 |
.ENVIRONment MIDAS |
| 41 |
#include <midas_def.h> Prototypes for MIDAS interfaces |
| 42 |
|
| 43 |
.VERSIONS 1.00 980708 implementation |
| 44 |
--------------------------------------------------------------*/ |
| 45 |
|
| 46 |
#include <stdio.h> |
| 47 |
#include <midas_def.h> |
| 48 |
|
| 49 |
|
| 50 |
/* |
| 51 |
|
| 52 |
*/ |
| 53 |
|
| 54 |
void fits_put_data(imno,nrow,nstart,jbuf,nend) |
| 55 |
int imno, nrow, nstart, nend; |
| 56 |
short int *jbuf; |
| 57 |
|
| 58 |
{ |
| 59 |
char *pntra; |
| 60 |
|
| 61 |
int npix[2], nullo, uni, mapsize, felem, iav; |
| 62 |
|
| 63 |
|
| 64 |
(void) SCDRDI(imno,"NPIX",1,2,&iav,npix,&uni,&nullo); |
| 65 |
|
| 66 |
felem = (nrow * npix[0]) + nstart + 1; |
| 67 |
mapsize = nend - nstart; |
| 68 |
pntra = (char *)jbuf; |
| 69 |
(void) SCFPUT(imno,felem,mapsize,pntra); |
| 70 |
} |
| 71 |
|
| 72 |
/* |
| 73 |
|
| 74 |
*/ |
| 75 |
|
| 76 |
void fits_get_data(imno,nrow,nstart,jbuf,nend) |
| 77 |
int imno, nrow, nstart, nend; |
| 78 |
short int *jbuf; |
| 79 |
{ |
| 80 |
char *pntra; |
| 81 |
|
| 82 |
int npix[2], nullo, uni, mapsize, felem, iav; |
| 83 |
|
| 84 |
|
| 85 |
(void) SCDRDI(imno,"NPIX",1,2,&iav,npix,&uni,&nullo); |
| 86 |
|
| 87 |
felem = (nrow * npix[0]) + nstart + 1; |
| 88 |
mapsize = nend - nstart; |
| 89 |
pntra = (char *)jbuf; |
| 90 |
(void) SCFGET(imno,felem,mapsize,&iav,pntra); |
| 91 |
} |
| 92 |
|
| 93 |
/* |
| 94 |
|
| 95 |
*/ |
| 96 |
|
| 97 |
void fits_close(imno) |
| 98 |
int imno; |
| 99 |
|
| 100 |
{ |
| 101 |
(void) SCFCLO(imno); |
| 102 |
} |
| 103 |
|
| 104 |
/* |
| 105 |
|
| 106 |
*/ |
| 107 |
|
| 108 |
int fits_open(name,dummy,nr,nc) |
| 109 |
char *name, *dummy; |
| 110 |
int *nr, *nc; |
| 111 |
|
| 112 |
{ |
| 113 |
int imno, iav, uni, nullo, npix[2]; |
| 114 |
|
| 115 |
imno = 0; |
| 116 |
if (*dummy == 'r') |
| 117 |
{ |
| 118 |
*nr = *nc = 1; |
| 119 |
(void) SCFOPN(name,D_I2_FORMAT,0,F_IMA_TYPE,&imno); |
| 120 |
(void) SCDRDI(imno,"NPIX",1,2,&iav,npix,&uni,&nullo); |
| 121 |
*nr = npix[1]; |
| 122 |
*nc = npix[0]; |
| 123 |
} |
| 124 |
|
| 125 |
else |
| 126 |
{ |
| 127 |
int size; |
| 128 |
|
| 129 |
npix[0] = *nc; |
| 130 |
npix[1] = *nr; |
| 131 |
size = npix[0] * npix[1]; |
| 132 |
(void) SCFCRE(name,D_I2_FORMAT,F_O_MODE,F_IMA_TYPE,size,&imno); |
| 133 |
size = 2; |
| 134 |
(void) SCDWRI(imno,"NAXIS",&size,1,1,&uni); |
| 135 |
(void) SCDWRI(imno,"NPIX",npix,1,2,&uni); |
| 136 |
} |
| 137 |
|
| 138 |
return (imno); |
| 139 |
} |
| 140 |
|
| 141 |
/* |
| 142 |
|
| 143 |
*/ |
| 144 |
|
| 145 |
void find(pattrn,strng,value) |
| 146 |
char *strng, *pattrn; |
| 147 |
float *value; |
| 148 |
|
| 149 |
{ |
| 150 |
char realpat[4], tmp[80]; |
| 151 |
|
| 152 |
int nn, ibuf; |
| 153 |
|
| 154 |
double dbuf; |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
realpat[0] = *pattrn; |
| 159 |
realpat[1] = '='; |
| 160 |
realpat[2] = '\0'; |
| 161 |
|
| 162 |
nn = CGN_INDEXS(strng,realpat); |
| 163 |
if (nn < 0) |
| 164 |
{ |
| 165 |
realpat[0] = CGN_UPPER(*pattrn); |
| 166 |
nn = CGN_INDEXS(strng,realpat); |
| 167 |
} |
| 168 |
|
| 169 |
if (nn > -1) |
| 170 |
{ |
| 171 |
nn = CGN_CNVT(&strng[nn+2],2,1,&ibuf,value,&dbuf); |
| 172 |
if (nn == 1) return; |
| 173 |
} |
| 174 |
|
| 175 |
sprintf(tmp,"invalid input: %s, pattern = %s\n",strng,realpat); |
| 176 |
SCTPUT(tmp); |
| 177 |
|
| 178 |
*value = -9999.999; |
| 179 |
} |
| 180 |
|