Skip to content

Commit

Permalink
Merge pull request #1 from eghummel/main
Browse files Browse the repository at this point in the history
Catching up to main
  • Loading branch information
WaveHello authored Oct 2, 2023
2 parents 6e2cad8 + a787568 commit e893a74
Show file tree
Hide file tree
Showing 115 changed files with 11,212 additions and 492 deletions.
1,305 changes: 1,305 additions & 0 deletions BD code - Duck Nearshore.py

Large diffs are not rendered by default.

2,384 changes: 2,384 additions & 0 deletions BD code - profile overlay.ipynb

Large diffs are not rendered by default.

1,128 changes: 1,128 additions & 0 deletions BD code - single drop analysis.ipynb

Large diffs are not rendered by default.

952 changes: 605 additions & 347 deletions BD code v7.py

Large diffs are not rendered by default.

2,551 changes: 2,551 additions & 0 deletions BD code v8.ipynb

Large diffs are not rendered by default.

360 changes: 215 additions & 145 deletions Bootleg Dropview.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,168 +6,238 @@
import math
from math import pi
from math import sqrt
import statistics
import scipy.integrate
from scipy.signal import find_peaks
from scipy.signal import argrelmin
from numpy import trapz
from scipy.integrate import cumtrapz
import shutil

# SETUP VARIABLES - USER INPUTS
BD = 2 #Bluedrop file is from
fileNum = '02B7' # write the bin file number you want to analyze (do not include 'bLog' or '.bin')
soiltype = "s" #s = sand, c=clay, m=mixed, u=unknown
atype = 'p' # m = mantle area (best for sands), p = projected area (best for clays)
tiptype = 'c' # c = cone, p = parabolic, b = blunt
offset = 1 # this value is subtracted from the accelerometer readings
droptype = 'w' #w = water, #a = air
sign = "uk" #enter an effective unit weight value in kg/m^3 or "uk" if unknown
BD = 3 #Bluedrop file is from
fileNum = '00A0'
# write the bin file number for the earliest drop in the folder (do not include 'bLog' or '.bin')
numFiles = 20 #write the number of bin files in the folder of interest (if only looking at 1 drop, write 2)
offset = 0 # this value is subtracted from the accelerometer readings
# paste the filepath to the folder where the BD data is stored
binFilepath = Path("H:\My Drive\CEE 5904 - Project & Report/2021 FRF Data\Bluedrop\October/14 October 2021 AM\Pier - BD2")
binFilepath = Path("C:/Users/elise/Desktop/Sequim_2021/")
#paste the filepath that you want the files containing drops copied to
outputPath = Path("H:\My Drive\CEE 5904 - Project & Report/2021 FRF Data\Bluedrop\October/14 October 2021 AM\Analysis Results-14 October 2021 AM.xlsx") # Path to pre-existing Excel File
plotPath = Path("H:\My Drive\CEE 5904 - Project & Report/2021 FRF Data\Bluedrop\October/14 October 2021 AM\Analysis Figures- 14 October 2021 AM")
#if applicable, paste the filepath to an excel file that troubleshooting data will be printed in
troubleshootingPath = Path("H:\My Drive\CEE 5904 - Project & Report/2021 FRF Data\Bluedrop\October/14 October 2021 AM\Troubleshooting.xlsx")

def overviewplot(): #Plot showing all accellerometers and pore pressure readings
fig, (ax1, ax2, ax3) = plt.subplots(3)
fig.set_size_inches(14, 7)
outputPath = Path("C:/Users/elise/Desktop/Sequim_2021/Drops Only")
plotPath = Path("C:/Users/elise/Desktop/Sequim_2021/Drops Only/Dec-Time Plots")

def overviewplot(): #Plot showing all accelerometers and pore pressure readings
fig, (ax1) = plt.subplots(1)
fig.set_size_inches(4, 4)
ax1.plot(time, g250g, label="250g")
ax1.plot(time, g50g, label="50g")
ax1.plot(time, g18g, label="18g")
ax1.plot(time, g2g, label="2g")
ax1.legend(loc = "upper right")
ax1.set(ylabel="Deceleration (g)")
ax1.set_title("BD file "+fileNum)
ax1.set_title("BD file "+ newName)
ax1.grid()

ax2.plot(time, ppm, label="Pore Pressure")
ax2.set(ylabel="Pore Pressure (kPa)")
ax2.grid()

ax3.plot(time, gX55g, label="X 55g")
ax3.plot(time, gY55g, label="Y 55g")
ax3.legend(loc = "upper right")
ax3.set(ylabel="Deceleration (g)")
ax3.set(xlabel="Time (s)")
ax3.grid()

fig.subplots_adjust(bottom=.1, left = .1)
#plotName = fileNum+" Overview.png"
#plt.savefig(plotPath / plotName)
plt.show()

# READ BD DATA IN
data_array = [] # creates an empty array for us to fill with bd data
fileName = 'bLog'+fileNum+".bin"
# print(fileName)
newPath = binFilepath / fileName
#print(newPath)
file = open(newPath, 'rb') # read file
element = file.read(3) # create a byte list with each element having 3 bytes

while element:
# Convert to signed integer before adding to data array
iVAl = int.from_bytes(element, byteorder='big', signed=True)
data_array.append(iVAl) # adds the reshaped data from the bd file to the data frame
element = file.read(3)

np_array = np.array(data_array) # create numpy array from the list
np_array = np.reshape(np_array, (-1, 10)) # convert the 1d array to 2d array with 10 cols

#print(np_array.shape)
# print(np_array)
'''
df = pd.DataFrame(np_array) # Creates a Dataframe in pandas from the bd data
df.columns = ['Count', 'no clue', 'g2g', 'g18g', 'g50g', 'ppm', 'g200g', 'gX55g', 'gY55g', 'g250g'] # names columns
# print(dfCal)
# APPLY CALIBRATION FACTORS
if BD == 3: # calibration factors from July 2019
g2g = (df['g2g']-38285.6)/1615800.9 - offset# accelerometers are in g
g18g = (df['g18g']+13738)/163516.8 - offset
g50g = (df['g50g']-238520.6)/63666 - offset
ppm = ((df['ppm']-139040.1)/20705) * 6.89475729 # converts to kPa
g200g = ((df['g200g'] +12142.6)/27751.9) - offset
gX55g = (df['gX55g']-90237)/65351.5
gY55g = (df['gY55g']-57464.2)/65545.
g250g = (df['g250g']-40420.3)/13636.9 - offset
if BD == 2: # calibration factors from Aug 26, 2021
g2g = (df['g2g']+37242.2)/1639250.2 - offset# accelerometers are in g
g18g = (df['g18g']-26867.0)/160460.5 - offset
g50g = (df['g50g']-213923.3)/64080.7- offset
ppm = ((df['ppm']+55518.9)/18981.7) * 6.89475729 # converts to kPa
g200g = (df['g200g']-171448.6)/30334.2 - offset
gX55g = (df['gX55g']-54242.6)/64767.7
gY55g = (df['gY55g']-40574.2)/66343.1
g250g = (df['g250g']-40614.9)/13654.6 - offset
if BD == 1: # calibration factors from July 2020
g2g = (df['g2g']-42590.9)/1626361.1 - offset # accelerometers are in g
g18g = (df['g18g']-44492.9)/161125.5 - offset
g50g = (df['g50g']-171656.1)/64020.3 - offset
ppm = ((df['ppm']+31776.1)/20679.7) * 6.89475729 # this is kPa
g200g = (df['g200g'] -723404.8)/32209.7 - offset
gX55g = (df['gX55g'] -54881.1)/64858.6
gY55g = (df['gY55g']-28735.5)/63839.9
g250g = (df['g250g']+13299.7)/13697.1 - offset
time = (df['Count']-df['Count'].iloc[0]+1)/2000 # gives time in s
count = df["Count"]-df['Count'].iloc[0]
# make a new dataframe of the calibrated values in units of g
dfCalg = pd.DataFrame([count, time, g2g, g18g, g50g, g200g, g250g, gX55g, gY55g, ppm])
dfCalg = dfCalg.T
dfCalg.columns = ['Count', 'Time (s)', '2g (g)', '18g (g)', '50g (g)', '200g (g)', '250g (g)', 'X55g (g)', 'Y55g (g)', 'Pore Pressure (kPa)'] # names columns
#print(dfCalg)
#make a new dataframe of the calibrated values in units of m/s^2
dfCal = pd.DataFrame([count, time, g2g, g18g, g50g, g200g, g250g, gX55g, gY55g, ppm])
dfCal = dfCal.T
dfCal.columns = ['Count','Time (s)', '2g (m/s^2)', '18g (m/s^2)', '50g (m/s^2)', '200g (m/s^2)', '250g (m/s^2)', 'X55g (m/s^2)', 'Y55g (m/s^2)', 'Pore Pressure (kPa)'] # names columns
dfCal['2g (m/s^2)'] = dfCal['2g (m/s^2)'] * 9.80665
dfCal['18g (m/s^2)'] = dfCal['18g (m/s^2)'] * 9.80665
dfCal['50g (m/s^2)'] = dfCal['50g (m/s^2)'] * 9.80665
dfCal['200g (m/s^2)'] = dfCal['200g (m/s^2)'] * 9.80665
dfCal['250g (m/s^2)'] = dfCal['250g (m/s^2)'] * 9.80665
dfCal['X55g (m/s^2)'] = dfCal['X55g (m/s^2)'] * 9.80665
dfCal['Y55g (m/s^2)'] = dfCal['Y55g (m/s^2)'] * 9.80665
#print(dfCal)
overviewplot()
print("Does the file contain a drop? (y/n)")
drop_input=input()
plt.draw()
print("Is there a drop? y/n")
plt.waitforbuttonpress(2)
drop_input=input()

if drop_input=='y':
files = Path(directory).glob('*')
for file in files:
print(file)
'''
name = [*fileNum]
print(name)
print(name[3])

