Skip to content

Instantly share code, notes, and snippets.

@yangyushi
yangyushi / base_call_toy.py
Created May 18, 2022 09:17
toy script to simulate a naïve base calling process
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
def get_transfer_mat(N, p, q):
"""
Calculating the transition matrix P with shape (N, N).
P_ij: the transition probability of two states:
@yangyushi
yangyushi / compile_py38.sh
Created December 10, 2021 16:29
compile python3.8 on Ubuntu
sudo rm -rf Python-3.8.6
tar -xzf Python-3.8.6.tgz
cd Python-3.8.6
export LD_LIBRARY_PATH=/usr/local/lib
export LD_RUN_PATH=/usr/local/lib
./configure --enable-optimizations --prefix=/usr/local\
--enable-shared --enable-loadable-sqlite-extensions\
CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"\
LDFLAGS="-L/usr/local/lib -L/usr/local/lib/openssl"
@yangyushi
yangyushi / label.py
Created October 19, 2021 00:31
demonstrate `ndimage.label`
import numpy as np
from scipy import ndimage
import matplotlib.pyplot as plt
x = np.zeros((30, 30))
x[10, 10] = 1
x[20, 10] = 1
x[10, 20] = 1
@yangyushi
yangyushi / essential_mat.py
Created July 27, 2021 14:30
different ways to calculate the essential matrix
p1 = np.random.random((100, 2)) # feature points in camera 1
p2 = np.random.random((100, 2)) # feature points in camera 1
# camera matrices
k1 = np.random.random((3, 3))
k2 = np.random.random((3, 3))
# Method 1: calculate essential matrix (E) from the fundamental matrix (F)
@yangyushi
yangyushi / msd.py
Created May 7, 2021 11:15
Calculate the MSD
#!/usr/bin/env python3
"""
This script demonstrated the way to link positions into trajectories
and then calculate the MSD
"""
import numpy as np
import trackpy as tp
from itertools import product
import matplotlib.pyplot as plt
import pandas as pd
@yangyushi
yangyushi / link.py
Created April 27, 2021 17:11
use `link_iter` to link positions into trajectories for colloids
@yangyushi
yangyushi / curvature-2d.ipynb
Created April 14, 2021 13:40
curvature-2d.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yangyushi
yangyushi / product.cpp
Created March 23, 2021 00:45
Calculate the N-Dimensional Cartesian product recursively
#include <iostream>
#include <vector>
using namespace std;
using VVI = vector<vector<int>>;
template<class T>
void recursive_product(
const vector<vector<T>>& arrays, vector<vector<T>>& result, int idx=0
@yangyushi
yangyushi / gist:26dc667a251874ce1d61b1c6c6540d79
Created March 5, 2021 23:39 — forked from tayvano/gist:6e2d456a9897f55025e25035478a3a50
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
@yangyushi
yangyushi / dump_big_array.py
Last active February 9, 2021 22:10
this gist demonstrates the way to save a big numpy array as a binary string
import json
import base64
import numpy as np
from io import BytesIO
# save data to the binary string
a = np.random.uniform(0, 255, (1500, 1500)).astype(np.uint8)
f = BytesIO()
np.savez_compressed(f, data=a)