Skip to content

Instantly share code, notes, and snippets.

@ahmedshaaban1
ahmedshaaban1 / increase_white.py
Created January 18, 2020 23:01
Extending the white color in the middle of blue-white-red colormap.
import numpy as np
import matplotlib.colors
cmap=plt.cm.bwr
cmap1=[cmap(i) for i in np.arange(cmap.N)]
cen1=int(cmap.N/2)
cen2=int(cen1-1)
for i in np.arange(cen2-3,cen1+4):
print(i)
@ahmedshaaban1
ahmedshaaban1 / calculate_time.py
Last active June 11, 2019 00:21
Calculate time
import time
start_time = time.time()
# put your code here
elapsed_time = time.time() - start_time
print(time.strftime("%H:%M:%S", time.gmtime(elapsed_time)))
@ahmedshaaban1
ahmedshaaban1 / guardian_gaza.ipynb
Created May 31, 2019 03:31 — forked from darribas/guardian_gaza.ipynb
A IPython Notebook to analyze the Gaza-Israel 2012 crisis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahmedshaaban1
ahmedshaaban1 / array_init.py
Last active June 11, 2019 00:21
Initialize array with nan ...
# I think that this is better than zero as it tell me whether the zero that I will get is becuase of the math or the initiation itself.
nlev=len(levP)
nh =len(h)
nlon=len(lonP)
reg_all_ahmed=np.full((nh,nlev,nlon),np.nan)