NI IIo ~OF~ THE APPLICATION OF KRIGING IN THE STATISTICAL ANALYSIS OF ANTHROPOMETRIC DATA VOLUME III THESIS Michael Grant I" I . TTC" A Tr ii __DTIC. ELECTE APRIS 1990 DEPARTMENT OF THE AIR FORCE U AIR UNIVERSITY AIR FORCE INSTITUTE OF TECHNOLOGY Wright-Patterson Air Force Base, Ohio i-., ob&,- 49=6i, 90 04 13 192
111
Embed
INSTITUTE OF TECHNOLOGY of the Air Force Institute of Technology Air University ... XMAX,YMAX: maximum values for x,y XMIN,YMIN: minimum values for x,y */ #define NX 100
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
NI
IIo
~OF~
THE APPLICATION OF KRIGINGIN THE STATISTICAL ANALYSISOF ANTHROPOMETRIC DATA
VOLUME III
THESIS
Michael GrantI" I . TTC" A Tr
ii __DTIC.
ELECTEAPRIS 1990
DEPARTMENT OF THE AIR FORCE UAIR UNIVERSITY
AIR FORCE INSTITUTE OF TECHNOLOGY
Wright-Patterson Air Force Base, Ohio
i-., ob&,- 49=6i, 90 04 13 192
AFIT/GOR/ENY/ENS/90M-8
THE APPLICATION OF KRIGINGIN THE STATISTICAL ANALYSISOF ANTHROPOMETRIC DATA
VOLUME III
THESIS
Michael GrantCaptain, USAF
AFIT/GOR/ENY/ENS/90M-8 jTC -OTICELECTE
S APR16 190D
Approved for public release; distribution unlimited
SECURITY CLASSIFICATION OF THIS PAGESForm Approved
REPORT DOCUMENTATION PAGE FMr No. Ao74-08e8
a. REPORT SECURITY CLASSIFICATION lb. RESTRICTIVE MARKINGS
UNCLASSIFIED -- -_-_-- -_- -_-_-_ I
2a. SECURITY CLASSIFICATION AUTHORITY 3. DISTRIBUTION /AVAILABILITY OF REPORTApproved for public release;
2b. DECLASSiFICATION / DOWNGRADING SCHEDULE distribution unlimited
4. PERFORMING ORGANIZATION REPORT NUMBER(S) S. MONITORING ORGANIZATION REPORT NUMBER(S)
AFIT/GOR/ENY/ENS/90M-8
6a NAME OF PERFORMING ORGANIZATION 6b. OFFICE SYMBOL 7a. NAME-O'F MONITORING ORGANIZATION(f applicable)
School of Engineering I6c. ADDRESS (City, State, and ZIP Code) 7b. ADDRESS(City, State, and ZIP Code)
Ba. NAME OF FUNDING/SPONSORING 8b. OFFICE SYMBOL 9. PROCUREMENT INSTRUMENT IDENTIFICATION NUMBERORGANIZATION (If applicable)
AAMRL HEG
8C. ADDRESS (City, State, and ZIP Code) 10. SOURCE OF FUNDING NUMBERSPROGRAM PROJECT TASK WORK UNITAAMRL/HEGIEMLEMENT NO, NO. NO. ACCESSION NO.WPAFB, OH 45433
11. TITLE (Include Security Classification)THE APPLICATION OF KRIGING IN THE STATISTICALANALYSIS OF ANTHROPCMETRIC DATA
12. PERSONAL AUTHOR(S)
Michael Grant, B.S., M.S., Capt, USAF13a. TYPE OF REPORT 13b. TIME COVERED 14. DATE OF REPORT (Year, Month, Day) 15. PAGE COUNT
MS Thesis FROM __ _ TO --_ l 43016. SUPPLEMENTARY NOTATION
17. / COSATI CODES 18. SUBJECT TERMS (Continue on reverse if necessary and identify by block number)
FIELD GROUP SUB-GROUP >Kriging- Bayesian Statistics-i Morphometrics12 03 Geostatistics; Multivariate Analysis, j
19. ABSTRACT (Continue on reverse if nocecciry, and identi.fy b--.ck n'-.'ber)
Thesis Advisors: David G. Robinson
Assistant Professou
Department of Aeronautics and Astronautics
Kenneth W. BauerAssistant ProfessorDepartment of Operational Sciences
20. DISTRIBUTION/AVAILABILITY OF ABSTRACT 21. ABSTRACT SECURITY CLASSIFICATION
M UNCLASSIFIED/UNU-MITED 0 SAME AS RPT. - DTIC USERS UNCLASSIFIED22a. NAME OF RESPONSIOJLE INDIVIDUAL 22b. TELEPHONE (Include Area Code) 122c OFFICE SYMBOL.
David G. Robinson, Asst. Profe3Eor (513) 255-2362 1 AFIT/ENYDO Form 1473, JUN 86 Pr,,vious editions are obsolete. SECURITY CLASSIFICATION OF THIS PAGE
al
-UNCLASSIFIED
Quality flight equipment is essential to flight crew safety andperformance. Oxygen masks, night-vision goggles, and other apparatusmust fit crew members comfortably and with complete functional precision.A problem currently facing the Air Force is the inconsistent quality offlight equipment. As new equipment is developed to improve crew members'performance, the requirement for design engineers-to accurately accountfor the shape and variability of facial features becomes more critical.
This thesis develops theapplication of kriging in the statisticalanalysis of anthropometric data to support improvements in the design of
- flight equipment. Specifically, the geostatistical estimation techniqueof kriging is used to estimate the facial surfaces which influence thedesigns of flight apparatus. These surfaces account for the shape of thefacial features and minimize uhe variance between individuals. A Kalmanfilter is developed to update and aggregate the kriged surfaces. As aproof of concept study, the techniques are demonstrated using data tosupport the design of the night-vision goggles currently under development.To further enhance the surface estimates, a multivariate analysis is performedto identify the factors which account for the majority of the variabilitybetween faces and to group the faces into homogenous clusters.
J i I/ __ 6
7/
, • l-- III II7
I I'.
AFIT/GOR/ENY/ENS/90M-8
THE APPLICATION OF KRIGING IN THE STATISTICAL
ANALYSIS OF ANTHROPOMETRIC DATA
VOLUME III
THESIS
Presented to the Faculty of the School of Engineering
of the Air Force Institute of Technology
Air University
In Partial Fulfillment of the
Requirements for the Degree of
Master of Science in Operations Research Aeo9664ton Jpor... •
DlTI$ UBI
Michael Grant, B.S., M.S. Justlfilatio
Captain, USAF1)i
. ---LAva11bt•ity Codea
Avall and/or
March 1990 Dia/t $Poo ---
Approved for public release; distribution unlimited
Appendix F. Data Alignment and Manipulation Programs
The program contained in this appendix was used for labelling the coordinates
of the aligned data points. The alignment program is not included in this thesis.
However, the program and user documentation are available through Major David
G. Robinson (AFIT/ENY).
F-I
Coordinate Labelling Program
This program reads from sXXX.align files and writes to the fXXX files.
Basically, the sXXX.align file contains the output from the alignment program.
Each record consists of the angle, altitude, and radius (followed by three dummy
variables which are not used) for a particular point. The following records are a
printf("7..4f %.4f %.2f %.2f %.2f\nle, x, y, ps->angle, ps->latitude,ps->radius);
ps = ps->next;I' while (ps != NUTQ~;
void Stat(i~j,ps)mnt i~j;struct point *ps;
float X'y;float mean, var;
float sum, surn2;int kntr;
x= XMIN+(i-.5)*DX;
y= YMIN+(j- .5)*DY;
sum - 0.;sum2 = 0.;kntr = 0.;mean = 0.;var = 0.;
if(ps != NULL){do
sum += (ps->radius);sunt2 += (ps->radius *ps->radius);kntr++;
ps = ps->next;}while (ps != NULL);
mean =sum/kntr;var =sum2/kntr - (mean*mean);printf("%d %d %/5.4f %5.4f %5.2f %5.2f %d\n", i,j, x, y, mean, var, kntr);
elseprintfQ'%d %d %.4f %.4f %.2f %.2f Wdn", i,j, x, y, mean, var, kntr);
F- 6
Appendix G. Structural Analysis Programs
The programs contained in this appe-idix were used in performing the struc-tural analysis of the data. Specifically, this appendix includes the programs forforming the grids, removing the trend, calculating the experimental variograrns, andestimating the model parameters.
C-I
Model Fitting Program
The model fitting program is written in FORTRAN. Data is read from the
output files of the experimental variogram program contained in the next section.
Each record consists of h (distance), -y(h), and the number of points used in deter-
mining 7 (h). The number of records for ea,'h subject is 40-4 directions times 10
lags. This program will also fit the models -,)r the overall variogram. A program for
consolidating the variogram data for an-, given number of subjects is provided later
in this appendix. The output of this prograim includes the parameter estimates for
the linear, De Wijsian, and spherical r "diels and the associated r-squared values.
The code for this program begins on the next page.
G -2
PROGRAM MAIN
C* THIS PROGRAM FITS A LINEAR, DE WIJSIAN, AND SPHERICAL MODEL *C
0* THIS ROUTINE ALLOWS THE USER TO ENTER THE FILE NAM±it OF *00* THE DATA FILES FROM THE TERMINAL OR TO READ THEM FRCI' *00* THE DEFAULT FILE (SPHERE.SET) *0
CHARACTER ANSWER*3, FILIN*32, FILOUTS*32WRITE(6,*)'DO YOU WANT TO SPECIFY THE FILES FROM THE TERMINAL?'WRITE(6, *)'I(ENTER YES IF SO; ELSE, kJVAFAULT - SPHEJRE. SET)'n-lEAD(5, '(A3)') ANSWER
IF (ANSWER.EQ.'YES') THENWRITE(6,*)'ENTER THE NAME OF THE INPUT- FILE'READ(5,' (A22)') FILINWRITE(6,*) 'ENTER THE NAME OF THE OUTPUT FILE'
END IFOPEN(10,FILE=FILIN.STATUS='OLD')OPEN(11 ,FILE=FILOUT,STATUS='NEW')RETURNEND
SUBROUTINE INPUT
0* THIS ROUTINE READS IN THE DATA FROM THE FILE S)Pý2IYFIED *00* H - THE DISTANCE *00* GAMMA (H - THE VARIOGRAM *00* WEIGHTS(H) - THE NUMBER OF POINTS USED FG:3 '2-AMM*A(H) *0
C* THIS SUBROUTINE WAS ADAPTED FROM NUMERICAL RECIPES, THE ART *CC* OF SCIENTIFIC COMPUTING, PP. 35-36. THE ARRAY, A, IS RE- *CC* ARRANGED AS ITS LU DECOMPOSITION. INDX IS A VECTOR WHICH *CC* RECORDS THE ROW PERMUTATION. D IS + OR - TO INDICATE EVEN *CC* OR ODD NUMBER OF ROW CHANGES. THIS SUBROUTINE IS USED WITH *CC* LUBKSB. *C
IF (ABS(A(I,J)).GT.AAMAX) AAMAX=ABS(A(I,J))10 CONTINUE
IF (AAMAX.EO.O.) WRITE(01.4) 'SINGULAR MATRTX.'VV(I)=I./AAMAX
20 CONTINUEDO 90 J=1,N
IF (J.GT.1) THENDO 40 I=1,J-I
SUM=A(I,J)IF (I.GT.1) THEN
DO 30 Klzl,I-iSUM=SUM-A(I,K)*A(K,J)
30 CONTINUE
A(I,J)=SUMENDIF
G-7
40 CONTINUEENDI FAAMAX=0.DO 60 I=J,N
SUM=A(I,J)IF (J.GT,1) THEN
DO 50 K=1,J-1
SUM=SUM-A(I ,K)*A(K, J)50 CONTINUE
A(IJ)=SUMENDIFDUM=VV (I) *ABS (SUM)IF (DUM.GE.AAMAX) THEN
IMAX=IA AMA X =DUM
END IF60 CONTINUE
IF (J.NE.IMAX) THEN
DO 70 K=1,NDUM=A(IMAX,K)
A(IMAX,K)=A(J,K)A(J,K)=DUM
70 CONTINUED=-DVV(IMAX)=VV(J)
ENDIFINDX(J)=IMAXIF (J.NE.N) THEN
IF (A(J,J).EQ.0.) A(J,J)=TINY
DUM=1 ./A(J,J)DO 80 I=J+I,N
A(I,J)=A(I,J)*DUM
80 CONTINUE
ENDIF90 CONI!INUE
IF (A(N,N).EQ.0.) A(N,N)=TINYRETURNEND
SUBROUTINE LUBKSB
C* THIS SUBROUTINE WAS ADAPTED FROM NUMERICAL RECIPES THE ART *C~
G-8
C* OF SCIENTIFIC COMPUTING, PP. 36-37. A AND INDX ARE DETER- *CC* MINED IN LUDCMP. B IS THE RIGHT HAND SIDE VECTOR INITIAL- *CC* LY AND THEN BECOMES THE SOLUTION VECTOR. THIS ROUTINE CAN *CC* BE CALLED SUCCESSIVELY WITH DIFFERENT B VECTORS. *C
COMMON/LU/N, A(3,3), INDX(3), VV(3), B(3), DII-0
DO 20 I=I,NLL=INDX(I)SUM=B(LL)B(LL)=B(I)IF (II.NE.O)THEN
The variogram calculation program reads from the grid files produced with
either the FORTRAN or C GRID programs. The output file consists of h, -y(h), and
the number of points used in determining y(h). A file for input to the IDL variogram
procedure is also generated.
The code is provided beluw.
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC THIS PROGRAM WAS V3ED TO DETERMINE THE VARIOGRAMS FOR THE FINAL CC FACES. THE RESIDUALS ARE LOCATED IN [MGRANT.RESIDUALS]. THE CC OUTPUT IS LOCATED IN [MGRANT.VARIOGRAMS]. THIS FILE READS FROM CC VARIO.SET AND THE RESIDUAL FILE. THE GRID CONTAINS VALUES IN A CC 100 BY 50 ARRAY. 13 JAN 90 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
COMMON RVALUE(2QO0oOO),TEMP(2,400,400),NPTS(400),MAX,MDIR,MLAG,1NOFH,GAMMA,NROW,NCOL,NDI1G,AVGR,A(4),ISTAT,IDLFLAG
INOFH,GAMMA,NROW,NCOL,NDIAG,AVGR,A(4),ISTAT,IDLFLAGCHARACTER FILIN*32,FILOUT*32,ANSWER*3,IDLOUT*32WRITE(*,*) 'INPUT THE NAME OF THE INPUT FILE'READ(*,'(A32)') FILINWRITE(*,*) 'INPUT THE NAME OF THE OUTPUT FILE'
G-12
READ(*, '(A32)') FILOUTWRITE(*,*) 'DO YOU WANT TO CREATE AN IDL FILE?'READ(*, '(A3)') ANSWERIF (ANSWER.EQ.'YES') THEN
WRITE(*',*) 'INPUT THE NAME OF THE IDL FILE'READ(*, '(A32)') IDLOUTOPEN(12,FILE=IDLOUT,STATUS= 'NEW')T')LFLAG = 1
C MAX -INDICATES THE MAXIMUM NUMBER OFDATA POINTSC MDIR -THE NUMBER OF DIRECTIONSC KLAG -THE NUMBER OF LAGSC NROW -THE NUMBER OF ROWSC NCOL -THE NUMBER OF COLUMNSC ISTAT -=1 IF AVERAGE RADIUS IS TO BE CALCULATED
IF(IDIR.EQ.1.AND.ILAG.EQ.1) THENIF(ISTAT.EQ.1) THEN
WRITE(11,*)'AVERAGE RADIUS = ',AVGRWRITE(li ,*)
END IFWRITE(11,*)'DIRECTION LAG A GAMMA NPTS
ENDIFWRITE(11 ,900)IDIR,ILAG,ILAG*A(IDIR) ,GAMMA,NOFHTP (TnT.FTAn rn I ) THEN
WRITE(12,910)ILAG*A(IDIR) ,GAMMA,NOFHENDIF
900 FO.RMA-T(5X,I1,7X,I3,5X,F7.2,6X,F7.2,4X,I4)
910 FORl4AT(F7.2,6X,F7.2,6X,I5)RETURNEND
G-17
C Program for Removing Trend
This program reads in the output of the coordinate labelling program for both
the subject and the average face. The data is stored in two arrays and differenced
to obtain an array of residuals. The output is similar to the two input files in that
it follows the same grid structure. This output file is used as input to the plotting
routines provided in Appendix i.
The code is provided below.
/*
This program reads in the output of f ill.c f or both the mean faceand a subject into two NROW by NCOL arrays. The mean values are thensubtracted from the subject values to produce a grid of residualswhich can be used for plotting or as data for the variogram programs.
To run this program, type:
differ.x <subject fn> <mean face fn> <output fn>
*/
#include<math.h>
#define NROW 100#define NCOL 50
main (argc, argv)int argc;char *argv[]);
int i,j,k,irow,icol,NUM;float x,y,z,dl,d2,float Grid [NROW] [NCUL];
G-18
float Mean..Face ENROW] ENCOL);float Subj ect [NRa WI ENCOL) ;
This program is a FORTRAN version of the preceeding program. The input
and output files are identical to the files described in the previous section.
The code is as follows.
PROGRAM MAINDIMENSION GRID(200,200), FACE(200,200), RMEAN(200,200)CHARACTER INFILE1*32, INFILE2*32, OUTFILE*32WRITE(6 *) ' THIS PROGRAM FORMS A GRID OF RESIDUALS FOR EACH FACE'WRITE(6,*) I IWRITE(6,*) ' ENTER THE NAME OF THE INPUT FILE FOR THE FACE'READ(5,'(A32)') INFILE1WRITE(6,*) 'ENTER THE NAME OF THE INPUT FILE FOR THE MEAN'READ(5,'(A32)') INFILE2WRITE(6,*) ' ENTER THE NAME OF THE OUTPUT FILE'READ(5,'(A32)') OUTFILEWRITE(6,*) 'ENTER THE GRID DIMENSIONS ENROW NCOL]-READ(5,*) NROW, NCOLOPEN(10,FILE=INFILE1,STATUS='OLD')OPEN(1i,FILE=INFILE2,STATUS='OLD')OPEN(12,FILE=OUTFILE,STATUS='NEW')TNVU--fTU WL T•TU
DO 20 I=1,NROWDO 10 J=1,NCOL
GRID(I,J)=O.OFACE(I,J)=O.ORMEAN(I,J)=O.O
10 CONTINUE20 CONTINUE
DO 30 I=I,NUMREAD(1O,*,END=40) IROW,ICOL,X,Y,ZFACE(IROW+I,ICOL+I)=Z
This is the FORTRAN version of tbc. preceeding program.
PROGRAM MAINDIMENSION GRID (200,200)
CHARACTER INFILE*32, OUTFILE*32WRITE(6,*) 'THIS PROGRAM FORMS A GRID FOR THE FACES'WRITE(6,*) IWRITE(6,*) 'ENTER THE NAME OF THE INPUT FILE'READ (5, '(A32)') INFILE
WRITE(6,*) ' ENTER THE NAME OF THE OUTPUT FILE'READ(S, '(A32)') OUTFILEWRITE(6,*) 'ENTER THE GRID DIMENSIONS [NROW NCOL]'READ(5,*) NROW, NCOLOPEN(lO ,FILE=INFILE,STATUS='OLD')
This program consolidates the output of the experimental variogram program.
The files to be combined are specified in a list.X file which is passed as an argument
in the execution command. The code for this program is as follows.
This program combines the variogram data for a specified numberof subjects and directions in the proper format for input intothe model fitting program.
To run this program, type:
con.x <filename>
*/
#include <stdio.h>#include <math. h>
NPTS: the number of points in each variogram fileMAXYlIR- .hba mAyimum •miml- -F '11-t f4il-e
VPTS: the number of points in each direction of a file*1
#define NPTS 40#define MAXSUBS 30#define VPTS 10
main (argc,argv)int argc;char *argv[];
/*
G-26
i,j: loop variablesnosub: number of subject files in the input filehE][10: the distanceg[][[1: gamma(h)n[10: the number of points used in the ganuna(h) calculationsubject-.name[]: temporary variable for subject file names
The appendix includes the kriging programs. The first program is the C pro-
gram for kriging the residuals. The second program verifies the results of the first
program and corrects for numerical difficulties. The last program combines the
kriged surfaces with the trend which was removed during the kriging process. The
first several comment line, f each program provide user instructions. The code may
be obtained by contacting Major Robinson.
H-i
C Program for Kriging
This program det •rmines the estimate and the estimation variancefor the value al each mid point of the grid for each data set.Currently, the piugram performs universal kriging with thex and y terms present for the linear drift. This program readsin the data set values, adjusts for the trend by subtracting themean values for the sample faces, and kriges the residuals toobtain the estimates and the variances.
NX,NY: number of increments on the x,y axesXMAX,YMAX: maximum values for x,yXMIN,YMIN: minimum values for x,yDX,DY: the length of the increments for the x,y axesKX,KY: scale parameterss for x,y axesIA: the integer value which defines the zone of influenceA: the zone of influence (range)C: the sill minus the nugget effect (sill - CO)CO: the nugget effect
HI-2
MAXKPTS: the maximum number of known points in a zone
[Note: IA and MAXKPTS are related in that if IA islarge, kpts could possibly exceed the value ofMAXKPTS. The trade-off is between estimation errorand computational efficiency. Reference documentationfor more information.]
*/
#define NX 100#define NY 50#define XMAX 4.#define XMIN 0.#define YMAX 300.#define YMIN 100.#define DX (XMAX-XMIN)/NX#define DY (YMAX-YMIN)/NY#define KX (1.0)/(DX)#define KY (1.0)/(DY)#define IA 7#define A 6.645#define C 2.226#define CO 0.689#define MAXKPTS 200
/*The following are global variables.
kpts: the number of points in the gamma structuredelta: the value to decrement IA if kpts > MAXKPTSMean-Face [I [I: the array of means for the mean faceSample[][]: the known points in a zoneMatA[][]: the A matrix in the AX=B format for the kriging systemMatB[]: the B matrix in the AX=B format for the kriging systemMatX[]: the X matrix in the AX-B format for the kriging systemGrid[][][]: the array of kriged estimates and variances
int kpts,delta;float Sanple[MAXKPTS] [3];float MeanFace[NX] [NY];float MatA[MAXKPTS+3] [MAXKPTS+31;
H-3
float MatB[MAXKPTS+3];
float MatX[MAXKPTS+3];
float Grid [2] [NX] [NY];
The dimension for the Mat* matrices allows for 3 more
terms than the number of points in a sample:
I - one for the row and column of ones,
2 - one for the x term for the linear drift, and3 - one for the y term for the linear drift.
struct point {float angle, latitude, radius;struct point *next;
/*This routine reads in the data. This routine was adapted fromDr. David G. Robinson's fill.c program.
The following are local variables.
i,j,k: loop variablesm,n: block labeL3npts: number of data points for a single data setnosub: number of subject data files to be readx: angley: altitudez: radiusdld2,d3: dummy variablessubject-name: name of the subject data file to be read
int i,j,k,m,n;int npts, nosub;float xy,z;float dl, d2, d3;char subject-name[I0];
FILE *fins, *fin;
struct point *temp;
/* initializing pointers to NULL */
H-6
for (i=O; i<NX; i++)for(j=O; j<NY; j++)point..array [ii [j] =NULL;
fins = fopen(argl,"r");fscanf(fins,"Yd\n" ,knosub);
for (k=O ;k<nosub ;k++) ffsca~nf(fins,"Ys YWdn",subject-.name, &npts);
fin = fopen(subject-.name,'r");
for (i-0; i<npts; i++) f
f scanf (f in, "%f %f %f %~f %~f %f \n", &x, &y, kz, &dl, &d2, &d3);
m = (int)(NY*(y-YMIN)/(YMAX-YMIN));n = (int)(NX*(x-XMIN)/(XMAX-XMIN));temp = (struct point *)malloc(sizeof(struct point)),
if( (m>0O)&&(n>0O)){if (temp != NULL){
temp->angle = Xtemp->latitude = y
temp->radius w =
temp->next = point-.array [n] [m];
point-.array~n] Fm] = temp;
fclose(f in);
void Mean-In(arg2)char *arg2;
This routine reads in the means for each grid point from
H-7
the mean face. The mean face is the average value of ea:h
This routine fills the Sample array with the points within a
zone. The mean values (Mean-.FaceE [I [D are subtracted from the
data to produce the residual values.
The following are local variables.
x: x coordinate of the (ij) block midpointy: y coordinate of the (i,j) bbnck midpointh: 'the distance between any t pointstempl,temp2: temporary variablus
If the value of radius = 0, the mean is not subtractedbecause subtracting the mean would provide a largeresidual which would then be kriged and readded tothe mean resulting in a value almost double what itshould be.
H1-10
kpts++;}
else {printf("Note: A sample point coincides with a grid point\n");
}
ps = ps->next;} while ((ps!-NULL)k&(kpts<MAXKPTS));} -
void BuildA()
/*
This routine builds the A matrix of the kriging equations.
The following are local variables.
i,j: loop variablestempl,temp2,gamma: temporary variablesh: the distance between any two points
*/
int i,j;double h,tenpi, temup2,•dmma ;
/*This portion completes the gamma structure of A.
This routine builds the B matrix of the kriging equations.
The following are local variables.
ii: loop variablex: x coordinate of the (i,j) block midpointy: y coordinate of the (i,j) block midpointh: the distarce betweein any two pointstempi,temp2,gamma: temporary variables
/* argc is a counter from the command line, its the number of argv variables *//* argv[O] contains the program name, it's a string */
/* Krerror: .1/, allows gracefull exit from program in case of serious error *//*******************************************************************/*void Krerror(errortext)char error-text [];{
This program reads in the output of krige.c and verifies the meansand variances to ensure numerical problems weren't encountered.If the values are wrong, new estimates are obtained by krigingthe neighboring values.
NROW,NCOL: number of increments on the x,y axesMAXMN: the tolerance on the kriged residualsDELTA: the parameter which defines the neighborhood for krigingX4AXYMAX: maximum values for xyXMIN,YMIN: minimum values for x,yDX,DY: the length of the increments for the x,y axesKX,KY: scale parameters for x,y axesMAXPTS: the maximum number of points in a zone
#define KX (1.0)/(DX)#define KY (1.0)/(DY)#define MAXPTS 200
The following are global variables.
num: the number of sampled pointsSample[I[[: the known points in a zoneMatA[][]: the A matrix in the AX=B format for the kriging equationsMatB[: the B matrix in the AX=B format for the kriging equationsMatX[ i: the X matrix in the AX=B format for the kriging equations
int num;float Sample[MAXPTS] [3);float MatA[MAXPTS+3] [MAXPTS+3];float MatB[MAXPTS+3];float MatX[MAXPTS+3];
main(argc,argv)i-r4 argc;
char *argv[];
/*
This is the main portion of the program.
The following are local variables.
i,j,k,irow,icol,i1,jj: loop variablesnumbad: counts the number of points which are out of toleranceiilow,iihigh,jjlow,jjhigh: ranges for loop variables ii,jjx,y: grid point coordinatessumvarsum: temporary variablesGrid[][][]: output means and variancesMean[] [: input meansVar[] []: input variances
*/
int i,j,k,irow,icol,numbad;int ii,iilow,iihigh,jj,jjlow,jjhigh;
11-27
float x,y;Ifloat sum,varsum;float Grid [21 [NROW1 [NCOL];float Mean ENROW] [NOOL];float Var ENROW] [NOOL];
void Build-AO;
void Build_.BO;void Build-Xo;
FILE *f-mnin, *f-varin, *f..mnout, *f-varout;
f-.mnin -fopen(argv[1]."r");
f...varin f open(argv [21 ,1ri");f-mnnout =fopen(argv[3L,"w");
This routine builds the B matrix of the kriging equations.
The following are local variables.
ii: loop variablex: x coordinate of the (i,j) block midpointy: y coordinate of the (i,j) block midpointh: the distance between any two pointstempl,temp2: temporary variables
f..-surf m = f open(argv [1)."r"f);f-.surfv - fopen(argv[2],11r");f..subm - fopen(argv[3],"r");f..subv = fopen(argv[4J,"rfl);f-.outm = fopen(argv[51,1'w");f-.outv = f open (argv [6],P"1W1);
This appendix includes the Interactive Data Language (IDL) procedures which
were used to plot the variograms and surfaces. IDL is a product of Research Systems,
Inc.. More information on IDL is available in the Introduction To IDL and the IDL
User's Guide. The following programs are only a sample of the routines which were
used. However, these procedures sufficiently demonstrate the method for producing
the plots.
J-1
Variograma Plotting Procedure3
This section provides examples of the variogram plotting programs. The firstprogram generates a postscript file for the variograms of Subject 09. The code isprovided below.
readf,l1, aclose, 1FOR K=O,1 DO BEGINFOR I=0,N-i DO f(K,0,1)=a(K,I)FOR I=ON-1 DO f(K,1,I)=a(KI4N)FOR I=0,N-1 DO f(K,2,I)=a(K,I+2l'N)FOR 10O,N-1 DO f(K,3,I)=a(K,I+3*N)FOR 10O,M-1 DO FOR J=0,3 DO g(K,3,I)=f(K,J,I)ENDFORplot,g(0,0,*),g(1,0,*),xtitle=J'8h (distance)',ytitle=''7'c!8(h)',xrange=[O,XR] ,yrange=[0,YRJ ,line=1,xcharsize=1 .3,ycharsize=1 .3oplot,g(O,1,*) ,g(1,1,*) ,line=2oplot,g(0,2,*) ,g(1,2,*) ,line=3oplot,g(0.3,*),g(1,3,*) ,line=4sphere=fltarr(2 ,M+2)FOR I=0,M+i DO BEGINsphere(0, I)=IIF (I GT 6.645) THEN BEGINsphere(l,I)=2.226.0.689ENDIF ELSE BEGINsphere(1,I)=2.226*(1.5*I/6.645 - .5*I*I*I/293.394) + 0.689ENDELSE;ENDFORoplot,sphere(0,*) ,sphere(1,*) ,line=Ob~fltarr(2, 2)c-fltarr(2,2)
ee (1, 0) =2*9 .00ee(1, 1) =2*9 .00openr,2, 'list.25'
readf ,2,NUM
readf,2,Sopenr,l1, Sreadf,l1, a
close, 1FOR K=0,1 DO BEGINFOR I=0,N-1 DO f(K,0,I)=a(K,I)FOR I=0,N-1 DO f(K,1,I)=a(K,I+N)FOR I=0,N-1 DO f(K,2,I)=a(K,I+2*N)FUR I=0,N-1 DO f(K,3,I)=a(K,I+3*N)
FOR I=0,M-1 DO FOR J=0,3 DO g(K,J,I)=f(K,J,I)ENDEOR
FOR LL=2,NUM DO BEGINreadf,2,Sopenr,l1 Sreadf,l1, aclose, 1FOR K=0,1 DO BEGINFOR I=O,N-1 DO f(K,0,I)=a(KI)FOR I=0,N-1 DO f(K,1,I)=a(K,I+N)FOR I=0,N-1 DO f(K,2,I)=a(K,I+2*N)FOR I=0,N-1 DO f(K,3,I)=a(K,I+3*N)FOR I-O,M-1 DO FOR J=0,3 DO g(K,J,I)=f(K,J,I)ENDFORoplot,g(O,0,*),g(1,O,*) ,line=1oplot,g(O,1,*) ,g(i,1,*) ,1ine=2oplot,g(O,2,*) ,g(1,2,*) ,line=3oplot,g(O,3,*) ,g(1,3,*) ,line-4ENDFORcloSe, 2oplot,bb(0,*) ,hb(1.*) ,line-1oplot,cc(O,*),cc(1,*),li~ne=2oplot,dd(0,*) ,dd(1,*) ,line=3oplot,ee(0,*),ee(1,*),line=4xyouts,3.8,18.0,'25 Subjects',size-1.0device,/close-.fileset..plot, 'sun'
end
This program is similar to the previous program except that it plots the vari-ograrns for 30 subjects.
readf,l,aclose, 1FOR K=0,1 DO BEGINFOR I=0,N-1 DO f(K0O,I)=a(K,I)FOR I=0,N-1 DO f(K,1,I)=a(K,I+N)FOR I=0,N-1 DO f(K,2,I)=a(K,I+2*N)FOR I=O,N-1 DO f(K,3,I)=a(K,I+3*N)FOR I=0,M-1 DO FOR J=0,3 DO g(K,J,I)=f(K,J,I)ENDFORplot,g(0,0,*),g(1,0,*),xtitle=''sh (distance)',ytitle='!7c!8(h)',xrange=E0,Xr) i,yrange=EO,YR] ,line=1 ,xcharsize=I .3,ycharsize=1 .3oplot,g(0,1,*) ,g(1,1,*) ,line=2
oplot~g(0,2,*) ,g(1,2,*) ,line=3oplot,g(O,3,*),g(1,3,*) ,line=4FOR LL=2,NUM DO BEGINreadf,2,Sopenr, 1, Sreadf,I., aclose, 1FOR K=O,l DO BEGINFOR I=O,N-I DO f(KO,I)=a(K,I)'FOR I=0,N-1 DO f(K,1,I)=a(K,I+N)FOR I=O,N-1 DO f(K,2,I)=a(K,I+2*N)FOR I=O,N-- DO f(K,3,I)=a(K,I+3*N)FOR I=O,M-1 DO FOR J=0,3 DO g(K,J,I)=f(K,J,I)ENDFORoplot,g(O,O,*) ,g(1,O,*) ,line~loplot,g(O,i,*) ,g(1,1,*) ,line=2oplot,g(O,2,*) ,g(1,2,*) ,line=3oplot,g(O,3,*) ,g(1,3,*) ,line=4ENDFORclose, 2oplot,bb(O,*),bb(1,*) ,line~loplot,cc(o,*),cc(l,*),line=2oplot,dd(O,*),dd(l,*) ,line=3oplot,ee(O,*),ee(1,*),line=4xyouts,3.8,18.O'130 Subjects',size=1.Odevice,/close-.fileset-plot, 'sun'end
J.-9
Surface Plotting Procedures
This section includes programs which require an interactive input to specify
the appropriate data file to plot. To obtain a hard copy of the output, the PLOT
and PRINT programs must be used in conjunction with these procedures. To obtain
an encapsulated postscript file, the OPEN and CLOSE procedures must be used.
These files are discussed later in this section.
The first procedure plots any facial data set.
FN=' )
READ,'Enter filename > ',FNa=fltarr(50,100)b=fltarr(40,80)openr, 1 ,FNreadf,1, aclose, 1for i=0,39 do beginfor j=0,79 do b(i,j)=a(10+i,5+j)endforsurface,b,az=45,ax=30,xrange=[0,40],yrange=[0,70] ,zrange=[0,200],xtitle=' '8Altitude' ,ytitle='Angle' ,ztitle='Radius' ,charsize=2.5end
This next procedure plots residual data files.
FN='READ,'Enter filename > ',FNa=fltarr(50, 100)b=fltarr (40,80)openr, 1 ,FNreadf, 1, aclose, 1for i=0,39 do beginfor j=0,79 do b(i,j)=a(10+i,5+j)endform-20surface, b, az=45, ax=30, xrange= [0,4 0] , yrar.4.e= [0,70] ,zrange= I-m, m,
J-10
end
The following program plots the variograms for an individual subject.
READ,'IEnter f ilena~me > 'FNa~fltarr(50, 100)bzfltarr (40,80)openr,l1,FNreadf,1, aclose, 1for i=0,39 do beginfor j=0,79 do beginif a(10+i,S+j) NE 20.0 then b(i,j)=a(10+i,5+j) else b(i,j)=0.O
The following miscellaneous procedures may be used to obtain hard copies,
to produce encapsulated postscript files, or to set the terminal type to emulate a
Tektronics terminal.
The first program, OPEN.PRO, is run prior to a sequence of plotting com-mands. Following this sequence, the CLOSE.PRO procedure is executed to producethe psotscript file. The combination of OPEN and CLOSE is necessary to pro-duce the file and to return IDL to the appropriate environment settings. The openprocedure is as follows.
set-plot, 'ps'FN= '
read,'Enter the name of the picture file > ',FNdevice,/encapsulated,f ilename=FNdevice,/inches,xsize=5.0,scale-factor=1.0device,/inches,ysize=5.0,scale.factor=1.0end
The close procedure is as follows.
device,/closefileset.plot, 'sun'end
The plot and print procedures work in the saame fashion as the two proceedingprograms and produce a plot from the laser printer. The code for the plot procedureis as follows.