This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Find height, width of the largest rectangle containing all 0's in the matrix. | |
The algorithm for `max_size()` is suggested by @j_random_hacker [1]. | |
The algorithm for `max_rectangle_size()` is from [2]. | |
The Python implementation [3] is under CC BY-SA 3.0 | |
(if you need other license, e-mail me) | |
[1]: http://stackoverflow.com/questions/2478447/find-largest-rectangle-containing-only-zeros-in-an-nn-binary-matrix#comment5169734_4671342 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Functions for retrieving the time axis from multiple | |
netCDF data files that do not have the same time units""" | |
import netCDF4 | |
import glob | |
import numpy as np | |
def read_mfdataset_time(pattern,timevar='time',calendar='proleptic_gregorian'): | |
"""Get time axis from multi-file netCDF data using np.append""" | |
files = sorted(glob.glob(pattern)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gaussian_grid_from_ecmwf_data(fname,name=None): | |
"""Read data copied from the Gaussian grid descriptions on | |
http://www.ecmwf.int/publications/manuals/libraries/interpolation/gaussianGridsFIS.html | |
Returns | |
------- | |
lon,lat : 1D arrays | |
""" | |
dtype = np.dtype(dict(names=['latnr','nreduced','nregular','lat'],formats=['i4','i4','i4','f8'])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""A module for various utilities and helper functions""" | |
import numpy as np | |
#cimport numpy as np | |
#cimport cython | |
DTYPEf = np.float64 | |
#ctypedef np.float64_t DTYPEf_t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Maximum rectangle algorithm | |
Main source: [1] | |
[1] http://stackoverflow.com/questions/8663079/maximum-rectangle-algorithm-implementation | |
""" | |
from collections import namedtuple | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
"""Non-interactive command line front end to NBody implementation""" | |
import time | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import itertools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Credits | |
------- | |
Stephane Raynaud | |
http://permalink.gmane.org/gmane.comp.python.matplotlib.general/24155 | |
""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import datetime as dtime | |
from matplotlib.dates import date2num |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Recipe from http://zulko.wordpress.com/2012/09/29/animate-your-3d-plots-with-pythons-matplotlib/""" | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
from mpl_toolkits.mplot3d import axes3d | |
import os, sys | |
import numpy as np | |
##### TO CREATE A SERIES OF PICTURES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CASE=$1 | |
DATA_ROOT=${DATA_ROOT:-$(pwd)} | |
RUNDIR="$DATA_ROOT/$CASE/run" | |
DOUT_S="TRUE" | |
DOUT_S_ROOT=${DOUT_S_ROOT:-"$DATA_ROOT/$CASE"} |