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
# Open file
f=open(fname)
# Read number of channels
nchan=int(np.fromfile(f,dtype='float32',count=1)[0])
# Read channel frequencies
freq=np.fromfile(f,dtype='float32',count=nchan)/1000.0
# Read entire file
@cbassa
cbassa / pgplot_test.c
Last active January 13, 2019 20:37
PGPLOT test code. Build with "gcc test_pgplot.c -lX11 -lcpgplot -lpgplot -lm -o test_pgplot"
#include <stdio.h>
#include <cpgplot.h>
int main(int argc,char *argv[])
{
cpgopen("?");
cpgend();
return 0;
@cbassa
cbassa / convert.py
Created February 11, 2019 21:14
rtl_power to STRF converter
import numpy as np
from astropy.time import Time
import matplotlib.pyplot as plt
def parse_line(line):
# Strip line and split
line = [part.strip() for part in line.strip().split(",")]
# Get MJD
t = Time("%sT%s"%(line[0], line[1]), format="isot", scale="utc")
@cbassa
cbassa / frequencies.txt
Last active July 12, 2019 12:05
UHF STRF frequencies
20442 437.126562
24278 435.795813
25397 435.225625
25544 437.005969
25544 437.049719
27607 436.793406
27844 436.836844
27848 436.849562
27939 435.354062
28895 437.465969
@cbassa
cbassa / satnogs_waterfall_converter.py
Last active April 25, 2020 12:28
satnogs_waterfall_converter.py
#!/usr/bin/env python3
import numpy as np
import h5py
import argparse
import os
if __name__ == "__main__":
# Parse arguments
parser = argparse.ArgumentParser(
description="Convert a SatNOGS waterfall file to HDF5 format")
@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
@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 / 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 / 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 / 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):