#include "fitsio.h" #define OFFSET 1 #define REAL 1 #define COMPLEX 2 #define NBASIC 10 #define NPARS 10 /********************************************************\ * Holds the primary input parameters specified by user * \********************************************************/ struct inpars { char initparfile[FLEN_FILENAME]; /* name of the prepared input file */ char data[FLEN_FILENAME]; char output[FLEN_FILENAME]; char sigma[FLEN_FILENAME]; char psf[FLEN_FILENAME]; char kernel[FLEN_FILENAME]; /* Diffusion kernel */ char constraints[FLEN_FILENAME]; /* Name of the file with constraints */ int sampfac; char badpix[FLEN_FILENAME]; char imgsect[70]; /* image section to fit */ float cboxcent[3]; /* convolution box center */ int convbox[3]; /* convolution box size */ float magzpt; /* magnitude zeropoint */ float d[3]; /* plate scale */ char device[10]; /* scrolling display type */ int create; /* A boolean to see whether to */ /* just create a model. */ }; /*******************************************************************\ * NOTE: "**z" and "*flux" will point to the SAME memory address. * * Therefore if the flux changes in vector *z, so will **flux * * and vice versa. ALL the arrays will use a one-offset * * convention * \*******************************************************************/ /* All the arrays will use a ONE-OFFSET Fortran convention */ struct image { char name[FLEN_FILENAME]; float **z; /* flux at pixel (x,y) */ long naxes[3]; /* X and Y dimensions. Do not use naxes[0] */ char imgsect[70]; /* section cut-out from the original image */ float exptime; /* image exposure time of the original image */ float magzpt; /* magnitude zeropoint of the original image */ float muzpt; /* mag/arcsec^2 zeropoint */ float dp[3]; /* arcsec per pixel. Do not use dp[0] */ float gain; /* gain of the image in electrons/adu */ float rdnoise; /* readnoise of the image in electrons */ int nread; /* Number of non-destructive reads */ int nsamp; /* Number of intermediate exposure time samples */ float ncombine; /* number of images combined to make up the current */ int err; /* Error code, when the image is blank. */ char logfile[20]; /* galfit output log file. */ }; struct sampars { int nobjs; /* Number of objects being fitted (including sky) */ long nmask; /* Total number of pixels masked out. */ }; /***********************************************************\ * Arrays holding the derivative of the flux at each pixel * * with respect to each of the parameters being fitted. * \***********************************************************/ struct derivs { char imgsect[70]; /* The section in the fitting region where */ /* one should copy the derivative images */ /* back into. */ long naxes[3]; /* The dimension of the derivative images. */ float ***dpm; /* 2-D image stack */ struct derivs *high; /* Higher order derivative images. */ struct derivs *next; }; struct fitpars { int compnum; /* Component number */ char objtype[20]; /* Sersic, Nuker, Expdisk, deVauc, Gaussian, */ /* Moffat, King, Sky, Radial, Length, Height. */ int normtype; /* How the flux is normalized: 0=total mag, */ /* 1=central surface brightness, 2=effective */ /* radius, 3=break radius. */ int *outer; /* Components w/ outer taper (only used by links) */ int *inner; /* Components w/ inner taper (only used by links) */ float *a; /* Parameters 1-10 are classical. */ float *sig; /* Parameter uncertainties. */ int *ia; /* 1 = fit parameter, 0 = hold parameter fixed */ /* -1 = not used. */ int npars; /* Total number of parameters in this set. */ int outtype; /* How to deal with the output of this object: */ /* 0 = create normal residual image. */ /* 1 = Do not remove this component in the resid. */ int tr_num; /* The truncation comp. number that this struct */ /* is associated. It's only used in fpar->high */ struct derivs *dp; /* Points to the derivative image pointer that */ /* this object corresponds to. */ struct fitpars *high; /* Higher order deviations. */ struct fitpars *next; /* Next object. */ }; /*************************\ * Parameter constraints * \*************************/ struct cons { int *comp; /* Component number involved. */ char parname[10]; /* Parameter name involved, in the intuitive */ /* scheme, as opposed to the one just below. */ int *par; /* An index that points to the appropriate param */ /* in the array of parameters, a[], used by */ /* subroutines mrqmin, mrqcof, and constraint. */ char op; /* operation */ float *cval; /* Constraint values (min, max) */ int ncomp; /* Number of components involved in constraints */ struct cons *next; }; /**************************\ * Convolution parameters * \**************************/ struct convpars { float cent[3]; /* x and y position of the convolution box */ int boxsz[3]; /* This is the valid length and width of the */ /* convolution region. It's equal to */ /* inpars.convbox if it can fit within the image. */ char imgsect[70]; /* Image section (relative to cut-out stamp */ /* coordinates) used in convolution. */ int sampfac; /* PSF sampling factor */ long psfsz[3]; /* x and y dimensions of the PSF image. */ }; /***************************************************************\ * Storage space for coefficients used to interpolate the PSF * * using bi-cubic interpolation. * \***************************************************************/ struct bicubic_grid { float **c; }; /***********************************************************************\ * Truncation things: constants for computing truncation derivatives, * * truncation link structures, and indices * \***********************************************************************/ struct trunc_val { int tilt; /* Same inclination as spiral disk? */ float gtr; float s; float tanh; float cosPA; float sinPA; float am; float dfnorm; /* When the flux is normalized at some radius. */ float P; float dfdam; /* df/dr for the trunc. function component. */ struct trunc_val *next; }; struct trunc_links { char *objtype; /* "radial", "height", or "length" */ int innout; /* Inner truncation = 0 or outer = 1 */ int lrtype; /* Trunc. length (1) or trunc. radius (2) */ /* as free parameters. */ int tilt; /* Same inclination as spiral disk? */ float *a; /* Truncation free parameters */ int *ia; /* Truncation fit flags */ struct fitpars *f; /* Truncation high order mode fit pars */ struct fitpars *r; /* Truncation coordinate rotation fit pars */ struct fitpars *b; /* Truncation bending mode fit pars */ struct fitpars *c0; /* Truncation diskyness/boxyness */ float *drd; /* Truncation dr/dro, dr/ddel, dr/dPA etc. */ float *fdrd; /* Truncation fourier dr/dmodes */ float *rdrd; /* Truncation coord. rot. dr/dbar, etc. */ float *bdrd; /* Truncation banana-fana indices */ float drdc; /* Truncation diskyness/boxyness dr/dc */ struct derivs *df; /* Truncation derivative images */ struct derivs *fdf; /* " */ struct derivs *rdf; /* " */ struct derivs *bdf; /* " */ struct derivs *c0df; /* " */ struct trunc_links *next; }; /***************\ * Input flags * \***************/ struct runflags { int noestsky; /* No sky estimation when creating sigma image. */ float skyped; /* Estimated sky pedestal for the purpose of */ /* creating a sigma image. */ float skyrms; /* Input sky RMS for the purpose of creating */ /* a sigma image. */ int outsig; /* Output sigma image. */ int interact; /* Interactive menu flag. */ }; /*******************************************************************\ * Precompute or store geometric parameters for tilt and rotations * \*******************************************************************/ struct rotpars { /* Traditional model parameters */ float xc; /* a[1] */ float yc; /* a[2] */ float q; /* a[9] */ float cosPA; /* cos (a[10]) */ float sinPA; /* sin (a[10]) */ /* Rotational parameters, e.g. for spiral: */ float rotang; /* r->a[3] */ float cosi; /* cos (r->a[9]) */ float sini; /* sin (r->a[9]) */ float cosskypa; /* cos (r->a[10]) */ float sinskypa; /* sin (r->a[10]) */ };