This repository was archived by the owner on Aug 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotWSPRspectrum.py
More file actions
executable file
·56 lines (44 loc) · 1.54 KB
/
PlotWSPRspectrum.py
File metadata and controls
executable file
·56 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
"""
plot spectrum and time of WSPR signals
./PlotWSPRspectrum.py ~/data/170309_2210.wav -f 1400 1700 -t 40 46
"""
from pathlib import Path
from datetime import datetime,timedelta
from pytz import UTC
from numpy import arange
from scipy.io import wavfile
from matplotlib.pyplot import figure,show
import seaborn
#
from piradar.plots import spec
FTICK = (1400,1600) # limit of WSPR audio frequency [Hz]
def wspr_spectrum(wavfn,flim=None,tlim=None):
wavfn = Path(wavfn).expanduser()
#%% get absolute time
t0 = datetime.strptime(wavfn.stem[:11],'%y%m%d_%H%M').replace(tzinfo=UTC)
fs,dat = wavfile.read(wavfn)
if tlim:
i = slice(int(tlim[0]*fs), int(tlim[1]*fs))
dat = dat[i]
t0 += timedelta(seconds=tlim[0])
else:
tlim = [0]
t = [t0 + timedelta(seconds=T) for T in arange(0,dat.size//fs,1/fs)]
spec(dat,fs,flim,t0,FTICK)
fg = figure()
ax = fg.gca()
ax.plot(t,dat)
ax.set_xlabel('time [UTC]')
ax.set_ylabel('amplitude [raw]')
ax.set_title(t0.strftime('%Y-%m-%d'))
ax.autoscale(True,tight=True)
if __name__ == '__main__':
from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument('wavfn',help='WSPR recorded wave file, 12kHz')
p.add_argument('-t','--tlim',help='plot between these seconds of the 110 second file',nargs=2,type=float)
p.add_argument('-f','--flim',help='plot between these frequencies Hz',nargs=2,type=float)
p = p.parse_args()
wspr_spectrum(p.wavfn,p.flim,p.tlim)
show()