mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
ZH: write more beacon properties to tx file
This commit is contained in:
parent
4131b3775a
commit
616a23ef2b
1 changed files with 47 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# vim: fdm=indent ts=4
|
# vim: fdm=marker ts=4
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Add a beacon measurement on top of the
|
Add a beacon measurement on top of the
|
||||||
|
@ -15,13 +15,16 @@ from copy import deepcopy
|
||||||
from earsim import REvent, Antenna, block_filter
|
from earsim import REvent, Antenna, block_filter
|
||||||
import lib
|
import lib
|
||||||
|
|
||||||
|
# {{{ vim marker
|
||||||
tx_fname = 'tx.json'
|
tx_fname = 'tx.json'
|
||||||
antennas_fname = 'antennas.hdf5'
|
antennas_fname = 'antennas.hdf5'
|
||||||
|
|
||||||
def write_tx_file(fname, tx, f_beacon):
|
def write_tx_file(fname, tx, f_beacon, **kwargs):
|
||||||
with open(fname, 'w') as fp:
|
with open(fname, 'w') as fp:
|
||||||
return json.dump(
|
return json.dump(
|
||||||
dict(
|
{
|
||||||
|
**kwargs,
|
||||||
|
**dict(
|
||||||
f_beacon=f_beacon,
|
f_beacon=f_beacon,
|
||||||
tx=dict(
|
tx=dict(
|
||||||
x=tx.x,
|
x=tx.x,
|
||||||
|
@ -29,7 +32,8 @@ def write_tx_file(fname, tx, f_beacon):
|
||||||
z=tx.z,
|
z=tx.z,
|
||||||
name=tx.name
|
name=tx.name
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
|
},
|
||||||
fp
|
fp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +44,10 @@ def read_tx_file(fname):
|
||||||
f_beacon = data['f_beacon']
|
f_beacon = data['f_beacon']
|
||||||
tx = Antenna(**data['tx'])
|
tx = Antenna(**data['tx'])
|
||||||
|
|
||||||
return tx, f_beacon
|
del data['f_beacon']
|
||||||
|
del data['tx']
|
||||||
|
|
||||||
|
return tx, f_beacon, data
|
||||||
|
|
||||||
def read_beacon_hdf5(fname, **h5ant_kwargs):
|
def read_beacon_hdf5(fname, **h5ant_kwargs):
|
||||||
with h5py.File(fname, 'r') as h5:
|
with h5py.File(fname, 'r') as h5:
|
||||||
|
@ -227,15 +234,26 @@ def write_baseline_time_diffs_hdf5(fname, baselines, true_phase_diffs, k_periods
|
||||||
data = np.vstack( (time_diffs, f_beacon, true_phase_diffs, k_periods) ).T
|
data = np.vstack( (time_diffs, f_beacon, true_phase_diffs, k_periods) ).T
|
||||||
dset = group.create_dataset(dset_name, data=data)
|
dset = group.create_dataset(dset_name, data=data)
|
||||||
|
|
||||||
|
# }}} vim marker
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
fname = "ZH_airshower/mysim.sry"
|
||||||
|
|
||||||
|
# Transmitter
|
||||||
remake_tx = True
|
remake_tx = True
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
tx = Antenna(x=-2e3,y=0,z=0,name='tx') # m
|
||||||
tx = Antenna(x=-500,y=0,z=0,name='tx') # m
|
if False:
|
||||||
if not True: # slowest beacon to be found:
|
# Move tx out a long way
|
||||||
|
tx.x, tx.y = -75e3, 75e3 # m
|
||||||
|
elif False:
|
||||||
|
# Move it to 0,0,0 (among the antennas)
|
||||||
|
tx.x, tx.y = 0, 0 #m
|
||||||
|
|
||||||
|
# Beacon properties
|
||||||
|
if False: # slowest beacon to be found:
|
||||||
f_beacon = 10e-3 # GHz
|
f_beacon = 10e-3 # GHz
|
||||||
low_bp = 5e-3 # GHz
|
low_bp = 5e-3 # GHz
|
||||||
high_bp = 80e-3 # GHz
|
high_bp = 80e-3 # GHz
|
||||||
|
@ -246,31 +264,35 @@ if __name__ == "__main__":
|
||||||
low_bp = 30e-3 # GHz
|
low_bp = 30e-3 # GHz
|
||||||
high_bp = 80e-3 # GHz
|
high_bp = 80e-3 # GHz
|
||||||
|
|
||||||
# Disable block_filter
|
beacon_amplitudes = 1e-6*np.array([1e5, 0, 0]) # mu V/m
|
||||||
if False:
|
beacon_radiate_rsq = True # beacon_amplitude is repaired for distance to 0,0,0
|
||||||
block_filter = lambda x, dt, low, high: x
|
|
||||||
|
|
||||||
beacon_amplitudes = 1e-6*np.array([1e2, 0, 0]) # mu V/m
|
|
||||||
beacon_radiate_rsq = True
|
|
||||||
|
|
||||||
|
# modify beacon power to be beacon_amplitude at 0,0,0
|
||||||
if beacon_radiate_rsq:
|
if beacon_radiate_rsq:
|
||||||
# Move tx out, and magnify beacon_amplitude (at tx)
|
|
||||||
tx = Antenna(x=-20e3,y=0,z=0,name='tx') # m
|
|
||||||
dist = lib.distance(tx, Antenna(x=0, y=0, z=0))
|
dist = lib.distance(tx, Antenna(x=0, y=0, z=0))
|
||||||
|
|
||||||
ampl = max(1, dist**2)
|
ampl = max(1, dist**2)
|
||||||
|
|
||||||
beacon_amplitudes *= ampl
|
beacon_amplitudes *= ampl
|
||||||
|
|
||||||
|
# Disable block_filter
|
||||||
|
if False:
|
||||||
|
block_filter = lambda x, dt, low, high: x
|
||||||
|
|
||||||
####
|
####
|
||||||
fname_dir = path.dirname(fname)
|
fname_dir = path.dirname(fname)
|
||||||
tx_fname = path.join(fname_dir, tx_fname)
|
tx_fname = path.join(fname_dir, tx_fname)
|
||||||
antennas_fname = path.join(fname_dir, antennas_fname)
|
antennas_fname = path.join(fname_dir, antennas_fname)
|
||||||
|
|
||||||
|
# read/write tx properties
|
||||||
if not path.isfile(tx_fname) or remake_tx:
|
if not path.isfile(tx_fname) or remake_tx:
|
||||||
write_tx_file(tx_fname, tx, f_beacon)
|
write_tx_file(tx_fname, tx, f_beacon, amplitudes=beacon_amplitudes.tolist(), radiate_rsq=beacon_radiate_rsq)
|
||||||
else:
|
else:
|
||||||
tx, f_beacon = read_tx_file(tx_fname)
|
tx, f_beacon, _ = read_tx_file(tx_fname)
|
||||||
|
|
||||||
|
|
||||||
|
print("Beacon amplitude at (0,0,0) [muV/m]:", beacon_amplitudes)
|
||||||
|
print("Tx location:", [tx.x, tx.y, tx.z])
|
||||||
|
|
||||||
# read in antennas
|
# read in antennas
|
||||||
ev = REvent(fname)
|
ev = REvent(fname)
|
||||||
|
|
Loading…
Reference in a new issue