Skip to content

Instantly share code, notes, and snippets.

View dpohanlon's full-sized avatar

Daniel O'Hanlon dpohanlon

View GitHub Profile
@dpohanlon
dpohanlon / renameFASTQ.py
Created September 30, 2022 18:06
Rename FASTQ files into the format Cellranger supports
import os
import subprocess as sp
import argparser
def buildName(sampleID, s = '1', lane = "001", read = "1", number = "001"):
name = f'{sampleID}_S{s}_L{lane}_R{read}_{number}.fastq'
@dpohanlon
dpohanlon / pdfReorder.py
Last active June 3, 2022 09:42
Move figures at the end of a PDF to the page after they're first referenced. Requires `pip install PyMuPDF`
import re
import argparse
# pip install PyMuPDF
import fitz
def pageToFigNo(file, pages):
# From https://gitlab.cern.ch/snippets/1303
import numpy as np
import cmath
from scipy.special import erf, erfc, wofz
from scipy.fftpack import fft, ifft, fft2, ifft2
from scipy.integrate import quad
@dpohanlon
dpohanlon / Dockerfile
Created August 23, 2021 21:49
Container for x86_64 Laura++
# I robbed most of this from:
# https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/debian/Dockerfile
# https://github.com/root-project/root-docker/blob/6.22.00-conda/conda/Dockerfile
FROM ubuntu:20.04
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@dpohanlon
dpohanlon / Dockerfile
Created August 23, 2021 21:47
Container for Laura++ aarm64
# I robbed most of this from:
# https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/debian/Dockerfile
# https://github.com/root-project/root-docker/blob/6.22.00-conda/conda/Dockerfile
# docker buildx build --push --platform linux/arm64/v8 -t dpohanlon/laura-arm .
FROM ubuntu:20.04
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
import json
import numpy as np
def sigmoid(x):
return 1./(1 + np.exp(-x))
d = 3 # number of features
h = 4 # number of hidden units
n = 1 # number of tracks

JSON file available at /eos/lhcb/user/d/dohanlon/FT/mvTestModelParams.json

In mvTestModelParams.json,

input: (5 timestep, 3 feature) input matrix

output: (5 timestep, 4 hidden) output matrix (one hidden (length 4) output for each timestep)

GRU_* : Weights and biases correspond to those in https://en.wikipedia.org/wiki/Gated_recurrent_unit#Fully_gated_unit, 4 hidden units

import json
import tensorflow.keras as keras
from tensorflow.keras.models import Model
import numpy as np
from pprint import pprint
def testModel(reset_after):
#!/usr/bin/python3.6
import subprocess as sp
import os
import re
import argparse
def writeBashScript(location, name, command):
import h5py
import numpy as np
import json
def getTracks(fileName = '/data/1/dan/veloSim/veloData.h5', nEvents = 100):
file = h5py.File(fileName, 'r')