Skip to content

Instantly share code, notes, and snippets.

@brews
brews / environment.yml
Last active December 27, 2019 01:07
Conda environment to create a py27 for the risingverse. Updates now hosted at https://anaconda.org/ClimateImpactLab/risingverse-py27
name: risingverse-py27
channels:
- conda-forge
- defaults
dependencies:
- click
- emcee
- gspread=3.1.0
- numpy>=1.14
- netCDF4
@brews
brews / parse_NOAAfire.py
Last active August 9, 2019 19:36
Parse NOAA servers for fire history data
#! /usr/bin/env python
# 2018-07-18
# S. B. Malevich <malevich@email.arizona.edu>
# Python script to parse the NOAA servers for fire history data.
# We grab latitude, longitude and data file URLs along with some other meta
# data and write it all to a tab-delimited file. Should run on default libs for
# Python 3.x (no py2).
@brews
brews / GitHub-Forking.md
Created July 11, 2019 00:03 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@brews
brews / examples.m
Last active May 3, 2019 21:36
Examples of some very basic sediment analysis in MATLAB
percents_example = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.038767 0.210932 0.388233 0.5434 0.670989 0.763819 0.827314 0.875141 0.9251 0.998257 1.110161 1.271364 1.481631 1.737837 2.033275 2.357837 2.697437 3.030084 3.338291 3.600196 3.810219 3.964794 4.079458 4.171464 4.267533 4.384367 4.533731 4.702413 4.864823 4.971393 4.968025 4.803981 4.447635 3.904993 3.215972 2.45426 1.708694 1.050809 0.56383 0.190557 0.040983 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
part_sizes = [0.039811 0.045709 0.052481 0.060256 0.069183 0.079433 0.091201 0.104713 0.120226 0.138038 0.158489 0.18197 0.20893 0.239883 0.275423 0.316228 0.363078 0.416869 0.47863 0.549541 0.630957 0.724436 0.831764 0.954993 1.096478 1.258925 1.44544 1.659587 1.905461 2.187762 2.511886 2.884031 3.311311 3.801894 4.365158 5.011872 5.754399 6.606934 7.585776 8.709636 10 11.481536 13.182567 15.135612 17.378008 19.952623 22.908677 26.30268 30.199517 34.673685 39.810717 45.708819 52.480746 60.255959 69.183097 79.432823 91.201084 104.712
@brews
brews / fetchmeta.py
Last active July 22, 2025 08:55 — forked from jrsmith3/doi2bib.py
Python function to access crossref.org DOI metadata resolver and return bibliography as dictionary or bibtex string.
import requests
import json
def fetchmeta(doi, fmt='dict', **kwargs):
"""Fetch metadata for a given DOI.
Parameters
----------
doi : str
#! /usr/bin/env bash
# 2018-05-23
# S. B. Malevich <malevich@email.arizona.edu>
#
# Script to (hopefully) create a conda environment and install the `dada2` R
# package (https://benjjneb.github.io/dada2/) on the Ocelote HPC. Run with:
#
# bash dada2_install.sh
#
# This may take some time. I'm assuming you have `miniconda` already installed
@brews
brews / backup_conda.sh
Created February 6, 2018 20:41
Backup specs for all conda environments on POSIX systems
#! /usr/bin/env bash
# Modified from David Mertz's original script.
NOW=$(date "+%Y-%m-%d")
mkdir -p $HOME/tmp/envs-$NOW
ENVS=$(conda env list | grep '^\w' | cut -d' ' -f1)
for env in $ENVS; do
source activate $env
conda env export > $HOME/tmp/envs-$NOW/$env.yml
@brews
brews / make_comparison.sh
Created February 1, 2018 16:16
compare CCSM3 TraCE21ka TS with regridded TOS
#! /usr/bin/env bash
# 2018-01-12
# Make a netCDF file that's diff between TS and TOS (TS - TOS).
cp data/regrid/tos_sfc_Odec_CCSM3_TraCE21ka_TSREGRID.nc data/combined_tmp.nc
ncks -A data/ts_sfc_Adec_CCSM3_TraCE21ka.nc data/combined_tmp.nc
ncap2 -s 'tdif=(ts-tos)' data/combined_tmp.nc data/combined.nc
# Cleanup
@brews
brews / scrape_IMPD_example.R
Last active July 14, 2017 22:25
How to pull hyperlinks and FHX files from an html directory, read with read_fhx() in an somewhat error-resistant way
# 2017-07-14
# S. Brewster Malevich <malevich@email.arizona.edu>
# How to pull hyperlinks from an html directory, read with read_fhx() in a
# somewhat error-resistant way.
# There are a couple ways to do this. Python or `wget` would be far
# better options, but let's do this with R.
# Another thing, this pesters the poor NCDC server every time you run this.
@brews
brews / matern.py
Created July 14, 2017 17:56
Python Matérn correlation function for given distances and parameters. Comparable to `geoR`'s `matern()`
import scipy
import numpy as np
def matern(u, phi, kappa):
"""Computes Matérn correlation function for given distances and parameters
Roughly based on the matern function from Ribeiro and Diggle's 'geoR'
package for R.
Parameters: