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
| # Format axes for lat and lon | |
| ax.xaxis.set_major_locator(ticker.MultipleLocator(base=2./60.)) | |
| ax.yaxis.set_major_locator(ticker.MultipleLocator(base=2./60.)) | |
| def latformatter(x, pos): | |
| 'The two args are the value and tick position' | |
| if x<0: | |
| x=-x | |
| minus=True | |
| else: | |
| minus=False |
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
| # make a good dissipation color map | |
| cdict = {'red': ((0., 1, 1), | |
| (0.05, 1, 1), | |
| (0.11, 1, 1), | |
| (0.4, 0, 0), | |
| (0.66, 1, 1), | |
| (0.89, 1, 1), | |
| (1, 0.5, 0.5)), | |
| 'green': ((0., 1, 1), |
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
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| fig,ax=plt.subplots(2,1) | |
| pcm0=ax[0].pcolormesh(np.random.randn(20,30)) | |
| fig.colorbar(pcm0,ax=ax[0],shrink=0.75) | |
| pcm1=ax[1].pcolormesh(np.random.randn(20,30)) | |
| fig.colorbar(pcm1,ax=ax[1],shrink=0.75) | |
| # or if you want one beside a bunch, you can make a list to steal from: |
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
| map=Basemap() | |
| ax = plt.gca() | |
| def format_coord(x, y): | |
| return 'x=%.4f, y=%.4f'%(map(x, y, inverse = True)) | |
| ax.format_coord = format_coord |
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
| fig=figure(figsize=(10,12)) | |
| def onclick(event): | |
| print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%( | |
| event.button, event.x, event.y, event.xdata, event.ydata) | |
| cid = fig.canvas.mpl_connect('button_press_event', onclick) |
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
| from jmkfigure import * | |
| cmap=gmtcmap('BlueWhiteOrangeRed') |
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
| #I have /Users/jklymak/codas/programs/: in my PYTHONPATH | |
| from pycurrents.adcp.rdiraw import Multiread | |
| # of course you need an ENX file from vmdas! | |
| m = Multiread('March10-2015-03/ADCP029*.ENX','wh') | |
| # ENX should already be in earth co-ordinates, but you may have to adjust the heading as below: | |
| data = m.read() | |
| from pycurrents.adcp.transform import heading_rotate | |
| from pycurrents.adcp.transform import rdi_xyz_enu | |
| dhead = -44. |
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
| import hdf5storage | |
| import numpy as np | |
| D =dict() | |
| D['boo']=np.arange(10) | |
| D['who']=np.arange(20)*2. | |
| hdf5storage.savemat('Boo.mat',D) | |
| Dread = hdf5storage.loadmat('Boo.mat') |
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
| # read a smith and sandwell image file: | |
| # http://topex.ucsd.edu/marine_topo/ | |
| import numpy as np | |
| nlon=21600 | |
| nlat=17280 | |
| fin = open('topo_18.1.img','rb') | |
| dat = np.fromfile(fin,dtype='i2') | |
| dat.byteswap('True') |
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
| try: | |
| print a+'1' | |
| except: | |
| traceback.print_exc() | |
| print 'hi' |
OlderNewer