def newName():
a = int(name[3])
print(a)
if a <=8:
b = a + 1
b = str(b)
elif a == 9:
b = "A"
elif a == "A":
origFile = 'bLog'+newName+".bin"
origFilePath = binFilepath / origFile
newFilePath = outputPath / origFile
plotFilePath = plotPath / newName
shutil.copyfile(origFilePath, newFilePath)
plt.savefig(plotPath / newName)

plt.close(fig)

def newNamefun(): #find the next sequential bin name a=existing last variable, b=new last variable
global newName
a = name[3]
c = name[2]
e = name[1]
g = name[0]
if a == "A":
b = "B"
elif a == "B":
b = "C"
elif a == "C":
b = "D"
elif a == "D":
b = "E"

newName = name
newName[3] = b
print(newName)

newName()
elif a == "E":
b = "F"
elif a == "F":
b = "0"
if c == "A":
d = "B"
elif c == "B":
d = "C"
elif c == "C":
d = "D"
elif c == "D":
d = "E"
elif c == "E":
d = "F"
elif c == "F":
d = "0"
if e == "A":
f = "B"
elif e == "B":
f = "C"
elif e == "C":
f = "D"
elif e == "D":
f = "E"
elif e == "E":
f = "F"
elif e == "F":
f = "0"
if g == "A":
h = "B"
elif g == "B":
h = "C"
elif g == "C":
h = "D"
elif g == "D":
h = "E"
elif g == "E":
h = "F"
elif g == "F":
h = "0"
f = "0"
d = "0"
b = "0"
elif g == "9":
h = "A"
else: #a <=8:
g = int(name[0]) #the only other options are numbers
h = g + 1
h = str(b)

elif e == "9":
f = "A"
else: #a <=8:
e = int(name[1]) #the only other options are numbers
f = e + 1
f = str(f)


elif c == "9":
d = "A"
else: #a <=8:
c = int(name[2]) #the only other options are numbers
d = c + 1
d = str(d)


elif a == "9":
b = "A"
else: #a <=8:
a = int(name[3]) #the only other options are numbers
b = a + 1
b = str(b)


newNameList = name
newNameList[3] = b #b always will change
if a == "F":
newNameList[2] = d
if c == "F":
newNameList[1] = f
if e == "F":
newNameList[0] = h

else:
newNameList[2] = c
newNameList[1] = e
newNameList[0] = g

print(newNameList)
newName = ""
newName = newName.join(newNameList)
print(newName)

newName = fileNum #for the first drop, select the earliest drop defined earlier

for i in range(1, numFiles):

# READ BD DATA IN
data_array = [] # creates an empty array for us to fill with bd data
fileName = 'bLog'+newName+".bin"
# print(fileName)
newPath = binFilepath / fileName
#print(newPath)
file = open(newPath, 'rb') # read file
element = file.read(3) # create a byte list with each element having 3 bytes

while element:
# Convert to signed integer before adding to data array
iVAl = int.from_bytes(element, byteorder='big', signed=True)
data_array.append(iVAl) # adds the reshaped data from the bd file to the data frame
element = file.read(3)

