Skip to content

Instantly share code, notes, and snippets.

View alexlib's full-sized avatar
:octocat:
Working

Alex Liberzon alexlib

:octocat:
Working
View GitHub Profile
@alexlib
alexlib / conda-pack-win.md
Created April 19, 2022 07:45 — forked from pmbaumgartner/conda-pack-win.md
Conda-Pack Windows Instructions

Packing Conda Environments

You must be using conda for this approach. You will need conda installed on the Source machine and the Target machine. The Source machine must have an internet connection, the Target does not. The OS in both environments must match; no going from macOS to Win10 for example.

1. (Source) Install conda-pack in your base python environment.

conda install -c conda-forge conda-pack
@alexlib
alexlib / kalman_filter.py
Created February 18, 2022 14:20 — forked from swang225/kalman_filter.py
Kalman Filter
import numpy as np
import pandas as pd
# dropping tennis ball
def problem1():
dt = 1
F = np.matrix([[1, dt, dt**2/2],
@alexlib
alexlib / pdist_pbc.py
Created January 1, 2022 16:34 — forked from yangyushi/pdist_pbc.py
Different ways to get pairwise distance in cubic box with PBC in Python
"""
Different functions to get pairwise distance in cubic box with PBC
Args:
positions: the positions of particles, shape (N, dim)
box (int or float): the size of the box
Return:
np.ndarray: the pair-wise distances, shape (N, N)
"""
@alexlib
alexlib / napari-track-tests.py
Created September 5, 2021 19:26 — forked from quantumjot/napari-track-tests.py
Tests for napari track layer
import napari
import numpy as np
def _circle(r, theta):
x = r*np.cos(theta)
y = r*np.sin(theta)
return x, y
def _sphere(r, theta, psi):
@alexlib
alexlib / xr_lowess.py
Created August 11, 2021 07:32 — forked from serazing/xr_lowess.py
Lowess for xarray
import numpy as np
import numba
import xarray as xr
@numba.jit(nopython=True)
def lowess_1d(y, x, alpha=2. / 3., it=10):
"""lowess(x, y, f=2./3., iter=3) -> yest
Lowess smoother: Robust locally weighted regression.
The lowess function fits a nonparametric regression curve to a scatterplot.
The arrays x and y contain an equal number of elements; each pair
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexlib
alexlib / elaborate_matplotlib_animations.py
Created June 13, 2021 18:15 — forked from hugke729/elaborate_matplotlib_animations.py
Quiver, 3D contour, polar, scatter, and fill animations with Matplotlib
# Example animations using matplotlib's FuncAnimation
# Ken Hughes. August 2019
# For more detail, see
#https://brushingupscience.com/2019/08/01/elaborate-matplotlib-animations/
# Examples include
# - quiver plot with variable positions and directions
# - 3D contour plot
# - line plot on a polar projection
# Example animations using matplotlib's FuncAnimation
# Ken Hughes. 18 June 2016.
# For more detail, see
# https://brushingupscience.wordpress.com/2016/06/21/matplotlib-animations-the-easy-way/
# Examples include
# - line plot
# - pcolor plot
# - scatter plot
@alexlib
alexlib / read_parquet.py
Created April 3, 2021 21:54 — forked from lpillmann/read_parquet.py
Read partitioned parquet files into pandas DataFrame from Google Cloud Storage using PyArrow
import gcsfs
import pyarrow
def read_parquet(gs_directory_path, to_pandas=True):
"""
Reads multiple (partitioned) parquet files from a GS directory
e.g. 'gs://<bucket>/<directory>' (without ending /)
"""
gs = gcsfs.GCSFileSystem()
arrow_df = pyarrow.parquet.ParquetDataset(gs_directory_path, filesystem=gs)
@alexlib
alexlib / matlab_notebook.ipynb
Created February 20, 2021 08:26 — forked from phaustin/matlab_notebook.ipynb
Chapter 1 A Brief Tutorial. A direct translation of Chapter 1 of D.J. Higham and N.J. Higham, MATLAB Guide (2005)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.