Skip to content

Commit

Permalink
Merge pull request #179 from jekhokie/add-pass-side
Browse files Browse the repository at this point in the history
Add Pass Side (East/West)
  • Loading branch information
jekhokie authored Feb 27, 2021
2 parents e86d062 + fc11026 commit 1da6bbe
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ansible/roles/common/files/annotation.html.j2_file
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* sat_name - name of the satellite
* sun_elevation - elevation of the sun during the capture
* pass_direction - direction of the satellite pass (relative to ground station)
* pass_side - whether the pass was east/west of the base station (represented as "E" or "W")
* pass_side_long - long form of whether the pass was east/west of the base station (represented as "East" or "West")

To have a variable replaced with the injected variables when this template is called, simply
wrap the variable in double curly braces like this: {{ my_var }}
Expand All @@ -24,6 +26,6 @@

<p style="color: yellow; font-weight: bold;">
Ground Station: {{ ground_station_location }}<br>
{{ sat_name }} {{ enhancement }} {{ capture_start }} Max Elev: {{ sat_max_elevation }}&#176;
{{ sat_name }} {{ enhancement }} {{ capture_start }} Max Elev: {{ sat_max_elevation }}&#176; {{ pass_side }}
Sun Elevation: {{ sun_elevation }}&#176; | {{ pass_direction }}
</p>
2 changes: 2 additions & 0 deletions db_migrations/05_add_pass_azimuth_at_max.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE predict_passes
ADD COLUMN azimuth_at_max int;
9 changes: 9 additions & 0 deletions db_migrations/update_database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ else
log " - ${script} already applied" "INFO"
fi

script="05_add_pass_azimuth_at_max.sql"
check=$($SQL_CMD $NOAA_HOME/db/panel.db ".schema predict_passes" | grep 'azimuth_at_max')
if [ -z "${check}" ]; then
log " - applying ${script}" "INFO"
$SQL_CMD $NOAA_HOME/db/panel.db < $NOAA_HOME/db_migrations/$script
else
log " - ${script} already applied" "INFO"
fi

log "Schema updates complete!" "INFO"
8 changes: 8 additions & 0 deletions scripts/image_processors/meteor_normalize_annotate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ INPUT_JPG=$1
OUTPUT_JPG=$2
QUALITY=$3

# provide a long-form pass side
pass_side_long="West"
if [ "${PASS_SIDE}" == "E" ]; then
pass_side_long="East"
fi

# get the base config and append vars as needed
yml_config=$(cat "${NOAA_HOME}/config/settings.yml")
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sat_name: '$SAT_NAME'\n.../") # sat_name
Expand All @@ -28,6 +34,8 @@ yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/enhancement: '$ENHANCEMENT
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sat_max_elevation: '$SAT_MAX_ELEVATION'\n.../") # sat_max_elevation
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sun_elevation: '$SUN_ELEV'\n.../") # sun_elevation
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_direction: $PASS_DIRECTION\n.../") # pass_direction
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_side: $PASS_SIDE\n.../") # pass_side
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_side_long: $pass_side_long\n.../") # pass_side_long

# vars for image manipulation
tmp_dir="${NOAA_HOME}/tmp/annotation"
Expand Down
8 changes: 8 additions & 0 deletions scripts/image_processors/noaa_normalize_annotate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ INPUT_JPG=$1
OUTPUT_JPG=$2
QUALITY=$3

# provide a long-form pass side
pass_side_long="West"
if [ "${PASS_SIDE}" == "E" ]; then
pass_side_long="East"
fi

# get the base config and append vars as needed
yml_config=$(cat "${NOAA_HOME}/config/settings.yml")
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sat_name: '$SAT_NAME'\n.../") # sat_name
Expand All @@ -28,6 +34,8 @@ yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/enhancement: '$ENHANCEMENT
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sat_max_elevation: '$SAT_MAX_ELEVATION'\n.../") # sat_max_elevation
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/sun_elevation: '$SUN_ELEV'\n.../") # sun_elevation
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_direction: $PASS_DIRECTION\n.../") # pass_direction
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_side: $PASS_SIDE\n.../") # pass_side
yml_config=$(echo "${yml_config}" | sed -e "s/\.\.\.$/pass_side_long: $pass_side_long\n.../") # pass_side_long