np_array = np.array(data_array) # create numpy array from the list
np_array = np.reshape(np_array, (-1, 10)) # convert the 1d array to 2d array with 10 cols


df = pd.DataFrame(np_array) # Creates a Dataframe in pandas from the bd data
df.columns = ['Count', 'no clue', 'g2g', 'g18g', 'g50g', 'ppm', 'g200g', 'gX55g', 'gY55g', 'g250g'] # names columns

# APPLY CALIBRATION FACTORS
if BD == 3: # calibration factors from March 2023
g2g = (df['g2g']-33570.1)/1614577.9 - offset# accelerometers are in g
g18g = (df['g18g']+13495)/163387.2 - offset
g50g = (df['g50g']-238817.4)/63779.5 - offset
ppm = ((df['ppm']-139040.1)/20705) * 6.89475729 # converts to kPa
g200g = ((df['g200g'] -262332.4/38888.7)) - offset
gX55g = (df['gX55g']-70406)/59754.3
gY55g = (df['gY55g']-69421.1)/141871.5
g250g = (df['g250g']-39077.4)/13746.9 - offset

if BD == 2: # calibration factors from Aug 26, 2021

g2g = (df['g2g']+37242.2)/1639250.2 - offset# accelerometers are in g
g18g = (df['g18g']-26867.0)/160460.5 - offset
g50g = (df['g50g']-213923.3)/64080.7- offset
ppm = ((df['ppm']+55518.9)/18981.7) * 6.89475729 # converts to kPa
g200g = (df['g200g']-171448.6)/30334.2 - offset
gX55g = (df['gX55g']-54242.6)/64767.7
gY55g = (df['gY55g']-40574.2)/66343.1
g250g = (df['g250g']-40614.9)/13654.6 - offset

if BD == 1: # calibration factors from July 2020
g2g = (df['g2g']-42590.9)/1626361.1 - offset # accelerometers are in g
g18g = (df['g18g']-44492.9)/161125.5 - offset
g50g = (df['g50g']-171656.1)/64020.3 - offset
ppm = ((df['ppm']+31776.1)/20679.7) * 6.89475729 # this is kPa
g200g = (df['g200g'] -723404.8)/32209.7 - offset
gX55g = (df['gX55g'] -54881.1)/64858.6
gY55g = (df['gY55g']-28735.5)/63839.9
g250g = (df['g250g']+13299.7)/13697.1 - offset

time = (df['Count']-df['Count'].iloc[0]+1)/2000 # gives time in s
count = df["Count"]-df['Count'].iloc[0]

# make a new dataframe of the calibrated values in units of g
dfCalg = pd.DataFrame([count, time, g2g, g18g, g50g, g200g, g250g, gX55g, gY55g, ppm])
dfCalg = dfCalg.T
dfCalg.columns = ['Count', 'Time (s)', '2g (g)', '18g (g)', '50g (g)', '200g (g)', '250g (g)', 'X55g (g)', 'Y55g (g)', 'Pore Pressure (kPa)'] # names columns
#print(dfCalg)

#make a new dataframe of the calibrated values in units of m/s^2
dfCal = pd.DataFrame([count, time, g2g, g18g, g50g, g200g, g250g, gX55g, gY55g, ppm])
dfCal = dfCal.T
dfCal.columns = ['Count','Time (s)', '2g (m/s^2)', '18g (m/s^2)', '50g (m/s^2)', '200g (m/s^2)', '250g (m/s^2)', 'X55g (m/s^2)', 'Y55g (m/s^2)', 'Pore Pressure (kPa)'] # names columns
dfCal['2g (m/s^2)'] = dfCal['2g (m/s^2)'] * 9.80665
dfCal['18g (m/s^2)'] = dfCal['18g (m/s^2)'] * 9.80665
dfCal['50g (m/s^2)'] = dfCal['50g (m/s^2)'] * 9.80665
dfCal['200g (m/s^2)'] = dfCal['200g (m/s^2)'] * 9.80665
dfCal['250g (m/s^2)'] = dfCal['250g (m/s^2)'] * 9.80665
dfCal['X55g (m/s^2)'] = dfCal['X55g (m/s^2)'] * 9.80665
dfCal['Y55g (m/s^2)'] = dfCal['Y55g (m/s^2)'] * 9.80665
#print(dfCal)

overviewplot()

name = [*newName]

newNamefun()

print("all files checked")
Loading

0 comments on commit e893a74

Please sign in to comment.