-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZZtoDipoleDipole.R
79 lines (60 loc) · 2.77 KB
/
ZZtoDipoleDipole.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#An R script for reformating the ZZ output Dipole-Dipole files into Res2D format
#Version 1.1
#Updated 11/12/2024 to remove the Rosner's Test option and to include topography
#Before running this script you need to output the Dipole-Dipole INP file using the ZZ Rdatacheck software.
#It is recommended to tick the "Output all data(no filter)" option and then press "Output INP File button"
#Read in INV file preserving file structure and deleting the first 74 lines (Default is ALine-1_IV_inv_Dpdp.inp)
DD<- read.table("ALine-1_IV_inv_Dpdp.inp",skip = 75, header = FALSE)
#FORMAT THE DATA This section changes the ZZ data output into Res2D format
#Define the electrode spacing, you need to enter the value below (default is 0.5)
Elect <- 0.5
#Define the file name, you need to enter the value below (default is A Line DD)
Name <- "A Line DD"
#Remove the unnecessary columns
DD<-DD[-c(6:8)]
#Add the extra columns required for Res2D format, run each line one at a time
DD$V6 <- 4
DD$V7 <- (DD$V1 * Elect - Elect)
DD$V8 <- 0
DD$V9 <- (DD$V2 * Elect - Elect)
DD$V10 <- 0
DD$V11 <- (DD$V3 * Elect - Elect)
DD$V12 <- 0
DD$V13 <- (DD$V4 * Elect - Elect)
DD$V14 <- 0
#Remove the unnecessary additional columns
DD<-DD[-c(1:4)]
#Move the resistance column to the end
DD <- DD[c("V6", "V7", "V8", "V9", "V10", "V11", "V12", "V13", "V14", "V5")]
#VISUALIZE AND FILTER This section allows you to filter out the large and small values that can make inverstions unstable
#Create a Histogram to see the distribution of data values
hist(DD$V5, breaks=20)
#What are the 10 most negative resistivity values?
head(sort(DD$V5),10)
#What are the 10 least negative resistivity values?
tail(sort(DD$V5),10)
#Having chosen which values you want to remove, remove all rows with a data value greater than a value (default is -100)
DD <- subset(DD, V5 > -100)
#Having chosen which values you want to remove, remove all rows with a data value less than a value (default is -2)
DD <- subset(DD, V5 < -02)
#OUTPUTTING THE RES2D File
#Count the number of data rows in the file
Rows <- nrow(DD)
#Creating a TxT file in Res2D format with the Original File Name
printer1<- file(Name,"w")
write(sprintf(Name), printer1, append=TRUE)
write(Elect,printer1,append=TRUE)
write("11",printer1,append=TRUE)
write("3",printer1,append=TRUE)
write("Type of Measurment",printer1,append=TRUE)
write("1",printer1,append=TRUE)
write(Rows,printer1,append=TRUE)
write("1",printer1,append=TRUE)
write("0",printer1,append=TRUE)
write.table(DD,printer1, append = TRUE, sep = " ", row.names = FALSE, col.names = FALSE)
#Only run rows 75-78 if you want to include topography values in the output
write("Topography in separate list",printer1,append=TRUE)
write("1",printer1,append=TRUE)
write("64",printer1,append=TRUE)
write("0, ",printer1,append=TRUE)
close(printer1)