Skip to content

Commit

Permalink
Modifying File Paths and Annotating
Browse files Browse the repository at this point in the history
  • Loading branch information
kallisons authored and kallisons committed Dec 8, 2014
1 parent 6805ca2 commit a546e9a
Show file tree
Hide file tree
Showing 31 changed files with 2,371 additions and 34 deletions.
Binary file added Model/MRM0D/MRM0D1
Binary file not shown.
883 changes: 883 additions & 0 deletions Model/MRM0D/MRM0D_v1.0.F90

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Model/MRM0D/RunModel_BATS_0D.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

#max_epsilon is the maximum exoenzyme production rate

#qfrac is the fraction of the surface area of the spherical particle covered by a single layer of bacteria, values greater than 1 mean that there is a second layer of bacteria

for max_epsilon in 0.0000 0.0005 0.0010 0.0015 0.0020 0.0025 0.0030 0.0035 0.0040 0.0045 0.0050 0.0055 0.0060 0.0065 0.0070 0.0075 0.0080 0.0085 0.0090 0.0095 0.0100 0.0105 0.0110 0.0115 0.0120 0.0125 0.0130 0.0135 0.0140 0.0145 0.0150 0.0155 0.0160 0.0165 0.0170 0.0175 0.0180 0.0185 0.0190 0.0195 0.0200 0.0205 0.0210 0.0215 0.0220 0.0225 0.0230 0.0235 0.0240 0.0245 0.0250 0.0255 0.0260 0.0265 0.0270 0.0275 0.0280 0.0285 0.0290 0.0295 0.0300 0.0305 0.0310 0.0315 0.0320 0.0325 0.0330 0.0335 0.0340 0.0345 0.0350 0.0355 0.0360 0.0365 0.0370 0.0375 0.0380 0.0385 0.0390 0.0395 0.0400 0.0405 0.0410 0.0415 0.0420 0.0425 0.0430 0.0435 0.0440 0.0445 0.0450 0.0455 0.0460 0.0465 0.0470 0.0475 0.0480 0.0485 0.0490 0.0495 0.0500
do
for qfrac in 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10
do
rm MassTransferRates.out
rm StateVariables.out
rm BacteriaRates.out
rm grow2.input
echo "&control" > grow2.input
echo "qfrac =" ${qfrac} >> grow2.input
echo "max_epsilon =" ${max_epsilon} >> grow2.input
echo "/" >> grow2.input
echo " " >> grow2.input

./MRM0D1 < grow2.input
cp StateVariables.out ../../Output/MRM0D/StateVariables/StateVariables_maxe${max_epsilon}_qfrac${qfrac}.out
cp BacteriaRates.out ../../Output/MRM0D/BacteriaRates/BacteriaRates_maxe${max_epsilon}_qfrac${qfrac}.out
cp MassTransferRates.out ../../Output/MRM0D/MassTransferRates/MassTransferRates_maxe${max_epsilon}_qfrac${qfrac}.out
done
done
5 changes: 5 additions & 0 deletions Model/MRM0D/grow2.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
&control
qfrac = 0.47
max_epsilon = 0.0075
/

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ do
echo "/" >> sizesink.input
echo " " >> sizesink.input

./MRM1 < sizesink.input
cp StateVariables.out ../Output/StateVariables/StateVariables_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
cp BacteriaRates.out ../Output/BacteriaRates/BacteriaRates_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
cp MassTransferRates.out ../Output/MassTransferRates/MassTransferRates_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
./MRM1D1 < sizesink.input
cp StateVariables.out ../../Output/MRM1D/StateVariables/StateVariables_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
cp BacteriaRates.out ../../Output/MRM1D/BacteriaRates/BacteriaRates_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
cp MassTransferRates.out ../../Output/MRM1D/MassTransferRates/MassTransferRates_Sink${w}_Size${r_top}_Qfrac${qfrac}.out
done
done
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Output/MRM1D/MassTransferRates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out
1 change: 1 addition & 0 deletions Output/MRM1D/StateVariables/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out
76 changes: 46 additions & 30 deletions RCode/DataToInput/BATS_CTDTables.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
##Data Input
source("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/RCode/sigmat.fun")
source("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/RCode/thetap.fun")
source("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/RCode/alr.fun")
#Change working directory to MicrobeReminModel_v1.0 using the setwd() command or using the Misc menu.
getwd() #shows the current working directory for the R gui.

