Created
August 16, 2019 11:37
-
-
Save dipanjanS/4bd6f83b3f1e2eeb87a51de7cc494ee4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get sample signal | |
import ibmseti | |
sample_data = ibmseti.compamp.SimCompamp(open(raw_signal_files[0],'rb').read()) | |
print('File Name:', raw_signal_files[0]) | |
print('Header:', sample_data.header()) | |
# Output | |
Out [4]: File Name: ./primary_small_v3/a33c85e3-9316-4871-bcdc-10882a7fe6bd.dat | |
Header: {'signal_classification': 'narrowband', | |
'uuid': 'a33c85e3-9316-4871-bcdc-10882a7fe6bd'} | |
# Convert raw signal into spectrogram | |
sample_spec = sample_data.get_spectrogram() | |
sample_spec.shape | |
# Output | |
Out [5]: (384, 512) | |
# Visualize sample spectrogram | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
fig, ax = plt.subplots(2, 2, figsize=(10, 6)) | |
p1 = ax[0, 0].imshow(sample_spec, aspect="auto") | |
t1 = ax[0, 0].set_title('Sample Spectrogram') | |
p2 = ax[0, 1].hist(sample_spec) | |
t2 = ax[0, 1].set_title('Sample Spectrogram - Histogram') | |
p3 = ax[1, 0].imshow(np.log(sample_spec), aspect="auto") | |
t3 = ax[1, 0].set_title('Sample Spectrogram (log scaled)') | |
p4 = ax[1, 1].hist(np.log(sample_spec)) | |
t4 = ax[1, 1].set_title('Sample Spectrogram - Histogram (log scaled)') | |
fig.tight_layout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment