Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php on line 245

Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php on line 245

Warning: Cannot modify header information - headers already sent by (output started at /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php:245) in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 62
Example R code to analyse Mass Balance from GW Vista output – Coal Geology and Mining: Consulting Services

Example R code to analyse Mass Balance from GW Vista output

For one of the hydro project, I had to create close to 100 MODFLOW models to understand whats going on with the flow system. Looking at the output from the modflow files could be time consuming. I have used the R program to get a quick summary of mass balance for the layers. If you know R and comfortable with manipulating the code little bit to fit your model, you are free to use it. The program asks you to select a .csv file. You need to open the .bal file with excel and save it as .csv before using the program. The program would ask you to choose a location for the file. Select it. The program will then calculate sumary by layers and print result in a new csv file named “MB.CSV”. Enjoy modeling the world.

 

#Program to analyze Mass Balance from Ground Water Vista 6.0 in R
#Programmer: Ankan Basu, PG, CPG, contact basu.ankan@gmail.com
#Date: 8/4/14

#Export “Detailed” mass balance as .bal file from GW Vista
#convert .bal file to .csv, remove text formatting.
#Read the csv file
M1=read.csv(file.choose(),header=T,sep=”,”,stringsAsFactors=FALSE)

#get the summary
summary(M1)
#look at the structure of the database
str(M1)

#convert flow “Type” to factor levels
M1$Type <- as.factor(M1$Type)
levels(M1$Type)

#Summarize data
RI=subset(M1[,c(4,9)], M1$Type==”Recharge inflow”)
RI
DR=subset(M1[,c(4,9)], M1$Type==”Drain”)
DR
sum(DR$flux)

GHB=subset(M1[,c(4,9)], M1$Type==”GHB”)
sum(GHB$flux)

#Top inflow
TI=subset(M1[,c(4,9)], M1$Type==”Qz Top inflow”)
#TI

#Bottom Inflow
BI=subset(M1[,c(4,9)], M1$Type==”Qz Bottom inflow”)
#BI

#storage inflow
SI=subset(M1[,c(4,9)], M1$Type==”Storage inflow”)
SI

#Top Outflow
TO=subset(M1[,c(4,9)], M1$Type==”Qz Top outflow”)
#BI

BO=subset(M1[,c(4,9)], M1$Type==”Qz Bottom outflow”)
#BO

#storage outflow
SO=subset(M1[,c(4,9)], M1$Type==”Storage outflow”)
SO

final=data.frame(TI$layer,TI$flux,BI$flux, SI$flux, TO$flux, BO$flux, SO$flux)
final.names=c(“Layers”, “Top Inflow”, “Bottom Inflow”, “Storage inflow”, “Top outflow”
, “Bottom Outflow”, “Storage Outflow”)
names(final)=final.names
final

#Convert to gallons per minute
F2=final[2:7]*7.48/1440
F2
F3=format(round(F2, 2), nsmall = 2)
rownames(F3) <- c(“Layer 1″,”Layer 2″,”Layer 3″,”Layer 4″,”Layer 5″,”Layer 6″,”Layer 7″,”Layer 8″,”Layer 9”)
F3
write.csv(F3, file = “MB.csv”, fileEncoding = “macroman”)

Leave a Comment

Your email address will not be published. Required fields are marked *