Skip to content

Instantly share code, notes, and snippets.

View jfburkhart's full-sized avatar

John F. Burkhart jfburkhart

View GitHub Profile
def closest(val, vallist, index=True):
""" returns the closest value or index to a date in a list
=========== ======================
keyword description
----------- ----------------------
index [True] returns index
=========== ======================
"""
In [62]: empty = xr.DataArray(zed, dims=['ageclass', 'pointspec', 'time', 'latitude', 'longitude'], coords={'time':taxis, 'latitude': dset.l
...: atitude, 'longitude':dset.longitude})
In [63]: empty
Out[63]:
<xarray.DataArray (ageclass: 1, pointspec: 1, time: 2557, latitude: 360, longitude: 720)>
array([[[[[ 0., ..., 0.],
...,
[ 0., ..., 0.]],
Starting Load Kernel Modules...
Starting Load/Save RF Kill Switch Status...
[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.
[ OK ] Started File System Check Daemon to report status.
Starting Load Kernel Modules...
[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.
[ OK ] Reached target Sound Card.
Starting Load Kernel Modules...
Trying to merge / combine to xray.Datasets:
In [161]: o1 = xray.Dataset({'x':(('t'), (np.ones(10)))}, coords={'t':np.arange(10)})
In [162]: o2 = xray.Dataset({'x':(('t'), (np.ones(10) * 2))}, coords={'t':np.arange(5,15)})
In [163]: o1
Out[163]:
<xray.Dataset>
Dimensions: (t: 10)
In [15]: em1
Out[15]:
<xray.Dataset>
Dimensions: (lat: 720, lon: 1440, time: 4)
Coordinates:
* lat (lat) float32 89.875 89.625 89.375 89.125 88.875 88.625 ...
* lon (lon) float32 -179.875 -179.625 -179.375 -179.125 -178.875 ...
* time (time) datetime64[ns] 2004-08-01 2004-08-02 2004-08-03 2004-08-04
Data variables:
emissions (time, lat, lon) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...
class Structure(dict, object):
""" A ditionary that acts like a matlab structure.
"""
def __getattr__(self, attr):
# Fake a __getstate__ method that returns None
if attr == "__getstate__":
return lambda: None
try:
@jfburkhart
jfburkhart / sysrun.py
Created May 7, 2012 12:49
a multiprocess script
#!/usr/bin/env python
"""
jfb, 2010.10.20
"""
from copy import copy
import shutil
import datetime as dt
@jfburkhart
jfburkhart / qt_mpl_pyside_datasource.py
Created April 19, 2012 19:06
A modification of Eli Bendersky's nice example of PyQt and matplotlib to work with PySide
"""
Series of data are loaded from a .csv file, and their names are
displayed in a checkable list view. The user can select the series
it wants from the list and plot them on a matplotlib canvas.
Use the sample .csv file that comes with the script for an example
of data series.
Eli Bendersky (eliben@gmail.com)
License: this code is in the public domain
@jfburkhart
jfburkhart / gist:1079991
Created July 13, 2011 09:28
concatenation to fill a dict
def remove_dups(x, y, z):
"""
## for regridding need to remove any duplicates
## First make sure there is enough data
"""
if len(z) > 10:
vals = zip(x, y, z)
vals.sort()
z0 = zip(x, y)