# vars for image manipulation
tmp_dir="${NOAA_HOME}/tmp/annotation"
Expand Down
4 changes: 3 additions & 1 deletion scripts/receive_meteor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
# 4. Duration of capture (seconds)
# 5. Max angle elevation for satellite
# 6. Direction of pass
# 7. Side of pass (W=West, E=East) relative to base station
#
# Example:
# ./receive_meteor.sh "METEOR-M 2" METEOR-M220210205-192623 1612571183 922 39 Northbound
# ./receive_meteor.sh "METEOR-M 2" METEOR-M220210205-192623 1612571183 922 39 Northbound W

# import common lib and settings
. "$HOME/.noaa-v2.conf"
Expand All @@ -25,6 +26,7 @@ export EPOCH_START=$3
export CAPTURE_TIME=$4
export SAT_MAX_ELEVATION=$5
export PASS_DIRECTION=$6
export PASS_SIDE=$7

# base directory plus filename_base for re-use
RAMFS_AUDIO_BASE="${RAMFS_AUDIO}/${FILENAME_BASE}"
Expand Down
4 changes: 3 additions & 1 deletion scripts/receive_noaa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# 5. Duration of capture (seconds)
# 6. Max angle elevation for satellite
# 7. Direction of pass
# 8. Side of pass (W=West, E=East) relative to base station
#
# Example:
# ./receive_noaa.sh "NOAA 18" NOAA1820210208-194829 ./orbit.tle 1612831709 919 31 Southbound
# ./receive_noaa.sh "NOAA 18" NOAA1820210208-194829 ./orbit.tle 1612831709 919 31 Southbound E

# import common lib and settings
. "$HOME/.noaa-v2.conf"
Expand All @@ -27,6 +28,7 @@ export EPOCH_START=$4
export CAPTURE_TIME=$5
export SAT_MAX_ELEVATION=$6
export PASS_DIRECTION=$7
export PASS_SIDE=$8

# base directory plus filename helper variables
AUDIO_FILE_BASE="${NOAA_AUDIO_OUTPUT}/${FILENAME_BASE}"
Expand Down
12 changes: 10 additions & 2 deletions scripts/schedule_captures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TLE_FILE=$3
predict_start=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" | head -1)
predict_end=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" | tail -1)
max_elev=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')
azimuth_at_max=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" | awk -v max=0 -v az=0 '{if($5>max){max=$5;az=$6}}END{print az}')
end_epoch_time=$(echo "${predict_end}" | cut -d " " -f 1)
starting_azimuth=$(echo "${predict_start}" | awk '{print $6}')

Expand Down Expand Up @@ -49,19 +50,26 @@ while [ "$(date --date="@${end_epoch_time}" +%D)" = "$(date +%D)" ]; do
direction="Northbound"
fi

# calculate side of travel
pass_side="W"
if [ $azimuth_at_max -ge 0 ] && [ $azimuth_at_max -le 180 ]; then
pass_side="E"
fi

printf -v safe_obj_name "%q" $(echo "${OBJ_NAME}" | sed "s/ /-/g")
log "Scheduling capture for: ${safe_obj_name} ${file_date_ext} ${max_elev}" "INFO"
echo "${NOAA_HOME}/scripts/${RECEIVE_SCRIPT} \"${OBJ_NAME}\" ${safe_obj_name}-${file_date_ext} ${receiver_tle_file} \
${start_epoch_time} ${timer} ${max_elev} ${direction}" | at "$(date --date="TZ=\"UTC\" ${start_datetime}" +"%H:%M %D")"
${start_epoch_time} ${timer} ${max_elev} ${direction} ${pass_side}" | at "$(date --date="TZ=\"UTC\" ${start_datetime}" +"%H:%M %D")"

