Skip to content

Instantly share code, notes, and snippets.

View johannah's full-sized avatar

Johanna Hansen johannah

View GitHub Profile
# to get mujoco-py to install with headless rendering without sudo access
##############################
# 1) first download and install mujoco according to instructions from https://github.com/deepmind/mujoco/
##############################
# 2) add environment variables to your bashrc
# importantly, this should be done before installing mujoco-py
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/$USER/.mujoco/mujoco210/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia
'''
This script saves each topic in a bagfile as a csv.
Accepts a filename as an optional argument. Operates on all bagfiles in current directory if no argument provided
Originally Written by Nick Speal in May 2013 at McGill University's Aerospace Mechatronics Laboratory
Modified by J.Hansen in 2021
'''
import rosbag, sys, csv
@johannah
johannah / pain_model.py
Last active June 5, 2019 20:38
ai4good pain model example
import numpy as np
import os
import sys
# hours_per_time_step should be greater than 1
hours_per_step = 2
class PainModel():
def __init__(self, seed):
# pain -1 is bad
# from KK
from copy import deepcopy
import time
import os
import torch
import torch.nn as nn
from torch.nn.utils.clip_grad import clip_grad_norm
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
@johannah
johannah / sine_wave_rnn.py
Last active May 1, 2018 17:12
learning rnn sinewaves
# from KK
import torch
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.init as init
from IPython import embed
dtype = torch.FloatTensor
input_size, hidden_size, output_size = 1,128,1
import os, sys
from glob import glob
from IPython import embed
from subprocess import call
# example <a href='catalog.html?dataset=NOAA/CBOFS/MODELS/201710/nos.cbofs.stations.nowcast.20171031.t18z.nc'><tt>nos.cbofs.stations.nowcast.20171031.t18z.nc</tt></a></td>^M
fpaths = glob('/localdata/jhansen/thredds/opendap.co-ops.nos.noaa.gov/thredds/catalog/NOAA/*')
output = '/localdata/jhansen/thredds/ncfiles'
fileServer = 'https://opendap.co-ops.nos.noaa.gov/thredds/fileServer/'
for station in fpaths:
# only get stations which have fairly open oceans
name: py-ros
channels:
- defaults
dependencies:
- backports=1.0=py27h63c9359_1
- backports.shutil_get_terminal_size=1.0.0=py27h5bc021e_2
- ca-certificates=2017.08.26=h1d4fec5_0
- certifi=2017.7.27.1=py27h9ceb091_0
- decorator=4.1.2=py27h1544723_0
- enum34=1.1.6=py27h99a27e9_1
@johannah
johannah / statistics_for_hackers.py
Last active July 7, 2017 18:16
stats for hackers
import matplotlib.pyplot as plt
import numpy as np
# example taken from Jake Vanderplas' talk "Statistics for Hackers"
def is_statistically_significant_shuffle(s1,s2,trials=10000,do_plot=False,null_hyp=.05):
# find difference of means to test null hyp
odiff = np.mean(s1)-np.mean(s2)
# join the lists together
a = np.array(s1+s2)
@johannah
johannah / dataset_links.md
Last active June 8, 2017 17:31
Dataset links and short descriptions
import numpy
import time
import matplotlib.pyplot as plt
import numpy as np
from copy import deepcopy
import os, sys
from scipy.misc import face
import GPy
from skimage.transform import resize
from skimage.filters import gaussian_filter