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
# dateAxis.py | |
# Usage: save dateAxis.py in directory with pyqtgraph py file | |
# Use sample code below to create plot with date axis | |
# from dateAxis import * | |
# daxis = DateAxis(orientation='bottom') | |
# flo = pg.PlotWidget(axisItems={'bottom': daxis, 'left': yaxis}) | |
import time | |
import pyqtgraph as pg | |
import numpy as np | |
from pyqtgraph.Qt import QtGui, QtCore |
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
# Calculate 18 zenith angles (radians) for CE-QUAL-W2 Topographic Shading | |
# Use ArcGIS "Solar Radiation Graphics" Tool, output optional sky map | |
# Sky Size: 1440, Zenith Divisions: 360 (0.25 deg), Azimuth Divisions: 72 (5 deg) | |
# Tool returns a viewshed with as many bands as input points, and a sky map which | |
# has values starting at zero at the north outside edge, and spiraling clockwise inward | |
# However, the results are looking up at the sky so West/East are reversed | |
# Each sky map wedge is centered on the main direction | |
# Sky maps values divisible by 72 with no remainder (modulo or %), are from 357.5 to 2.5 azimuth | |
# Example: skymap value of 6210, where is it? | |
# Solution: 6210 % 72 = 18, There are 72 azimuth divisions so 18 is due west |
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
## This script processes a bathymetric surface model into 2D blocks for CE-QUAL-W2 | |
## "CEQUALRivSegm" is a shapefile with segment numbers, lengths, and reverse-azimuth directions | |
## "CEQUAL_seg" is a raster from a polygon file with segment numbers and pixels matching "DEM" | |
## The resulting histogram multiplied by the cell area gives the area-elevation curve for each segment | |
## The area-elevation curve divided by the segment length gives the average width for CE-QUAL-W2 | |
from scipy import ndimage as ndi | |
import numpy as np | |
tabl = arcpy.da.TableToNumPyArray("CEQUALRivSegm",['OBJECTID','Length_m','Bearing']) |
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
# This script is used to calculate the segment angle for CE-QUAL-W2 | |
# My segment streamline was drawn going downstream | |
# The CE-QUAL input wants radians east of north (CW), pointing upstream | |
# atan2 results are north of east (CCW), the sign change makes it CW | |
# adding pi/2 gives the reverse azimuth, subtracting would be azimuth | |
# In ArcMap Field Calculator using Python Parser: | |
# Pre-Logic Script Code: | |
def reverseAzimuth(shp): | |
a = -math.atan2(shp.firstPoint.Y - shp.lastPoint.Y, shp.firstPoint.X - shp.lastPoint.X) + math.pi/2 | |
if a < 0: |
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
Sub ExtractTrendline() | |
Dim outRng As Range | |
Dim useB As String | |
Dim poly As String | |
Dim poly2 As String | |
useB = "TRUE" | |
poly = "{1" | |
If TypeName(Selection) = "Trendline" Then | |
If Not Selection.Type = xlMovingAvg Then | |
Set outRng = Application.InputBox(Prompt:="Select uppler-left of location where coeffients are to be stored (2-6 cols, 7 rows):", _ |
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
# name=HEC-YEAH | |
# description=HEC-YEAH | |
# description=Aimee Kindel and Rob Sherrick, HDR, Inc. | |
# description=This script unlocks the cryptic file storage of the HEC-RAS Water Quality Module output (*.wq##) | |
# description=On line 101: "range(1,ct+1,4):" says to output only every fourth WQ cell (for speed). | |
# description=On line 105: You may want to change "FPART" to something more descriptive. | |
# displayinmenu=false | |
# displaytouser=true | |
# displayinselector=false | |
from hec.script import * |
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
Function Int2d(rowLookup As Double, colLookup As Double, lookupRange As Range) As Double | |
'This function performs 2 dimensional linear interpolation using built-in linear functions | |
'Lookup range includes column and row lookup values | |
Dim Row, col As Integer | |
Dim RowVals, ColVals, lookup As Variant | |
Dim sl1, sl2, sl3, int1, int2, int3, col1, col2 As Double | |
Row = 1 | |
col = Row | |
On Error Resume Next | |
Row = WorksheetFunction.Match(rowLookup, lookupRange.Offset(1, 0).Columns(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
from http import client | |
def USGS10mElev(lat,lon): | |
usgs = client.HTTPConnection('nationalmap.gov') | |
usgs.request('GET','/epqs/pqs.php?x=%.6f&y=%.6f&units=FEET&output=xml'% (lon, lat)) | |
result = usgs.getresponse() | |
if result.status == 200: | |
xml = result.read() | |
return float(xml[xml.find(b'<Elevation>')+11:xml.find(b'</Elevation>')-1]) | |
else: return request |
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
# This script interpolates river bathymetry in an anisotropic way. | |
# Following the stream centerline, the interpolation is weighted longitudinally. | |
# This is accomplished by projecting the sinuous river to a straight line (s, n) coordinates, | |
# where s is distance downstream and n is distance left/right perpindicular to centerline. | |
# In (s, n) coordinates, the river is then compressed longitudinally, and then interpolated normally. | |
# The compression gives interpolation weight to upstream/downstream points instead of going up the bank. | |
# For best results the centerline should be smoothed, otherwise the inside bend has overlapping points. | |
# Input Excel file has three sheets, with simple X, Y, Z columns. X, Y only for centerline. | |
import pandas as pd |
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
' Multiple Linear Regressions in Excel | |
' This group of functions uses the Hat Matrix and | |
' Leverages to calculate the PRESS statistic | |
' A column of ones must precede your X columns (exR) | |
' https://en.wikipedia.org/wiki/PRESS_statistic | |
' https://en.wikipedia.org/wiki/Projection_matrix | |
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Function Hat(exR As Range) As Variant | |
'Returns a symmetrical array of dimensions n by n |
OlderNewer