From 70e160cf2b33dca09037d57e900f850726b925b2 Mon Sep 17 00:00:00 2001 From: David Ho <63018145+dvdhoz@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:12:59 -0700 Subject: [PATCH 1/3] Script to reduce rainfall depths --- reduce-rainfall | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 reduce-rainfall diff --git a/reduce-rainfall b/reduce-rainfall new file mode 100644 index 0000000..0d861a0 --- /dev/null +++ b/reduce-rainfall @@ -0,0 +1,51 @@ +import random +from com.rma.io import DssFileManagerImpl +from com.rma.io import DssFileManagerImpl +from hec.hecmath import TimeSeriesMath + +## +# +# computeAlternative function is called when the ScriptingAlternative is computed. +# Arguments: +# currentAlternative - the ScriptingAlternative. hec2.wat.plugin.java.impl.scripting.model.ScriptPluginAlt +# computeOptions - the compute options. hec.wat.model.ComputeOptions +# +# return True if the script was successful, False if not. +# no explicit return will be treated as a successful return +# +## +def computeAlternative(currentAlternative, computeOptions): + output = None + currentAlternative.addComputeMessage("Computing ScriptingAlternative:" + currentAlternative.getName() ) + + for loc in currentAlternative.getInputDataLocations(): + currentAlternative.addComputeMessage(loc.getName()) + + # 1. read time series + tsc = currentAlternative.loadTimeSeries(loc) + hm = TimeSeriesMath(tsc) + + #2. Choose a reduction factor + arf = selectArf() + + # 3. multily time series by randomly selected areal reduction factor + hm = hm.multiply(arf) + currentAlternative.addComputeMessage("reduced") + + # 4. add to output + output = hm + + + # write output + dfm = DssFileManagerImpl.getDssFileManager() + odl = currentAlternative.getOutputDataLocations()[0] + output.setPathname(odl.getDssPath()) + currentAlternative.writeTimeSeries(output.getData()) + currentAlternative.addComputeMessage("saved output") + + return True + +def selectArf(): + numbers = [.87, .813, .824, .904, .919, .903, .842, .915] + arf = random.choice(numbers) + return arf From 7cffad84b0cce7e5ad124a398977b8176c320c52 Mon Sep 17 00:00:00 2001 From: David Ho <63018145+dvdhoz@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:23:06 -0700 Subject: [PATCH 2/3] Delete reduce-rainfall --- reduce-rainfall | 51 ------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 reduce-rainfall diff --git a/reduce-rainfall b/reduce-rainfall deleted file mode 100644 index 0d861a0..0000000 --- a/reduce-rainfall +++ /dev/null @@ -1,51 +0,0 @@ -import random -from com.rma.io import DssFileManagerImpl -from com.rma.io import DssFileManagerImpl -from hec.hecmath import TimeSeriesMath - -## -# -# computeAlternative function is called when the ScriptingAlternative is computed. -# Arguments: -# currentAlternative - the ScriptingAlternative. hec2.wat.plugin.java.impl.scripting.model.ScriptPluginAlt -# computeOptions - the compute options. hec.wat.model.ComputeOptions -# -# return True if the script was successful, False if not. -# no explicit return will be treated as a successful return -# -## -def computeAlternative(currentAlternative, computeOptions): - output = None - currentAlternative.addComputeMessage("Computing ScriptingAlternative:" + currentAlternative.getName() ) - - for loc in currentAlternative.getInputDataLocations(): - currentAlternative.addComputeMessage(loc.getName()) - - # 1. read time series - tsc = currentAlternative.loadTimeSeries(loc) - hm = TimeSeriesMath(tsc) - - #2. Choose a reduction factor - arf = selectArf() - - # 3. multily time series by randomly selected areal reduction factor - hm = hm.multiply(arf) - currentAlternative.addComputeMessage("reduced") - - # 4. add to output - output = hm - - - # write output - dfm = DssFileManagerImpl.getDssFileManager() - odl = currentAlternative.getOutputDataLocations()[0] - output.setPathname(odl.getDssPath()) - currentAlternative.writeTimeSeries(output.getData()) - currentAlternative.addComputeMessage("saved output") - - return True - -def selectArf(): - numbers = [.87, .813, .824, .904, .919, .903, .842, .915] - arf = random.choice(numbers) - return arf From 17824f83ca3432ac9c1632b0dd42df60cc01637d Mon Sep 17 00:00:00 2001 From: David Ho <63018145+dvdhoz@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:24:47 -0700 Subject: [PATCH 3/3] Apply area reduction functions to rainfall depths --- ARF/reduce-rainfall | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ARF/reduce-rainfall diff --git a/ARF/reduce-rainfall b/ARF/reduce-rainfall new file mode 100644 index 0000000..a7f1f41 --- /dev/null +++ b/ARF/reduce-rainfall @@ -0,0 +1,52 @@ +import random +from com.rma.io import DssFileManagerImpl +from com.rma.io import DssFileManagerImpl +from hec.hecmath import TimeSeriesMath + +## +# +# computeAlternative function is called when the ScriptingAlternative is computed. +# Arguments: +# currentAlternative - the ScriptingAlternative. hec2.wat.plugin.java.impl.scripting.model.ScriptPluginAlt +# computeOptions - the compute options. hec.wat.model.ComputeOptions +# +# return True if the script was successful, False if not. +# no explicit return will be treated as a successful return +# +## +def computeAlternative(currentAlternative, computeOptions): + output = None + currentAlternative.addComputeMessage("Computing ScriptingAlternative:" + currentAlternative.getName() ) + + for loc in currentAlternative.getInputDataLocations(): + currentAlternative.addComputeMessage(loc.getName()) + + # 1. read time series + tsc = currentAlternative.loadTimeSeries(loc) + hm = TimeSeriesMath(tsc) + + #2. Choose a reduction factor + arf = selectArf() + + # 3. multily time series by randomly selected areal reduction factor + hm = hm.multiply(arf) + currentAlternative.addComputeMessage("reduced") + + # 4. add to output + output = hm + + + # write output + dfm = DssFileManagerImpl.getDssFileManager() + odl = currentAlternative.getOutputDataLocations()[0] + output.setPathname(odl.getDssPath()) + currentAlternative.writeTimeSeries(output.getData()) + currentAlternative.addComputeMessage("saved output") + + return True + +def selectArf(): + # Reduction values to select. Update values for your storm + numbers = [.87, .813, .824, .904, .919, .903, .842, .915] + arf = random.choice(numbers) + return arf