Skip to content

Commit

Permalink
Merge branch '210-spatial-consistency' into 'master'
Browse files Browse the repository at this point in the history
Introduce Spatial Consistencyy

Closes #210 and #208

See merge request barkhauseninstitut/wicon/hermespy!186
  • Loading branch information
adlerjan committed May 25, 2024
2 parents c2c6009 + bcf91d0 commit 53c4827
Show file tree
Hide file tree
Showing 281 changed files with 17,581 additions and 14,362 deletions.
10 changes: 5 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Unit Testing:
- unzip dist/$HERMES_WHEEL_11 "hermespy/fec/aff3ct/*.so"
- pip install -qq pyzmq>=25.1.1 usrp-uhd-client memray>=1.11.0
script:
- coverage run --include=hermespy/* ./scripts/performance/test_install_memray.py ./tests/unit_tests/
- coverage run --include=hermespy/* ./tests/test_install.py ./tests/unit_tests/
after_script:
- coverage xml
- coverage report -m --include=hermespy/* --skip-covered
Expand All @@ -96,7 +96,7 @@ Integration Testing:
- pip install -qq dist/$HERMES_WHEEL_11\[test,quadriga,audio\]
- pip install -qq memray
script:
- python ./scripts/performance/test_install_memray.py ./tests/integration_tests/
- python ./tests/test_install.py ./tests/integration_tests/
artifacts:
paths:
- ./scripts/performance/results/integration_tests/results.json
Expand All @@ -111,7 +111,7 @@ Integrity Python 3.11:
- pip install -qq dist/$HERMES_WHEEL_11\[test,quadriga,audio\]
- pip install -qq memray
script:
- python ./scripts/performance/test_install_memray.py ./tests/integrity_tests/
- python ./tests/test_install.py ./tests/integrity_tests/
artifacts:
paths:
- ./scripts/performance/results/integration_tests/results.json
Expand All @@ -126,7 +126,7 @@ Integrity Python 3.10:
- pip install -qq dist/$HERMES_WHEEL_10\[test,quadriga,audio\]
- pip install -qq memray
script:
- python ./scripts/performance/test_install_memray.py ./tests/integrity_tests/
- python ./tests/test_install.py ./tests/integrity_tests/
artifacts:
paths:
- ./scripts/performance/results/integration_tests/results.json
Expand All @@ -140,7 +140,7 @@ Integrity Python 3.9:
- pip install -qq dist/$HERMES_WHEEL_09\[test,quadriga,audio\]
- pip install -qq memray
script:
- python ./scripts/performance/test_install_memray.py ./tests/integrity_tests/
- python ./tests/test_install.py ./tests/integrity_tests/
artifacts:
paths:
- ./scripts/performance/results/integration_tests/results.json
Expand Down
4 changes: 2 additions & 2 deletions _examples/library/getting_started_loop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os.path import join

from hermespy.channel import MultipathFading5GTDL
from hermespy.channel import TDL
from hermespy.hardware_loop import HardwareLoop, PhysicalDeviceDummy, PhysicalScenarioDummy, ReceivedConstellationPlot, DeviceTransmissionPlot, DeviceReceptionPlot
from hermespy.modem import BitErrorEvaluator, SimplexLink, RootRaisedCosineWaveform, SingleCarrierLeastSquaresChannelEstimation, SingleCarrierZeroForcingChannelEqualization

Expand All @@ -14,7 +14,7 @@

# Specifiy the channel instance linking the two devices
# Only available for PhysicalScenarioDummy, which is a simulation of hardware behaviour
hardware_scenario.set_channel(tx_device, rx_device, MultipathFading5GTDL())
hardware_scenario.set_channel(tx_device, rx_device, TDL())

# Define a simplex communication link between the two devices
link = SimplexLink(tx_device, rx_device)
Expand Down
4 changes: 2 additions & 2 deletions _examples/library/getting_started_simulation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt

from hermespy.core import dB
from hermespy.channel import MultipathFading5GTDL
from hermespy.channel import TDL
from hermespy.simulation import Simulation, SNR
from hermespy.modem import BitErrorEvaluator, SimplexLink, RootRaisedCosineWaveform, SingleCarrierLeastSquaresChannelEstimation, SingleCarrierZeroForcingChannelEqualization

Expand All @@ -17,7 +17,7 @@
rx_device.noise_level = SNR(dB(20), tx_device)

# Specifiy the channel instance linking the two devices
simulation.set_channel(tx_device, rx_device, MultipathFading5GTDL())
simulation.set_channel(tx_device, rx_device, TDL())

# Define a simplex communication link between the two devices
link = SimplexLink(tx_device, rx_device)
Expand Down
54 changes: 22 additions & 32 deletions _examples/library/lena.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,58 @@
import matplotlib.pyplot as plt
import numpy as np

from hermespy.modem import Modem, RootRaisedCosineWaveform, SingleCarrierCorrelationSynchronization, SingleCarrierLeastSquaresChannelEstimation, SingleCarrierZeroForcingChannelEqualization
from hermespy.core.scenario import Scenario
from hermespy.modem.waveform_single_carrier import SingleCarrierSynchronization
from hermespy.simulation import SimulatedDevice
from hermespy.modem.bits_source import StreamBitsSource
from hermespy.channel import TDL, TDLType
from hermespy.fec import Scrambler3GPP
from hermespy.modem import SimplexLink, RootRaisedCosineWaveform, SingleCarrierLeastSquaresChannelEstimation, SingleCarrierZeroForcingChannelEqualization, StreamBitsSource
from hermespy.simulation import SimulationScenario

__author__ = "Jan Adler"
__copyright__ = "Copyright 2023, Barkhausen Institut gGmbH"
__copyright__ = "Copyright 2024, Barkhausen Institut gGmbH"
__credits__ = ["Jan Adler"]
__license__ = "AGPLv3"
__version__ = "0.2.7"
__version__ = "1.2.0"
__maintainer__ = "Jan Adler"
__email__ = "[email protected]"
__status__ = "Prototype"


# Create a new HermesPy simulation scenario
scenario = Scenario[SimulatedDevice]()
scenario = SimulationScenario()

# Create a new simulated device
device = SimulatedDevice()
scenario.add_device(device)
carrier_frequency = 1e8
tx_device = scenario.new_device(carrier_frequency=carrier_frequency)
rx_device = scenario.new_device(carrier_frequency=carrier_frequency)
scenario.set_channel(rx_device, tx_device, TDL(TDLType.E))

waveform = RootRaisedCosineWaveform(symbol_rate=1e6, num_preamble_symbols=0, num_data_symbols=40, oversampling_factor=8, roll_off=.9)
waveform = RootRaisedCosineWaveform(symbol_rate=1e6, num_preamble_symbols=0 , num_data_symbols=120, oversampling_factor=4, roll_off=.9)
waveform.num_preamble_symbols = 128
waveform.num_data_symbols = 1024
waveform.modulation_order = 4
waveform.synchronization = SingleCarrierSynchronization()
waveform.num_data_symbols = 2048
waveform.modulation_order = 256
waveform.channel_estimation = SingleCarrierLeastSquaresChannelEstimation()
waveform.channel_equalization = SingleCarrierZeroForcingChannelEqualization()

device.sampling_rate = waveform.sampling_rate

source = StreamBitsSource(os.path.join(os.path.dirname(__file__), '../resources/leena.raw'))
leena_num_bits = 512 * 512 * 8
image_buffer = np.zeros((512, 512), dtype=np.uint8)
image_buffer[0, 0] = 255

# Add a modem at the simulated device
modem = Modem()
modem.device = device
modem.bits_source = source
modem.waveform = waveform
link = SimplexLink(tx_device, rx_device, waveform=waveform)
link.encoder_manager.add_encoder(Scrambler3GPP())
link.bits_source = StreamBitsSource(os.path.join(os.path.dirname(__file__), '../resources/leena.raw'))

# Compute number of required frames
bits_per_frame = modem.num_data_bits_per_frame
bits_per_frame = link.num_data_bits_per_frame
byte_per_frame = int(bits_per_frame / 8)
num_frames = int(leena_num_bits / bits_per_frame)

plt.ion()
fig, axes = plt.subplots()
image = axes.imshow(image_buffer)
image = axes.imshow(image_buffer, cmap='gray', vmin=0, vmax=255)

for f in range(num_frames):

tx_signal, tx_symbols, tx_bits = modem.transmit()
device_transmissions = device.transmit(clear_cache=True)
device.receive_signal(device_transmissions[0]) # , snr=8.)
rx_signal, rx_symbols, data_bits = modem.receive()

if len(data_bits) > 0:
image_buffer.flat[f*byte_per_frame:(f+1)*byte_per_frame] = np.packbits(data_bits)
drop = scenario.drop()
if link.reception.bits.size > 0:
image_buffer.flat[f*byte_per_frame:(f+1)*byte_per_frame] = np.packbits(link.reception.bits)
image.set_data(image_buffer)
fig.canvas.flush_events()

Expand Down
4 changes: 1 addition & 3 deletions _examples/settings/chirp_qam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ Operators:
guard_interval: 1e-6

# Post-Processing
channel_estimation: !<SC-Ideal>
transmitter: *device_alpha
receiver: *device_alpha
channel_estimation: !<SC-LS>
channel_equalization: !<SC-MMSE>

# Performance indication evaluation configuration
Expand Down
3 changes: 2 additions & 1 deletion _examples/settings/ofdm_5g.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Devices:
Channels:

# 5G TDL model at the self-interference channel of device_alpha
- !<5GTDL>
- &channel !<5GTDL>
devices: [*device_alpha, *device_alpha] # Devices linked by the channel
model_type: !<TDLType> E # Type of the TDL model. A-E are available
rms_delay: 100e-9 # Root mean square delay in seconds
Expand Down Expand Up @@ -69,6 +69,7 @@ Operators:
dc_suppression: False # Do not ignore the DC component during the DFT
num_subcarriers: 4096 # Number of subcarriers per communiction frame
channel_estimation: !<OFDM-Ideal> # Assume ideal channel state information at the receiver
channel: *channel
transmitter: *device_alpha
receiver: *device_alpha
channel_equalization: !<ZF> # Least-squares channel equalization
Expand Down
3 changes: 2 additions & 1 deletion _examples/settings/ofdm_single_carrier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Devices:
Channels:

# 5G TDL model at the self-interference channel of device_alpha
- !<5GTDL>
- &channel !<5GTDL>
devices: [*device_alpha, *device_alpha]
model_type: !<TDLType> A # Type of the TDL model. A-E are available
rms_delay: 1e-9 # Root mean square delay in seconds
Expand Down Expand Up @@ -55,6 +55,7 @@ Operators:
dc_suppression: False # Consider the DC component during the DFT
num_subcarriers: 128 # Number of subcarriers per communication frame
channel_estimation: !<OFDM-Ideal> # Ideal channel estimation routine
channel: *channel
transmitter: *device_alpha
receiver: *device_alpha
channel_equalization: !<ZF> # Zero-forcing channel equalization
Expand Down
2 changes: 1 addition & 1 deletion docssource/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The subpackages may have interdependencies, but in general, the root of dependen

modem
radar
channel
channel/channel
simulation
hardware_loop
core
Expand Down
8 changes: 0 additions & 8 deletions docssource/api/channel.channel.Channel.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docssource/api/channel.channel.ChannelPropagation.rst

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions docssource/api/channel.channel.InterpolationMode.rst

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 53c4827

Please sign in to comment.