View pandas-example.py
import pandas as pd
data_frame = pd.io.parsers.read_csv('time-series.csv',index_col = 0, names=['index','heave'])
_max = [[5, 259.0]]
indexes = [x[0] for x in _max ]
index = data_frame.index
timestamps = [index[z] for z in indexes]
#['2011-12-30 00:00:04']
print data_frame.ix[timestamps]
# heave
View SyntaxErrors
/usr/local/lib/python3.2/subprocess.py:389: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
matplotlib: 1.2.x
python: 3.2.3 (default, Sep 6 2012, 14:51:03) [GCC 4.1.2
20080704 (Red Hat 4.1.2-46)]
platform: linux2
View log_to_dataframe.py
# Python modules for taking Cumulus ( sandaysoft.com ) logs into a Pandas
# ( pandas.pydata.org ) DataFrame, and using the date and time columns to
# create a DateTimeIndex for the DataFrame and sort upon it.
import pandas as pd
import os
import glob
from datetime import datetime
log_path = 'D:\\log_files_folder'
View historical_concat.py
import os
import glob
import pandas as pd
from datetime import datetime
# Example below assumes following folder hierarchy D:\Buoy_Data\Buoy_Name\Year\Month\
buoy_names = ['Buoy_Name']
buoy_path = 'D:\\Buoy_Data\\'
his_columns = ['date_time', 'Tp', 'dirp', 'sprp', 'Tz', 'Hm0', 'TI', 'T1', 'Tc',
View HebMarine_Basemap_Test
{
"metadata": {
"name": "Basemap HebMarine"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
View arcgis_raster_to_xyz
# Initial data obtained from hdr file produced with flt file when running
# Raster to Float in ArcToolBox and numpy file ( npy ) from RasterToNumpyArray
# in ArcPy
import numpy as np
np.load('numpy_bathy.npy')
cell_size = 3
no_of_columns = 18325
no_of_rows = 13303
lower_left_x = 607512
lower_left_y = 6455598
View iter_loadtxt.py
# Code copied from Joe Kington's StackOverflow answer
# http://stackoverflow.com/a/8964779/1135883
# For large files with regular records this is a much faster and memory
# efficient solution
def iter_loadtxt(filename, delimiter=' ', skiprows=0, dtype=float):
def iter_func():
with open(filename, 'r') as infile:
for _ in range(skiprows):
next(infile)
View grid_bathy_xyz.py
# Initial data obtained from hdr file produced with flt file when running
# Raster to Float in ArcToolBox and numpy file ( npy ) from RasterToNumpyArray
# in ArcPy
# Numpy uses top left as origin and geopgraphic coordinate systems treat the
# origin as lower left, you can either flip the incoming bathymetry maxtrix
# vertically or create a descending range of y_coordinates
import numpy as np
bathy = np.load('D:\\numpy_bathy.npy')
View plot_3d_surface_xyz.py
# -*- coding: utf-8 -*-
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.mlab import griddata
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
import sys
def xyz_ret(file):
View ipython_history_query.py
#Example of searching for a string in IPython sqlite history
from IPython.core.history import HistoryAccessor
history_accessor = HistoryAccessor()
sqlite_cursor = history_accessor.search('*threshold*')
results = sqlite_cursor.fetchall()
for result in results:
print result
#From the first number in the printed results you can see the relevant session
#number, and then below retrieve the whole session using get_range
session_results = history_accessor.get_range(1321)