Skip to content

Instantly share code, notes, and snippets.

View jklymak's full-sized avatar

Jody Klymak jklymak

View GitHub Profile
dlat = dlat.rename({'latb':'lat'})
dlat['lat'].data = data['lat'].data
@jklymak
jklymak / writeable_mds_store.py
Last active January 30, 2017 21:45 — forked from rabernat/writeable_mds_store.py
writable MDS store for dask
class writable_mds_store:
'''
This will write each chunk to a binary file. Really only works if chunks are the k-index of the matrix
'''
def __init__(self, prefix, itern, suffix='data', dtype='>f4'):
self.prefix = prefix
self.itern = itern
self.suffix = suffix
self.dtype = dtype
self.fname = '%s.%010d.%s' % (self.prefix, self.itern, self.suffix)
@jklymak
jklymak / gendata_justregrid.py
Created February 9, 2017 23:59
Regridding of coarse to fine w/ dask. Example of using dask.map_blocks and of writing dask files as mds stores.
coarsename = '/scr/jklymak/LeeCoarse/coarse3d%s01U10/_Model/input/'%runtype
print(coarsename)
def interpolateAtDepth(X,T,x0,y0,x,y,defaultval,block_id=None):
import scipy.interpolate
good = np.where(T[0,0,:,:]>20.)
bad = np.where(T[0,0,:,:]<=20.)
Tt = X.copy()[0,0,:,:]
print(Tt)
#print(good)
@jklymak
jklymak / cleanup.py
Created March 1, 2017 17:34
Cleanup mitgcm data on server
import os
import glob
TODO = 'LWRegrid2full01U10'
Root = '../results/'+TODO+'/_Model/input/'
print(Root)
dd = glob.glob(Root+'S.*')
print(dd)
@jklymak
jklymak / ExampleLegend.ipynb
Last active March 7, 2017 17:12
matplotlib: Make legend labels be aligned for a table...
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jklymak
jklymak / parsegrades.py
Created April 18, 2017 17:35
Parse a UVic grade sheet. Obviously a lot is hardcoded
import pandas
df = pandas.read_excel('ClassListGradeEntry_07-02-2017_11-15-08_AM.xls')
for ii in range(6):
for col in range(len(df.loc[ii])-2):
if (col in [11,15]):
print('--------------------------------------------------------------')
if col in [0,1,16]:
print('%20s: %20s'%(df.keys()[col],df.loc[ii][col]))
@jklymak
jklymak / runModel.py
Created May 21, 2017 19:12
python pbs script. This is just an outline. It works fine, so maybe a nice way to do PBS scripts.
#!/u/home/jklymak/miniconda2/bin/python
#PBS -m be
#PBS -M jklymak@gmail.com
#PBS -l select=1:ncpus=1
#PBS -l walltime=00:00:10
#PBS -q transfer
#PBS -A XXXXXXXXXXX
#PBS -j oe
#PBS -N Test
@jklymak
jklymak / ColorbarYTicks.ipynb
Last active June 7, 2017 20:12
colorbar y ticks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jklymak
jklymak / MVPTranslate.ipynb
Last active June 28, 2017 15:08
Make CF-compliant netcdf MVP files
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.