Last active
November 13, 2024 19:50
-
-
Save pyRobShrk/fd5f6d33ffcc26f7e639c18dddb9869a to your computer and use it in GitHub Desktop.
Godin Filter jython script for HEC-DSSVue
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=Godin | |
# description=This jython script reads your DSSVue selection, and performs Godin tidal smoothing. | |
# description=The original 1972 Godin algorithm was to apply successive 25-hour averages to hourly data. | |
# description=This filter is slightly modified for 15-minute data, and specific to the periods of tidal constituents. | |
# description=The 51-period (12.5-hr) filters M4, MS4 and MN4, 97-period (24-hr) filters S2 and K2, and 101-period (25-hr) filters M2, N2, and L2. | |
# displayinmenu=false | |
# displaytouser=true | |
# displayinselector=false | |
from hec.hecmath import HecMath | |
from hec.heclib.dss import HecDss, DSSPathname | |
from hec.dssgui import ListSelection | |
ls = ListSelection.getMainWindow() | |
selection = ls.getSelectionList() | |
dssFile = HecDss.open(selection[0].getFilename()) | |
for ts in selection: | |
tidalData = ls.read(ts.getPathname(),ls.getStartTime(),ls.getEndTime()) | |
tidalData = HecMath.createInstance(tidalData) | |
godin = tidalData.interpolateDataAtRegularInterval('15MIN', '') | |
godin = godin.centeredMovingAverage(51,1,1).centeredMovingAverage(97,1,1).centeredMovingAverage(101,1,1) | |
pn2 = DSSPathname(godin.getPath()) | |
pn2.setFPart(pn2.fPart()+'_godin') | |
godin.setPathname(pn2.getPathname()) | |
dssFile.write(godin) | |
ls.refreshCatalog() | |
dssFile.done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment