Skip to content

Instantly share code, notes, and snippets.

View franktoffel's full-sized avatar

Fran Navarro franktoffel

View GitHub Profile
@franktoffel
franktoffel / find_NEF.py
Created December 15, 2018 12:39
This program finds NEF files without a JPG copy and deletes them
import os
import fnmatch
import sys
'''The following script searches for NEF files that do not have
a JPG copy and deletes them. This is intended to be used after
a manual selection of the best JPGfiles that the photographer has
selected.
It only runs on Python 3.x so yo need to have it installed it.
@franktoffel
franktoffel / complex_step_derivative.py
Last active July 18, 2022 02:33
Complex-step derivative approximation (implemented in Python, NumPy, matplotlib)
# coding: utf-8
'''The following code reproduces an example of the paper:
'The Complex-Step Derivative Approximation'
by Joaquim R. R. A. MARTINS, Peter STURDZA and Juan J. Alonso published in 2003.
License: MIT
Author: FJ Navarro Brull
'''
@franktoffel
franktoffel / magic_head.py
Created May 31, 2017 23:09
Python alternative to bash head command: prints the first -n lines of a text file defined within the string.
from IPython.core.magic import register_line_magic
from itertools import islice
@register_line_magic
def head(parameter_s=''):
'''Prints the first -n lines of a text file defined within the string.
Examples:
%head -n 5 file.txt
%head -5 file.txt
@franktoffel
franktoffel / python_heart.py
Last active October 2, 2023 07:05
How to plot a 3D heart for San Valentin with Python (matplotlib)
'''
=================================
3D heart shape in matplotlib
=================================
Demonstrates how to plot a 3D function in cartesian coordinates.
Uses the marching cubes algorithm in scikit-image to obtain a isosurface.
Example contributed by CAChemE.org
Adapted from: http://www.walkingrandomly.com/?p=2326
'''
@franktoffel
franktoffel / digital_bokeh.py
Created November 2, 2016 16:45
A comparison between different methods to obtain out of the focus bokeh with Python (scikit image)
import numpy as np
from skimage.morphology import disk
from skimage.filters.rank import mean
from skimage.filters import gaussian
import matplotlib.pyplot as plt
n = 20
l = 256
@franktoffel
franktoffel / bokey_shapes.py
Last active November 2, 2016 16:40
Different digital bokeh shapes with Python (scikit image)
import numpy as np
from skimage.morphology import diamond, disk, square
from skimage.filters.rank import mean
import matplotlib.pyplot as plt
n = 20
l = 256
im = np.zeros((l, l))
@franktoffel
franktoffel / NikolaWindows
Created June 19, 2016 10:43
How to install Nikola on Windows with Anconda-conda env
conda create --name nikolaenv python=3
activate nikolaenv
conda install pillow lxml
pip install Nikola[extras]
@franktoffel
franktoffel / plot_PFR.py
Last active August 29, 2015 14:18
A simple plug flow reactor figure using Python (matplotlib)
# coding: utf-8
"""
Plug flow reactor figure created with Python
This example displays a simple representation of a plug flow reactor (PFR)
by means of matplotlib API. A full list of artists and the documentation is
available at http://matplotlib.org/api/artist_api.html.
Copyright (c) 2015, Francisco J. Navarro-Brull
http://CAChemE.org
@franktoffel
franktoffel / python-3d-cluster-projection.py
Created April 1, 2015 15:32
3D cluster projection by means of matplotlib (Python)
# coding: utf-8
""" 3D cluster projection by means of matplotlib.
Author: Fran Navarro-Brull <http://CAChemE.org>
This code is an snippet from the original Spanish article:
OriginLab vs Python
https://github.com/franktoffel/origin/
LICENSE: MIT
@franktoffel
franktoffel / Python-Christmas-tree.py
Last active December 20, 2019 07:21
Draw a minimalist Christmas tree with Python and their awesome libraries
# coding: utf-8
"""
Draw a minimalist Christmas tree with Python and their awesome libraries.
Code inspired by a StackEchange post and the Christmas spirit.
http://codegolf.stackexchange.com/questions/15860/make-a-scalable-christmas-tree/16358#16358
Author: Franz Navarro - CAChemE.org
License: MIT
Dependencies: Python, NumPy, matplotlib
"""