/*****************************************************************************\ * Truncation parameters are stored in their own truncation structures. * * But, because the components are coupled, and because of convolution * * issues when you have high resolution images, each component needs to have * * its own derivative images for the break and softening radii; they are * * stored in 'fpar->high' structures. The fit parameter block in * * 'fpar->high' is a clone of the main truncation function structure in the * * main object link list, 'fpar', identified as one of the components. * \*****************************************************************************/ #include #include #include "structs.h" int istrunc (char *objtype); struct fitpars *dup_one_obj (struct fitpars *fpar); void link_trunc_fpar (struct fitpars *fpar) { void link_fpar_high (struct fitpars *fpar, struct fitpars *trptr, int comps[]); struct fitpars *trptr; int i, j; trptr = fpar; /* Truncation pointer */ /*---------------------------------------------------------------\ | Now do the appropriate linking for the truncation parameters | \---------------------------------------------------------------*/ while (trptr != NULL) { if (istrunc (trptr->objtype)) { link_fpar_high (fpar, trptr, trptr->outer); link_fpar_high (fpar, trptr, trptr->inner); }; trptr = trptr->next; }; } /****************************************************************************\ * Creates a new truncation storage space in fpar->high for each object * * which is involved in linking. This new space stores a copy of * * the truncation function parameters to be optimized, back in the * * main 'fpar' structure. For instance, if the second Sersic component is * * involved in truncation, and the information about the truncation is * * stored as the 4th component in the main fpar object structure (i.e. * * fpar->objtype="radial"), then the Sersic component will have a high * * order struct, e.g. fpar->high->objtype="radial", which is a copy * * of that 4th component. * * * * The reason why this is necessary is explained above. * \****************************************************************************/ void link_fpar_high (struct fitpars *fpar, struct fitpars *trptr, int comps[]) { int i, j; struct fitpars *fptr, *new_tr; for (i=1; i <= comps[0]; i++) { /*------------------------------------------------------------------\ | Completely clone the truncation component and its high order | | structures that may also contain fourier or bending modes. | \------------------------------------------------------------------*/ new_tr = dup_one_obj (trptr); /*-------------------------------------------------------------------\ | The truncation "mirror" in fpar->high struct needs to keep track | | of the corresponding comp where the main truncation pars are | | stored. | \-------------------------------------------------------------------*/ new_tr->tr_num = trptr->compnum; /*------------------------------------------------------------------\ | Now advance down the list to find components that are involved | | in truncation. The component numbers are stored in comps[i]. | \------------------------------------------------------------------*/ fptr = fpar; /* fitpar pointer */ for (j=1; j < comps[i]; j++) fptr = fptr->next; /*------------------------------------------------------------------\ | This new structure now holding the truncation information is | | tacked on to THE END of the fpar->high structure, of the | | component involved in truncation. | \------------------------------------------------------------------*/ if (fptr->high != NULL) { fptr = fptr->high; while (fptr->next != NULL) /* Go to the end */ fptr = fptr->next; fptr->next = new_tr; } else fptr->high = new_tr; }; }