質問編集履歴
2
コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,558 +1,4 @@
|
|
1
|
-
```python
|
2
|
-
|
3
|
-
#!/usr/bin/env python
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
import numpy as np
|
8
|
-
|
9
|
-
import matplotlib.pyplot as plt
|
10
|
-
|
11
|
-
import sys
|
12
|
-
|
13
|
-
import glob
|
14
|
-
|
15
|
-
import matplotlib.dates as mdates
|
16
|
-
|
17
|
-
from pylab import *
|
18
|
-
|
19
|
-
from struct import *
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
sta_name="SGD"
|
24
|
-
|
25
|
-
dyear = 2019
|
26
|
-
|
27
|
-
dyear = 2019
|
28
|
-
|
29
|
-
dmon = 10
|
30
|
-
|
31
|
-
dday = 12
|
32
|
-
|
33
|
-
#dmon = 12
|
34
|
-
|
35
|
-
#dday = 30
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# the frequency of the carrier wave
|
40
|
-
|
41
|
-
carrier = 0 # 5 MHz
|
42
|
-
|
43
|
-
carrier = 1 # 8 MHz
|
44
|
-
|
45
|
-
carrier = 2 # 6 MHz
|
46
|
-
|
47
|
-
carrier = 3 # 9 MHz
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
flabel=[5, 8, 6, 9]
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
datadir='C:\Users\berus\Documents\kuruma\hfd\hfddatabin'
|
60
|
-
|
61
|
-
datadir='C:\Users\berus\Documents\kuruma\hfd\hfddatabin'
|
62
|
-
|
63
|
-
hfddir=datadir+"hfd/{0:04}/".format(dyear)
|
64
|
-
|
65
|
-
bindir=datadir+"bin/{0:04}/".format(dyear)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
hfd_name=hfddir+"{0:04}{1:02}{2:02}*.hfd".format(dyear,dmon,dday)
|
72
|
-
|
73
|
-
bin_name=bindir+"{0:04}{1:02}{2:02}*-{3:1}.bin".format(dyear,dmon,dday,carrier)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
hfd_file=glob.glob(hfd_name)
|
80
|
-
|
81
|
-
bin_file=glob.glob(bin_name)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
print(hfd_file)
|
86
|
-
|
87
|
-
print(bin_file)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
if not (len(hfd_file)==1 and len(bin_file)==1):
|
94
|
-
|
95
|
-
print(hfd_file)
|
96
|
-
|
97
|
-
print(bin_file)
|
98
|
-
|
99
|
-
print("stop because the number of files is not one.")
|
100
|
-
|
101
|
-
sys.exit()
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
sec=[]
|
106
|
-
|
107
|
-
hfd_doppler=[]
|
108
|
-
|
109
|
-
hfd_intensity=[]
|
110
|
-
|
111
|
-
hfd_time=[]
|
112
|
-
|
113
|
-
bin_time=[]
|
114
|
-
|
115
|
-
inittime = datetime.datetime(dyear, dmon, dday, 0, 0, 0, 0)
|
116
|
-
|
117
|
-
with open(hfd_file[0]) as f:
|
118
|
-
|
119
|
-
d = f.readline()
|
120
|
-
|
121
|
-
# print(d)
|
122
|
-
|
123
|
-
d = f.readline()
|
124
|
-
|
125
|
-
# print(d)
|
126
|
-
|
127
|
-
freqs=d.split()
|
128
|
-
|
129
|
-
# print(freqs)
|
130
|
-
|
131
|
-
d = f.readline()
|
132
|
-
|
133
|
-
# print(d)
|
134
|
-
|
135
|
-
d = f.readline()
|
136
|
-
|
137
|
-
# print(d)
|
138
|
-
|
139
|
-
d = f.readline()
|
140
|
-
|
141
|
-
for line in f.readlines():
|
142
|
-
|
143
|
-
data=line.split()
|
144
|
-
|
145
|
-
isec =int(float(data[2]))
|
146
|
-
|
147
|
-
msec = (float(data[2]) - isec)*1.0e6
|
148
|
-
|
149
|
-
tbuf = datetime.datetime(dyear,dmon,dday,int(data[0]),int(data[1]), isec, int(msec))
|
150
|
-
|
151
|
-
hfd_doppler.append(float(data[carrier*2+3])-8.0)
|
152
|
-
|
153
|
-
hfd_intensity.append(float(data[carrier*2+4]))
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
hfd_time.append(tbuf)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
#print(hfd_time)
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
#plt.plot(hfd_time,hfd_doppler)
|
166
|
-
|
167
|
-
#print('len(hfd_doppler)',len(hfd_doppler))
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
#plt.show()
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
#sys.exit()
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
#plt.figure(1)
|
180
|
-
|
181
|
-
#plt.plot(hfd_doppler)
|
182
|
-
|
183
|
-
#plt.figure(2)
|
184
|
-
|
185
|
-
#plt.plot(hfd_intensity)
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
# Start time of the data
|
194
|
-
|
195
|
-
shh = 0
|
196
|
-
|
197
|
-
smm = 0
|
198
|
-
|
199
|
-
# End time of the data
|
200
|
-
|
201
|
-
ehh = 24
|
202
|
-
|
203
|
-
#ehh = 23
|
204
|
-
|
205
|
-
emm = 0
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
# the number of ticks
|
210
|
-
|
211
|
-
nt = 24
|
212
|
-
|
213
|
-
nt = 12
|
214
|
-
|
215
|
-
nt = 6
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
timetick=[]
|
220
|
-
|
221
|
-
inittime = datetime.datetime(dyear, dmon, dday, 0, 0, 0, 0)
|
222
|
-
|
223
|
-
starttime = datetime.datetime(dyear, dmon, dday, shh, smm, 0, 0)
|
224
|
-
|
225
|
-
endtime = datetime.datetime(dyear, dmon, dday, ehh, emm, 0, 0)
|
226
|
-
|
227
|
-
stime= (starttime-inittime).seconds
|
228
|
-
|
229
|
-
etime= (endtime-inittime).seconds + 60
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
td = endtime-starttime
|
234
|
-
|
235
|
-
for i in range(nt+1):
|
236
|
-
|
237
|
-
tickbuff = starttime+(td+datetime.timedelta(seconds=60))*i/nt
|
238
|
-
|
239
|
-
timetick.append(tickbuff.strftime('%H:%M'))
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
data = []
|
244
|
-
|
245
|
-
tdata = []
|
246
|
-
|
247
|
-
bin_doppler =[]
|
248
|
-
|
249
|
-
bin_int =[]
|
250
|
-
|
251
|
-
zero_int =[]
|
252
|
-
|
253
|
-
#with open(ofilename, 'rb') as f:
|
254
|
-
|
255
|
-
with open(bin_file[0], 'rb') as f:
|
256
|
-
|
257
|
-
while True:
|
258
|
-
|
259
|
-
d = f.read(2)
|
260
|
-
|
261
|
-
if len(d) == 0:
|
262
|
-
|
263
|
-
break
|
264
|
-
|
265
|
-
tbuf=unpack('<h',d)[0]
|
266
|
-
|
267
|
-
a=tbuf*0.0153
|
268
|
-
|
269
|
-
data.append(a)
|
270
|
-
|
271
|
-
tdata.append(tbuf)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
print("len(data)=",len(data))
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
with open("textdata.dat",mode='w') as of:
|
280
|
-
|
281
|
-
for i in range(0, len(tdata)):
|
282
|
-
|
283
|
-
of.write(str(tdata[i])+"\n")
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
# temporal resolution
|
288
|
-
|
289
|
-
tsamp = 100 # in seconds
|
290
|
-
|
291
|
-
tsamp = 10 # in seconds
|
292
|
-
|
293
|
-
sduration = td.seconds+60
|
294
|
-
|
295
|
-
timenum=int(sduration/tsamp)
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
#Freq range from -8 Hz to 8 Hz
|
300
|
-
|
301
|
-
#fstart = 0
|
302
|
-
|
303
|
-
#fend = 656
|
304
|
-
|
305
|
-
fstart = 10
|
306
|
-
|
307
|
-
fend = 646
|
308
|
-
|
309
|
-
fend = 500
|
310
|
-
|
311
|
-
plt.ylim(-8,8)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
###Freq range from -6 Hz to 6 Hz
|
316
|
-
|
317
|
-
fstart = 60
|
318
|
-
|
319
|
-
fend = 600
|
320
|
-
|
321
|
-
plt.ylim(-6.5,6.5)
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
##Freq range from -4 Hz to 4 Hz
|
326
|
-
|
327
|
-
fstart = 164
|
328
|
-
|
329
|
-
fend = 492
|
330
|
-
|
331
|
-
plt.ylim(-4,4)
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
###Freq range from -3 Hz to 3 Hz
|
336
|
-
|
337
|
-
#fstart = 205
|
338
|
-
|
339
|
-
#fend = 451
|
340
|
-
|
341
|
-
#plt.ylim(-3,3)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
fsize = fend - fstart
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
# FFT size and sample rate (100 Hz)
|
350
|
-
|
351
|
-
fftsize = 4096
|
352
|
-
|
353
|
-
#fftsize = 2048
|
354
|
-
|
355
|
-
#fftsize = 1024
|
356
|
-
|
357
|
-
#fftsize = 8192
|
358
|
-
|
359
|
-
dt = 0.01
|
360
|
-
|
361
|
-
fs = 1/dt
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
freqbuf = np.zeros(fsize)
|
366
|
-
|
367
|
-
afftbuf = np.zeros(fsize)
|
368
|
-
|
369
|
-
spectl = np.zeros((fsize,timenum+1))
|
370
|
-
|
371
|
-
freq = np.fft.fftfreq(fftsize,dt)
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
freqbuf[:] = freq[fstart:fend] - 8.0
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
print("freqbuf[160-170]",freqbuf[160:170])
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
for i in range(0, timenum):
|
384
|
-
|
385
|
-
snum=stime*100+i*(tsamp*100)
|
386
|
-
|
387
|
-
enum=snum+fftsize
|
388
|
-
|
389
|
-
dbuf = data[snum:enum]
|
390
|
-
|
391
|
-
fwindow=np.hamming(len(dbuf))
|
392
|
-
|
393
|
-
# fwindow=np.kaiser(len(dbuf),6)
|
394
|
-
|
395
|
-
# print(i,len(dbuf),len(fwindow))
|
396
|
-
|
397
|
-
# fftbuf = np.fft.fft(fwindow*dbuf)/(fftsize*dt)
|
398
|
-
|
399
|
-
fftbuf = np.fft.fft(fwindow*dbuf)
|
400
|
-
|
401
|
-
afftbuf = 20*np.log10(np.abs(fftbuf[fstart:fend])/2.0)
|
402
|
-
|
403
|
-
# print('len(afftbuf)',len(afftbuf))
|
404
|
-
|
405
|
-
spectl[:,i] = afftbuf[:]
|
406
|
-
|
407
|
-
bin_doppler.append(freqbuf[np.argmax(afftbuf)])
|
408
|
-
|
409
|
-
bin_int.append(np.max(afftbuf))
|
410
|
-
|
411
|
-
zero_int.append(afftbuf[164])
|
412
|
-
|
413
|
-
hh = int(i*10/3600)
|
414
|
-
|
415
|
-
mm = int((i*10-hh*3600)/60)
|
416
|
-
|
417
|
-
ss = int(i*10-hh*3600-mm*60)
|
418
|
-
|
419
|
-
# print(i,snum, hh,mm,ss)
|
420
|
-
|
421
|
-
tbuf = datetime.datetime(dyear, dmon, dday, hh, mm, ss, 0)
|
422
|
-
|
423
|
-
bin_time.append(tbuf)
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
plt.figure(1)
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
fig_ttle ="{0:04}/{1:02}/{2:02} {3:1}MHz Sugadaira".format(dyear,dmon,dday,flabel[carrier])
|
434
|
-
|
435
|
-
xlabelpos = list(range(0,timenum+1,int(timenum/(nt))))
|
436
|
-
|
437
|
-
plt.xticks(xlabelpos, timetick)
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
x=np.arange(timenum+1)
|
442
|
-
|
443
|
-
y=freqbuf
|
444
|
-
|
445
|
-
plt.axes().set_aspect('auto','datalim')
|
446
|
-
|
447
|
-
pcolor(x,y,spectl,cmap='ocean',vmin=20)
|
448
|
-
|
449
|
-
cb=plt.colorbar()
|
450
|
-
|
451
|
-
cb.set_label('Intensity [dBm]')
|
452
|
-
|
453
|
-
#plt.title("2011/03/11 5MHz Sugadaira")
|
454
|
-
|
455
|
-
plt.title(fig_ttle)
|
456
|
-
|
457
|
-
plt.ylabel("Doppler Frequency [Hz]")
|
458
|
-
|
459
|
-
plt.xlabel("Time [JST]")
|
460
|
-
|
461
|
-
plt.plot(x[0:timenum],bin_doppler,color="r",linewidth=0.5)
|
462
|
-
|
463
|
-
#plt.plot(hfd_doppler,color="b",linewidth=0.5)
|
464
|
-
|
465
|
-
#plt.savefig("a.png")
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
fig = plt.figure(2)
|
470
|
-
|
471
|
-
ax = fig.add_subplot(1,1,1)
|
472
|
-
|
473
|
-
daysFmt = mdates.DateFormatter('%H:%M')
|
474
|
-
|
475
|
-
ax.xaxis.set_major_formatter(daysFmt)
|
476
|
-
|
477
|
-
plt.title(str(dyear)+"/"+str(dmon)+"/"+str(dday)+" "+sta_name+" "+str(flabel[carrier])+" MHz Doppler Shift")
|
478
|
-
|
479
|
-
plt.plot(bin_time,bin_doppler,label="bin",linewidth=0.5)
|
480
|
-
|
481
|
-
plt.plot(hfd_time,hfd_doppler,label="hfd",linewidth=0.5)
|
482
|
-
|
483
|
-
plt.ylabel("Doppler Frequency [Hz]")
|
484
|
-
|
485
|
-
plt.xlabel("Time [JST]")
|
486
|
-
|
487
|
-
plt.legend()
|
488
|
-
|
489
|
-
#plt.savefig("b.png")
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
fig = plt.figure(3)
|
494
|
-
|
495
|
-
ax = fig.add_subplot(1,1,1)
|
496
|
-
|
497
|
-
daysFmt = mdates.DateFormatter('%H:%M')
|
498
|
-
|
499
|
-
ax.xaxis.set_major_formatter(daysFmt)
|
500
|
-
|
501
|
-
plt.title(str(dyear)+"/"+str(dmon)+"/"+str(dday)+" "+sta_name+" "+str(flabel[carrier])+" MHz Signal Intensity")
|
502
|
-
|
503
|
-
plt.plot(bin_time,bin_int,label="bin",linewidth=0.5)
|
504
|
-
|
505
|
-
#plt.plot(bin_time,zero_int,label="zero")
|
506
|
-
|
507
|
-
plt.plot(hfd_time,hfd_intensity,label="hfd",linewidth=0.5)
|
508
|
-
|
509
|
-
plt.ylabel("Signal Intensity [Hz]")
|
510
|
-
|
511
|
-
plt.xlabel("Time [JST]")
|
512
|
-
|
513
|
-
plt.legend(loc='lower right')
|
514
|
-
|
515
|
-
#plt.savefig("c.png")
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
#for i in range(0, timenum):
|
520
|
-
|
521
|
-
for i in range(0, 7000):
|
522
|
-
|
523
|
-
hh = (i*10)/3600
|
524
|
-
|
525
|
-
mm = (i*10-hh*3600)/60
|
526
|
-
|
527
|
-
ss = i*10-hh*3600-mm*60
|
528
|
-
|
529
|
-
# print(x[i],bin_doppler[i],bin_int[i])
|
530
|
-
|
531
|
-
# print hfd_time[i],hfd_doppler[i],hfd_intensity[i]
|
532
|
-
|
533
|
-
# print('{0:02} {1:02} {2:02} {3:6.3f} {4:7.3f} {5:6.3f} {7:7.3f}'.format(hh,mm,ss,bin_doppler[i],bin_int[i],hfd_doppler[i],hfd_intensity[i]))
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
#plt.savefig("20150101.pdf")
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
#fig=plt.figure(4)
|
542
|
-
|
543
|
-
##plt.plot(x[0:timenum],data[0:timenum])
|
544
|
-
|
545
|
-
#plt.plot(x[1000:6000],tdata[1000:6000],linewidth=0.3)
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
plt.show()
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
1
|
+
Anaconda Prompt上で.pyファイルを実行すると、
|
556
2
|
|
557
3
|
[]
|
558
4
|
|
1
ソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,558 @@
|
|
1
|
+
```python
|
2
|
+
|
3
|
+
#!/usr/bin/env python
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
import numpy as np
|
8
|
+
|
9
|
+
import matplotlib.pyplot as plt
|
10
|
+
|
11
|
+
import sys
|
12
|
+
|
13
|
+
import glob
|
14
|
+
|
15
|
+
import matplotlib.dates as mdates
|
16
|
+
|
17
|
+
from pylab import *
|
18
|
+
|
19
|
+
from struct import *
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
sta_name="SGD"
|
24
|
+
|
25
|
+
dyear = 2019
|
26
|
+
|
27
|
+
dyear = 2019
|
28
|
+
|
29
|
+
dmon = 10
|
30
|
+
|
31
|
+
dday = 12
|
32
|
+
|
33
|
+
#dmon = 12
|
34
|
+
|
35
|
+
#dday = 30
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# the frequency of the carrier wave
|
40
|
+
|
41
|
+
carrier = 0 # 5 MHz
|
42
|
+
|
43
|
+
carrier = 1 # 8 MHz
|
44
|
+
|
45
|
+
carrier = 2 # 6 MHz
|
46
|
+
|
47
|
+
carrier = 3 # 9 MHz
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
flabel=[5, 8, 6, 9]
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
datadir='C:\Users\berus\Documents\kuruma\hfd\hfddatabin'
|
60
|
+
|
61
|
+
datadir='C:\Users\berus\Documents\kuruma\hfd\hfddatabin'
|
62
|
+
|
63
|
+
hfddir=datadir+"hfd/{0:04}/".format(dyear)
|
64
|
+
|
65
|
+
bindir=datadir+"bin/{0:04}/".format(dyear)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
hfd_name=hfddir+"{0:04}{1:02}{2:02}*.hfd".format(dyear,dmon,dday)
|
72
|
+
|
73
|
+
bin_name=bindir+"{0:04}{1:02}{2:02}*-{3:1}.bin".format(dyear,dmon,dday,carrier)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
hfd_file=glob.glob(hfd_name)
|
80
|
+
|
81
|
+
bin_file=glob.glob(bin_name)
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
print(hfd_file)
|
86
|
+
|
87
|
+
print(bin_file)
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
if not (len(hfd_file)==1 and len(bin_file)==1):
|
94
|
+
|
95
|
+
print(hfd_file)
|
96
|
+
|
97
|
+
print(bin_file)
|
98
|
+
|
99
|
+
print("stop because the number of files is not one.")
|
100
|
+
|
101
|
+
sys.exit()
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
sec=[]
|
106
|
+
|
107
|
+
hfd_doppler=[]
|
108
|
+
|
109
|
+
hfd_intensity=[]
|
110
|
+
|
111
|
+
hfd_time=[]
|
112
|
+
|
113
|
+
bin_time=[]
|
114
|
+
|
115
|
+
inittime = datetime.datetime(dyear, dmon, dday, 0, 0, 0, 0)
|
116
|
+
|
117
|
+
with open(hfd_file[0]) as f:
|
118
|
+
|
119
|
+
d = f.readline()
|
120
|
+
|
121
|
+
# print(d)
|
122
|
+
|
123
|
+
d = f.readline()
|
124
|
+
|
125
|
+
# print(d)
|
126
|
+
|
127
|
+
freqs=d.split()
|
128
|
+
|
129
|
+
# print(freqs)
|
130
|
+
|
131
|
+
d = f.readline()
|
132
|
+
|
133
|
+
# print(d)
|
134
|
+
|
135
|
+
d = f.readline()
|
136
|
+
|
137
|
+
# print(d)
|
138
|
+
|
139
|
+
d = f.readline()
|
140
|
+
|
141
|
+
for line in f.readlines():
|
142
|
+
|
143
|
+
data=line.split()
|
144
|
+
|
145
|
+
isec =int(float(data[2]))
|
146
|
+
|
147
|
+
msec = (float(data[2]) - isec)*1.0e6
|
148
|
+
|
149
|
+
tbuf = datetime.datetime(dyear,dmon,dday,int(data[0]),int(data[1]), isec, int(msec))
|
150
|
+
|
151
|
+
hfd_doppler.append(float(data[carrier*2+3])-8.0)
|
152
|
+
|
153
|
+
hfd_intensity.append(float(data[carrier*2+4]))
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
hfd_time.append(tbuf)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
#print(hfd_time)
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
#plt.plot(hfd_time,hfd_doppler)
|
166
|
+
|
167
|
+
#print('len(hfd_doppler)',len(hfd_doppler))
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
#plt.show()
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
#sys.exit()
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
#plt.figure(1)
|
180
|
+
|
181
|
+
#plt.plot(hfd_doppler)
|
182
|
+
|
183
|
+
#plt.figure(2)
|
184
|
+
|
185
|
+
#plt.plot(hfd_intensity)
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
# Start time of the data
|
194
|
+
|
195
|
+
shh = 0
|
196
|
+
|
197
|
+
smm = 0
|
198
|
+
|
199
|
+
# End time of the data
|
200
|
+
|
201
|
+
ehh = 24
|
202
|
+
|
203
|
+
#ehh = 23
|
204
|
+
|
205
|
+
emm = 0
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
# the number of ticks
|
210
|
+
|
211
|
+
nt = 24
|
212
|
+
|
213
|
+
nt = 12
|
214
|
+
|
215
|
+
nt = 6
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
timetick=[]
|
220
|
+
|
221
|
+
inittime = datetime.datetime(dyear, dmon, dday, 0, 0, 0, 0)
|
222
|
+
|
223
|
+
starttime = datetime.datetime(dyear, dmon, dday, shh, smm, 0, 0)
|
224
|
+
|
225
|
+
endtime = datetime.datetime(dyear, dmon, dday, ehh, emm, 0, 0)
|
226
|
+
|
227
|
+
stime= (starttime-inittime).seconds
|
228
|
+
|
229
|
+
etime= (endtime-inittime).seconds + 60
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
td = endtime-starttime
|
234
|
+
|
235
|
+
for i in range(nt+1):
|
236
|
+
|
237
|
+
tickbuff = starttime+(td+datetime.timedelta(seconds=60))*i/nt
|
238
|
+
|
239
|
+
timetick.append(tickbuff.strftime('%H:%M'))
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
data = []
|
244
|
+
|
245
|
+
tdata = []
|
246
|
+
|
247
|
+
bin_doppler =[]
|
248
|
+
|
249
|
+
bin_int =[]
|
250
|
+
|
251
|
+
zero_int =[]
|
252
|
+
|
253
|
+
#with open(ofilename, 'rb') as f:
|
254
|
+
|
255
|
+
with open(bin_file[0], 'rb') as f:
|
256
|
+
|
257
|
+
while True:
|
258
|
+
|
259
|
+
d = f.read(2)
|
260
|
+
|
261
|
+
if len(d) == 0:
|
262
|
+
|
263
|
+
break
|
264
|
+
|
265
|
+
tbuf=unpack('<h',d)[0]
|
266
|
+
|
267
|
+
a=tbuf*0.0153
|
268
|
+
|
269
|
+
data.append(a)
|
270
|
+
|
271
|
+
tdata.append(tbuf)
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
print("len(data)=",len(data))
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
with open("textdata.dat",mode='w') as of:
|
280
|
+
|
281
|
+
for i in range(0, len(tdata)):
|
282
|
+
|
283
|
+
of.write(str(tdata[i])+"\n")
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
# temporal resolution
|
288
|
+
|
289
|
+
tsamp = 100 # in seconds
|
290
|
+
|
291
|
+
tsamp = 10 # in seconds
|
292
|
+
|
293
|
+
sduration = td.seconds+60
|
294
|
+
|
295
|
+
timenum=int(sduration/tsamp)
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
#Freq range from -8 Hz to 8 Hz
|
300
|
+
|
301
|
+
#fstart = 0
|
302
|
+
|
303
|
+
#fend = 656
|
304
|
+
|
305
|
+
fstart = 10
|
306
|
+
|
307
|
+
fend = 646
|
308
|
+
|
309
|
+
fend = 500
|
310
|
+
|
311
|
+
plt.ylim(-8,8)
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
###Freq range from -6 Hz to 6 Hz
|
316
|
+
|
317
|
+
fstart = 60
|
318
|
+
|
319
|
+
fend = 600
|
320
|
+
|
321
|
+
plt.ylim(-6.5,6.5)
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
##Freq range from -4 Hz to 4 Hz
|
326
|
+
|
327
|
+
fstart = 164
|
328
|
+
|
329
|
+
fend = 492
|
330
|
+
|
331
|
+
plt.ylim(-4,4)
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
###Freq range from -3 Hz to 3 Hz
|
336
|
+
|
337
|
+
#fstart = 205
|
338
|
+
|
339
|
+
#fend = 451
|
340
|
+
|
341
|
+
#plt.ylim(-3,3)
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
fsize = fend - fstart
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
# FFT size and sample rate (100 Hz)
|
350
|
+
|
351
|
+
fftsize = 4096
|
352
|
+
|
353
|
+
#fftsize = 2048
|
354
|
+
|
355
|
+
#fftsize = 1024
|
356
|
+
|
357
|
+
#fftsize = 8192
|
358
|
+
|
359
|
+
dt = 0.01
|
360
|
+
|
361
|
+
fs = 1/dt
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
freqbuf = np.zeros(fsize)
|
366
|
+
|
367
|
+
afftbuf = np.zeros(fsize)
|
368
|
+
|
369
|
+
spectl = np.zeros((fsize,timenum+1))
|
370
|
+
|
371
|
+
freq = np.fft.fftfreq(fftsize,dt)
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
freqbuf[:] = freq[fstart:fend] - 8.0
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
print("freqbuf[160-170]",freqbuf[160:170])
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
for i in range(0, timenum):
|
384
|
+
|
385
|
+
snum=stime*100+i*(tsamp*100)
|
386
|
+
|
387
|
+
enum=snum+fftsize
|
388
|
+
|
389
|
+
dbuf = data[snum:enum]
|
390
|
+
|
391
|
+
fwindow=np.hamming(len(dbuf))
|
392
|
+
|
393
|
+
# fwindow=np.kaiser(len(dbuf),6)
|
394
|
+
|
395
|
+
# print(i,len(dbuf),len(fwindow))
|
396
|
+
|
397
|
+
# fftbuf = np.fft.fft(fwindow*dbuf)/(fftsize*dt)
|
398
|
+
|
399
|
+
fftbuf = np.fft.fft(fwindow*dbuf)
|
400
|
+
|
401
|
+
afftbuf = 20*np.log10(np.abs(fftbuf[fstart:fend])/2.0)
|
402
|
+
|
403
|
+
# print('len(afftbuf)',len(afftbuf))
|
404
|
+
|
405
|
+
spectl[:,i] = afftbuf[:]
|
406
|
+
|
407
|
+
bin_doppler.append(freqbuf[np.argmax(afftbuf)])
|
408
|
+
|
409
|
+
bin_int.append(np.max(afftbuf))
|
410
|
+
|
411
|
+
zero_int.append(afftbuf[164])
|
412
|
+
|
413
|
+
hh = int(i*10/3600)
|
414
|
+
|
415
|
+
mm = int((i*10-hh*3600)/60)
|
416
|
+
|
417
|
+
ss = int(i*10-hh*3600-mm*60)
|
418
|
+
|
419
|
+
# print(i,snum, hh,mm,ss)
|
420
|
+
|
421
|
+
tbuf = datetime.datetime(dyear, dmon, dday, hh, mm, ss, 0)
|
422
|
+
|
423
|
+
bin_time.append(tbuf)
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
plt.figure(1)
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
fig_ttle ="{0:04}/{1:02}/{2:02} {3:1}MHz Sugadaira".format(dyear,dmon,dday,flabel[carrier])
|
434
|
+
|
435
|
+
xlabelpos = list(range(0,timenum+1,int(timenum/(nt))))
|
436
|
+
|
437
|
+
plt.xticks(xlabelpos, timetick)
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
x=np.arange(timenum+1)
|
442
|
+
|
443
|
+
y=freqbuf
|
444
|
+
|
445
|
+
plt.axes().set_aspect('auto','datalim')
|
446
|
+
|
447
|
+
pcolor(x,y,spectl,cmap='ocean',vmin=20)
|
448
|
+
|
449
|
+
cb=plt.colorbar()
|
450
|
+
|
451
|
+
cb.set_label('Intensity [dBm]')
|
452
|
+
|
453
|
+
#plt.title("2011/03/11 5MHz Sugadaira")
|
454
|
+
|
455
|
+
plt.title(fig_ttle)
|
456
|
+
|
457
|
+
plt.ylabel("Doppler Frequency [Hz]")
|
458
|
+
|
459
|
+
plt.xlabel("Time [JST]")
|
460
|
+
|
461
|
+
plt.plot(x[0:timenum],bin_doppler,color="r",linewidth=0.5)
|
462
|
+
|
463
|
+
#plt.plot(hfd_doppler,color="b",linewidth=0.5)
|
464
|
+
|
465
|
+
#plt.savefig("a.png")
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
fig = plt.figure(2)
|
470
|
+
|
471
|
+
ax = fig.add_subplot(1,1,1)
|
472
|
+
|
473
|
+
daysFmt = mdates.DateFormatter('%H:%M')
|
474
|
+
|
475
|
+
ax.xaxis.set_major_formatter(daysFmt)
|
476
|
+
|
477
|
+
plt.title(str(dyear)+"/"+str(dmon)+"/"+str(dday)+" "+sta_name+" "+str(flabel[carrier])+" MHz Doppler Shift")
|
478
|
+
|
479
|
+
plt.plot(bin_time,bin_doppler,label="bin",linewidth=0.5)
|
480
|
+
|
481
|
+
plt.plot(hfd_time,hfd_doppler,label="hfd",linewidth=0.5)
|
482
|
+
|
483
|
+
plt.ylabel("Doppler Frequency [Hz]")
|
484
|
+
|
485
|
+
plt.xlabel("Time [JST]")
|
486
|
+
|
487
|
+
plt.legend()
|
488
|
+
|
489
|
+
#plt.savefig("b.png")
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
fig = plt.figure(3)
|
494
|
+
|
495
|
+
ax = fig.add_subplot(1,1,1)
|
496
|
+
|
497
|
+
daysFmt = mdates.DateFormatter('%H:%M')
|
498
|
+
|
499
|
+
ax.xaxis.set_major_formatter(daysFmt)
|
500
|
+
|
501
|
+
plt.title(str(dyear)+"/"+str(dmon)+"/"+str(dday)+" "+sta_name+" "+str(flabel[carrier])+" MHz Signal Intensity")
|
502
|
+
|
503
|
+
plt.plot(bin_time,bin_int,label="bin",linewidth=0.5)
|
504
|
+
|
505
|
+
#plt.plot(bin_time,zero_int,label="zero")
|
506
|
+
|
507
|
+
plt.plot(hfd_time,hfd_intensity,label="hfd",linewidth=0.5)
|
508
|
+
|
509
|
+
plt.ylabel("Signal Intensity [Hz]")
|
510
|
+
|
511
|
+
plt.xlabel("Time [JST]")
|
512
|
+
|
513
|
+
plt.legend(loc='lower right')
|
514
|
+
|
515
|
+
#plt.savefig("c.png")
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
#for i in range(0, timenum):
|
520
|
+
|
521
|
+
for i in range(0, 7000):
|
522
|
+
|
523
|
+
hh = (i*10)/3600
|
524
|
+
|
525
|
+
mm = (i*10-hh*3600)/60
|
526
|
+
|
527
|
+
ss = i*10-hh*3600-mm*60
|
528
|
+
|
529
|
+
# print(x[i],bin_doppler[i],bin_int[i])
|
530
|
+
|
531
|
+
# print hfd_time[i],hfd_doppler[i],hfd_intensity[i]
|
532
|
+
|
533
|
+
# print('{0:02} {1:02} {2:02} {3:6.3f} {4:7.3f} {5:6.3f} {7:7.3f}'.format(hh,mm,ss,bin_doppler[i],bin_int[i],hfd_doppler[i],hfd_intensity[i]))
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
#plt.savefig("20150101.pdf")
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
#fig=plt.figure(4)
|
542
|
+
|
543
|
+
##plt.plot(x[0:timenum],data[0:timenum])
|
544
|
+
|
545
|
+
#plt.plot(x[1000:6000],tdata[1000:6000],linewidth=0.3)
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
plt.show()
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
1
|
-
Anaconda Prompt上で.pyファイルを実行すると、
|
555
|
+
```Anaconda Prompt上で.pyファイルを実行すると、
|
2
556
|
|
3
557
|
[]
|
4
558
|
|