Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
nicoguaro / vtkinterface_example.py
Last active May 4, 2018 00:22
Examples of use of vtkInterface for Scientific Visualization in Python using VTK.
import vtkInterface
from vtkInterface import examples
# Load Grid
grid = vtkInterface.UnstructuredGrid(examples.hexbeamfile)
# scalar demo
plobj = vtkInterface.PlotClass()
plobj.AddMesh(grid, scalars=grid.points[:, 2], colormap='viridis')
plobj.AddScalarBar()
@nicoguaro
nicoguaro / quad_system_scipy.py
Created February 22, 2018 14:07
Solve a system of quadratic equations
from __future__ import division, print_function
import numpy as np
from scipy.optimize import fsolve
def fun(X):
x, y, z = X
return [x**2 + y + z - 1,
x + y**2 + z - 1,
x + y + z**2 - 1]
@nicoguaro
nicoguaro / lattice_points.py
Last active February 9, 2018 00:23
Create a 3D lattice of points for some lattice parameters
# -*- coding: utf-8 -*-
"""
Create a 3D lattice of points for some lattice parameters
@author: Nicolas Guarin-Zapata
"""
from __future__ import division, print_function
import numpy as np
from numpy import sin, cos, sqrt
@nicoguaro
nicoguaro / manifold_learning_toroidal_helix.py
Created January 16, 2018 15:14
Dimensional reduction using non-linear methods present in scikit-learn
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Dimensional reduction using non-linear methods present in scikit-learn
Based on an example by Jake Vanderplas
"""
from time import time
import matplotlib.pyplot as plt
@nicoguaro
nicoguaro / fourier_slider.py
Last active September 26, 2017 15:16
Snippets related with pyQt
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import (QMainWindow, QApplication, QDockWidget, QWidget,
QGridLayout, QSlider)
from PyQt5.QtCore import Qt
import numpy
@nicoguaro
nicoguaro / BESFUN.FOR
Last active September 26, 2017 15:15
Usage example of SLATEC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C Compute the values for the Bessel function of the first kind C
C and order 0 in the interval [XA,XB] with N points. C
C C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C C
C AUTHOR: NICOLAS GUARIN Z. C
C GRUPO DE MECANICA APLICADA- UNIVERSIDAD EAFIT C
C LAST MOD: 25 JULY 2012 C
@nicoguaro
nicoguaro / fit_ellip.py
Created March 16, 2017 22:07
Fit an ellipse for a point cloud
# -*- coding: utf-8 -*-
"""
Fit an ellipse for a point cloud
@author: Nicolas Guarin-Zapata
"""
from __future__ import division, print_function
import numpy as np
from numpy import sin, cos, arctan2, mean
from numpy.linalg import norm
@nicoguaro
nicoguaro / Makefile
Last active October 3, 2016 19:31
Automate a pipeline to run a program and visualize the results using make
sine_plot.png : plot_data.py
python plot_data.py
plot_data.py: gen_sine_data
./gen_sine_data
gen_sine_data : gen_sine_data.c
cc -o gen_sine_data gen_sine_data.c -lm
@nicoguaro
nicoguaro / clean_folder_png.py
Last active October 6, 2016 19:29
Python scripts for working with files.
# -*- coding: utf-8 -*-
"""
Erase all PNG files in a folder that do not end
with a certain pattern
@author: Nicolas Guarin-Zapata
"""
import os
files = os.listdir("./")
@nicoguaro
nicoguaro / Matrix_labels_plot.py
Last active July 30, 2016 16:46
Plot a matrix with different labels in each cell as a series of circles with colors that represent each label.
# -*- coding: utf-8 -*-
"""
Plot a matrix with different labels in each cell as a series
of circles with colors that represent each label.
@author: Nicolas Guarin-Zapata
"""
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt