Skip to content

Instantly share code, notes, and snippets.

View mehdirezaie's full-sized avatar

Mehdi Rezaie mehdirezaie

View GitHub Profile
@mehdirezaie
mehdirezaie / hideaxis.ipynb
Last active November 17, 2023 07:42
Hide axis markers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mehdirezaie
mehdirezaie / chi2table.ipynb
Last active June 22, 2023 18:52
Table of Chi-2 values given confidence and degree of freedom
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mehdirezaie
mehdirezaie / vimrc.md
Last active August 30, 2022 15:17
VIM settings

For best VIM settings (in your ~/.vimrc):

filetype plugin indent on
syntax on
set number
set tabstop     =4
set softtabstop =4
set shiftwidth  =4
set expandtab
@mehdirezaie
mehdirezaie / plotperfect.md
Last active April 10, 2021 00:55
Publication quality

Publication Quality with Python

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.rcParams['font.family'] = 'Liberation Sans Narrow'
plt.rcParams['font.size'] = 18
@mehdirezaie
mehdirezaie / colorblind.md
Created January 27, 2021 02:19
Colorblind friendly colors

Colorblind friendly visualization

import matplotlib.pyplot as plt
import numpy as np
from cycler import cycler


colors = ['#377eb8', '#ff7f00', '#4daf4a',
 '#f781bf', '#a65628', '#984ea3',

Colormaps and Contours

This example illustrates how to visualize two maps with colorbars and contours.

x = np.linspace(-10, 10, num=100)
y = np.linspace(-10, 10, num=100)
X, Y = np.meshgrid(x, y)

Z1 = X*X + Y*Y
Z2 = abs(X) + abs(Y)
@mehdirezaie
mehdirezaie / git-cleanup
Created August 14, 2020 17:07 — forked from nook-ru/git-cleanup
Clean up old git branches
#!/bin/bash
# This has to be run from master
git checkout master
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
git branch --merged master | grep -v 'master$' | grep -v 'dev$' | xargs git branch -d
@mehdirezaie
mehdirezaie / C_and_Python.md
Last active April 14, 2023 15:58
Wrap C functions in Python

Pi Calculation in C vs Python

This is another example which we show how we can wrap a function in C to gain more performance. We use the integral of $\int_{0}^{1} \frac{4}{1+x^{2}} dx$ to calculate $\pi$.

This is the C code:

/*
    Code to compute the number Pi = 3.14

    Integral 4/(1+x^2) from 0 to 1 is 3.14

Jobs Array

Main Reference: https://docs.nersc.gov/jobs/examples/#job-arrays
"Job arrays provides a mechanism for submitting and managing collections of similar jobs quickly and easily." You will create a single script (e.g., job.sbatch) which uses the variable SLURM_ARRAY_TASK_ID to point at the correct files:

#!/bin/bash
#SBATCH -q debug
#SBATCH -o job_array_test%j.out
#SBATCH -n 1
#SBATCH --time 00:02:00
#SBATCH -C haswell
@mehdirezaie
mehdirezaie / threeaxes.md
Last active August 3, 2020 15:29
Visualization with three axes

Three axes visualizations

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np