DataFolder<-paste("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/CTD/", sep="")
DataFiles<-list.files(DataFolder)
#---------------------
# Source R Functions
#---------------------
source("RCode/R_functions/sigmat.fun")
source("RCode/R_functions/thetap.fun")
source("RCode/R_functions/alr.fun")

#quartz()
#plot(CTD$Temp, CTD$Depth*-1, type="l")
#------------------------------
# Read in List of Data Files
#------------------------------

depths<-seq(150, 4000, 10)
DataFolder<-paste("Data/BATS/CTD/", sep="")
DataFiles<-list.files(DataFolder)

#depths<-seq(10, 50, 10)
#-----------------
# Create Tables
#-----------------

depths<-seq(150, 4000, 10) # Final data in 10 m intervals

TempTable<-as.data.frame(matrix(NA, length(depths), 1))
colnames(TempTable)<-c("Depth")
Expand All @@ -23,6 +31,10 @@ RhoTable<-as.data.frame(matrix(NA, length(depths), 1))
colnames(RhoTable)<-c("Depth")
RhoTable$Depth<-depths

#----------------------------
# Read and Process CTD Data
#----------------------------

for(k in 1:length(DataFiles)){

FileName<-paste(DataFolder, DataFiles[k], sep="")
Expand All @@ -33,11 +45,12 @@ colnames(CTD)<-c("ID", "Date", "Lat", "Lon", "Pres", "Depth", "Temp", "Sal", "DO

CTD<-CTD[c("ID", "Date", "Pres","Depth","Temp","Sal")]

#Replace Bad Values with NA
CTD$Sal<-ifelse(CTD$Sal<0, NA, CTD$Sal)
CTD$Sal<-ifelse(CTD$Sal>38, NA, CTD$Sal)
CTD$Temp<-ifelse(CTD$Temp<0, NA, CTD$Temp)


#Time Process
CTD$Year<-floor(CTD$Date)
CTD$Yfrac<-CTD$Date-CTD$Year
CTD$Sfrac<-unclass(ISOdate(CTD$Year+1,1,1,0,0,0)) - unclass(ISOdate(CTD$Year,1,1,0,0,0))
Expand All @@ -46,53 +59,45 @@ CTD$Date<-substr(CTD$Date2,1,10)

CTD$Cast<-substr(CTD$ID, 6, 7)

#Average CTD casts done on the same day
CTDagg<-aggregate(CTD[c("Pres", "Temp", "Sal")], list(CTD[,c("Year")], CTD[,c("Date")], CTD[,c("Depth")]), mean, na.rm=TRUE)

colnames(CTDagg)<-c("Year","Date","Depth","Pres", "Temp", "Sal")


CTDagg$Depth<-round(CTDagg$Depth, digits=0)

#Interpolate CTD data
CTDinterp<-as.data.frame(matrix(NA, max(CTDagg$Depth), 2))
colnames(CTDinterp)<-c("Depth","Blank")
CTDinterp$Depth<-as.numeric(row.names(CTDinterp))
CTDinterp<-subset(CTDinterp, CTDinterp$Depth>=min(CTDagg$Depth, na.rm=TRUE))

CTDinterp2<-merge(CTDinterp, CTDagg, all=TRUE)
CTDinterp2<-CTDinterp2[,-2]


p1<-approx(CTDinterp2$Depth, CTDinterp2$Pres, CTDinterp2$Depth)
CTDinterp2$Pres<-p1$y

t1<-approx(CTDinterp2$Depth, CTDinterp2$Temp, CTDinterp2$Depth)
CTDinterp2$Temp<-t1$y

if(length(table(CTDinterp2$Sal))>0){
s1<-approx(CTDinterp2$Depth, CTDinterp2$Sal, CTDinterp2$Depth)
CTDinterp2$Sal<-s1$y
}

#Calculate density
CTDinterp2$Rho<-sigmat(CTDinterp2$Temp, CTDinterp2$Sal, CTDinterp2$Pres)

#Add time to the interpolations
CTDinterp2<-CTDinterp2[order(CTDinterp2$Pres),]

CTDinterp2$Year<-rep(CTDinterp2$Year[1])
CTDinterp2$Date<-rep(CTDinterp2$Date[1])

CTDinterp2<-unique(CTDinterp2)

#Move data to final tables
depths<-seq(150, 4000, 10)
#depths<-seq(10, 50, 10)
depths<-subset(depths, depths<max(CTDinterp2$Depth))
diff<-(nrow(TempTable)-length(depths))
for(d in 1:length(depths)){
depths[d]<-which(CTDinterp2$Depth==eval(depths[d]))
}
CTDfinal<-CTDinterp2[c(depths),]

Date<-CTDfinal$Date[1]

TempTable<-cbind(TempTable, c(CTDfinal$Temp, rep(NA, eval(diff))))
colnames(TempTable)[k+1]<-eval(Date)
SalTable<-cbind(SalTable, c(CTDfinal$Sal, rep(NA, eval(diff))))
Expand All @@ -102,13 +107,19 @@ colnames(RhoTable)[k+1]<-eval(Date)

}

#Bad Salinity Values on 1989-06
#-------------
# Bad Data
#-------------
#Bad Salinity Values on 1989-06, replace with NA
SalTable[,10]<-rep(NA)
RhoTable[,10]<-rep(NA)
#Bad Salinity Values on 1990-03
#Bad Salinity Values on 1990-03, replace with NA
SalTable[,18]<-rep(NA)
RhoTable[,18]<-rep(NA)

#----------------------------
# Plot Profiles of CTD Data
#----------------------------
quartz()
plot(TempTable[,2], TempTable$Depth*-1, type="l", xlim=c(0,22))
last<-ncol(TempTable)-2
Expand All @@ -127,7 +138,9 @@ last<-ncol(RhoTable)-2
for(y in 3:last){
lines(RhoTable[,y], RhoTable$Depth*-1)}


#------------------------------------
# Calculate Long-term Means of Data
#------------------------------------
TempTable2<-TempTable
SalTable2<-SalTable
RhoTable2<-RhoTable
Expand All @@ -147,12 +160,15 @@ RhoTable[,2:9]<-round(RhoTable[,2:9], digits=2)
RhoTable[,11:17]<-round(RhoTable[,11:17], digits=2)
RhoTable[,19:length(RhoTable)]<-round(RhoTable[,19:length(RhoTable)], digits=2)

outfile<-paste("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/CTDTables_PP/BATS_CTDTemp_10m.txt", sep="")
#--------------------------------
# Write Processed Data to Files
#--------------------------------
outfile<-paste("Data/BATS/BATS_CTDTemp_10m.txt", sep="")
write.table(TempTable, outfile, quote=FALSE, col.names=TRUE, row.names=FALSE, sep=" ")

outfile<-paste("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/CTDTables_PP/BATS_CTDSal_10m.txt", sep="")
outfile<-paste("Data/BATS/BATS_CTDSal_10m.txt", sep="")
write.table(SalTable, outfile, quote=FALSE, col.names=TRUE, row.names=FALSE, sep=" ")

outfile<-paste("/Users/kasmith/Documents/EnzymeBacteriaModel/Data/BATS/CTDTables_PP/BATS_CTDRho_10m.txt", sep="")
outfile<-paste("Data/BATS/BATS_CTDRho_10m.txt", sep="")
write.table(RhoTable, outfile, quote=FALSE, col.names=TRUE, row.names=FALSE, sep=" ")

Loading

0 comments on commit a546e9a

Please sign in to comment.