# update database with scheduled pass
$SQLITE3 $DB_FILE "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev,is_active,pass_start_azimuth,direction) values (\"${OBJ_NAME}\",$start_epoch_time,$end_epoch_time,$max_elev,1,$starting_azimuth,'$direction');"
$SQLITE3 $DB_FILE "INSERT OR REPLACE INTO predict_passes (sat_name,pass_start,pass_end,max_elev,is_active,pass_start_azimuth,azimuth_at_max,direction) VALUES (\"${OBJ_NAME}\",$start_epoch_time,$end_epoch_time,$max_elev,1,$starting_azimuth,$azimuth_at_max,'$direction');"
fi

next_predict=$(expr "${end_epoch_time}" + 60)
predict_start=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" "${next_predict}" | head -1)
predict_end=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" "${next_predict}" | tail -1)
max_elev=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" "${next_predict}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}')
azimuth_at_max=$($PREDICT -t $TLE_FILE -p "${OBJ_NAME}" "${next_predict}" | awk -v max=0 -v az=0 '{if($5>max){max=$5;az=$6}}END{print az}')
end_epoch_time=$(echo "${predict_end}" | cut -d " " -f 1)
starting_azimuth=$(echo "${predict_start}" | awk '{print $6}')
done
3 changes: 2 additions & 1 deletion webpanel/App/Models/Capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function getList($page, $img_per_page) {
predict_passes.sat_name,
predict_passes.max_elev,
predict_passes.pass_start_azimuth,
predict_passes.direction
predict_passes.direction,
predict_passes.azimuth_at_max
FROM decoded_passes
INNER JOIN predict_passes
ON predict_passes.pass_start = decoded_passes.pass_start
Expand Down
1 change: 1 addition & 0 deletions webpanel/App/Models/Pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function getList() {
pass_end,
max_elev,
pass_start_azimuth,
azimuth_at_max,
direction
FROM predict_passes
WHERE (pass_start > $today)
Expand Down
7 changes: 6 additions & 1 deletion webpanel/App/Views/Captures/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
<div class="card-body my-0 py-0 pt-3">
<h5 class="card-title">{{ capture.sat_name }}</h5>
<p>
<strong>{{ lang.elev }}: </strong>{{ capture.max_elev }}&#176;<br>
<strong>{{ lang.elev }}: </strong>{{ capture.max_elev }}&#176;&nbsp;
{% if capture.azimuth_at_max != "" %}
{% if capture.azimuth_at_max >= 0 and capture.azimuth_at_max <= 180 %}E{% else %}W{% endif %}
{% endif %}

<br>
{% if capture.pass_start_azimuth != '' %}
<strong>{{ lang.pass_start_azimuth }}: </strong>{{ capture.pass_start_azimuth }}&#176;<br>
{% endif %}
Expand Down
7 changes: 6 additions & 1 deletion webpanel/App/Views/Passes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
</td>
<td class="text-center">{{ pass_start }}</td>
<td class="text-center">{{ pass_end }}</td>
<td class="text-center">{{ pass.max_elev }}&#176;</td>
<td class="text-center">
{{ pass.max_elev }}&#176;
{% if pass.azimuth_at_max != "" %}
{% if pass.azimuth_at_max >= 0 and pass.azimuth_at_max <= 180 %}E{% else %}W{% endif %}
{% endif %}
</td>
<td class="text-center d-none d-sm-table-cell">{% if pass.pass_start_azimuth != "" %}{{ pass.pass_start_azimuth }}&#176;{% endif %}</td>
<td class="text-center d-none d-sm-table-cell">{% if pass.direction != "" %}{{ pass.direction }}{% endif %}</td>
</tr>
Expand Down

0 comments on commit 1da6bbe

Please sign in to comment.