Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions sharc/parameters/parameters_p528.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
"""Parameters definitions for P528 propagation model
"""
from dataclasses import dataclass
from typing import Union
from sharc.parameters.parameters_base import ParametersBase


@dataclass
class ParametersP528(ParametersBase):
"""Dataclass containing the P.528 propagation model parameters"""

# Time percentage between 1-99 or "RANDOM"
time_percentage: Union[float, str] = "RANDOM"
# 0 (horizontal), 1 (vertical) polarization or "RANDOM"
polarization: Union[int, str] = "RANDOM"
# Channel model, possible values are "P528"
channel_model: str = "P528"


@dataclass
class ParametersP528(ParametersBase):
"""Dataclass containing the P.528 propagation model parameters"""

# Time percentage between 1-99 or "RANDOM"
time_percentage: Union[float, str] = "RANDOM"
# 0 (horizontal), 1 (vertical) polarization or "RANDOM"
polarization: Union[int, str] = "RANDOM"
# Channel model, possible values are "P528"
channel_model: str = "P528"

def load_from_parameters(self, param: ParametersBase):
"""Used to load parameters of P.528 from parent parameters

Parameters
----------
param : ParametersBase
Parent parameters object containing P.528 values in param_p528
"""
# Get values from the param_p528 section of parent parameters
if hasattr(param, 'param_p528'):
config = getattr(param, 'param_p528')
if hasattr(config, 'time_percentage'):
self.time_percentage = config.time_percentage
if hasattr(config, 'polarization'):
self.polarization = config.polarization
if hasattr(config, 'channel_model'):
self.channel_model = config.channel_model

# Validate time percentage
if isinstance(self.time_percentage, str):
if self.time_percentage != "RANDOM":
raise ValueError(
f"ParametersP528: Invalid time_percentage {self.time_percentage}. "
"Must be between 1-99 or 'RANDOM'"
)
else:
try:
time_pct = float(self.time_percentage)
if time_pct < 1 or time_pct > 99:
raise ValueError(
f"ParametersP528: Invalid time_percentage {time_pct}. "
"Must be between 1-99 or 'RANDOM'"
)
except (ValueError, TypeError):
raise ValueError(
f"ParametersP528: Invalid time_percentage {self.time_percentage}. "
"Must be between 1-99 or 'RANDOM'"
)

# Validate polarization
if isinstance(self.polarization, str):
if self.polarization != "RANDOM":
raise ValueError(
f"ParametersP528: Invalid polarization {self.polarization}. "
"Must be 0 (horizontal), 1 (vertical) or 'RANDOM'"
)
else:
try:
pol = int(self.polarization)
if pol not in [0, 1]:
raise ValueError(
f"ParametersP528: Invalid polarization {pol}. "
"Must be 0 (horizontal), 1 (vertical) or 'RANDOM'"
)
except (ValueError, TypeError):
raise ValueError(
f"ParametersP528: Invalid polarization {self.polarization}. "
"Must be 0 (horizontal), 1 (vertical) or 'RANDOM'"
)
30 changes: 20 additions & 10 deletions sharc/parameters/parameters_rns.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
from dataclasses import dataclass

from dataclasses import dataclass, field
from sharc.parameters.parameters_base import ParametersBase
from sharc.parameters.parameters_p528 import ParametersP528


@dataclass
class ParametersRns(ParametersBase):
"""
Simulation parameters for radionavigation service
"""
# whether to enable recursive parameters setting on .yaml file
nested_parameters_enabled: bool = True
section_name: str = "rns"
# x-y coordinates [m]
x: float = 660.0
Expand All @@ -31,7 +33,7 @@ class ParametersRns(ParametersBase):
# Channel parameters
# channel model, possible values are "FSPL" (free-space path loss),
# "SatelliteSimple" (FSPL + 4 dB + clutter loss)
# "P619"
# "P619", "P528"
channel_model: str = "P619"
# Parameters for the P.619 propagation model
# earth_station_alt_m - altitude of IMT system (in meters)
Expand All @@ -45,6 +47,8 @@ class ParametersRns(ParametersBase):
season: str = "SUMMER"
# Adjacent channel selectivity [dB]
acs: float = 30.0
# Parameters for P528 model
param_p528: ParametersP528 = field(default_factory=ParametersP528)

def load_parameters_from_file(self, config_file: str):
"""Load the parameters from file an run a sanity check
Expand All @@ -61,14 +65,20 @@ def load_parameters_from_file(self, config_file: str):
"""
super().load_parameters_from_file(config_file)
if self.antenna_pattern not in ["ITU-R M.1466", "OMNI"]:
raise ValueError(f"ParametersRns: \
raise ValueError(
f'ParametersRns: \
Invalid value for parameter {self.antenna_pattern}. \
Allowed values are \"ITU-R M.1466\", \"OMNI\".")
if self.channel_model.upper() not in ["FSPL", "SatelliteSimple", "P619"]:
raise ValueError(f"ParametersRns: \
Allowed values are "ITU-R M.1466", "OMNI".'
)
if self.channel_model.upper() not in ["FSPL", "SatelliteSimple", "P619", "P528"]:
raise ValueError(
f'ParametersRns: \
Invalid value for paramter channel_model = {self.channel_model}. \
Possible values are \"FSPL\", \"SatelliteSimple\", \"P619\".")
Possible values are "FSPL", "SatelliteSimple", "P619", "P528".'
)
if self.season.upper() not in ["SUMMER", "WINTER"]:
raise ValueError(f"ParametersRns: \
raise ValueError(
f'ParametersRns: \
Invalid value for parameter season - {self.season}. \
Possible values are \"SUMMER\", \"WINTER\".")
Possible values are "SUMMER", "WINTER".'
)
22 changes: 17 additions & 5 deletions sharc/propagation/propagation_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from sharc.propagation.propagation_tvro import PropagationTvro
from sharc.propagation.propagation_indoor import PropagationIndoor
from sharc.propagation.propagation_hdfss import PropagationHDFSS
from sharc.propagation.propagation_p528 import PropagationP528


class PropagationFactory(object):
Expand Down Expand Up @@ -68,6 +69,15 @@ def create_propagation(
return PropagationSatSimple(random_number_gen)
elif channel_model == "TerrestrialSimple":
return PropagationTerSimple(random_number_gen)
elif channel_model == "P528":
# Check IF ther's P528 parameters
if not hasattr(param_system, 'param_p528'):
raise AttributeError("param_system does not have an attribute named 'param_p528'")
return PropagationP528(
random_number_gen=random_number_gen,
time_percentage=param_system.param_p528.time_percentage,
polarization=param_system.param_p528.polarization,
)
elif channel_model == "P619":
if isinstance(param_system, ParametersImt):
if param_system.topology.type != "NTN":
Expand All @@ -77,11 +87,13 @@ def create_propagation(
else:
# P.619 model is used only for space-to-earth links
if param.imt.topology.type != "NTN" and not param_system.is_space_to_earth:
raise ValueError((
"PropagationFactory: Channel model P.619 is invalid"
f"for system {param.general.system} and IMT "
f"topology {param.imt.topology.type}"
))
raise ValueError(
(
"PropagationFactory: Channel model P.619 is invalid"
f"for system {param.general.system} and IMT "
f"topology {param.imt.topology.type}"
)
)
return PropagationP619(
random_number_gen=random_number_gen,
space_station_alt_m=param_system.param_p619.space_station_alt_m,
Expand Down
Loading
Loading