Skip to content

Instantly share code, notes, and snippets.

View jhamman's full-sized avatar
🔨
Building something new!

Joe Hamman jhamman

🔨
Building something new!
View GitHub Profile
@jhamman
jhamman / header.h
Last active August 29, 2015 14:26
VIC python driver preprocessed header
typedef float float_t;
typedef double double_t;
extern int __math_errhandling(void);
extern int __fpclassifyf(float);
extern int __fpclassifyd(double);
extern int __fpclassifyl(long double);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinitef(float);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinited(double);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinitel(long double);
@jhamman
jhamman / vic_global_options.py
Created February 5, 2016 23:52
Parsing VIC global parameter files in Python
import warnings
from collections import namedtuple, OrderedDict
class Forcing(object):
def __init__(self, *args, version='4'):
# initialize variables
self.name = None
self.path = None
self.types = []
@jhamman
jhamman / example.py
Last active February 11, 2016 19:11
grids for Diana
from acf.raster import grid_info
#----------------------------------------------#
fnames = os.listdir(force_dir)
lons = np.empty(len(fnames))
lats = np.empty(len(fnames))
for i, fname in enumerate(fnames):
pre, lat, lon = fname.split('_')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhamman
jhamman / hydra.makefile
Created March 31, 2016 21:28
Custom VIC 5 Makefiles
##############################################################################
# @section DESCRIPTION
#
# VIC Image Driver Makefile
#
# @section LICENSE
#
# The Variable Infiltration Capacity (VIC) macroscale hydrological model
# Copyright (C) 2014 The Land Surface Hydrology Group, Department of Civil
# and Environmental Engineering, University of Washington.
@jhamman
jhamman / ccsm.log.160401-205640
Last active April 1, 2016 21:17
CESM/VIC debugging (2016-04-01)
PE 0: MPICH processor detected:
PE 0: GenuineIntel (6:62:4) (family:model:stepping)
MPI VERSION : CRAY MPICH version 6.3.1 (ANL base 3.0.3)
BUILD INFO : Built Mon Apr 7 21:04:59 2014 (svn rev 10100) RT-G CPR-R
PE 0: MPICH environment settings:
PE 0: MPICH_ENV_DISPLAY = 1
PE 0: MPICH_VERSION_DISPLAY = 1
PE 0: MPICH_ABORT_ON_ERROR = 1
PE 0: MPICH_CPUMASK_DISPLAY = 0
PE 0: MPICH_RANK_REORDER_METHOD = 1
@jhamman
jhamman / random_effects.py
Last active February 1, 2017 19:54
GARD post processing
def add_random_effect(ds, ds_rand, pop_thresh=None, t_root=1., p_root=3.):
'''Add random effects to dataset `ds`
Parameters
----------
ds : xarray.Dataset
Input dataset with variables `tas` and/or `pr`
ds_rand : xarray.Dataset
Input dataset with random fields with variable names `t_rand` and `p_rand`
pop_thresh : float
@jhamman
jhamman / test_quantile_mapping_dask
Created May 3, 2017 21:07
dask quantile mapping traceback
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-17-2776a0e3d860> in <module>()
----> 1 test_quantile_mapping_dask()
<ipython-input-16-09fe8c5dfb29> in test_quantile_mapping_dask()
21
22 new = quantile_mapping(input_data, data_to_match)
---> 23 new.compute()
24 new.data.visualize()
import numpy as np
from scipy import stats
import dask.array as da
import xarray as xr
def test_quantile_mapping_dask():
# input datasets -- dims (time, y, x)
@jhamman
jhamman / xarray_resample.ipynb
Created October 12, 2017 19:17
xarray_resample
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.