static void _pgaxis (void) { char *opt; float x1, y_1, x2, y2, v1, v2, step; int nsub; float dmajl, dmajr, f_min, disp, orient; if (-1 == pop_5_floats (&dmajl, &dmajr, &f_min, &disp, &orient)) return; if (-1 == SLang_pop_integer (&nsub)) return; if (-1 == pop_5_floats (&x2, &y2, &v1, &v2, &step)) return; if (-1 == pop_5_floats (&x1, &y_1, NULL, NULL, NULL)) return; if (-1 == SLang_pop_slstring (&opt)) return; cpgaxis (opt, x1, y_1, x2, y2, v1, v2, step, nsub, dmajl, dmajr, f_min, disp, orient); SLang_free_slstring (opt); }
int closure ( const char ctypeS[9], double restfrq, double restwav, int naxisj, double crpixj, double cdeltX, double crvalX) { char ptype, sname[32], title[80], units[8], xtype, ylab[80]; int nFail = 0, restreq, stat1[NSPEC], stat2[NSPEC], status; register int j; float tmp, x[NSPEC], xmin, xmax, y[NSPEC], ymax, ymin; double cdeltS, clos[NSPEC], crvalS, dSdX, resid, residmax, spec1[NSPEC], spec2[NSPEC]; struct spcprm spc; /* Get keyvalues for the required spectral axis type. */ if ((status = spcxps(ctypeS, crvalX, restfrq, restwav, &ptype, &xtype, &restreq, &crvalS, &dSdX))) { printf("ERROR %d from spcxps() for %s.\n", status, ctypeS); return 1; } cdeltS = cdeltX * dSdX; spcini(&spc); if (ctypeS[5] == 'G') { /* KPNO MARS spectrograph grism parameters. */ spc.pv[0] = mars[0]; spc.pv[1] = mars[1]; spc.pv[2] = mars[2]; spc.pv[3] = mars[3]; spc.pv[4] = mars[4]; spc.pv[5] = mars[5]; spc.pv[6] = mars[6]; } /* Construct the axis. */ for (j = 0; j < naxisj; j++) { spec1[j] = (j+1 - crpixj)*cdeltS; } printf("%4s (CRVALk+w) range: %13.6e to %13.6e, step: %13.6e\n", ctypeS, crvalS+spec1[0], crvalS+spec1[naxisj-1], cdeltS); /* Initialize. */ spc.flag = 0; spc.crval = crvalS; spc.restfrq = restfrq; spc.restwav = restwav; strncpy(spc.type, ctypeS, 4); spc.type[4] = '\0'; strcpy(spc.code, ctypeS+5); /* Convert the first to the second. */ if ((status = spcx2s(&spc, naxisj, 1, 1, spec1, spec2, stat1))) { printf("spcx2s ERROR %d: %s.\n", status, spc_errmsg[status]); } /* Convert the second back to the first. */ if ((status = spcs2x(&spc, naxisj, 1, 1, spec2, clos, stat2))) { printf("spcs2x ERROR %d: %s.\n", status, spc_errmsg[status]); } residmax = 0.0; /* Test closure. */ for (j = 0; j < naxisj; j++) { if (stat1[j]) { printf("%s: w =%20.12e -> %s = ???, stat = %d\n", ctypeS, spec1[j], spc.type, stat1[j]); continue; } if (stat2[j]) { printf("%s: w =%20.12e -> %s =%20.12e -> w = ???, stat = %d\n", ctypeS, spec1[j], spc.type, spec2[j], stat2[j]); continue; } resid = fabs((clos[j] - spec1[j])/cdeltS); if (resid > residmax) residmax = resid; if (resid > tol) { nFail++; printf("%s: w =%20.12e -> %s =%20.12e ->\n w =%20.12e, " "resid =%20.12e\n", ctypeS, spec1[j], spc.type, spec2[j], clos[j], resid); } } printf("%s: Maximum closure residual = %.1e pixel.\n", ctypeS, residmax); /* Draw graph. */ cpgbbuf(); cpgeras(); xmin = (float)(crvalS + spec1[0]); xmax = (float)(crvalS + spec1[naxisj-1]); ymin = (float)(spec2[0]) - xmin; ymax = ymin; for (j = 0; j < naxisj; j++) { x[j] = (float)(j+1); y[j] = (float)(spec2[j] - (crvalS + spec1[j])); if (y[j] > ymax) ymax = y[j]; if (y[j] < ymin) ymin = y[j]; } j = (int)crpixj + 1; if (y[j] < 0.0) { tmp = ymin; ymin = ymax; ymax = tmp; } cpgask(0); cpgenv(1.0f, (float)naxisj, ymin, ymax, 0, -1); cpgsci(1); cpgbox("ABNTS", 0.0f, 0, "BNTS", 0.0f, 0); spctyp(ctypeS, 0x0, 0x0, sname, units, 0x0, 0x0, 0x0); sprintf(ylab, "%s - correction [%s]", sname, units); sprintf(title, "%s: CRVALk + w [%s]", ctypeS, units); cpglab("Pixel coordinate", ylab, title); cpgaxis("N", 0.0f, ymax, (float)naxisj, ymax, xmin, xmax, 0.0f, 0, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f); cpgaxis("N", (float)naxisj, ymin, (float)naxisj, ymax, (float)(ymin/cdeltS), (float)(ymax/cdeltS), 0.0f, 0, 0.5f, 0.0f, 0.5f, 0.1f, 0.0f); cpgmtxt("R", 2.2f, 0.5f, 0.5f, "Pixel offset"); cpgline(naxisj, x, y); cpgsci(7); cpgpt1((float)crpixj, 0.0f, 24); cpgebuf(); printf("Type <RETURN> for next page: "); (void)getchar(); printf("\n"); return nFail; }