Skip to content

Instantly share code, notes, and snippets.

View dantrim's full-sized avatar

Daniel Antrim dantrim

View GitHub Profile
@dantrim
dantrim / linfit2dpix.py
Last active February 1, 2022 18:57
Fitting a 2D pixel matrix over "time" steps (or some other independent quantity)
import numpy as np
# create dummy two-dimensional (3x3) data that represents
# per-pixel measured quantities taken at various "time steps"
# (say, 4 of such steps):
pixel_maps = np.asarray([
[
[0, 0, 0],
[2, 2, 2],
[3, 3, 3],
@dantrim
dantrim / simple-parquet-write.cpp
Created August 13, 2021 21:33
Write simple parquet file with keyvalue metadata on a field
//std/stl
#include <string>
#include <memory>
#include <stdint.h>
#include <map>
// arrow/parquet
#include <arrow/api.h>
#include <arrow/io/api.h>
#include <parquet/arrow/reader.h>
@dantrim
dantrim / plot-yarr-histo2d.py
Last active June 22, 2021 23:15
Plot a YARR 2D histogram using numpy+matplotlib
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import griddata
import json
##
## YARR histogram data output file
##
@dantrim
dantrim / update_register.sh
Last active June 11, 2021 22:44
Updates an integer value of a field at a specific path
#!/bin/bash
# This is an example showing how to update a value of a specified key
# (that is potentially nested) in a JSON file using shell variables
# in some shell script. For example, some utility for updatiing in-place
# a common set of fields in a JSON configuration file.
# In the snippet below, we assume that the input is a key ("register_name")
# in some nested JSON object whose path is "RD53B.GlobalConfig".
filename=${1}
@dantrim
dantrim / hbd.py
Last active May 30, 2021 20:59
HBD
#!/usr/bin/env python
import pytest
import some_lib
@pytest.fixture
def not_a_day_over():
return 29
def test_current_age(not_a_day_over):