SUBROUTINE VMAP3S ( * * inputs * : NPTS, DIM, V2, V3, CT, DCT, EPOCH, : OKVAL, HITVAL, * * output * : COUNT, DCOUNT, FLAG, V2ARR, V3ARR, : SIDEPT, EPOMIN, EPOMAX, STATUS) * * Module number: 15.11.2.3.1.2 * * Module name: smaperloc * * Keyphrase: * ---------- * Take the one dimensional input data and the corrsponding V2, V3 coordinates * to construct two dimensional arrays of the count rates and the associated * coordinates. * * Description: * ------------ * * FORTRAN name: VMAP3S.FOR * * Keywords of accessed files and tables: * -------------------------------------- * Name I/O Description / Comments * * Subroutines Called: * ------------------- * CDBS: * None * SDAS: * UMSPUT * Others: * None * * History: * -------- * Version Date Author Description * 1 01-20-87 J.-C. HSU design and coding * 2 11-16-87 J.-C. HSU F77 SDAS *------------------------------------------------------------------------------- * *== input: * --total number of data points of the * --input time series INTEGER NPTS, * --dimension of COUNT, FLAG, V2, and V3 * --as declared in the calling routine : DIM * --input arrays of count rate, its standard * --deviation, V2 and V3 coordinates REAL CT(1), DCT(1), V2(1), V3(1), * --mask value of good points : OKVAL, * --mask value of particle events : HITVAL * --epoch of observation DOUBLE PRECISION EPOCH(1) * *== output * --observed (average) number of counts, * --its standard error, its flag and its * --coordinates of each point of the scan REAL COUNT(DIM, DIM), DCOUNT(DIM, DIM), : FLAG(DIM, DIM), : V2ARR(DIM, DIM), V3ARR(DIM, DIM) * --number of points on each side of the * --grid INTEGER SIDEPT, * --error status : STATUS * --epoch range DOUBLE PRECISION EPOMIN, EPOMAX * *== local: * --error status and loop indices INTEGER STATOK, I, J, K, * --number of points with same V3 coordinate : NCOL * --grid step sizes REAL DV2, DV3, * --V2, V3 limits : V2MIN, V2MAX, V3MIN, V3MAX, * --dummies : INDX, Y * --error message context CHARACTER*130 CONTXT *=========================begin hsp.inc========================================= * --status return code INTEGER OK, ERRNUM(20) * --message destination and priority INTEGER DEST, PRIO DATA OK /0/ DATA ERRNUM /701, 702, 703, 704, 705, 706, 707, 708, 709, 710, : 711, 712, 713, 714, 715, 716, 717, 718, 719, 720/ DATA DEST, PRIO /1, 0/ *=========================end hsp.inc=========================================== *------------------------------------------------------------------------------ * * check number of input data points must be a square of an integer and > 8 * SIDEPT = INT(SQRT(FLOAT(NPTS)) + 0.01) * IF (SIDEPT ** 2 .NE. NPTS .OR. NPTS .LT. 9) THEN STATUS = ERRNUM(1) CONTXT = 'number of input points is not a square or less ' : // 'than 9' GO TO 999 END IF * * look for minimum and maximum of V2 and V3 * V2MIN = V2(1) V2MAX = V2(1) V3MIN = V3(1) V3MAX = V3(1) * DO 10 I = 2, NPTS IF (V2(I) .LT. V2MIN) THEN V2MIN = V2(I) ELSE IF (V2(I) .GT. V2MAX) THEN V2MAX = V2(I) END IF * IF (V3(I) .LT. V3MIN) THEN V3MIN = V3(I) ELSE IF (V3(I) .GT. V3MAX) THEN V3MAX = V3(I) END IF 10 CONTINUE * * determine the grid step size(s) * DV2 = (V2MAX - V2MIN) / REAL(SIDEPT - 1) DV3 = (V3MAX - V3MIN) / REAL(SIDEPT - 1) * * rearrange the arrays to follow the order of increasing V2, V3: * DO 30 I = 1, SIDEPT Y = V3MIN + (I - 1) * DV3 NCOL = 0 * * for each row, find the points with same V3 coordinate * DO 20 J = 1, NPTS IF (ABS(V3(J) - Y) / DV3 .LT. 0.01) THEN NCOL = NCOL + 1 INDX = (V2(J) - V2MIN) / DV2 + 1.001 K = INT(INDX) * * for points withe the same V3 coordinate, check their V2 are at the grid * points * IF (ABS(REAL(K) - INDX) .LT. 0.01) THEN V2ARR(I, K) = V2(J) V3ARR(I, K) = V3(J) COUNT(I, K) = CT(J) DCOUNT(I, K) = DCT(J) FLAG(I, K) = OKVAL ELSE STATUS = ERRNUM(2) CONTXT = 'observed point is not at grid point' GO TO 999 END IF END IF 20 CONTINUE * * check each row has SIDEPT points * IF (NCOL .NE. SIDEPT) THEN STATUS = ERRNUM(3) CONTXT = 'observed point is not at a grid point' GO TO 999 END IF 30 CONTINUE * * find the range of epoch * EPOMIN = EPOCH(1) EPOMAX = EPOCH(1) DO 40 I = 2, NPTS IF (EPOCH(I) .LT. EPOMIN) THEN EPOMIN = EPOCH(I) ELSE IF (EPOCH(I) .GT. EPOMAX) THEN EPOMAX = EPOCH(I) END IF 40 CONTINUE * STATUS = OK GO TO 1000 * * write error message * 999 CALL UMSPUT ('VMAP3S: ' // CONTXT, DEST, PRIO, STATOK) * 1000 RETURN END