Skip to content

Instantly share code, notes, and snippets.

View nicoguaro's full-sized avatar

Nicolás Guarín-Zapata nicoguaro

View GitHub Profile
@nicoguaro
nicoguaro / plot_inset_rect.py
Created June 12, 2019 23:55
Plot with an inset and a background color for the inset
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
x = np.linspace(0, 1, 100)
y = np.sin(4*np.pi*x)
# Big plot
ax = plt.subplot(111)
plt.plot(x, y, "k", zorder=3, alpha=0.4)
@nicoguaro
nicoguaro / astro_sound.wav
Last active November 7, 2018 21:59
Convert from ordering in a Hilbert-like curve and a 1D array and vice-versa.
This file has been truncated, but you can view the full file.
@nicoguaro
nicoguaro / spline_contour.geo
Last active October 1, 2018 21:54
Gmsh examples.
/*
Programmatically define a mesh for a region enclosed by a curve
given in parametric for for polar coordinates.
Author: Nicolas Guarin-Zapata
Date: October, 2018
*/
size = 0.05;
npts = 50;
@nicoguaro
nicoguaro / line_approx.py
Last active February 22, 2021 21:24
Minimize the best approximation to points that lie over a straight line with outliers for L^p norm.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Minimize the best approximation to points that lie over
a straight line with outliers for L^p norm.
@author: Nicolas-Guarin-Zapata
"""
import numpy as np
import matplotlib.pyplot as plt
@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 December 21, 2025 18:52
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