/**************************************************************************\ * Assign pointers to the appropriate hybrid arrays and derivative images * * so they can be accessed more quickly. * * * * Type 1 truncation has an inner truncation (e.g. ring). * * Type 2 truncation has an outer truncation. * * Type 3 truncation has both an inner truncation and an outer. * \**************************************************************************/ #include #include "structs.h" #include "nrutil.h" int hybpars (char objtype[], int ia[], struct fitpars *fpar, struct derivs *df, struct hyblinks *hout, struct hyblinks *hin, int *hybrid) { int i, ttype = 0; struct fitpars *hf; struct derivs *hdf; if (index (objtype, '/') != NULL && index (objtype, '\\') != NULL) { ttype = 3; } else if (index (objtype, '/') != NULL) ttype = 2; else if (index (objtype, '\\') != NULL) ttype = 1; if (fpar != NULL) /* df points at the object df images, */ df = df->high; /* not the hybrid df images. */ while (fpar != NULL) { if (strncmp (fpar->objtype, "hybrid", 6) == 0) { /*---------------------------------------------------------\ | Type 1 hybrid has PA and ellip. that are modulated by | | the tilt of the spiral component, whereas type 2 has | | tilt and PA and ellip. in the plane of the sky. | \---------------------------------------------------------*/ if (index (fpar->objtype, 'b') != NULL) *hybrid = 2; else *hybrid = 1; for (i=1; i <= fpar->outer[0]; i++) { if (fpar->outer[i] == fpar->compnum) { if (index (fpar->objtype, '2') != NULL) hout->type = 2; hout->a = fpar->a; hout->ia = fpar->ia; hout->ia[1] = ia[1]; hout->ia[2] = ia[2]; hout->df = df; hout->drd = vector (1, fpar->npars); /*************************************************\ * Now do the same thing for the high order pars * \*************************************************/ if (fpar->high != NULL) { hf = fpar->high; hdf = df->high; while (hf != NULL) { if (strncmp (hf->objtype, "C0", 2) == 0) { hout->c0 = hf; hout->c0df = hdf; }; if (strncmp (hf->objtype, "four", 4) == 0) { hout->f = hf; hout->fdf = hdf; hout->fdrd = vector (1, hf->npars); }; if (strncmp (hf->objtype, "bend", 4) == 0) { hout->b = hf; hout->bdf = hdf; hout->bdrd = vector (1, hf->npars); }; hf = hf->next; hdf = hdf->next; }; }; }; }; for (i=1; i <= fpar->inner[0]; i++) { if (fpar->inner[i] == fpar->compnum) { if (index (fpar->objtype, '2') != NULL) hin->type = 2; hin->a = fpar->a; hin->ia = fpar->ia; hin->ia[1] = ia[1]; hin->ia[2] = ia[2]; hin->df = df; hin->drd = vector (1, fpar->npars); /*************************************************\ * Now do the same thing for the high order pars * \*************************************************/ if (fpar->high != NULL) { hf = fpar->high; hdf = fpar->dp->high; while (hf != NULL) { if (strncmp (hf->objtype, "C0", 2) == 0) { hin->c0 = hf; hin->c0df = hdf; }; if (strncmp (hf->objtype, "four", 4) == 0) { hin->f = hf; hin->fdf = hdf; hin->fdrd = vector (1, hf->npars); }; if (strncmp (hf->objtype, "bend", 4) == 0) { hin->b = hf; hin->bdf = hdf; hin->bdrd = vector (1, hf->npars); }; hf = hf->next; hdf = hdf->next; }; }; }; }; }; fpar = fpar->next; df = df->next; }; return (ttype); } /**************************************************************************\ * If the light model is a spiral component, need to assign the tilt * * parameters (inclination and sky PA) to the hybrid, 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 *hyb_spiral (struct fitpars *r) { struct fitpars *tilt; int i; tilt = (struct fitpars *) malloc (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); }