Skip to content

Commit

Permalink
switching to library plotting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
valentina-s authored Jun 9, 2024
1 parent 1bf7ef0 commit f75bc78
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions noise_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,54 +36,10 @@
if not os.path.exists('img'):
os.makedirs('img')

def plot_spec(psd_df):
"""
This function converts a table of power spectral data, having the columns represent frequency bins and the rows
represent time segments, to a spectrogram.
Args:
psd_df: Dataframe of power spectral data.
Returns: Spectral plot
"""

fig = go.Figure(
data=go.Heatmap(x=psd_df.index, y=psd_df.columns, z=psd_df.values.transpose(), colorscale='Viridis',
colorbar={"title": 'Magnitude'}))
fig.update_layout(
title="Hydrophone Power Spectral Density",
xaxis_title="Time",
yaxis_title="Frequency (Hz)",
legend_title="Magnitude"
)
fig.update_yaxes(type="log")
fig.show()
return(fig)

def plot_bb(bb_df):
"""
This function plots the broadband levels in relative decibels.
Args:
bb_df: Dataframe of broadband levels.
Returns: Time series of broadband levels.
"""
plt.figure()
plt.plot(bb_df)
plt.title('Relative Broadband Levels')
plt.xlabel('Time')
plt.ylabel('Relative Decibels')
plt.xticks(rotation = 45)
# plt.show()
return(plt.gcf())



# Create and save psd plot
fig = plot_spec(psd_df)
fig.write_image('img/psd.png')



# Create and save bb plot
fig = plot_bb(bb_df)
fig.savefig('img/broadband.png')

0 comments on commit f75bc78

Please sign in to comment.