Skip to content

Instantly share code, notes, and snippets.

View cbassa's full-sized avatar

Cees Bassa cbassa

  • ASTRON Netherlands Institute for Radio Astronomy
  • Netherlands
View GitHub Profile
@cbassa
cbassa / compare_sgp4_cysgp4.py
Created January 5, 2020 17:55
Comparing the results of sgp4 and cysgp4
#!/usr/bin/env python3
import numpy as np
from sgp4.earth_gravity import wgs84
from sgp4.io import twoline2rv
from astropy.time import Time
import astropy.units as u
from cysgp4 import PyTle, PyObserver, propagate_many, Satellite, PyDateTime
if __name__ == "__main__":
# TLE
@cbassa
cbassa / starlink_tles_for_turin.txt
Created December 20, 2019 17:14
Simulated Starlink TLEs for Turin, March 20, 2020 from 19:00UTC to 19:30UTC.
@cbassa
cbassa / satnogs_waterfall_plotter.py
Created December 17, 2019 14:44
Waterfall plotter
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import matplotlib
#matplotlib.use("Agg")
import matplotlib.pyplot as plt
import sys
# Get filename
fname=sys.argv[1]
@cbassa
cbassa / iss_transit_astropy.py
Created November 25, 2019 22:42
Reproducing the ISS->Venus->Solar transit of June 8, 2004 (Astropy)
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import get_body, solar_system_ephemeris
from astropy.coordinates import EarthLocation, GCRS, FK5
from astropy.coordinates import SkyCoord, PrecessedGeocentric, CartesianRepresentation
from astropy.wcs import wcs
@cbassa
cbassa / iss_transit_skyfield.py
Created November 25, 2019 22:40
Reproducing the ISS->Venus->Solar transit of June 8, 2004 (Skyfield)
#!/usr/bin/env python3
import numpy as np
from skyfield.api import Topos, load
from skyfield.api import EarthSatellite
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import astropy.units as u
from astropy.wcs import wcs
if __name__ == "__main__":
@cbassa
cbassa / cola.py
Last active November 22, 2021 16:45
Compute collisions/encounters between satellites in a catalog
#!/usr/bin/env python3
import numpy as np
from sgp4.earth_gravity import wgs84
from sgp4.io import twoline2rv
from astropy.time import Time
class TwoLineElement:
"""TLE class"""
def __init__(self, tle0, tle1, tle2):
@cbassa
cbassa / crota.py
Created November 4, 2019 22:01
FITS WCS rotation angles
#!/usr/bin/env python3
import sys
import numpy as np
from astropy.wcs import wcs
w = wcs.WCS(sys.argv[1])
sx = np.sqrt(w.wcs.cd[0, 0]**2+w.wcs.cd[0, 1]**2)*3600.0
sy = np.sqrt(w.wcs.cd[1, 0]**2+w.wcs.cd[1, 1]**2)*3600.0
ang1 = np.arctan2(w.wcs.cd[0, 1], w.wcs.cd[0, 0])*180.0/np.pi
@cbassa
cbassa / sgp4_comparison.py
Created October 31, 2019 21:46
sgp4 comparison
#!/usr/bin/env python3
"""
This test will compare the output of ephem, skyfield and sgp4
Reference information from cbassa/sattools skymap
Time: 2019-10-31T18:22:00
Location: 52.8344N, 6.3785E, 10m
TLE:
USA 276
1 42689U 17022A 19300.77210760 0.00002000 00000-0 26008-4 0 09
@cbassa
cbassa / plot_lightsail-data.py
Created October 28, 2019 15:52
Extract LightSail data from spacetrack and plot it.
#!/usr/bin/env python3
import json
import datetime
from spacetrack import SpaceTrackClient
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
if __name__ == "__main__":
# Login
st = SpaceTrackClient("username", "password")
@cbassa
cbassa / starlink_tles.txt
Created October 24, 2019 18:33
Two-line elements (TLEs) for the SpaceX Starlink constellation. Computed using https://github.com/cbassa/satellite_analysis/blob/master/starlink_sunlit_satellites.ipynb