Skip to content

Instantly share code, notes, and snippets.

@telegraphic
telegraphic / board_managers.py
Created June 21, 2022 05:02
Gist for controlling multiple snap boards through `casperfpga` and multiprocessing
from utmost2d_snap import UtmostSnap
from rpi_bf_control import RpiBeamformerController
import time
from multiprocessing import JoinableQueue
from threading import Thread
class BoardManager(object):
""" Base class for multithreaded control of multiple boards
@telegraphic
telegraphic / pygedm-dask-example.ipynb
Created July 8, 2020 05:49
Parallel computation of DM model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@telegraphic
telegraphic / dp4a_cross_correlator.py
Last active November 10, 2021 20:31
Use of CUDA DP4A instruction using PyCUDA
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
import numpy as np
def compute_xcorr_cpu(d):
dc = d.astype('float32').view('complex64')
dc = dc.transpose((0,2,3,1)).copy()
xcorr_cpu = np.einsum('...i,...j', dc, np.conj(dc)).view('float32').astype('int32').sum(axis=-4)
return xcorr_cpu
@telegraphic
telegraphic / app.py
Last active January 12, 2023 02:01
Dash (plot.ly) with ZMQ PubSub, sending numpy arrays with msgpack
"""
# app.py - example Dash + ZMQ + msgpack + numpy monitor
This app receives data from zmq_pub.py, and plots it.
Run the app, browse to localhost:8085 in your web browser, and run zmq_pub.py in a different terminal.
"""
import dash
import dash_core_components as dcc
import dash_html_components as html
#!/usr/bin/env python
from astroquery.jplhorizons import Horizons
from datetime import datetime, timedelta
import pylab as plt
srclist = [
'2015 BZ509',
'2011 SP25',
'2017 RR2',
@telegraphic
telegraphic / app.py
Created June 3, 2018 05:07
Example bottle.py app showing how to embed Bokeh plots that update dynamically with AJAX, using AjaxDataSource.
"""
# app.py -- Example bottle.py app showing how to embed AJAX Bokeh plots that update automatically.
"""
from bottle import *
from bokeh.plotting import figure
from bokeh.embed import components
from bokeh.resources import CDN
from bokeh.models.sources import AjaxDataSource
@telegraphic
telegraphic / vizier_test.ipynb
Created March 30, 2018 07:25
breakthrough_listen_vizier.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@telegraphic
telegraphic / tutorial.ipynb
Last active June 6, 2017 16:43
BL Python tutorial
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@telegraphic
telegraphic / quantization_efficiency.py
Created May 10, 2017 21:13
ADC quantization efficiency calculations for radio astronomy
"""
# quantization_efficiency.py
This script implements the formulas for quantization efficiency
as used in radio astronomy. The formulas appear in:
Thompson, A. R., D. T. Emerson, and F. R. Schwab (2007),
"Convenient formulas for quantization efficiency",
Radio Sci., 42, RS3022, doi:10.1029/2006RS003585.
@telegraphic
telegraphic / parse_nvidia_smi.py
Created September 23, 2016 00:37
Parse nvidia-smi from python
"""
Parse output of nvidia-smi into a python dictionary.
This is very basic!
"""
import subprocess
import pprint
sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)