Skip to content

Commit

Permalink
Merge pull request #301 from ut-issl/develop
Browse files Browse the repository at this point in the history
Merge develop into main for v5.3.0 release
  • Loading branch information
200km authored Jan 31, 2023
2 parents f2b54a0 + 77c4f02 commit b79bd19
Show file tree
Hide file tree
Showing 47 changed files with 1,028 additions and 392 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
ver=$(grep python_version ./Pipfile | sed -e 's/^python_version\s=\s"\(.*\)"$/\1/')
echo "version=$ver" >> "$GITHUB_OUTPUT"
- uses: actions/setup-python@v4.4.0
- uses: actions/setup-python@v4.5.0
with:
python-version: ${{ steps.python-version.outputs.version }}

Expand All @@ -243,7 +243,7 @@ jobs:
- name: comment imgs
if: contains(matrix.compiler, 'clang') && contains(matrix.build_bit, 'OFF') && contains(github.event.pull_request.labels.*.name, 'automation::comment-graph')
uses: actions/github-script@v6.3.3
uses: actions/github-script@v6.4.0
with:
script: |
const output = `## \`position.png\`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
ver=$(grep python_version ./Pipfile | sed -e 's/^python_version\s=\s"\(.*\)"$/\1/')
echo "version=${ver}" >> "$GITHUB_OUTPUT"
- uses: actions/setup-python@v4.4.0
- uses: actions/setup-python@v4.5.0
with:
python-version: ${{ steps.python-version.outputs.version }}

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_policy(SET CMP0048 NEW)
project(S2E
LANGUAGES CXX
DESCRIPTION "S2E: Spacecraft Simulation Environment"
VERSION 5.2.0
VERSION 5.3.0
)

cmake_minimum_required(VERSION 3.13)
Expand Down
4 changes: 4 additions & 0 deletions data/SampleSat/ini/SampleGS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ height_m = 3.4

// The minimum limit of elevation to work the station
elevation_limit_angle_deg = 5.0

[COMPONENTS_FILE]
ant_gs_file = ../../data/SampleSat/ini/component/ANT_GS.ini
gs_calculator_file = ../../data/SampleSat/ini/component/GScalculator.ini
2 changes: 1 addition & 1 deletion data/SampleSat/ini/SampleSat.ini
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ mag_torquer_file = ../../data/SampleSat/ini/component/magtorquer.ini
rw_file = ../../data/SampleSat/ini/component/RW.ini
thruster_file = ../../data/SampleSat/ini/component/Thruster.ini
force_generator_file = ../../data/SampleSat/ini/component/ForceGenerator.ini
antenna_file = ../../data/SampleSat/ini/component/ANT.ini
antenna_file = ../../data/SampleSat/ini/component/ANT_SC.ini
4 changes: 2 additions & 2 deletions data/SampleSat/ini/component/ANT_GS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tx_loss_pointing = 0.0
// Antenna gain model
// ISOTROPIC: Ideal isotropic antenna
// RADIATION_PATTERN_CSV: Radiation pattern obtained by CSV files
tx_antenna_gain_model = RADIATION_PATTERN_CSV
tx_antenna_gain_model = ISOTROPIC

// Gain for ISOTROPIC mode [dBi]
// Generally, it is zero but users can set any value for ideal analysis
Expand Down Expand Up @@ -57,7 +57,7 @@ rx_system_noise_temperature = 230
// Antenna gain model
// ISOTROPIC: Ideal isotropic antenna
// RADIATION_PATTERN_CSV: Radiation pattern obtained by CSV files
rx_antenna_gain_model = RADIATION_PATTERN_CSV
rx_antenna_gain_model = ISOTROPIC

// Gain for ISOTROPIC mode [dBi]
// Generally, it is zero but users can set any value for ideal analysis
Expand Down
23 changes: 11 additions & 12 deletions data/SampleSat/ini/component/GScalculator.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
[GScalculator]
//通信回線のうち,ANT同士をつなぐ部分のパラメータ
//偏波損失[dB]
// Polarization loss [dB]
loss_polarization = 0.0

//大気吸収損失[dB]
// Atmospheric loss [dB]
loss_atmosphere = -0.5

//降雨損失[dB]
// Rain fall loss [dB]
loss_rainfall = -0.12

//その他損失[dB]
// Other losses [dB]
loss_others = 0.0

//通信回線のデータ方式まわりの計算のパラメータ
//要求Eb/N0[dB](QPSKでBER1e-6の場合)
// Required Eb/N0 [dB](The following value is QPSK and BER=1e-6)
EbN0 = 10.8

//ハードウェア劣化[dB]
// Deterioration of hardware [dB]
hardware_deterioration = 1.5

//符号化利得[dB](RS(E16)+畳み込みでBER1e-6の場合
// Codig gain [dB](The following value is RS(E16)+Convolution and BER=1e-6
coding_gain = -8.17

//ビットレート[kbps](最大ビットレート履歴を求めるという解析目的ではこれは指定する値ではない)

//確保する回線マージン[dB]
// Required margin to calclate maximum bitrate [dB]
margin_req = 3.0

// Downlink bitrate to calculate receive margin [bps]
downlink_bitrate_bps = 100000
4 changes: 2 additions & 2 deletions scripts/Plot/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name = "pypi"

[packages]
basemap = "==1.3.6"
matplotlib = "==3.6.2"
matplotlib = "==3.6.3"
numpy = "==1.23.5"
pandas = "==1.5.2"
pandas = "==1.5.3"

[dev-packages]

Expand Down
497 changes: 252 additions & 245 deletions scripts/Plot/Pipfile.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions scripts/Plot/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import numpy as np
from numpy.linalg import norm
import pandas

def find_latest_log_tag(logs_dir):
dlist = sorted(os.listdir(logs_dir))
Expand All @@ -17,3 +18,18 @@ def normalize_csv_read_vector(vector):
norm_v = norm(vector, axis=1)
normalized_vector = vector / norm_v[:, None]
return np.transpose(normalized_vector)

def read_3d_vector_from_csv(read_file_name, header_name, unit):
name_x = header_name + "(X)" + '[' + unit + ']'
name_y = header_name + "(Y)" + '[' + unit + ']'
name_z = header_name + "(Z)" + '[' + unit + ']'
csv_data = pandas.read_csv(read_file_name, sep=',', usecols=[name_x, name_y, name_z])
vector = np.array([csv_data[name_x].to_numpy(),
csv_data[name_y].to_numpy(),
csv_data[name_z].to_numpy()])
return vector

def read_scalar_from_csv(read_file_name, header_name):
csv_data = pandas.read_csv(read_file_name, sep=',', usecols=[header_name])
vector = np.array([csv_data[header_name].to_numpy()])
return vector
105 changes: 105 additions & 0 deletions scripts/Plot/plot_disturbance_force.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Plot Disturbances
#
# arg[1] : read_file_tag : time tag for default CSV output log file. ex. 220627_142946
#

#
# Import
#
# plots
import matplotlib.pyplot as plt
# local function
from common import find_latest_log_tag
from common import read_3d_vector_from_csv
from common import read_scalar_from_csv
# arguments
import argparse

aparser = argparse.ArgumentParser()

aparser.add_argument('--logs-dir', type=str, help='logs directory like "../../data/SampleSat/logs"', default='../../data/SampleSat/logs')
aparser.add_argument('--file-tag', type=str, help='log file tag like 220627_142946')
aparser.add_argument('--no-gui', action='store_true')

args = aparser.parse_args()

#
# Read Arguments
#
# log file path
path_to_logs = args.logs_dir

read_file_tag = args.file_tag
if read_file_tag == None:
print("file tag does not found. use latest.")
read_file_tag = find_latest_log_tag(path_to_logs)

print("log: " + read_file_tag)

#
# CSV file name
#
read_file_name = path_to_logs + '/' + 'logs_' + read_file_tag + '/' + read_file_tag + '_default.csv'

#
# Data read and edit
#
# Read S2E CSV
time = read_scalar_from_csv(read_file_name, 'time[sec]')

srp_force_b = read_3d_vector_from_csv(read_file_name, 'srp_force_b', 'N')
airdrag_force_b = read_3d_vector_from_csv(read_file_name, 'airdrag_force_b', 'N')

third_body_acc_i = read_3d_vector_from_csv(read_file_name, 'acc_thirdbody_i', 'm/s2')
geopotential_acc_ecef = read_3d_vector_from_csv(read_file_name, 'a_geop_ecef', 'm/s2')

total_acc_i = read_3d_vector_from_csv(read_file_name, 'sat_acc_i_i', 'm/s^2')

#
# Plot
#
plt.figure(0)
plt.plot(time[0], srp_force_b[0], marker=".", c="red", label="SRP-X")
plt.plot(time[0], srp_force_b[1], marker=".", c="green", label="SRP-Y")
plt.plot(time[0], srp_force_b[2], marker=".", c="blue", label="SRP-Z")
plt.plot(time[0], airdrag_force_b[0], marker=".", c="orange", label="AIR-X")
plt.plot(time[0], airdrag_force_b[1], marker=".", c="yellow", label="AIR-Y")
plt.plot(time[0], airdrag_force_b[2], marker=".", c="purple", label="AIR-Z")
plt.title("Non-gravitational Disturbance Force @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Force [N]")
plt.legend()

plt.figure(1)
plt.plot(time[0], third_body_acc_i[0], marker=".", c="red", label="X")
plt.plot(time[0], third_body_acc_i[1], marker=".", c="green", label="Y")
plt.plot(time[0], third_body_acc_i[2], marker=".", c="blue", label="Z")
plt.title("Third body acceleration @ Inertial frame")
plt.xlabel("Time [s]")
plt.ylabel("Acceleration [m/s2]")
plt.legend()

plt.figure(2)
plt.plot(time[0], geopotential_acc_ecef[0], marker=".", c="red", label="X")
plt.plot(time[0], geopotential_acc_ecef[1], marker=".", c="green", label="Y")
plt.plot(time[0], geopotential_acc_ecef[2], marker=".", c="blue", label="Z")
plt.title("Geo-potential acceleration @ ECEF frame")
plt.xlabel("Time [s]")
plt.ylabel("Acceleration [m/s2]")
plt.legend()

plt.figure(3)
plt.plot(time[0], total_acc_i[0], marker=".", c="red", label="X")
plt.plot(time[0], total_acc_i[1], marker=".", c="green", label="Y")
plt.plot(time[0], total_acc_i[2], marker=".", c="blue", label="Z")
plt.title("Total acceleration @ Inertial frame")
plt.xlabel("Time [s]")
plt.ylabel("Acceleration [m/s2]")
plt.legend()

# Data save
if args.no_gui:
plt.savefig(read_file_tag + "_disturbance_torque.png") # save last figure only
else:
plt.show()
109 changes: 109 additions & 0 deletions scripts/Plot/plot_disturbance_torque.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#
# Plot Disturbances
#
# arg[1] : read_file_tag : time tag for default CSV output log file. ex. 220627_142946
#

#
# Import
#
# plots
import matplotlib.pyplot as plt
# local function
from common import find_latest_log_tag
from common import read_3d_vector_from_csv
from common import read_scalar_from_csv
# arguments
import argparse

aparser = argparse.ArgumentParser()

aparser.add_argument('--logs-dir', type=str, help='logs directory like "../../data/SampleSat/logs"', default='../../data/SampleSat/logs')
aparser.add_argument('--file-tag', type=str, help='log file tag like 220627_142946')
aparser.add_argument('--no-gui', action='store_true')

args = aparser.parse_args()

#
# Read Arguments
#
# log file path
path_to_logs = args.logs_dir

read_file_tag = args.file_tag
if read_file_tag == None:
print("file tag does not found. use latest.")
read_file_tag = find_latest_log_tag(path_to_logs)

print("log: " + read_file_tag)

#
# CSV file name
#
read_file_name = path_to_logs + '/' + 'logs_' + read_file_tag + '/' + read_file_tag + '_default.csv'

#
# Data read and edit
#
# Read S2E CSV
time = read_scalar_from_csv(read_file_name, 'time[sec]')

total_torque_b = read_3d_vector_from_csv(read_file_name, 'torque_true_b', 'Nm')
gg_torque_b = read_3d_vector_from_csv(read_file_name, 'ggtorque_b', 'Nm')
srp_torque_b = read_3d_vector_from_csv(read_file_name, 'srp_torque_b', 'Nm')
airdrag_torque_b = read_3d_vector_from_csv(read_file_name, 'airdrag_torque_b', 'Nm')
mag_torque_b = read_3d_vector_from_csv(read_file_name, 'mag_dist_torque_b', 'Nm')

#
# Plot
#
plt.figure(0)
plt.plot(time[0], gg_torque_b[0], marker=".", c="red", label="X")
plt.plot(time[0], gg_torque_b[1], marker=".", c="green", label="Y")
plt.plot(time[0], gg_torque_b[2], marker=".", c="blue", label="Z")
plt.title("Gravity Gradient torque @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Torque [Nm]")
plt.legend()

plt.figure(1)
plt.plot(time[0], srp_torque_b[0], marker=".", c="red", label="X")
plt.plot(time[0], srp_torque_b[1], marker=".", c="green", label="Y")
plt.plot(time[0], srp_torque_b[2], marker=".", c="blue", label="Z")
plt.title("Solar Radiation Pressure torque @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Torque [Nm]")
plt.legend()

plt.figure(2)
plt.plot(time[0], airdrag_torque_b[0], marker=".", c="red", label="X")
plt.plot(time[0], airdrag_torque_b[1], marker=".", c="green", label="Y")
plt.plot(time[0], airdrag_torque_b[2], marker=".", c="blue", label="Z")
plt.title("Air drag torque @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Torque [Nm]")
plt.legend()

plt.figure(3)
plt.plot(time[0], mag_torque_b[0], marker=".", c="red", label="X")
plt.plot(time[0], mag_torque_b[1], marker=".", c="green", label="Y")
plt.plot(time[0], mag_torque_b[2], marker=".", c="blue", label="Z")
plt.title("Magnetic disturbance torque @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Torque [Nm]")
plt.legend()

plt.figure(4)
plt.plot(time[0], total_torque_b[0], marker=".", c="red", label="X")
plt.plot(time[0], total_torque_b[1], marker=".", c="green", label="Y")
plt.plot(time[0], total_torque_b[2], marker=".", c="blue", label="Z")
plt.title("Total torque @ Body frame")
plt.xlabel("Time [s]")
plt.ylabel("Torque [Nm]")
plt.legend()

# Data save
if args.no_gui:
plt.savefig(read_file_tag + "_disturbance_torque.png") # save last figure only
else:
plt.show()
2 changes: 2 additions & 0 deletions src/Component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ add_library(${PROJECT_NAME} STATIC
CommGS/GScalculator.cpp
CommGS/InitGsCalculator.cpp

Examples/ChangeStructure.cpp

IdealComponents/ForceGenerator.cpp
IdealComponents/InitializeForceGenerator.cpp

Expand Down
8 changes: 4 additions & 4 deletions src/Component/CommGS/Antenna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ Antenna::Antenna(const int id, const libra::Quaternion& q_b2c, const bool is_tra
Antenna::~Antenna() {}

double Antenna::CalcAntennaGain(const AntennaParameters ant_params, const double theta_rad, const double phi_rad) const {
double gain_dB = 0.0;
double gain_dBi = 0.0;
switch (ant_params.antenna_gain_model) {
case AntennaGainModel::ISOTROPIC:
gain_dB = ant_params.gain_dBi_;
gain_dBi = ant_params.gain_dBi_;
break;
case AntennaGainModel::RADIATION_PATTERN_CSV:
gain_dB = ant_params.radiation_pattern.GetGain_dBi(theta_rad, phi_rad);
gain_dBi = ant_params.radiation_pattern.GetGain_dBi(theta_rad, phi_rad);
break;
default:
break;
}
return gain_dB;
return gain_dBi;
}

double Antenna::CalcTxEIRP(const double theta_rad, const double phi_rad) const {
Expand Down
Loading

0 comments on commit b79bd19

Please sign in to comment.