mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
ZH: move c_light value to lib
This commit is contained in:
parent
a4fa874b54
commit
3fce4036f3
4 changed files with 10 additions and 17 deletions
|
@ -18,6 +18,7 @@ import lib
|
||||||
# {{{ vim marker
|
# {{{ vim marker
|
||||||
tx_fname = 'tx.json'
|
tx_fname = 'tx.json'
|
||||||
antennas_fname = 'antennas.hdf5'
|
antennas_fname = 'antennas.hdf5'
|
||||||
|
c_light = lib.c_light
|
||||||
|
|
||||||
def write_tx_file(fname, tx, f_beacon, **kwargs):
|
def write_tx_file(fname, tx, f_beacon, **kwargs):
|
||||||
with open(fname, 'w') as fp:
|
with open(fname, 'w') as fp:
|
||||||
|
@ -326,16 +327,7 @@ if __name__ == "__main__":
|
||||||
if i%10 == 0:
|
if i%10 == 0:
|
||||||
print(f"Modified trace lengths by {pre_N},{after_N-N_samples}")
|
print(f"Modified trace lengths by {pre_N},{after_N-N_samples}")
|
||||||
|
|
||||||
t0 = 0
|
beacon = lib.beacon_from(tx, antenna, f_beacon, antenna.t, c_light=c_light, radiate_rsq=beacon_radiate_rsq)
|
||||||
c_light = 3e8*1e-9 # m/ns
|
|
||||||
if False:
|
|
||||||
# precalculate t0
|
|
||||||
# set c_light=np.inf to suppress the time delay
|
|
||||||
# in the function call
|
|
||||||
t0 = lib.distance(tx, antenna)/c_light
|
|
||||||
c_light = np.inf
|
|
||||||
|
|
||||||
beacon = lib.beacon_from(tx, antenna, f_beacon, antenna.t, t0=t0, c_light=c_light, radiate_rsq=beacon_radiate_rsq)
|
|
||||||
traces = np.array([antenna.Ex, antenna.Ey, antenna.Ez, beacon])
|
traces = np.array([antenna.Ex, antenna.Ey, antenna.Ez, beacon])
|
||||||
|
|
||||||
# add to relevant polarisation
|
# add to relevant polarisation
|
||||||
|
@ -344,7 +336,7 @@ if __name__ == "__main__":
|
||||||
for j, amp in enumerate(beacon_amplitudes):
|
for j, amp in enumerate(beacon_amplitudes):
|
||||||
traces[j] = block_filter(traces[j] + amp*beacon, dt, low_bp, high_bp)
|
traces[j] = block_filter(traces[j] + amp*beacon, dt, low_bp, high_bp)
|
||||||
|
|
||||||
append_antenna_hdf5( antennas_fname, antenna, traces, name='traces', prepend_time=True, attrs_dict=dict(t0=t0))
|
append_antenna_hdf5( antennas_fname, antenna, traces, name='traces', prepend_time=True)
|
||||||
|
|
||||||
# Save E field in E_AxB
|
# Save E field in E_AxB
|
||||||
E_AxB = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])]
|
E_AxB = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])]
|
||||||
|
|
|
@ -19,7 +19,7 @@ if __name__ == "__main__":
|
||||||
matplotlib.use('Agg')
|
matplotlib.use('Agg')
|
||||||
|
|
||||||
fname = "ZH_airshower/mysim.sry"
|
fname = "ZH_airshower/mysim.sry"
|
||||||
c_light = 3e8*1e-9 # m/ns
|
c_light = lib.c_light
|
||||||
show_plots = True
|
show_plots = True
|
||||||
|
|
||||||
remove_absolute_phase_offset_first_antenna = True # takes precedence
|
remove_absolute_phase_offset_first_antenna = True # takes precedence
|
||||||
|
|
|
@ -6,6 +6,7 @@ import numpy as np
|
||||||
from numpy.polynomial import Polynomial
|
from numpy.polynomial import Polynomial
|
||||||
|
|
||||||
from earsim import Antenna
|
from earsim import Antenna
|
||||||
|
c_light = 3e8*1e-9 # m/ns
|
||||||
|
|
||||||
""" Beacon utils """
|
""" Beacon utils """
|
||||||
def sine_beacon(f, t, t0=0, amplitude=1, baseline=0, phase=0):
|
def sine_beacon(f, t, t0=0, amplitude=1, baseline=0, phase=0):
|
||||||
|
@ -34,13 +35,13 @@ def distance(x1, x2):
|
||||||
|
|
||||||
return np.sqrt( np.sum( (x1-x2)**2 ) )
|
return np.sqrt( np.sum( (x1-x2)**2 ) )
|
||||||
|
|
||||||
def geometry_time(dist, x2=None, c_light=3e8):
|
def geometry_time(dist, x2=None, c_light=c_light):
|
||||||
if x2 is not None:
|
if x2 is not None:
|
||||||
dist = distance(dist, x2)
|
dist = distance(dist, x2)
|
||||||
|
|
||||||
return dist/c_light
|
return dist/c_light
|
||||||
|
|
||||||
def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1,**kwargs):
|
def beacon_from(tx, rx, f, t=0, t0=0, c_light=c_light, radiate_rsq=True, amplitude=1,**kwargs):
|
||||||
dist = distance(tx,rx)
|
dist = distance(tx,rx)
|
||||||
# suppress extra time delay from distance
|
# suppress extra time delay from distance
|
||||||
if c_light is not None and np.isfinite(c_light):
|
if c_light is not None and np.isfinite(c_light):
|
||||||
|
@ -53,7 +54,7 @@ def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1
|
||||||
|
|
||||||
return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)
|
return sine_beacon(f, t, t0=t0, amplitude=amplitude,**kwargs)
|
||||||
|
|
||||||
def remove_antenna_geometry_phase(tx, antennas, f_beacon, measured_phases=None, c_light=3e8):
|
def remove_antenna_geometry_phase(tx, antennas, f_beacon, measured_phases=None, c_light=c_light):
|
||||||
"""
|
"""
|
||||||
Remove the geometrical phase from the measured antenna phase.
|
Remove the geometrical phase from the measured antenna phase.
|
||||||
"""
|
"""
|
||||||
|
@ -110,7 +111,7 @@ def direct_fourier_transform(freqs, time, samplesets_iterable):
|
||||||
# Numpy array
|
# Numpy array
|
||||||
return np.dot(c_k, samplesets_iterable), np.dot(s_k, samplesets_iterable)
|
return np.dot(c_k, samplesets_iterable), np.dot(s_k, samplesets_iterable)
|
||||||
|
|
||||||
def phase_field_from_tx(x, y, tx, f_beacon, c_light=3e8, t0=0, wrap_phase=True, return_meshgrid=True):
|
def phase_field_from_tx(x, y, tx, f_beacon, c_light=c_light, t0=0, wrap_phase=True, return_meshgrid=True):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ seed = 12345
|
||||||
dt = 1 # ns
|
dt = 1 # ns
|
||||||
frequency = 45e-3 # GHz
|
frequency = 45e-3 # GHz
|
||||||
N = 5e2
|
N = 5e2
|
||||||
c_light = 3e8*1e-9
|
c_light = lib.c_light
|
||||||
|
|
||||||
t = np.arange(0, 10*int(1e3), dt, dtype=float)
|
t = np.arange(0, 10*int(1e3), dt, dtype=float)
|
||||||
rng = np.random.default_rng(seed)
|
rng = np.random.default_rng(seed)
|
||||||
|
|
Loading…
Reference in a new issue