This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Oct 21 15:49:56 2014 | |
@author: le12jm | |
""" | |
import os | |
import numpy as np | |
import matplotlib.cm as cm |
This file contains 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 pandas as pd | |
from datetime import datetime | |
def month_his_to_df(his_file_path, resample=True): | |
his_columns = ['date_time', 'Tp', 'dirp', 'sprp', 'Tz', 'Hm0', 'TI', 'T1', | |
'Tc', 'Tdw2', 'Tdw1', 'Tpc', 'nu','eps','QP','Ss','TRef', | |
'TSea','Bat'] | |
month_dataframe = pd.io.parsers.read_csv(his_file_path, names = his_columns) | |
date_time_array = [] | |
for date_time_string in month_dataframe['date_time'].values: |
This file contains 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 pandas as pd | |
import datetime | |
import os | |
def make_raw_files(path_to_raw_df, output_folder): | |
raw_df = pd.read_pickle(path_to_raw_df) | |
os.chdir(output_folder) | |
timestamp = datetime.datetime(2013,2,1,0,17,59) | |
half_hour_delta = datetime.timedelta(0,1800) | |
final_timestamp = datetime.datetime(2013,2,28,23,48) |
This file contains 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 shapely.geometry import mapping | |
from shapely.ops import polygonize | |
import fiona | |
def polyline_to_polygon(input_file, output_file): | |
polylines = fiona.open(input_file) | |
geom = [x['geometry'] for x in polylines] | |
coords = [x['coordinates']for x in geom[:-1]] | |
schema = {'geometry': 'Polygon','properties': {'id': 'int'}} | |
with fiona.open(output_file, 'w', 'ESRI Shapefile', schema) as c: |
This file contains 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
# translate_multipoint | |
# Translation of Shapefile record geometries in a functional style. | |
from fiona import collection | |
from functools import partial | |
from itertools import imap | |
import logging | |
log = logging.getLogger() |
This file contains 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 LatLon | |
import pandas as pd | |
import re | |
leica_points = pd.read_csv('D://project_3.csv',names=['id','type','timestamp','Latitude','Longtitude','Height','Quality']) | |
coords = [] | |
chars = '[\xb0\'"]' | |
for index, row in leica_points.iterrows(): | |
lat_dmds = re.sub(chars,'',row.Latitude) | |
long_dmds = re.sub(chars,'',row.Longtitude) |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Feb 06 14:38:11 2015 | |
@author: le12jm | |
""" | |
from datetime import datetime | |
#from hebtools.common import wave_power | |
import glob |
This file contains 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 LatLon | |
import pandas as pd | |
import re | |
# Function for importing Leica Geo Office created comma separated variables | |
# files from post processed data, decimal seconds coordinates are converted | |
# to decimal degrees. | |
def read_lgo_csv_decimal_seconds_to_decimal_degrees(input_file, output_file): | |
cols = ['id','type','timestamp', 'Latitude', 'Longtitude', 'Height', |
This file contains 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 sys | |
# Be safe and define a maximum of frames we're trying to walk up | |
MAX_FRAMES = 20 | |
def save_to_interactive(dct): | |
n = 0 | |
# Walk up the stack looking for '__name__' | |
# with a value of '__main__' in frame globals | |
for n in range(MAX_FRAMES): |
This file contains 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
{'datetime':'Timestamp: date and time (ISO8601)', | |
'Tp': 'the peak period (the reciprocal of the peak frequency) [s]', | |
'Dirp': 'the wave direction at the peak frequency [°]', | |
'Sprp': 'the directional spread at the peak frequency [°]', | |
'Tz': 'the zero-upcross period [s]', | |
'Hs': 'the significant wave height [cm]', | |
'TI': 'the integral period, or Tm(-2,0) [s]', | |
'T1': 'the mean period, or Tm(0,1) [s]', | |
'Tc': 'the crest period, or Tm(2,4) [s]', | |
'Tdw2': 'wave period Tm(-1,1) [s]', |