Skip to content

Instantly share code, notes, and snippets.

View TaylorMutch's full-sized avatar

Taylor Mutch TaylorMutch

  • Unity Technologies
  • Snohomish, WA
  • 00:46 (UTC -07:00)
View GitHub Profile
@TaylorMutch
TaylorMutch / terrain_gen.py
Created October 29, 2015 05:21
Generate terrain from a service
__author__ = 'Taylor'
'''
Makes a request to our terrain generation server and then outputs a .bin in web-friendly format.
Uses a version of convert_envi.py
'''
import os, struct, sys, math, requests
server = 'http://<terrain_server>/<terrain_script>.ashx?'
@TaylorMutch
TaylorMutch / sdr_file_test.py
Last active November 3, 2015 16:38
Scans a directory and returns a list of SODAR files that are corrupt (I.e. averaging the data was not done correctly when outputted)
import os
import sys
date_tag = 'SDR'
def main():
if len(sys.argv) < 2:
print('Usage: sdr_file_test.py sodar/path/dir/')
sys.exit(-1)
@TaylorMutch
TaylorMutch / get_ascii.py
Created December 3, 2015 00:24
Convert from simple binary format to ArcAscii - based on https://gist.github.com/nikmolnar/284b5541bfc54946a24b
__author__ = 'Taylor'
'''
Convert binary format to ArcAscii Format - adapted from https://gist.github.com/nikmolnar/284b5541bfc54946a24b
'''
import os, struct, sys, math, requests
server = 'your/terrain/server/here' # Ask for the URL if you want to try it out.
@TaylorMutch
TaylorMutch / SdrToCsvUtil
Created May 23, 2016 01:35
METEK SOdar (.sdr) to CSV converter. Includes support for gzipped files.
"""
Created by Taylor Mutch on 22 May, 2016
Simple SOdar to CSV file converter.
"""
import os
import sys
import csv
import gzip
@TaylorMutch
TaylorMutch / computeHeights.ts
Created September 8, 2016 00:07
TypeScript function for converting a heightmap texture into Float32Array
function computeHeights(hmTexture: THREE.Texture, stats: any) {
const image = hmTexture.image
let w = image.naturalWidth
let h = image.naturalHeight
let canvas = document.createElement('canvas')
canvas.width = w
canvas.height = h
let ctx = canvas.getContext('2d')
ctx.drawImage(image, 0, 0, w, h)
let data = ctx.getImageData(0, 0, w, h).data
@TaylorMutch
TaylorMutch / convert_shapefile.py
Last active October 13, 2016 01:43
Converts a 2D shapefile to a 3D shapefile
""" Converts a 2D shapefile to a 3D shapefile """
import sys
import os
import struct
import numpy as np
import fiona
from fiona.transform import transform_geom, transform
from fiona.crs import from_epsg
from PIL import Image
@TaylorMutch
TaylorMutch / convert_shapefile_vectorized.py
Last active October 13, 2016 02:02
Convert a 2D shapefile to 3D shapefile, faster with vectors.
""" Converts a 2D shapefile to a 3D shapefile """
import sys
import os
import struct
import numpy as np
import fiona
from fiona.transform import transform_geom, transform
from fiona.crs import from_epsg
from PIL import Image
@TaylorMutch
TaylorMutch / workcrew.js
Created October 20, 2016 15:12 — forked from kig/workcrew.js
WorkCrew - a WebWorker work queue library
/*
WorkCrew - a WebWorker work queue library
Usage:
// Create an 8 worker pool using worker.js.
var crew = new WorkCrew('worker.js', 8);
// Do something whenever a job is completed.
// The result object structure is
@TaylorMutch
TaylorMutch / sodar_utils.py
Last active November 23, 2016 21:51
Utilities for working with Sodar files.
"""
Taylor Mutch,
Revision date - 11/22/2016
Utilities for working with the VALCEX data.
timestamp in this context will refer to either a Sodar timestamp (e.x. 120314124500),
or a datetime.datetime object (e.x. datetime(2012, 3, 14, 12, 45))
"""
import os
import sys
@TaylorMutch
TaylorMutch / plot_sodar_night.py
Created November 22, 2016 21:28
An example for reading sodar data into a matplotlib chart.
from sodar_utils import SodarCollection
import matplotlib.pyplot as plt
import numpy as np
sodars = SodarCollection('sodar_data/Primet')
data = sodars.night_array('speed')
# Find the index of the specific night we're interested in
index = [i for i, j in enumerate(data[1]) if j['name']=='0518'][0]