Skip to content

Commit 7bddb64

Browse files
committed
Small cleanups
1 parent 2301291 commit 7bddb64

6 files changed

Lines changed: 17 additions & 13 deletions

File tree

python/examples/beacon/beacon_record.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Example configurations are included along with this script.
1414
1515
"""
16+
1617
from __future__ import absolute_import, division, print_function
1718

1819
import datetime
@@ -29,7 +30,6 @@
2930
import ephem
3031
import numpy as np
3132
from digital_rf import DigitalMetadataWriter
32-
3333
from six.moves import configparser
3434

3535

@@ -580,7 +580,7 @@ def ephemeris_passes(opt, st0, et0):
580580

581581
if opt.el_mask:
582582
el_val = np.rad2deg(el)
583-
el_mask = np.float(opt.el_mask)
583+
el_mask = np.float64(opt.el_mask)
584584

585585
if opt.debug:
586586
print("# el_val ", el_val, " el_mask ", el_mask)

python/examples/benchmark_rf_read_hdf5.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Assumes the benchmark write script has already been run.
1212
1313
"""
14+
1415
from __future__ import absolute_import, division, print_function
1516

1617
import os

python/examples/benchmark_rf_write_hdf5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
for i in range(WRITE_BLOCK_SIZE):
3939
j = i * 2
4040
k = i * 2 + 1
41-
data_int16[i][0] = (j % 32768) * (j + 8192) * (j % 13)
42-
data_int16[i][1] = (k % 32768) * (k + 8192) * (k % 13)
41+
data_int16[i][0] = np.array((j % 32768) * (j + 8192) * (j % 13)).astype("i2")
42+
data_int16[i][1] = np.array((k % 32768) * (k + 8192) * (k % 13)).astype("i2")
4343

4444
datadir = os.path.join(tempfile.gettempdir(), "benchmark_digital_rf")
4545
print("creating top level dir {0}".format(datadir))

python/tools/drf_cross_sti.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, control):
7070

7171
elif self.control.xtype == "pairs":
7272
args = [iter(pl)] * 2
73-
self.xlist = list(it.izip_longest(*args))
73+
self.xlist = list(it.zip_longest(*args))
7474

7575
elif self.control.xtype == "combo":
7676
self.xlist = list(it.combinations(pl, 2))
@@ -226,10 +226,10 @@ def plot(self):
226226

227227
for p in np.arange(0, self.control.frames * 2, 2):
228228
sti_csd_data_coherence = np.zeros(
229-
[self.control.num_fft, self.control.bins], np.float
229+
[self.control.num_fft, self.control.bins], np.float64
230230
)
231231
sti_csd_data_phase = np.zeros(
232-
[self.control.num_fft, self.control.bins], np.float
232+
[self.control.num_fft, self.control.bins], np.float64
233233
)
234234

235235
sti_times = np.zeros([self.control.bins], np.complex128)
@@ -383,7 +383,7 @@ def plot(self):
383383
print("last ", start_sample)
384384

385385
# create a time stamp
386-
start_time, picoseconds = drf.util.sample_to_time_floor(st0, self.sr)
386+
start_time, picoseconds = drf.util.sample_to_time_floor(st0, sr)
387387
srt_time = time.gmtime(start_time)
388388
sub_second = int(round(picoseconds / 1e10))
389389

python/tools/drf_plot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,15 +1182,16 @@ def usage():
11821182
print("loading metadata")
11831183

11841184
drf_properties = drf.get_properties(chans[chidx])
1185-
sfreq = drf_properties["sample_rate"]
1185+
sample_rate = drf_properties["sample_rate"]
1186+
sfreq = float(sample_rate)
11861187
toffset = start_sample
11871188

11881189
print(toffset)
11891190

11901191
if atime == 0:
11911192
atime = ustart
11921193
else:
1193-
atime = drf.util.time_to_sample_ceil(atime, sfreq)
1194+
atime = drf.util.time_to_sample_ceil(atime, sample_rate)
11941195

11951196
sstart = atime + int(toffset)
11961197
dlen = stop_sample - start_sample

python/tools/drf_sound.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def makeasound(self):
107107

108108
print("first ", start_sample)
109109

110-
audiostuff = np.zeros((blocks, reads_per_block * dsamps), dtype=np.float)
110+
audiostuff = np.zeros((blocks, reads_per_block * dsamps), dtype=np.float64)
111111
if self.control.verbose:
112112
print(
113113
"processing info : ",
@@ -129,7 +129,9 @@ def makeasound(self):
129129
)
130130

131131
if self.control.freqshift:
132-
tvec = np.arange(len(data), dtype=np.float) / sr + start_sample / sr
132+
tvec = np.arange(len(data), dtype=np.float64) / float(sr) + float(
133+
start_sample / sr
134+
)
133135
f_osc = np.exp(1j * 2 * np.pi * self.control.freqshift * tvec)
134136
data_fs = data * f_osc
135137
else:
@@ -143,7 +145,7 @@ def makeasound(self):
143145
start_sample += samples_per_stripe
144146
audiostuff_cent = audiostuff - audiostuff.flatten().mean()
145147
audiostuff_norm = audiostuff_cent / np.abs(audiostuff_cent.flatten()).max()
146-
audiostuff_norm = audiostuff_norm.astype(float)
148+
audiostuff_norm = audiostuff_norm.astype(np.float64)
147149
if self.control.outname:
148150
fname = os.path.splitext(self.control.outname)[0]
149151
ext = ".wav"

0 commit comments

Comments
 (0)