diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3516cb9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.formatting.provider": "autopep8" +} \ No newline at end of file diff --git a/code/chirpdetection.py b/code/chirpdetection.py index 7146ec3..b1e232c 100644 --- a/code/chirpdetection.py +++ b/code/chirpdetection.py @@ -11,6 +11,9 @@ from thunderfish.powerspectrum import spectrogram, decibel from modules.filters import bandpass_filter, envelope, highpass_filter from modules.filehandling import ConfLoader, LoadData +from modules.plotstyle import PlotStyle + +ps = PlotStyle() def instantaneos_frequency( @@ -275,19 +278,19 @@ def main(datapath: str) -> None: ) # compute envelopes - baseline_envelope = envelope( + baseline_envelope_unfiltered = envelope( baseline, data.raw_rate, config.envelope_cutoff) search_envelope = envelope( search, data.raw_rate, config.envelope_cutoff) # highpass filter envelopes baseline_envelope = highpass_filter( - baseline_envelope, + baseline_envelope_unfiltered, data.raw_rate, config.envelope_highpass_cutoff ) - baseline_envelope = np.abs(baseline_envelope) + # baseline_envelope = np.abs(baseline_envelope) # search_envelope = highpass_filter( # search_envelope, # data.raw_rate, @@ -323,6 +326,7 @@ def main(datapath: str) -> None: int(window_edge), len(baseline_envelope) - int(window_edge) ) + baseline_envelope_unfiltered = baseline_envelope_unfiltered[valid] baseline_envelope = baseline_envelope[valid] search_envelope = search_envelope[valid] @@ -374,23 +378,22 @@ def main(datapath: str) -> None: # plot baseline instantaneos frequency axs[1, i].plot(baseline_freq_time, baseline_freq - - np.median(baseline_freq), marker=".") + np.median(baseline_freq)) # plot waveform of filtered signal - axs[2, i].plot(time_oi, baseline, c="k") + axs[2, i].plot(time_oi, baseline, c=ps.green) - # plot narrow filtered baseline + # plot broad filtered baseline axs[2, i].plot( time_oi, - baseline_envelope, - c="orange", + broad_baseline, ) - # plot broad filtered baseline + # plot narrow filtered baseline envelope axs[2, i].plot( time_oi, - broad_baseline, - c="green", + baseline_envelope_unfiltered, + c=ps.red ) # plot waveform of filtered search signal @@ -400,7 +403,7 @@ def main(datapath: str) -> None: axs[3, i].plot( time_oi, search_envelope, - c="orange", + c=ps.red ) # plot filtered and rectified envelope @@ -408,7 +411,7 @@ def main(datapath: str) -> None: axs[4, i].scatter( (time_oi)[baseline_peaks], baseline_envelope[baseline_peaks], - c="red", + c=ps.red, ) # plot envelope of search signal @@ -416,7 +419,7 @@ def main(datapath: str) -> None: axs[5, i].scatter( (time_oi)[search_peaks], search_envelope[search_peaks], - c="red", + c=ps.red, ) # plot filtered instantaneous frequency @@ -424,7 +427,7 @@ def main(datapath: str) -> None: axs[6, i].scatter( baseline_freq_time[inst_freq_peaks], np.abs(inst_freq_filtered)[inst_freq_peaks], - c="red", + c=ps.red, ) axs[6, i].set_xlabel("Time [s]") diff --git a/code/chirpdetector_conf.yml b/code/chirpdetector_conf.yml index 6db5142..b60518c 100644 --- a/code/chirpdetector_conf.yml +++ b/code/chirpdetector_conf.yml @@ -13,7 +13,7 @@ search_boundary: 100 envelope_cutoff: 25 # Cutoff frequency for envelope highpass filter -envelope_highpass_cutoff: 5 +envelope_highpass_cutoff: 4 # Cutoff frequency for envelope of envelope envelope_envelope_cutoff: 5 diff --git a/code/modules/plotstyle.py b/code/modules/plotstyle.py index 0f7fd5f..9e382a7 100644 --- a/code/modules/plotstyle.py +++ b/code/modules/plotstyle.py @@ -18,17 +18,17 @@ def PlotStyle() -> None: black = "#111116" white = "#e0e4f7" gray = "#6c6e7d" - pink = "#f5c2e7" - purple = "#cba6f7" - red = "#f38ba8" - maroon = "#eba0ac" - orange = "#fab387" - yellow = "#f9e2af" - green = "#a6e3a1" - teal = "#94e2d5" - sky = "#89dceb" - sapphire = "#74c7ec" blue = "#89b4fa" + sapphire = "#74c7ec" + sky = "#89dceb" + teal = "#94e2d5" + green = "#a6e3a1" + yellow = "#f9e2af" + orange = "#fab387" + maroon = "#eba0ac" + red = "#f38ba8" + purple = "#cba6f7" + pink = "#f5c2e7" lavender = "#b4befe" @classmethod @@ -218,7 +218,7 @@ def PlotStyle() -> None: plt.rcParams["image.cmap"] = 'cmo.haline' # plt.rcParams["axes.xmargin"] = 0.1 # plt.rcParams["axes.ymargin"] = 0.15 - plt.rcParams["axes.titlelocation"] = "center" + plt.rcParams["axes.titlelocation"] = "left" plt.rcParams["axes.titlesize"] = BIGGER_SIZE # plt.rcParams["axes.titlepad"] = -10 plt.rcParams["legend.frameon"] = False @@ -244,8 +244,8 @@ def PlotStyle() -> None: plt.rcParams["text.color"] = white plt.rcParams["axes.facecolor"] = black # axes background color plt.rcParams["axes.edgecolor"] = gray # axes edge color - plt.rcParams["axes.grid"] = True # display grid or not - plt.rcParams["axes.grid.axis"] = "y" # which axis the grid is applied to + # plt.rcParams["axes.grid"] = True # display grid or not + # plt.rcParams["axes.grid.axis"] = "y" # which axis the grid is applied to plt.rcParams["axes.labelcolor"] = white plt.rcParams["axes.axisbelow"] = True # draw axis gridlines and ticks: plt.rcParams["axes.spines.left"] = True # display axis spines @@ -254,18 +254,18 @@ def PlotStyle() -> None: plt.rcParams["axes.spines.right"] = False plt.rcParams["axes.prop_cycle"] = cycler( 'color', [ - '#f5c2e7', - '#cba6f7', - '#f38ba8', - '#eba0ac', - '#fab387', - '#f9e2af', - '#a6e3a1', - '#94e2d5', - '#89dceb', - '#74c7ec', - '#89b4fa', '#b4befe', + '#89b4fa', + '#74c7ec', + '#89dceb', + '#94e2d5', + '#a6e3a1', + '#f9e2af', + '#fab387', + '#eba0ac', + '#f38ba8', + '#cba6f7', + '#f5c2e7', ]) plt.rcParams["xtick.color"] = gray # color of the ticks plt.rcParams["ytick.color"] = gray # color of the ticks