SUBROUTINE ZSHFT(WAVE,FLUX,NS,WPROF,PROF,NP,MAXDEV,OFFSET, * WOFF,ISTAT) * * Module number: * * Module name: zshft * * Keyphrase: * ---------- * Compute spectral offset * Description: * ------------ * This routine computes the offset of a spectral line template * from its nominal position in an HRS observation. * * FORTRAN name: zshft.for * * Keywords of accessed files and tables: * -------------------------------------- * none * * Subroutines Called: * ------------------- * CDBS: * zcorel * SDAS: * umsput * Others: * * History: * -------- * Version Date Author Description * 1 Aug 88 D. Lindler Designed and coded *------------------------------------------------------------------------------- * * Input parameters * * WAVE - wavelength vector for the HRS observation (real*8) * FLUX - flux vector (real*8) * NS - number of points in WAVE and FLUX (integer) * WPROF - wavelengths for line profile (real*8) * PROF - line profile to be correlated with FLUX (real*8) * NP - number of points in WPROF and PROF (integer) * MAXDEV - maximum distance to search for correlation maximum (integer) * * Output parameters * * OFFSET - offset in sample or diode units (real*8) * WOFF - offset in wavelength units (real*8) * ISTAT - error status (integer) *------------------------------------------------------------------------------ C C UMSPUT DESTINATIONS -- CB, DAO, 4-SEP-87 C INTEGER STDOUT PARAMETER (STDOUT = 1) INTEGER STDERR PARAMETER (STDERR = 2) DOUBLE PRECISION WAVE(1),FLUX(1),WPROF(1),PROF(1),OFFSET,WOFF INTEGER NS,NP,MAXDEV,ISTAT C C LOCAL VARIABLES C INTEGER I,IPOS,NT,XSTEPS CHARACTER*130 CONTXT DOUBLE PRECISION TEMPLT(2000),WMIN,WMAX,DISP C C----------------------------------------------------------------------------- C C FIND RANGE OF INPUT DATA COVERED BY THE TEMPLATE C WMIN=WPROF(1) WMAX=WPROF(NP) IF(WMAX.LT.WMIN)THEN CONTXT='ERROR: Line profile table must be in ascending '// * ' wavelength order' GO TO 999 ENDIF DO 10 I=1,NS IPOS=I IF (WAVE(IPOS).GT.WMIN)GO TO 15 10 CONTINUE 15 NT=0 DO 20 I=IPOS,NS IF (WAVE(I).GT.WMAX)GO TO 25 NT=NT+1 20 CONTINUE 25 IF((IPOS.LT.MAXDEV).OR.((IPOS+NT+MAXDEV).GT.NS))THEN CONTXT='Error: Insufficient wavelength overlap between '// * 'data and template,' CALL UMSPUT(CONTXT,STDOUT+STDERR,0,ISTAT) CONTXT=' or template too near the edge of the '// * 'observation' GO TO 999 ENDIF C C RESAMPLE TEMPLATE TO MATCH THE WAVELENGTHS OF THE OBSERVATION C CALL ZLINTP(WPROF,PROF,NP,WAVE(IPOS),TEMPLT,NT,ISTAT) IF(ISTAT.NE.0)THEN CONTXT='Error interpolating template to match '// * ' the input observation' GO TO 999 ENDIF C C FIND THE OFFSET USING CORRELATION WITH THE TEMPLATE C CALL ZCOREL(FLUX,NS,TEMPLT,NT,IPOS,MAXDEV,OFFSET,ISTAT) IF(ISTAT.NE.0)THEN CONTXT=' ' GO TO 999 ENDIF C C COMPUTE DELTA WAVELENGTH USING AVERAGE DISPERSION C DISP = (WAVE(IPOS+NT-1)-WAVE(IPOS))/NT WOFF=OFFSET*DISP C C CHANGE OFFSET TO DIODE UNITS BY DIVIDING BY NUMBER OF XSTEPS C XSTEPS = NS/500 OFFSET=OFFSET/XSTEPS C C PRINT RESULTS C WRITE(CONTXT,99)OFFSET,WOFF 99 FORMAT(' COMPUTED OFFSET =',F8.3,' Diodes OR ',F9.4, * ' Angstroms') CALL UMSPUT(CONTXT,STDOUT,0,ISTAT) ISTAT=0 GO TO 1000 C C FINISHED C 999 CALL UMSPUT(CONTXT,STDOUT+STDERR,0,ISTAT) ISTAT=1 1000 RETURN END