This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tested with plotly 5.13.1, matplotlib 3.5.3 | |
from matplotlib import pyplot as plt | |
import plotly.tools as tls | |
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot | |
plt.plot([1,2,3]) | |
fig=plt.gcf() | |
fig_plotly=tls.mpl_to_plotly(fig) | |
fig_plotly.write_html("my_image.html") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def digital_filter(x,y,f=1000,order=10,kind="lowpass"): | |
dt = x[1]-x[0] | |
fs = 1/dt | |
sos = signal.butter(order, f, kind, fs=fs, output='sos') | |
return signal.sosfiltfilt(sos,y) | |
def lowpass(x,y,f=1000,order=10): | |
return digital_filter(x,y,f=f,order=order,kind="lowpass") | |
def highpass(x,y,f=1000,order=10,add_average=True): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as mpl | |
mpl.use('Agg') | |
import argparse | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import xrt.backends.raycing as raycing | |
import xrt.backends.raycing.sources as rsource | |
import xrt.backends.raycing.screens as rscreens | |
import xrt.backends.raycing.oes as roes | |
import xrt.backends.raycing.apertures as rslits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from inspect import signature | |
def auto_args(f): | |
sig = signature(f) # Get a signature object for the target: | |
def replacement(self, *args, **kwargs): | |
# Parse the provided arguments using the target's signature: | |
bound_args = sig.bind(self, *args, **kwargs) | |
# add defaults otherwise defaults are unbonund, thus not in the list | |
bound_args.apply_defaults(); | |
# Save away the arguments on `self`: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import h5py | |
import numpy as np | |
import os | |
_fname = "/tmp/links_test.h5" | |
def write(): | |
f=h5py.File(_fname,"w") | |
f["/data1/v1"] = np.random.random(1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
import matplotlib.pyplot as plt | |
g_fname = "beams_f16.npy" | |
_colors = ["#a6611a","#dfc27d","#80cdc1","#018571"]; # from colorbrewer2.prg | |
def maskEdges(img,edge=5,makeCopy=True): | |
if edge is None or edge == 0: return img |