Skip to content

Instantly share code, notes, and snippets.

@soravux
soravux / submit-pbrt.sh
Created July 8, 2016 18:10
PBRT job array submission script
#!/bin/bash
#PBS -A ###-###-##
#PBS -l walltime=00:05:00
#PBS -l nodes=1:ppn=8
#PBS -t [1-10]%10
# More information about the identification section available at:
# https://wiki.calculquebec.ca/w/Moab/en
# PBRT generic submission script
#!/usr/bin/env python
"""
Data from: http://www.siata.gov.co/newpage/index.php
Archives: http://www.siata.gov.co/kml/00_Radar/Ultimo_Barrido/
Exemple d'utilisation:
$ python convert_radar_to_numeric.py 201606031736.png AreaMetropolitanaRadar_05_240_DBZH.png 0 80 output.npz
$ python
>>> import numpy as np
>>> f = np.load(open('output.npz', 'rb'))
>>> from matplotlib import pyplot as plt
function [map] = reference_normal_map(imsize)
% Script that builds the normal map of a sphere for reference
if (nargin < 1), imsize = 201; end;
range = linspace(-1, 1, imsize);
X = repmat(range, [size(range, 2), 1]);
Y = flipud(repmat(range', [1, size(range, 2)]));
Z = (1 - (X.^2 + Y.^2)).^0.5;
% Change the range for display from 0..1 instead of -1..1
import sys
import os
import shutil
import pickle
from glob import glob
import numpy as np
from scipy.misc import imread
from scipy.ndimage.filters import gaussian_laplace
from scipy.signal import find_peaks_cwt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from scipy import interpolate
from plyfile import PlyData, PlyElement
def plotPointCloud(pc, color='b', marker='o', fig_ax=None, blocking=False):
if not fig_ax:
fig = plt.figure()
@soravux
soravux / arithmetic_tree_example.py
Last active January 30, 2016 17:02
Example of generation and parallel execution of arithmetic trees.
import concurrent.futures
from random import choice, randint
from collections import Iterable
from operator import add, mul, sub, neg, abs
MIN_VAL, MAX_VAL = -20, 20
def pdiv(left, right):
"""Division protected against divisions by zero."""
import concurrent.futures
from operator import add, mul, sub
def pdiv(left, right):
try:
return left / right
except ZeroDivisionError:
return 1
from operator import add, mul, sub
def pdiv(left, right):
try:
return left / right
except ZeroDivisionError:
return 1
%% 1. Load the LuxRender
luxrend = load('ico_lux.mat');
mask = luxrend.mask; mask = imerode( mask, strel('disk', 2) ); mask(end,:) = false;
% Convert to intensity
%intensity_luxrender = zeros(size(luxrend.I, 1)/3, size(luxrend.I, 2));
intensity_luxrender = zeros(sum(luxrend.mask(:)), size(luxrend.I, 2));
for i = 1:size(luxrend.I, 2)
%im = hdr_rgb2gray(reshape(l.I(:,i), [], 3));
im = hdr_rgb2gray(reshape(l.I(:,i), [size(l.mask, 1), size(l.mask, 2), 3]));
k = 3; % Number of columns to take
%L = normc([1, 0, 0; 0, 1, 0; rand(3, 10)']');
%L = normc([1, 0, 0; 1, 0, 1; 1, 1, 0; 0, 1, 1; 0, 0, 1]');
%L = normc([1, 0, 0; 0, 1, 0; 0.1, 0.9, 0; -0.1, 0.9, 0; 0.1, 0.1, 0.1]');
L = normc([0.2, 0, 0.1; -0.1, 0.9, 0; 0.1, 0.1, 0.2; 0, 1, 0; 0.1, 0.9, 0]');
% Golub's algorithm
[~,~,V] = svd(L);
[~,~,E] = qr(V(:,1:k)',0);
E = E(1:k);