forked from SIMULATOR-WG/SHARC
-
Notifications
You must be signed in to change notification settings - Fork 24
Feat/antenna 1245 fs #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/antenna 1245 fs #246
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
65bac3b
Merge pull request #219 from Radio-Spectrum/release/v1.0.1
artistrea f5ceb1f
Merge branch 'development' of https://github.com/Radio-Spectrum/SHARC…
fabriciofcampos 1441145
update(antenna): Added antenna F.1245 used by FS system
fabriciofcampos 0ff32ce
fix(build): Fixed syntax errors
fabriciofcampos 57f1844
fix(build): Added Docstring
fabriciofcampos 42b3ea5
update(antenna): changed ParametersAntennaWithDiameter as the paramet…
fabriciofcampos a4a17e2
Fixed antenna_f1245_fs.py header
fabriciofcampos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
|
|
||
| # -*- coding: utf-8 -*- | ||
| """ | ||
brunohcfaria marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Created on Wed Apr 4 17:08:00 2018 | ||
| @author: Calil | ||
| """ | ||
| import matplotlib.pyplot as plt | ||
| from sharc.antenna.antenna import Antenna | ||
| from sharc.parameters.imt.parameters_imt import ParametersImt | ||
| from sharc.parameters.imt.parameters_imt import ParametersImt | ||
| from sharc.parameters.imt.parameters_antenna_imt import ParametersAntennaImt | ||
| from sharc.parameters.parameters_antenna import ParametersAntenna | ||
| import numpy as np | ||
| import math | ||
|
|
||
|
|
||
| class Antenna_f1245_fs(Antenna): | ||
| """Class that implements the ITU-R F.1245 antenna pattern for fixed | ||
| satellite service earth stations.""" | ||
|
|
||
| def __init__(self, param: ParametersImt): | ||
brunohcfaria marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| super().__init__() | ||
| self.peak_gain = param.gain | ||
| lmbda = 3e8 / (param.frequency * 1e6) | ||
| self.d_lmbda = param.diameter / lmbda | ||
| self.g_l = 2 + 15 * math.log10(self.d_lmbda) | ||
| self.phi_m = (20 / self.d_lmbda) * math.sqrt(self.peak_gain - self.g_l) | ||
| self.phi_r = 12.02 * math.pow(self.d_lmbda, -0.6) | ||
|
|
||
| def calculate_gain(self, *args, **kwargs) -> np.array: | ||
| """ | ||
| Calculate the antenna gain for the given parameters. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| *args : tuple | ||
| Positional arguments (not used). | ||
| **kwargs : dict | ||
| Keyword arguments, expects 'phi_vec', 'theta_vec', and 'beams_l'. | ||
|
|
||
| Returns | ||
| ------- | ||
| np.array | ||
| Calculated antenna gain values. | ||
| """ | ||
| # phi_vec = np.absolute(kwargs["phi_vec"]) | ||
| # theta_vec = np.absolute(kwargs["theta_vec"]) | ||
| # beams_l = np.absolute(kwargs["beams_l"]) | ||
| off_axis = np.absolute(kwargs["off_axis_angle_vec"]) | ||
| if self.d_lmbda > 100: | ||
| gain = self.calculate_gain_greater(off_axis) | ||
| else: | ||
| gain = self.calculate_gain_less(off_axis) | ||
| # idx_max_gain = np.where(beams_l == -1)[0] | ||
| # gain = self.peak_gain | ||
| return gain | ||
|
|
||
| def calculate_gain_greater(self, phi: float) -> np.array: | ||
| """ | ||
| For frequencies in the range 1 GHz to about 70 GHz, in cases where the | ||
| ratio between the antenna diameter and the wavelength is GREATER than | ||
| 100, this method should be used. | ||
| Parameter | ||
| --------- | ||
| phi : off-axis angle [deg] | ||
| Returns | ||
| ------- | ||
| a numpy array containing the gains in the given angles | ||
| """ | ||
| gain = np.zeros(phi.shape) | ||
| idx_0 = np.where(phi < self.phi_m)[0] | ||
| gain[idx_0] = self.peak_gain - 2.5e-3 * \ | ||
| np.power(self.d_lmbda * phi[idx_0], 2) | ||
| phi_thresh = max(self.phi_m, self.phi_r) | ||
| idx_1 = np.where((self.phi_m <= phi) & (phi < phi_thresh))[0] | ||
| gain[idx_1] = self.g_l | ||
| idx_2 = np.where((phi_thresh <= phi) & (phi < 48))[0] | ||
| gain[idx_2] = 29 - 25 * np.log10(phi[idx_2]) | ||
| idx_3 = np.where((48 <= phi) & (phi <= 180))[0] | ||
| gain[idx_3] = -13 | ||
| return gain | ||
|
|
||
| def calculate_gain_less(self, phi: float) -> np.array: | ||
| """ | ||
| For frequencies in the range 1 GHz to about 70 GHz, in cases where the | ||
| ratio between the antenna diameter and the wavelength is LESS than | ||
| or equal to 100, this method should be used. | ||
| Parameter | ||
| --------- | ||
| phi : off-axis angle [deg] | ||
| Returns | ||
| ------- | ||
| a numpy array containing the gains in the given angles | ||
| """ | ||
| gain = np.zeros(phi.shape) | ||
| idx_0 = np.where(phi < self.phi_m)[0] | ||
| gain[idx_0] = self.peak_gain - 0.0025 * \ | ||
| np.power(self.d_lmbda * phi[idx_0], 2) | ||
| idx_1 = np.where((self.phi_m <= phi) & (phi < 48))[0] | ||
| gain[idx_1] = 39 - 5 * \ | ||
| math.log10(self.d_lmbda) - 25 * np.log10(phi[idx_1]) | ||
| idx_2 = np.where((48 <= phi) & (phi < 180))[0] | ||
| gain[idx_2] = -3 - 5 * math.log10(self.d_lmbda) | ||
| return gain | ||
|
|
||
| def add_beam(self, phi: float, theta: float): | ||
| """ | ||
| Add a new beam to the antenna. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| phi : float | ||
| Azimuth angle in degrees. | ||
| theta : float | ||
| Elevation angle in degrees. | ||
| """ | ||
| self.beams_list.append((phi, theta)) | ||
|
|
||
| def calculate_off_axis_angle(self, Az, b): | ||
| """ | ||
| Calculate the off-axis angle between the main beam and a given direction. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| Az : float or np.array | ||
| Azimuth angle(s) in degrees. | ||
| b : float or np.array | ||
| Elevation angle(s) in degrees. | ||
|
|
||
| Returns | ||
| ------- | ||
| float or np.array | ||
| Off-axis angle(s) in degrees. | ||
| """ | ||
| Az0 = self.beams_list[0][0] | ||
| a = 90 - self.beams_list[0][1] | ||
| C = Az0 - Az | ||
| off_axis_rad = np.arccos( | ||
| np.cos( | ||
| np.radians(a)) * | ||
| np.cos( | ||
| np.radians(b)) + | ||
| np.sin( | ||
| np.radians(a)) * | ||
| np.sin( | ||
| np.radians(b)) * | ||
| np.cos( | ||
| np.radians(C)), | ||
| ) | ||
| off_axis_deg = np.degrees(off_axis_rad) | ||
| return off_axis_deg | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| off_axis_angle_vec = np.linspace(0.1, 180, num=1001) | ||
| # initialize antenna parameters | ||
| param = ParametersAntenna() | ||
| param.frequency = 2155 | ||
| param_gt = ParametersAntennaImt() | ||
| param.gain = 33.1 | ||
| param.diameter = 2 | ||
| antenna_gt = Antenna_f1245_fs(param) | ||
| antenna_gt.add_beam(0, 0) | ||
| gain_gt = antenna_gt.calculate_gain( | ||
| off_axis_angle_vec=off_axis_angle_vec, | ||
| ) | ||
| param.diameter = 3 | ||
| antenna_gt = Antenna_f1245_fs(param) | ||
| gain_gt_3 = antenna_gt.calculate_gain( | ||
| off_axis_angle_vec=off_axis_angle_vec, | ||
| ) | ||
| param.diameter = 1.8 | ||
| antenna_gt = Antenna_f1245_fs(param) | ||
| gain_gt_18 = antenna_gt.calculate_gain( | ||
| off_axis_angle_vec=off_axis_angle_vec, | ||
| ) | ||
|
|
||
| fig = plt.figure( | ||
| figsize=(8, 7), facecolor='w', | ||
| edgecolor='k', | ||
| ) # create a figure object | ||
| plt.semilogx(off_axis_angle_vec, gain_gt, "-b", label="$f = 10.7$ $GHz,$ $D = 2$ $m$") | ||
| plt.semilogx(off_axis_angle_vec, gain_gt_3, "-y", label="$f = 10.7$ $GHz,$ $D = 3$ $m$") | ||
| plt.semilogx(off_axis_angle_vec, gain_gt_18, "-g", label="$f = 10.7$ $GHz,$ $D = 1.8$ $m$") | ||
|
|
||
| plt.title("ITU-R F.1245 antenna radiation pattern") | ||
| plt.xlabel(r"Off-axis angle $\phi$ [deg]") | ||
| plt.ylabel("Gain relative to $G_m$ [dB]") | ||
| plt.legend(loc="lower left") | ||
| # plt.xlim((phi[0], phi[-1])) | ||
| plt.ylim((-20, 50)) | ||
| # ax = plt.gca() | ||
| # ax.set_yticks([-30, -20, -10, 0]) | ||
| # ax.set_xticks(np.linspace(1, 9, 9).tolist() + np.linspace(10, 100, 10).tolist()) | ||
| plt.grid() | ||
| plt.show() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.