Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mfalkvidd/c2c75d23bb648bf539aadf5913f44ade to your computer and use it in GitHub Desktop.
Save mfalkvidd/c2c75d23bb648bf539aadf5913f44ade to your computer and use it in GitHub Desktop.

Revisions

  1. mfalkvidd created this gist Jun 23, 2021.
    31 changes: 31 additions & 0 deletions get_all_observations_for_statnogs_station.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/bin/bash
    re='^[0-9]+$'
    if ! [[ "$1" =~ $re ]] ; then
    echo "Usage: $0 <station_number>"
    exit
    fi
    PAGE=1
    OUTPUT=""
    STATION=$1
    JSONFILE="observations_$STATION.json"
    CSVFILE="observations_$STATION.csv"
    echo "[" >> "$JSONFILE"

    while true
    do
    OUTPUT=$(curl "https://network.satnogs.org/api/observations/?format=json&ground_station=$STATION&page=$PAGE")
    if echo "$OUTPUT" | grep -q 'Invalid page'; then
    break;
    fi
    if [[ $PAGE -gt 1 ]]; then
    echo "," >> "$JSONFILE"
    fi
    echo "$OUTPUT" >> "$JSONFILE"
    PAGE=$((PAGE+1))
    done
    echo "]" >> "$JSONFILE"

    echo "obs_ID,status,transmitter,satellite" > "$CSVFILE"
    jq -r '.[][] | "\(.id),\(.status),\(.transmitter_uuid),\(.tle0)"' "$JSONFILE" >> "$CSVFILE"

    echo "Output is in $CSVFILE"