Skip to content

Instantly share code, notes, and snippets.

Avatar

Floris van Breugel florisvb

View GitHub Profile
View multiprocessing_example.py
import multiprocessing
import numpy as np
import time
def compute_something(input):
a = input[0]
b = input[1]
r = a**b**b
return r
@florisvb
florisvb / read_hdf5.py
Created May 2, 2018
Psuedo script for opening and plotting hdf5 data
View read_hdf5.py
import h5py
f = h5py.File(filename)
print f.keys()
data = f[keyname].value # choose a keyname from the list of keys
print data
a = data[name] # choose a name from the data dtype names
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
@florisvb
florisvb / install_ros_and_mac_cam.sh
Last active Jan 14, 2019
Install ROS and make mac camera available
View install_ros_and_mac_cam.sh
#!/bin/sh
sudo apt-get update
sudo apt-get upgrade -y
# install ROS
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full -y
sudo rosdep init
rosdep update
@florisvb
florisvb / figurefirst_install_notes.md
Last active Apr 11, 2018
Some handy commands for getting FigureFirst and Jupyter installed in a virtualenv
View figurefirst_install_notes.md

Install inkscape

sudo apt-get install inkscape

Download figurefirst:

git clone https://github.com/FlyRanch/figurefirst.git

Make a virtual environment

Include the system site packages (that way we don't have to install numpy, scipy, etc)
sudo apt-get install python-virtualenv

virtualenv FIG --system-site-packages

@florisvb
florisvb / SystemVersion.plist
Created Mar 23, 2018
File required for making ubuntu bootable on a Mac
View SystemVersion.plist
<xml version="1.0" encoding="utf-8"?>
<plist version="1.0">
<dict>
<key>ProductBuildVersion</key>
<string></string>
<key>ProductName</key>
<string>Linux</string>
<key>ProductVersion</key>
<string>Ubuntu Linux</string>
</dict>
View map elevation data
import gdal
d = gdal.Open('10n060e_20101117_gmted_mea300.tif')
arr = d.ReadAsArray()
def get_elevation_at_point(x, y, elevation_array):
# skip interpolation for now
return elevation_array[int(x), int(y)]
def get_elevation_profile_for_path(x, y, elevation_array):
e = [get_elevation_at_point(x[i], y[i], elevation_array) for i in range(len(x))]