Skip to content

Instantly share code, notes, and snippets.

@aewallin
aewallin / allantools_realtime_minimal.py
Created June 12, 2023 06:43
Minimal demo of AllanTools realtime use
import allantools as at
import numpy as np
decades = 3
x_all = np.random.randn(pow(10, decades)) # test time-series
dev_rt = at.realtime.oadev_realtime(auto_afs=True,tau0=1.0)
@aewallin
aewallin / jabref_timestamp_to_creationdate.py
Created October 9, 2022 07:42
Modify bibtex file for new JabRef, old timestamp-fields modified to new creationdate-fields (is8601 format)
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 9 10:09:25 2022
@author: awanders
"""
import bibtexparser
import datetime
@aewallin
aewallin / tai_weight_plot.py
Last active March 29, 2021 07:56
Plot TAI-weights from BIPM Circular-T data file
"""
Read a clock-weight file from the BIPM Circular-T website
plot some figres
AW2021-03-28, update 2021-03-29
"""
import os
import datetime
@aewallin
aewallin / chi2_stable32.py
Last active December 31, 2020 09:42
Comparison between scipy and approximations for inverse chi-squared cumulative distribution
# The code below relates to computing the inverse chi-squared cumulative distribution,
# used e.g. in Stable32 and allantools for computing confidence intervals.
# This blog post has the images produced by the code, and some comments
# http://www.anderswallin.net/2020/12/fun-with-chi-squared/
#
# Anders Wallin, 2020-12-29
#
import numpy as np
import scipy.stats
import scipy.special
#
# Assume white phase noise sampled at 1 MS/s
# visualize what happens when we decimate 10x six times to 1 S/s
#
import allantools as at
import numpy
import matplotlib.pyplot as plt
import scipy
# simulated data
@aewallin
aewallin / strontium_freqs.py
Created November 23, 2019 20:26
Plot 88Sr+ ion clock transition frequencies
# Sr+ frequencies
# AW2019-11-20
# https://www.bipm.org/utils/common/pdf/mep/88Sr+_445THz_2017.pdf
import matplotlib.pyplot as plt
import numpy
f_srs = 444779044095486.50
f_offset = 444779044095000
u_y_srs = 1.5e-15
@aewallin
aewallin / clock.html
Last active November 20, 2019 08:19 — forked from Flybel/clock.html
OBS Studio: A HTML page for showing current ISO-date and UTC-time in the video
<!--
Usage in OBS
Browser source: local file\clock.html
Custom CSS box: body { background-color: rgba(0, 0, 0, 0); margin: 0px auto; overflow: hidden;
color: white; font: bold 40px monospace; }
-->
<!DOCTYPE html>
<html>
<head>
# simple script for reading Keysight 53230A counter
import vxi11 # https://pypi.org/project/python-vxi11/
import time
import datetime
import pytz
instr1 = vxi11.Instrument("194.100.49.155") # lower counter
init_commands = ["*RST",
"SYST:TIM 5.0",
"CONF:TINT (@1), (@2)", # REVERSE!
# AW2018-12-06
# very simple auto-courtyard for KiCad footprints
# 1. reads bounding-box of F.fab and pads
# 2. expands by clearance
# 4. writes rectangle to F.CrtYd layer
# 5. writes modified footprint to a new file
import sys
import os
import math
@aewallin
aewallin / ustep_calc.py
Created October 22, 2018 12:30
DDS and u-stepper calclations
import bigfloat
import numpy
dds_clk=1.0e9
ftw_length = pow(2,48)
IF = 100e6/1024.0 # 97656.25
def ftw_dds(f_hz):
return numpy.round(f_hz*ftw_length/dds_clk,0)