1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
/*============================================================================
WCSLIB 4.8 - an implementation of the FITS WCS standard.
Copyright (C) 1995-2011, Mark Calabretta
This file is part of WCSLIB.
WCSLIB is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
WCSLIB 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 Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with WCSLIB. If not, see <http://www.gnu.org/licenses/>.
Correspondence concerning WCSLIB may be directed to:
Internet email: mcalabre@atnf.csiro.au
Postal address: Dr. Mark Calabretta
Australia Telescope National Facility, CSIRO
PO Box 76
Epping NSW 1710
AUSTRALIA
Author: Mark Calabretta, Australia Telescope National Facility
http://www.atnf.csiro.au/~mcalabre/index.html
$Id: lin_f.c,v 4.8.1.1 2011/08/15 08:07:07 cal103 Exp cal103 $
*===========================================================================*/
#include <stdio.h>
#include <lin.h>
/* Fortran name mangling. */
#include <wcsconfig_f77.h>
#define linini_ F77_FUNC(linini, LININI)
#define lincpy_ F77_FUNC(lincpy, LINCPY)
#define linput_ F77_FUNC(linput, LINPUT)
#define linget_ F77_FUNC(linget, LINGET)
#define linfree_ F77_FUNC(linfree, LINFREE)
#define linprt_ F77_FUNC(linprt, LINPRT)
#define linset_ F77_FUNC(linset, LINSET)
#define linp2x_ F77_FUNC(linp2x, LINP2X)
#define linx2p_ F77_FUNC(linx2p, LINX2P)
#define linptd_ F77_FUNC(linptd, LINPTD)
#define linpti_ F77_FUNC(linpti, LINPTI)
#define lingtd_ F77_FUNC(lingtd, LINGTD)
#define lingti_ F77_FUNC(lingti, LINGTI)
#define LIN_FLAG 100
#define LIN_NAXIS 101
#define LIN_CRPIX 102
#define LIN_PC 103
#define LIN_CDELT 104
#define LIN_PIXIMG 200
#define LIN_IMGPIX 201
#define LIN_UNITY 202
#define LIN_ERR 203
/*--------------------------------------------------------------------------*/
int linini_(const int *naxis, int *lin)
{
return linini(1, *naxis, (struct linprm *)lin);
}
/*--------------------------------------------------------------------------*/
int lincpy_(const int *linsrc, int *lindst)
{
return lincpy(1, (const struct linprm *)linsrc, (struct linprm *)lindst);
}
/*--------------------------------------------------------------------------*/
int linput_(
int *lin,
const int *what,
const void *value,
const int *i,
const int *j)
{
int i0, j0, k;
const int *ivalp;
const double *dvalp;
struct linprm *linp;
/* Cast pointers. */
linp = (struct linprm *)lin;
ivalp = (const int *)value;
dvalp = (const double *)value;
/* Convert 1-relative FITS axis numbers to 0-relative C array indices. */
i0 = *i - 1;
j0 = *j - 1;
linp->flag = 0;
switch (*what) {
case LIN_FLAG:
linp->flag = *ivalp;
break;
case LIN_NAXIS:
linp->naxis = *ivalp;
break;
case LIN_CRPIX:
linp->crpix[i0] = *dvalp;
break;
case LIN_PC:
k = (i0)*(linp->naxis) + (j0);
*(linp->pc+k) = *dvalp;
break;
case LIN_CDELT:
linp->cdelt[i0] = *dvalp;
break;
default:
return 1;
}
return 0;
}
int linptd_( int *lin, const int *what, const double *value,
const int *i, const int *j)
{
return linput_(lin, what, value, i, j);
}
int linpti_( int *lin, const int *what, const int *value,
const int *i, const int *j)
{
return linput_(lin, what, value, i, j);
}
/*--------------------------------------------------------------------------*/
int linget_(const int *lin, const int *what, void *value)
{
int i, j, k, naxis;
int *ivalp;
double *dvalp;
const int *ilinp;
const double *dlinp;
const struct linprm *linp;
/* Cast pointers. */
linp = (const struct linprm *)lin;
ivalp = (int *)value;
dvalp = (double *)value;
naxis = linp->naxis;
switch (*what) {
case LIN_FLAG:
*ivalp = linp->flag;
break;
case LIN_NAXIS:
*ivalp = naxis;
break;
case LIN_CRPIX:
for (i = 0; i < naxis; i++) {
*(dvalp++) = linp->crpix[i];
}
break;
case LIN_PC:
/* C row-major to FORTRAN column-major. */
for (j = 0; j < naxis; j++) {
dlinp = linp->pc + j;
for (i = 0; i < naxis; i++) {
*(dvalp++) = *dlinp;
dlinp += naxis;
}
}
break;
case LIN_CDELT:
for (i = 0; i < naxis; i++) {
*(dvalp++) = linp->cdelt[i];
}
break;
case LIN_PIXIMG:
/* C row-major to FORTRAN column-major. */
for (j = 0; j < naxis; j++) {
dlinp = linp->piximg + j;
for (i = 0; i < naxis; i++) {
*(dvalp++) = *dlinp;
dlinp += naxis;
}
}
break;
case LIN_IMGPIX:
/* C row-major to FORTRAN column-major. */
for (j = 0; j < naxis; j++) {
dlinp = linp->imgpix + j;
for (i = 0; i < naxis; i++) {
*(dvalp++) = *dlinp;
dlinp += naxis;
}
}
break;
case LIN_UNITY:
*ivalp = linp->unity;
break;
case LIN_ERR:
/* Copy the contents of the wcserr struct. */
if (linp->err) {
ilinp = (int *)(linp->err);
for (k = 0; k < ERRLEN; k++) {
*(ivalp++) = *(ilinp++);
}
} else {
for (k = 0; k < ERRLEN; k++) {
*(ivalp++) = 0;
}
}
break;
default:
return 1;
}
return 0;
}
int lingtd_(const int *lin, const int *what, double *value)
{
return linget_(lin, what, value);
}
int lingti_(const int *lin, const int *what, int *value)
{
return linget_(lin, what, value);
}
/*--------------------------------------------------------------------------*/
int linfree_(int *lin)
{
return linfree((struct linprm *)lin);
}
/*--------------------------------------------------------------------------*/
int linprt_(int *lin)
{
/* This may or may not force the Fortran I/O buffers to be flushed. If
* not, try CALL FLUSH(6) before calling LINPRT in the Fortran code. */
fflush(NULL);
return linprt((struct linprm *)lin);
}
/*--------------------------------------------------------------------------*/
int linset_(int *lin)
{
return linset((struct linprm *)lin);
}
/*--------------------------------------------------------------------------*/
int linp2x_(
int *lin,
const int *ncoord,
const int *nelem,
const double pixcrd[],
double imgcrd[])
{
return linp2x((struct linprm *)lin, *ncoord, *nelem, pixcrd, imgcrd);
}
/*--------------------------------------------------------------------------*/
int linx2p_(
int *lin,
const int *ncoord,
const int *nelem,
const double imgcrd[],
double pixcrd[])
{
return linx2p((struct linprm *)lin, *ncoord, *nelem, imgcrd, pixcrd);
}
|