-12.70000 64.30000 165.3000 4.900000 64.00000 166.6000 23.90000 64.90000 168.7000 ////////////// lines: And that's it! Couldn't be easier, right? One little thing to take care of is that import numpy as np dtype = np.dtype('B') try: with open("c:\temp\Binary_File.jpg", "rb") as f: numpy_data = np.fromfile(f,dtype) print(numpy_data) except IOError: print('Error While Opening the file!') ///////////////// with open(file_path, 'rb') as file_obj: file_obj.seek(seek_to_position) data_ro = np.frombuffer(file_obj.read(total_num_bytes), dtype=your_dtype_here) data_rw = data_ro.copy() #without copy(), the result is read-only /////////////////////// import numpy as np >>> import cv2 >>> xbash = np.fromfile('/bin/bash', dtype='uint8') >>> xbash.shape (1086744,) >>> cv2.imwrite('bash1.png', xbash[:10000].reshape(100,100)) ////////// # Plot 2D histogram using pcolor fig2 = plt.figure() plt.pcolormesh(xedges,yedges,Hmasked) plt.xlabel('x') plt.ylabel('y') cbar = plt.colorbar() cbar.ax.set_ylabel('Counts') ////////////////////// dt=np.transpose(np.genfromtxt(ft)) lon=dt[0,:] lat=dt[1,:] temp=dt[2,:] import csv import numpy as np import matplotlib.pyplot as plt # Make plot 1 fig1, ax1 = plt.subplots(1) #plt.fill_between(dist2shore,bathy,1000,color='k') plt.scatter(dist2shore,depth,s=20,c=temp,marker='o', edgecolor='none') plt.ylim((-0.5,max(depth)+5)) ax1.set_ylim(ax1.get_ylim()[::-1]) ax1.set_xlim(min(dist2shore),max(dist2shore)) cbar = plt.colorbar(orientation='horizontal', extend='both') cbar.ax.set_xlabel('Temperature ($^\circ$C)') plt.title('OTN Glider transect') plt.ylabel('Depth (m)') plt.xlabel('Distance form shore (km)') plt.show() # Save figure (without 'white' borders) plt.savefig('glider_Dist2Shore.png', bbox_inches='tight') //////////////////////// # For original tutorial, see (bottom of page): This tutorial came from here (bottom of page): http://polar.ncep.noaa.gov/global/examples/usingpython.shtml from mpl_toolkits.basemap import Basemap import numpy as np import matplotlib.pyplot as plt from pylab import * import netCDF4 plt.figure() nc = '/data/SSTlobster/RTOFS/rtofs_glo_3dz_n048_daily_3ztio.nc' # In this example we will extract the surface temperature field from the model. # Remember that indexing in Python starts at zero. file = netCDF4.Dataset(nc) lat = file.variables['Latitude'][:] lon = file.variables['Longitude'][:] data = file.variables['temperature'][0,0,:,:] file.close() #There is a quirk to the global NetCDF files that isn't in the NOMADS data, namely that there are junk values of longitude (lon>500) in the rightmost column of the longitude array (they are ignored by the model itself). So we have to work around them a little with NaN substitution. lon = np.where(np.greater_equal(lon,500),np.nan,lon) #Plot the field using Basemap. Start with setting the map projection using the limits of the lat/lon data itself m=Basemap(projection='mill',lat_ts=10, \ llcrnrlon=np.nanmin(lon),urcrnrlon=np.nanmax(lon), \ llcrnrlat=lat.min(),urcrnrlat=lat.max(), \ resolution='c') #Convert the lat/lon values to x/y projections. x, y = m(lon,lat) #Plot the field using the fast pcolormesh routine and set the colormap to jet. cs = m.pcolormesh(x,y,data,shading='flat', \ cmap=plt.cm.jet) #Add a coastline and axis values. m.drawcoastlines() m.fillcontinents() m.drawmapboundary() m.drawparallels(np.arange(-90.,120.,30.), \ labels=[1,0,0,0]) m.drawmeridians(np.arange(-180.,180.,60.), \ labels=[0,0,0,1]) #Add a colorbar and title, and then show the plot. colorbar(cs) plt.title('Global RTOFS SST from NetCDF') plt.show()