/***************************************************************************\ * Assign pointers to the appropriate truncation arrays and derivative * * images so they can be accessed more quickly. The values stored in * * trunc_pars->innout encodes the type of truncation: * * * * 0 = truncation has an inner truncation (e.g. ring). * * 1 = truncation has an outer truncation. * * * * Don't get these confused with tr_out->lrtype and tr_in->lrtype, which * * store info on whether the free parameters are softening length (1) vs. * * softening radius (2)... * * * * Also, don't get these confused with the value in trunc->tilt, which * * stores info on whether the truncation is tilted with respect to the * * disk (1) when fitting spiral arms, or with respect to the sky * * plane (0). * * * * For edge on disk galaxies, the length and width can be truncated * * separately. Each can have an inner or outer truncations, or both. * * Therefore, ttype is actually a bit complicated for edge-on disks, and * * has the following scheme: * * * * Type 1##, where # goes from 1 to 3, corresponding to the scheme * * defined above. The first index is for the height truncation, * * whereas the second is the length truncation. For instance: * * * * Type 101: No height truncation. Length has outer truncation. * * Type 123: Height has inner truncation. Length has inner & outer. * * Type 130: Height has both inner & outer trunc.. Length has none. * * * \***************************************************************************/ #include #include #include "structs.h" #include "nrutil.h" int istrunc (char *objtype); struct trunc_links *new_trunclink (); struct trunc_val *new_truncval (); void trunc_pars (char objtype[], int ia[], struct fitpars *fpar, struct derivs *df, struct trunc_links *trlinks, struct trunc_val *trval) { int i; struct fitpars *trf; struct derivs *trdf; if (fpar != NULL) /* df points at the object df images, */ df = df->high; /* not the truncation df images. */ while (fpar != NULL) { if (istrunc (fpar->objtype)) { /*---------------------------------------------------------\ | Tilt=1 trunc has PA and ellip. that are modulated by | | the tilt of the spiral component, whereas tilt=0 has | | tilt and PA and ellip. in the plane of the sky. | \---------------------------------------------------------*/ if (index (fpar->objtype, 'b') != NULL) trlinks->tilt = 0; for (i=1; i <= fpar->outer[0]; i++) { if (fpar->outer[i] == fpar->compnum) { /*-----------------------------------------------------\ | Check to see if a trunc_link structure is already | | in use. If so, create new one. | \-----------------------------------------------------*/ if (trlinks->objtype != NULL && istrunc(trlinks->objtype)) { trlinks->next = new_trunclink(); trlinks = trlinks->next; trval->next = new_truncval (); trval = trval->next; }; trlinks->objtype = fpar->objtype; trlinks->innout = 1; if (index (fpar->objtype, '2') != NULL) trlinks->lrtype = 2; trlinks->a = fpar->a; trlinks->ia = fpar->ia; trlinks->df = df; trlinks->drd = vector (1, fpar->npars); /*************************************************\ * Now do the same thing for the high order pars * \*************************************************/ if (fpar->high != NULL) { trf = fpar->high; trdf = df->high; while (trf != NULL) { if (strncmp (trf->objtype, "C0", 2) == 0) { trlinks->c0 = trf; trlinks->c0df = trdf; }; if (strncmp (trf->objtype, "four", 4) == 0) { trlinks->f = trf; trlinks->fdf = trdf; trlinks->fdrd = vector (1, trf->npars); }; if (strncmp (trf->objtype, "bend", 4) == 0) { trlinks->b = trf; trlinks->bdf = trdf; trlinks->bdrd = vector (1, trf->npars); }; trf = trf->next; trdf = trdf->next; }; }; }; }; for (i=1; i <= fpar->inner[0]; i++) { if (fpar->inner[i] == fpar->compnum) { /*-----------------------------------------------------\ | Check to see if a trunc_link structure is already | | in use. If so, create new one. | \-----------------------------------------------------*/ if (trlinks->objtype != NULL && istrunc (trlinks->objtype)) { trlinks->next = new_trunclink(); trlinks = trlinks->next; trlinks->next = NULL; trval->next = new_truncval (); trval = trval->next; }; trlinks->objtype = fpar->objtype; trlinks->innout = 0; if (index (fpar->objtype, '2') != NULL) trlinks->lrtype = 2; trlinks->a = fpar->a; trlinks->ia = fpar->ia; trlinks->df = df; trlinks->drd = vector (1, fpar->npars); /*------------------------------------------------\ | Now do the same thing for the high order pars | \------------------------------------------------*/ if (fpar->high != NULL) { trf = fpar->high; trdf = fpar->dp->high; while (trf != NULL) { if (strncmp (trf->objtype, "C0", 2) == 0) { trlinks->c0 = trf; trlinks->c0df = trdf; }; if (strncmp (trf->objtype, "four", 4) == 0) { trlinks->f = trf; trlinks->fdf = trdf; trlinks->fdrd = vector (1, trf->npars); }; if (strncmp (trf->objtype, "bend", 4) == 0) { trlinks->b = trf; trlinks->bdf = trdf; trlinks->bdrd = vector (1, trf->npars); }; trf = trf->next; trdf = trdf->next; }; }; }; }; }; fpar = fpar->next; df = df->next; }; } /**************************************************************************\ * If the light model is a spiral component, need to assign the tilt * * parameters (inclination and sky PA) to the truncation, so that it is * * tilted in the same way. This makes it more intuitive for users to * * think about if they want to create a ring in the spiral model. * \**************************************************************************/ struct fitpars *trunc_spiral (struct fitpars *r) { struct fitpars *tilt; int i; tilt = (struct fitpars *) malloc ((size_t)(sizeof (struct fitpars))); tilt->npars = 10; tilt->a = (float *) malloc ((size_t)(sizeof (float) * (tilt->npars+1))); tilt->ia = (int *) malloc ((size_t)(sizeof (int) * (tilt->npars+1))); tilt->sig = NULL; tilt->inner = NULL; tilt->outer = NULL; tilt->high = NULL; tilt->next = NULL; tilt->dp = NULL; strcpy (tilt->objtype, "none"); for (i=1; i <= 8; i++) { tilt->a[i] = 0.; tilt->ia[i] = 0; }; tilt->a[9] = r->a[9]; tilt->ia[9] = 0; tilt->a[10] = r->a[10]; tilt->ia[10] = 0; return (tilt); }