diff --git a/.github/workflows/build-wheel.yml b/.github/workflows/build-wheel.yml new file mode 100644 index 0000000..7b3fdae --- /dev/null +++ b/.github/workflows/build-wheel.yml @@ -0,0 +1,50 @@ +name: Build Python Wheel + +on: + workflow_call: + inputs: + ref: + description: Git ref to check out + required: false + type: string + default: "" + +jobs: + build-wheel: + name: Build Python wheel + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + ref: ${{ inputs.ref || github.ref }} + + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 21 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Make Gradle wrapper executable + run: chmod +x ./gradlew + + - name: Build and test + run: ./gradlew clean build buildPythonWheel + + - name: Collect wheel + run: | + mkdir -p dist + find . -path "*/build/install/*/dist/*.whl" -exec cp {} dist/ \; + + - name: Upload Python wheel artifact + uses: actions/upload-artifact@v4 + with: + name: python-wheel + path: dist/*.whl + if-no-files-found: error + retention-days: 14 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0be5339..c9f1b40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,35 +9,18 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - build: + build-wheel: name: Build and test - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Set up Java - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: 21 - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v6 - - - name: Make Gradle wrapper executable - run: chmod +x ./gradlew - - - name: Build and test - run: ./gradlew clean build + uses: ./.github/workflows/build-wheel.yml dependency-submission: name: Submit Gradle dependencies - needs: build + needs: build-wheel runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/main' permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e0833f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release + +on: + release: + types: + - published + +permissions: + contents: write + actions: read + +concurrency: + group: release-${{ github.event.release.id }} + cancel-in-progress: false + +jobs: + build-wheel: + name: Build wheel from release tag + uses: ./.github/workflows/build-wheel.yml + with: + ref: ${{ github.event.release.tag_name }} + + publish-wheel: + name: Publish Python wheel to GitHub Release + needs: build-wheel + runs-on: ubuntu-latest + + steps: + - name: Download Python wheel artifact + uses: actions/download-artifact@v4 + with: + name: python-wheel + path: dist + + - name: Generate checksums + run: | + cd dist + sha256sum *.whl > SHA256SUMS.txt + + - name: Publish wheel to GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.release.tag_name }} + files: | + dist/*.whl + dist/SHA256SUMS.txt \ No newline at end of file diff --git a/build.gradle b/build.gradle index 84613dc..046d611 100644 --- a/build.gradle +++ b/build.gradle @@ -3,14 +3,65 @@ plugins { id "org.sonarqube" version "7.3.1.8318" } -def versionLabel(gitInfo) { - def branch = gitInfo.branchName // all branches are snapshots, only tags get released - def tag = gitInfo.lastTag - // tag is returned as is. Branch may need cleanup - return branch == null ? tag : "99." + branch.replace("/","-") + "-SNAPSHOT" +def gitOutput(String... args) { + return providers.exec { + commandLine(['git'] + args.toList()) + ignoreExitValue = true + }.standardOutput.asText.get().trim() +} + +def normalizeReleaseTag(String tag) { + if (!tag) { + return null + } + + return tag.startsWith('v') ? tag.substring(1) : tag +} + +def pep440VersionFromLatestTag() { + def exactTag = gitOutput('describe', '--tags', '--exact-match') + if (exactTag) { + return normalizeReleaseTag(exactTag) + } + + def tag = gitOutput('describe', '--tags', '--abbrev=0') + if (!tag) { + tag = '0.0.0' + } + + def baseVersion = normalizeReleaseTag(tag) + + def distanceText = tag == '0.0.0' + ? gitOutput('rev-list', 'HEAD', '--count') + : gitOutput('rev-list', "${tag}..HEAD", '--count') + def distance = distanceText?.isInteger() ? distanceText.toInteger() : 0 + + def hash = gitOutput('rev-parse', '--short=7', 'HEAD') + def dirty = gitOutput('status', '--porcelain') ? true : false + + if (distance == 0 && !dirty) { + return baseVersion + } + + def version = "${baseVersion}.post${distance}" + def localParts = [] + + if (hash) { + localParts.add("g${hash}") + } + + if (dirty) { + localParts.add("dirty") + } + + if (!localParts.isEmpty()) { + version += "+" + localParts.join(".") + } + + return version } allprojects { - group = 'mil.army.wmist.regi-headless' - version = versionLabel(versionDetails()) + group = 'mil.army.wmist.regi-python' + version = pep440VersionFromLatestTag() } diff --git a/district-scripts/SWF/GateFlow5.py b/district-scripts/SWF/GateFlow5.py index f64000c..d0d4e3f 100644 --- a/district-scripts/SWF/GateFlow5.py +++ b/district-scripts/SWF/GateFlow5.py @@ -1,196 +1,206 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -8) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -# endCal.clear() -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) - -officeID = "SWF" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate - - -calculateSingleFlowGroups = False -flowGroupGate = "Gated_Total" -flowGroupTotal = "Project_Total" -flowGroupTurbine = "Turbine_Total" -flowGroupPumpOutBelow = "Pump_Out_Below_Total" -flowGroupUncontrol = "Uncontrolled_Total" -flowGroupJSPturbine1 = "Turbine1" -flowGroupJSPturbine2 = "Turbine2" - - -locationList = ["BNBT2", - "GGLT2", - "LEWT2", - "LVNT2", - "SCLT2" - ] -ohit2Group = ["OHIT2"] -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True - -FlowGroupList = [ "ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BSLT2", - "CLDL1", - "DAWT2", - "GPET2", - "GNGT2", - "GPVT2", - "HORT2", - "JPLT2", - "JFNT2", - "JSPT2", - "TBLT2", - "PCTT2", - "RRLT2", - "FRHT2", - "SAGT2", - "SMCT2", - "SOMT2", - "STIT2", - "TXKT2", - "WTYT2", - "TRNT2", - "FFLT2", - "EAMT2", - "FLWT2", - "LLST2", - "GBYT2", - "PSMT2", - "SAGT2", - "BPRT2", - "TBRT2", - "MSDT2", - "BNBT2", - "GGLT2", - "LEWT2", - "LVNT2", - "SCLT2", - "OHIT2" - ] - -tempList = ["JFNT2"] - -#if calculateSingleFlowGroups: -# for location in locationList: -# print "Now Running", location, "SINGLE" -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) -#compute_Single_Flowgroup(officeID, "GGLT2", startCal, endCal, "Spillway GGL_Total") - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - -compute_Single_Flowgroup(officeID, "JSPT2", startCal, endCal, "Turbine1") -compute_Single_Flowgroup(officeID, "JSPT2", startCal, endCal, "Turbine2") - - -#if calculateSingleFlowGroups: -# for location in ohit2Group: -# print "Now Running", location, "SINGLE" -# compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance(timeZone) + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -8) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(timeZone) + # endCal.clear() + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + # endCal.set(Calendar.YEAR, 2015) + # endCal.set(Calendar.MONTH, 11) + + officeID = "SWF" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + + + calculateSingleFlowGroups = False + flowGroupGate = "Gated_Total" + flowGroupTotal = "Project_Total" + flowGroupTurbine = "Turbine_Total" + flowGroupPumpOutBelow = "Pump_Out_Below_Total" + flowGroupUncontrol = "Uncontrolled_Total" + flowGroupJSPturbine1 = "Turbine1" + flowGroupJSPturbine2 = "Turbine2" + + + locationList = ["BNBT2", + "GGLT2", + "LEWT2", + "LVNT2", + "SCLT2" + ] + ohit2Group = ["OHIT2"] + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = True + + FlowGroupList = [ "ACTT2", + "ALAT2", + "BDWT2", + "BLNT2", + "BSLT2", + "CLDL1", + "DAWT2", + "GPET2", + "GNGT2", + "GPVT2", + "HORT2", + "JPLT2", + "JFNT2", + "JSPT2", + "TBLT2", + "PCTT2", + "RRLT2", + "FRHT2", + "SAGT2", + "SMCT2", + "SOMT2", + "STIT2", + "TXKT2", + "WTYT2", + "TRNT2", + "FFLT2", + "EAMT2", + "FLWT2", + "LLST2", + "GBYT2", + "PSMT2", + "SAGT2", + "BPRT2", + "TBRT2", + "MSDT2", + "BNBT2", + "GGLT2", + "LEWT2", + "LVNT2", + "SCLT2", + "OHIT2" + ] + + tempList = ["JFNT2"] + + #if calculateSingleFlowGroups: + # for location in locationList: + # print "Now Running", location, "SINGLE" + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) + #compute_Single_Flowgroup(officeID, "GGLT2", startCal, endCal, "Spillway GGL_Total") + + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + compute_All_Flowgroups(officeID, location, startCal, endCal) + + compute_Single_Flowgroup(officeID, "JSPT2", startCal, endCal, "Turbine1") + compute_Single_Flowgroup(officeID, "JSPT2", startCal, endCal, "Turbine2") + + + #if calculateSingleFlowGroups: + # for location in ohit2Group: + # print "Now Running", location, "SINGLE" + # compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWF/GateFlow_MonthlyPumpBackFill.py b/district-scripts/SWF/GateFlow_MonthlyPumpBackFill.py index 704ef93..7bb1ae5 100644 --- a/district-scripts/SWF/GateFlow_MonthlyPumpBackFill.py +++ b/district-scripts/SWF/GateFlow_MonthlyPumpBackFill.py @@ -1,202 +1,212 @@ -from java.util import Calendar -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance() -# startCal.clear() -startCal.set(Calendar.HOUR, 0) ### set startCal hour/minute/second/millisecond to 0 for midnight -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -startCal.add(Calendar.YEAR, -1) ### go back one year to today -startCal.set(Calendar.MONTH, 9) ### change month to month 9 (october) -startCal.set(Calendar.DAY_OF_MONTH, 1) ### change start date to start of the month day 1 - -getYear = startCal.get(Calendar.YEAR) ### get value of startCal year/month/day to print and to initilize endCal -getMonth = startCal.get(Calendar.MONTH) -getDayofMonth = startCal.get(Calendar.DAY_OF_MONTH) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance() -# endCal.clear() -endCal.set(Calendar.HOUR, 0) ### set endCal hour/minute/second/millisecond to 0 for midnight -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -###endCal will be set to current date unless reset with the following 4 lines -#endCal.set(Calendar.YEAR, getYear) ### set endCal year same as startCal -#endCal.set(Calendar.MONTH, getMonth) ### set endCal month same as startCal -#endCal.add(Calendar.MONTH, 12) ##add 1 month to startcal month -#endCal.set(Calendar.DAY_OF_MONTH, 1) ### set to day one - -### time window starts 01Feb2019(one year ago) and ends 01Mar2019 (one year ago plus one month) - -getEndDay = endCal.get(Calendar.DAY_OF_MONTH) -getEndYear = endCal.get(Calendar.YEAR) -getEndMonth = endCal.get(Calendar.MONTH) - - -officeID = "SWF" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = True -flowGroupGate = "ConduitGate_Total" -flowGroupTotal = "Project_Total" -flowGroupTurbine = "Turbine_Total" -flowGroupPumpOutBelow = "Pump_Out_Below_Total" -flowGroupPumpOut = "Pump_Out_Total" -flowGroupPumpIn = "Pump_In_Total" -flowGroupUncontrol = "Uncontrolled_Total" - -locationList = [ - "ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "DAWT2", - "GGLT2", - "GNGT2", - "GPVT2", - "HORT2", - "JFNT2", - "HORT2", - "JPLT2", - "LEWT2", - "LVNT2", - "PCTT2", - "RRLT2", - "SCLT2", - "SMCT2", - "SOMT2", - "STIT2", - "TXKT2", - "SAGT2", - "BCAT2", - "WTYT2" - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = False -FlowGroupList = [ - "ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "DAWT2", - "GGLT2", - "GNGT2", - "GPVT2", - "HORT2", - "JFNT2", - "HORT2", - "JPLT2", - "LEWT2", - "LVNT2", - "PCTT2", - "RRLT2", - "SCLT2", - "SMCT2", - "SOMT2", - "STIT2", - "TXKT2", - "BCAT2", - "SAGT2", - "WTYT2" - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOut) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpIn) -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - #compute_All_Flowgroups(officeID, location, startCal, endCal) - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance() + # startCal.clear() + startCal.set(Calendar.HOUR, 0) ### set startCal hour/minute/second/millisecond to 0 for midnight + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + startCal.add(Calendar.YEAR, -1) ### go back one year to today + startCal.set(Calendar.MONTH, 9) ### change month to month 9 (october) + startCal.set(Calendar.DAY_OF_MONTH, 1) ### change start date to start of the month day 1 + + getYear = startCal.get(Calendar.YEAR) ### get value of startCal year/month/day to print and to initilize endCal + getMonth = startCal.get(Calendar.MONTH) + getDayofMonth = startCal.get(Calendar.DAY_OF_MONTH) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance() + # endCal.clear() + endCal.set(Calendar.HOUR, 0) ### set endCal hour/minute/second/millisecond to 0 for midnight + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + ###endCal will be set to current date unless reset with the following 4 lines + #endCal.set(Calendar.YEAR, getYear) ### set endCal year same as startCal + #endCal.set(Calendar.MONTH, getMonth) ### set endCal month same as startCal + #endCal.add(Calendar.MONTH, 12) ##add 1 month to startcal month + #endCal.set(Calendar.DAY_OF_MONTH, 1) ### set to day one + + ### time window starts 01Feb2019(one year ago) and ends 01Mar2019 (one year ago plus one month) + + getEndDay = endCal.get(Calendar.DAY_OF_MONTH) + getEndYear = endCal.get(Calendar.YEAR) + getEndMonth = endCal.get(Calendar.MONTH) + + + officeID = "SWF" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + # by changing the "flowGroup" variable. + calculateSingleFlowGroups = True + flowGroupGate = "ConduitGate_Total" + flowGroupTotal = "Project_Total" + flowGroupTurbine = "Turbine_Total" + flowGroupPumpOutBelow = "Pump_Out_Below_Total" + flowGroupPumpOut = "Pump_Out_Total" + flowGroupPumpIn = "Pump_In_Total" + flowGroupUncontrol = "Uncontrolled_Total" + + locationList = [ + "ACTT2", + "ALAT2", + "BDWT2", + "BLNT2", + "BNBT2", + "DAWT2", + "GGLT2", + "GNGT2", + "GPVT2", + "HORT2", + "JFNT2", + "HORT2", + "JPLT2", + "LEWT2", + "LVNT2", + "PCTT2", + "RRLT2", + "SCLT2", + "SMCT2", + "SOMT2", + "STIT2", + "TXKT2", + "SAGT2", + "BCAT2", + "WTYT2" + ] + + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = False + FlowGroupList = [ + "ACTT2", + "ALAT2", + "BDWT2", + "BLNT2", + "BNBT2", + "DAWT2", + "GGLT2", + "GNGT2", + "GPVT2", + "HORT2", + "JFNT2", + "HORT2", + "JPLT2", + "LEWT2", + "LVNT2", + "PCTT2", + "RRLT2", + "SCLT2", + "SMCT2", + "SOMT2", + "STIT2", + "TXKT2", + "BCAT2", + "SAGT2", + "WTYT2" + ] + + + if calculateSingleFlowGroups: + for location in locationList: + print("Now Running", location, "SINGLE") + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOut) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpIn) + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + #compute_All_Flowgroups(officeID, location, startCal, endCal) + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWF/GateFlow_PumpBackFill.py b/district-scripts/SWF/GateFlow_PumpBackFill.py index cb5b818..bc58977 100644 --- a/district-scripts/SWF/GateFlow_PumpBackFill.py +++ b/district-scripts/SWF/GateFlow_PumpBackFill.py @@ -1,186 +1,196 @@ -from java.util import Calendar -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance() -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -1) -startCal.set(Calendar.HOUR, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance() -# endCal.clear() -endCal.add(Calendar.DAY_OF_MONTH, 0) -endCal.set(Calendar.HOUR, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) - -officeID = "SWF" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = True -flowGroupGate = "ConduitGate_Total" -flowGroupTotal = "Project_Total" -flowGroupTurbine = "Turbine_Total" -flowGroupPumpOutBelow = "Pump_Out_Below_Total" -flowGroupPumpOut = "Pump_Out_Total" -flowGroupPumpIn = "Pump_In_Total" -flowGroupUncontrol = "Uncontrolled_Total" -flowGroupNTMWD = "Pump_NTMWD" -flowGroupUTRWD = "Pump_UTRWD" -flowGroupSS= "Pump_Sulphur_Springs" -flowGroupIrving = "Pump_Irving" -flowGroupLewisville = "Lewisville" -flowGroupUTRWD_Out = "UTRWD_Out" -flowGroupUTRWD_In = "UTRWD_In" -flowGroupIrv = "Irving" -flowGroupDenton = "Denton" -flowGroupBenbrook = "Benbrook" -flowGroupTRWD = "TRWD" -flowGroupWeatherford = "Weatherford" -flowGroupGeorgetown = "Georgetown" -flowGroupRound_Rock = "Round_Rock" -flowGroupBrushy_Ck = "Brushy_Ck" -flowGroupNTMWD_LVN = "NTMWD" -flowGroupCooper = "Cooper" -flowGroupEast_Fork = "East_Fork" -flowGroupTawakoni = "Tawakoni" - - -locationList = ["BNBT2", - "GGLT2", - "LEWT2", - "LVNT2", - "SCLT2" - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = False -FlowGroupList = ["BNBT2", - "GGLT2", - "LEWT2", - "LVNT2", - "SCLT2" - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) - #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOut) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpIn) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupNTMWD) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupSS) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupIrving) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupLewisville) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD_Out) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD_In) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupIrv) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupDenton) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupBenbrook) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTRWD) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupWeatherford) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGeorgetown) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupRound_Rock) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupBrushy_Ck) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupNTMWD_LVN) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupCooper) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupEast_Fork) - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTawakoni) -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - #compute_All_Flowgroups(officeID, location, startCal, endCal) - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance() + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -1) + startCal.set(Calendar.HOUR, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance() + # endCal.clear() + endCal.add(Calendar.DAY_OF_MONTH, 0) + endCal.set(Calendar.HOUR, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + # endCal.set(Calendar.YEAR, 2015) + # endCal.set(Calendar.MONTH, 11) + + officeID = "SWF" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + # by changing the "flowGroup" variable. + calculateSingleFlowGroups = True + flowGroupGate = "ConduitGate_Total" + flowGroupTotal = "Project_Total" + flowGroupTurbine = "Turbine_Total" + flowGroupPumpOutBelow = "Pump_Out_Below_Total" + flowGroupPumpOut = "Pump_Out_Total" + flowGroupPumpIn = "Pump_In_Total" + flowGroupUncontrol = "Uncontrolled_Total" + flowGroupNTMWD = "Pump_NTMWD" + flowGroupUTRWD = "Pump_UTRWD" + flowGroupSS= "Pump_Sulphur_Springs" + flowGroupIrving = "Pump_Irving" + flowGroupLewisville = "Lewisville" + flowGroupUTRWD_Out = "UTRWD_Out" + flowGroupUTRWD_In = "UTRWD_In" + flowGroupIrv = "Irving" + flowGroupDenton = "Denton" + flowGroupBenbrook = "Benbrook" + flowGroupTRWD = "TRWD" + flowGroupWeatherford = "Weatherford" + flowGroupGeorgetown = "Georgetown" + flowGroupRound_Rock = "Round_Rock" + flowGroupBrushy_Ck = "Brushy_Ck" + flowGroupNTMWD_LVN = "NTMWD" + flowGroupCooper = "Cooper" + flowGroupEast_Fork = "East_Fork" + flowGroupTawakoni = "Tawakoni" + + + locationList = ["BNBT2", + "GGLT2", + "LEWT2", + "LVNT2", + "SCLT2" + ] + + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = False + FlowGroupList = ["BNBT2", + "GGLT2", + "LEWT2", + "LVNT2", + "SCLT2" + ] + + + if calculateSingleFlowGroups: + for location in locationList: + print("Now Running", location, "SINGLE") + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGate) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTotal) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTurbine) + #compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUncontrol) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOutBelow) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpOut) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupPumpIn) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupNTMWD) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupSS) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupIrving) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupLewisville) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD_Out) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupUTRWD_In) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupIrv) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupDenton) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupBenbrook) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTRWD) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupWeatherford) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupGeorgetown) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupRound_Rock) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupBrushy_Ck) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupNTMWD_LVN) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupCooper) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupEast_Fork) + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroupTawakoni) + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + #compute_All_Flowgroups(officeID, location, startCal, endCal) + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWF/GateSettings.py b/district-scripts/SWF/GateSettings.py index 1a0a938..b94e476 100644 --- a/district-scripts/SWF/GateSettings.py +++ b/district-scripts/SWF/GateSettings.py @@ -1,79 +1,89 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from usace.rowcps.headless import LoggingOptions - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Gate Settings object -gateSettings = registry.getCalculation(1.0, "Gate Settings") - -# configure the start calendar -startCal = Calendar.getInstance() -#startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.set(Calendar.HOUR, 0) ######use Calendar.HOUR_OF_DAY -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance() -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.clear() -#endCal.set(Calendar.YEAR, 2016) -#endCal.set(Calendar.MONTH, 4) - - -# gateSettings contains four callable methods -# void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; -# void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; -# void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; -# void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; - -gateSettings.createGateSettingsOutletFromTs("SWF", "FFLT2", startCal.getTime(), endCal.getTime(), "Release", "FFLT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "EAMT2", startCal.getTime(), endCal.getTime(), "Release", "EAMT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "TRNT2", startCal.getTime(), endCal.getTime(), "Release", "TRNT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "BPRT2", startCal.getTime(), endCal.getTime(), "Release", "BPRT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "LLST2", startCal.getTime(), endCal.getTime(), "Release", "LLST2.Opening.Const.0.0.Rev-BRA-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "GBYT2", startCal.getTime(), endCal.getTime(), "Release", "GBYT2.Opening.Const.0.0.Rev-BRA-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "PSMT2", startCal.getTime(), endCal.getTime(), "Release", "PSMT2.Opening.Const.0.0.Rev-BRA-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "MSDT2", startCal.getTime(), endCal.getTime(), "Release", "MSDT2.Opening.Const.0.0.Rev-LCRA-Decodes" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "FRHT2", startCal.getTime(), endCal.getTime(), "Release", "FRHT2.Opening.Const.0.0.Raw-Observer" ) -gateSettings.createGateSettingsOutletFromTs("SWF", "GPET2", startCal.getTime(), endCal.getTime(), "Release", "GPET2.Opening.Const.0.0.Raw-Observer" ) +from regi_python import regi_session, run_headless +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from usace.rowcps.headless import LoggingOptions + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # this gets a scriptable Gate Settings object + gateSettings = registry.getCalculation(1.0, "Gate Settings") + + # configure the start calendar + startCal = Calendar.getInstance() + #startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.set(Calendar.HOUR, 0) ######use Calendar.HOUR_OF_DAY + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance() + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.clear() + #endCal.set(Calendar.YEAR, 2016) + #endCal.set(Calendar.MONTH, 4) + + + # gateSettings contains four callable methods + # void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; + # void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; + # void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; + # void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; + + gateSettings.createGateSettingsOutletFromTs("SWF", "FFLT2", startCal.getTime(), endCal.getTime(), "Release", "FFLT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "EAMT2", startCal.getTime(), endCal.getTime(), "Release", "EAMT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "TRNT2", startCal.getTime(), endCal.getTime(), "Release", "TRNT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "BPRT2", startCal.getTime(), endCal.getTime(), "Release", "BPRT2.Opening.Const.0.0.Rev-TRWD-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "LLST2", startCal.getTime(), endCal.getTime(), "Release", "LLST2.Opening.Const.0.0.Rev-BRA-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "GBYT2", startCal.getTime(), endCal.getTime(), "Release", "GBYT2.Opening.Const.0.0.Rev-BRA-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "PSMT2", startCal.getTime(), endCal.getTime(), "Release", "PSMT2.Opening.Const.0.0.Rev-BRA-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "MSDT2", startCal.getTime(), endCal.getTime(), "Release", "MSDT2.Opening.Const.0.0.Rev-LCRA-Decodes" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "FRHT2", startCal.getTime(), endCal.getTime(), "Release", "FRHT2.Opening.Const.0.0.Raw-Observer" ) + gateSettings.createGateSettingsOutletFromTs("SWF", "GPET2", startCal.getTime(), endCal.getTime(), "Release", "GPET2.Opening.Const.0.0.Raw-Observer" ) + + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWF/InflowCalcComputeEvapAsFlow.py b/district-scripts/SWF/InflowCalcComputeEvapAsFlow.py index 589a7f6..fd6f4e3 100644 --- a/district-scripts/SWF/InflowCalcComputeEvapAsFlow.py +++ b/district-scripts/SWF/InflowCalcComputeEvapAsFlow.py @@ -1,49 +1,59 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone - - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -##startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -## -## -##startCal.clear() -##startCal.set(Calendar.YEAR, 2018) -##startCal.set(Calendar.MONTH, 11) -## -##endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -##endCal.clear() -##endCal.set(Calendar.YEAR, 2019) -##endCal.set(Calendar.MONTH, 0) -##endCal.set(Calendar.DAY_OF_MONTH, 7) - -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -# endCal.clear() -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -locationList = ["WTYT2","JSPT2","TBLT2","SCLT2","TXKT2","BSLT2","JFNT2","CLDL1", - "BPRT2","EAMT2","FLWT2","BNBT2","JPLT2","GPET2","RRLT2","LEWT2", - "GPVT2","LVNT2","FRHT2","TRNT2","DAWT2","BDWT2","FFLT2","PSMT2", - "GBYT2","ALAT2","ACTT2","PCTT2","BLNT2","STIT2","GGLT2","GNGT2", - "SOMT2","LLST2","TBRT2","SAGT2","HORT2","MSDT2","SMCT2"] - -for loc in locationList: - inflowCalc.computeEvapAsFlow("SWF", loc, startCal.getTime(), endCal.getTime()) +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from java.util import TimeZone + + + # this gets a ScriptableInflow instance. + inflowCalc = registry.getCalculation(1.0, "Inflow") + + # configure the start calendar + ##startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + ## + ## + ##startCal.clear() + ##startCal.set(Calendar.YEAR, 2018) + ##startCal.set(Calendar.MONTH, 11) + ## + ##endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + ##endCal.clear() + ##endCal.set(Calendar.YEAR, 2019) + ##endCal.set(Calendar.MONTH, 0) + ##endCal.set(Calendar.DAY_OF_MONTH, 7) + + startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # endCal.clear() + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + locationList = ["WTYT2","JSPT2","TBLT2","SCLT2","TXKT2","BSLT2","JFNT2","CLDL1", + "BPRT2","EAMT2","FLWT2","BNBT2","JPLT2","GPET2","RRLT2","LEWT2", + "GPVT2","LVNT2","FRHT2","TRNT2","DAWT2","BDWT2","FFLT2","PSMT2", + "GBYT2","ALAT2","ACTT2","PCTT2","BLNT2","STIT2","GGLT2","GNGT2", + "SOMT2","LLST2","TBRT2","SAGT2","HORT2","MSDT2","SMCT2"] + + for loc in locationList: + inflowCalc.computeEvapAsFlow("SWF", loc, startCal.getTime(), endCal.getTime()) + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWF/InflowCalcComputedInflow.py b/district-scripts/SWF/InflowCalcComputedInflow.py index ff2e4d9..99d5331 100644 --- a/district-scripts/SWF/InflowCalcComputedInflow.py +++ b/district-scripts/SWF/InflowCalcComputedInflow.py @@ -1,64 +1,74 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption +from regi_python import regi_session, run_headless -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar -##startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -## -## -##startCal.clear() -##startCal.set(Calendar.YEAR, 2019) -##startCal.set(Calendar.MONTH, 1) -## -##endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -##endCal.clear() -##endCal.set(Calendar.YEAR, 2019) -##endCal.set(Calendar.MONTH, 1) -##endCal.set(Calendar.DAY_OF_MONTH, 4) +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.add(Calendar.DAY_OF_MONTH, -4) -startCal.set(Calendar.HOUR, 0) ######use Calendar.HOUR_OF_DAY -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) + # this gets a ScriptableInflow instance. + inflowCalc = registry.getCalculation(1.0, "Inflow") -# inflowCalc includes a setComputationStorageOptions function, which takes in either one or many -# InflowComputationStorageOption values. This is used by computeInflow to determine if it should save additional -# computed values like evaporation as flow and project releases. -# -# The InflowComputationStorageOption enum contains two values: -# EVAP_AS_FLOW -# PROJECT_RELEASES -# -# None is supported by setComputationStorageOptions as well, and clears out all storage options. -# -# inflowCalc.setComputationStorageOptions is entirely optional, and if it's not used no additional computed values will -# be stored with the computed inflow -# -# Example uses: -#inflowCalc.setComputationStorageOptions(None) -#inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.EVAP_AS_FLOW) -#inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.PROJECT_RELEASES) + # configure the start calendar + ##startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + ## + ## + ##startCal.clear() + ##startCal.set(Calendar.YEAR, 2019) + ##startCal.set(Calendar.MONTH, 1) + ## + ##endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + ##endCal.clear() + ##endCal.set(Calendar.YEAR, 2019) + ##endCal.set(Calendar.MONTH, 1) + ##endCal.set(Calendar.DAY_OF_MONTH, 4) -#inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.EVAP_AS_FLOW, InflowComputationStorageOption.PROJECT_RELEASES) + startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + startCal.add(Calendar.DAY_OF_MONTH, -4) + startCal.set(Calendar.HOUR, 0) ######use Calendar.HOUR_OF_DAY + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + # inflowCalc includes a setComputationStorageOptions function, which takes in either one or many + # InflowComputationStorageOption values. This is used by computeInflow to determine if it should save additional + # computed values like evaporation as flow and project releases. + # + # The InflowComputationStorageOption enum contains two values: + # EVAP_AS_FLOW + # PROJECT_RELEASES + # + # None is supported by setComputationStorageOptions as well, and clears out all storage options. + # + # inflowCalc.setComputationStorageOptions is entirely optional, and if it's not used no additional computed values will + # be stored with the computed inflow + # + # Example uses: + #inflowCalc.setComputationStorageOptions(None) + #inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.EVAP_AS_FLOW) + #inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.PROJECT_RELEASES) -locationList = ["WTYT2","JSPT2","TBLT2","SCLT2","TXKT2","BSLT2","JFNT2","CLDL1", - "BPRT2","EAMT2","FLWT2","BNBT2","JPLT2","GPET2","RRLT2","LEWT2", - "GPVT2","LVNT2","FRHT2","TRNT2","DAWT2","BDWT2","FFLT2","PSMT2", - "GBYT2","ALAT2","ACTT2","PCTT2","BLNT2","STIT2","GGLT2","GNGT2", - "SOMT2","LLST2","TBRT2","SAGT2","HORT2","SMCT2","MSDT2"] -for loc in locationList: - inflowCalc.computeInflow("SWF", loc, startCal.getTime(), endCal.getTime()) + #inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.EVAP_AS_FLOW, InflowComputationStorageOption.PROJECT_RELEASES) + + + locationList = ["WTYT2","JSPT2","TBLT2","SCLT2","TXKT2","BSLT2","JFNT2","CLDL1", + "BPRT2","EAMT2","FLWT2","BNBT2","JPLT2","GPET2","RRLT2","LEWT2", + "GPVT2","LVNT2","FRHT2","TRNT2","DAWT2","BDWT2","FFLT2","PSMT2", + "GBYT2","ALAT2","ACTT2","PCTT2","BLNT2","STIT2","GGLT2","GNGT2", + "SOMT2","LLST2","TBRT2","SAGT2","HORT2","SMCT2","MSDT2"] + for loc in locationList: + inflowCalc.computeInflow("SWF", loc, startCal.getTime(), endCal.getTime()) + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/Big3-GateFlow.py b/district-scripts/SWL/Big3-GateFlow.py index bc72ce4..3b09287 100644 --- a/district-scripts/SWL/Big3-GateFlow.py +++ b/district-scripts/SWL/Big3-GateFlow.py @@ -1,134 +1,144 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) -startCal.set(Calendar.MILLISECOND, 0) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -# endCal.clear() -##################endCal.add(Calendar.DAY_OF_MONTH, 5) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = False -flowGroup = "ConduitGate_Total" -locationList = ["ACTT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True -FlowGroupList = ["Blue_Mtn_Dam", - "Nimrod_Dam", - "Clearwater_Dam", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance(timeZone) + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + startCal.set(Calendar.MILLISECOND, 0) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(timeZone) + # endCal.clear() + ##################endCal.add(Calendar.DAY_OF_MONTH, 5) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + # endCal.set(Calendar.YEAR, 2015) + # endCal.set(Calendar.MONTH, 11) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + # by changing the "flowGroup" variable. + calculateSingleFlowGroups = False + flowGroup = "ConduitGate_Total" + locationList = ["ACTT2", + # "MSDT2", + ] + + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = True + FlowGroupList = ["Blue_Mtn_Dam", + "Nimrod_Dam", + "Clearwater_Dam", + ] + + + if calculateSingleFlowGroups: + for location in locationList: + print("Now Running", location, "SINGLE") + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) + + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + compute_All_Flowgroups(officeID, location, startCal, endCal) + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/Big3-InflowCalcMultipleActions.py b/district-scripts/SWL/Big3-InflowCalcMultipleActions.py index 25340e4..5a8378e 100644 --- a/district-scripts/SWL/Big3-InflowCalcMultipleActions.py +++ b/district-scripts/SWL/Big3-InflowCalcMultipleActions.py @@ -1,125 +1,135 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): - # Takes in locations defined by user in group and computes the given command at the given station. - try: - if function.lower() == "cloneinflows": - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - elif function.lower() == "computeinflow": - inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) - elif function.lower() == "zeronegatives": - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - elif function.lower() == "balanceall": - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - elif function.lower() == "autoadjust": - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) - else: - print "Input command", function, "is not recognized. Please edit your input and try again." - except Exception as e: - print "Error Completing action {0} at {1} {2}".format(function, officeID, location) - print e - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar' -#startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -timeZone = TimeZone.getTimeZone("US/Central") - -#startCal.clear() -#startCal.set(Calendar.YEAR, 2015) -#startCal.set(Calendar.MONTH, 4) - -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -7) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -endCal = Calendar.getInstance(timeZone) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" -# If the Auto Adjust command is not used, these arguments will have no influence on the other commands. -useLimits_ON = False -freezeRain_ON = False - -# Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. -# The action must come first, and they must be separated by a "@" symbol. -# Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. -actions = ["computeInflow @ Blue_Mtn_Dam", - "cloneInflows @ Blue_Mtn_Dam", - "autoAdjust @ Blue_Mtn_Dam", - "computeInflow @ Nimrod_Dam", - "cloneInflows @ Nimrod_Dam", - "autoAdjust @ Nimrod_Dam", - "computeInflow @ Clearwater_Dam", - "cloneInflows @ Clearwater_Dam", - "autoAdjust @ Clearwater_Dam", - ] - -for command in actions: - location = command.split('@')[1].strip() - function = command.split('@')[0].strip() - print "" - print "Now running", function, "at", location - print "" - inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): + # Takes in locations defined by user in group and computes the given command at the given station. + try: + if function.lower() == "cloneinflows": + inflowCalc.cloneInflows(officeID, location, startCal.getTime()) + elif function.lower() == "computeinflow": + inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) + elif function.lower() == "zeronegatives": + inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) + elif function.lower() == "balanceall": + inflowCalc.balanceAll(officeID, location, startCal.getTime()) + elif function.lower() == "autoadjust": + inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) + else: + print("Input command", function, "is not recognized. Please edit your input and try again.") + except Exception as e: + print("Error Completing action {0} at {1} {2}".format(function, officeID, location)) + print(e) + print("") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # this gets a scriptable Pool Percent object + inflowCalc = registry.getCalculation(1.0, "Inflow") + + # configure the start calendar' + #startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + timeZone = TimeZone.getTimeZone("US/Central") + + #startCal.clear() + #startCal.set(Calendar.YEAR, 2015) + #startCal.set(Calendar.MONTH, 4) + + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -7) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + endCal = Calendar.getInstance(timeZone) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # inflowCalc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + + # Each method takes the following arguments: + # officeId + # locationId + # startDate + + # autoAdjust also takes booleans: + # useLimits + # freezeRain + + # UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, + # the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" + # If the Auto Adjust command is not used, these arguments will have no influence on the other commands. + useLimits_ON = False + freezeRain_ON = False + + # Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. + # The action must come first, and they must be separated by a "@" symbol. + # Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. + actions = ["computeInflow @ Blue_Mtn_Dam", + "cloneInflows @ Blue_Mtn_Dam", + "autoAdjust @ Blue_Mtn_Dam", + "computeInflow @ Nimrod_Dam", + "cloneInflows @ Nimrod_Dam", + "autoAdjust @ Nimrod_Dam", + "computeInflow @ Clearwater_Dam", + "cloneInflows @ Clearwater_Dam", + "autoAdjust @ Clearwater_Dam", + ] + + for command in actions: + location = command.split('@')[1].strip() + function = command.split('@')[0].strip() + print("") + print("Now running", function, "at", location) + print("") + inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/Millwd-Tri-Lks-GateFlow.py b/district-scripts/SWL/Millwd-Tri-Lks-GateFlow.py index 730f364..998bddc 100644 --- a/district-scripts/SWL/Millwd-Tri-Lks-GateFlow.py +++ b/district-scripts/SWL/Millwd-Tri-Lks-GateFlow.py @@ -1,135 +1,145 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) -startCal.set(Calendar.MILLISECOND, 0) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -# endCal.clear() -##################endCal.add(Calendar.DAY_OF_MONTH, 5) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = False -flowGroup = "ConduitGate_Total" -locationList = ["ACTT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True -FlowGroupList = ["Millwood_Dam", - "DeQueen_Dam", - "Dierks_Dam", - "Gillham_Dam", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance(timeZone) + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + startCal.set(Calendar.MILLISECOND, 0) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(timeZone) + # endCal.clear() + ##################endCal.add(Calendar.DAY_OF_MONTH, 5) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + # endCal.set(Calendar.YEAR, 2015) + # endCal.set(Calendar.MONTH, 11) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + # by changing the "flowGroup" variable. + calculateSingleFlowGroups = False + flowGroup = "ConduitGate_Total" + locationList = ["ACTT2", + # "MSDT2", + ] + + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = True + FlowGroupList = ["Millwood_Dam", + "DeQueen_Dam", + "Dierks_Dam", + "Gillham_Dam", + ] + + + if calculateSingleFlowGroups: + for location in locationList: + print("Now Running", location, "SINGLE") + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) + + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + compute_All_Flowgroups(officeID, location, startCal, endCal) + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/Millwd-Tri-Lks-InflowCalcMultipleActions.py b/district-scripts/SWL/Millwd-Tri-Lks-InflowCalcMultipleActions.py index 567bcb3..5c04e5a 100644 --- a/district-scripts/SWL/Millwd-Tri-Lks-InflowCalcMultipleActions.py +++ b/district-scripts/SWL/Millwd-Tri-Lks-InflowCalcMultipleActions.py @@ -1,129 +1,139 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): - # Takes in locations defined by user in group and computes the given command at the given station. - try: - if function.lower() == "cloneinflows": - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - elif function.lower() == "computeinflow": - inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) - elif function.lower() == "zeronegatives": - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - elif function.lower() == "balanceall": - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - elif function.lower() == "autoadjust": - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) - else: - print "Input command", function, "is not recognized. Please edit your input and try again." - except Exception as e: - print "Error Completing action {0} at {1} {2}".format(function, officeID, location) - print e - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar' -#startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -timeZone = TimeZone.getTimeZone("US/Central") - -#startCal.clear() -#startCal.set(Calendar.YEAR, 2015) -#startCal.set(Calendar.MONTH, 4) - -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -7) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -endCal = Calendar.getInstance(timeZone) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" -# If the Auto Adjust command is not used, these arguments will have no influence on the other commands. -useLimits_ON = False -freezeRain_ON = False - -# Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. -# The action must come first, and they must be separated by a "@" symbol. -# Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. -actions = ["computeInflow @ Dequeen_Dam", - "cloneInflows @ Dequeen_Dam", - "autoAdjust @ Dequeen_Dam", - "computeInflow @ Dierks_Dam", - "cloneInflows @ Dierks_Dam", - "autoAdjust @ Dierks_Dam", - "computeInflow @ Gillham_Dam", - "cloneInflows @ Gillham_Dam", - "autoAdjust @ Gillham_Dam", - "computeInflow @ Millwood_Dam", - "cloneInflows @ Millwood_Dam", - "autoAdjust @ Millwood_Dam", - ] - -for command in actions: - location = command.split('@')[1].strip() - function = command.split('@')[0].strip() - print "" - print "Now running", function, "at", location - print "" - inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): + # Takes in locations defined by user in group and computes the given command at the given station. + try: + if function.lower() == "cloneinflows": + inflowCalc.cloneInflows(officeID, location, startCal.getTime()) + elif function.lower() == "computeinflow": + inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) + elif function.lower() == "zeronegatives": + inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) + elif function.lower() == "balanceall": + inflowCalc.balanceAll(officeID, location, startCal.getTime()) + elif function.lower() == "autoadjust": + inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) + else: + print("Input command", function, "is not recognized. Please edit your input and try again.") + except Exception as e: + print("Error Completing action {0} at {1} {2}".format(function, officeID, location)) + print(e) + print("") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # this gets a scriptable Pool Percent object + inflowCalc = registry.getCalculation(1.0, "Inflow") + + # configure the start calendar' + #startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + timeZone = TimeZone.getTimeZone("US/Central") + + #startCal.clear() + #startCal.set(Calendar.YEAR, 2015) + #startCal.set(Calendar.MONTH, 4) + + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -7) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + endCal = Calendar.getInstance(timeZone) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # inflowCalc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + + # Each method takes the following arguments: + # officeId + # locationId + # startDate + + # autoAdjust also takes booleans: + # useLimits + # freezeRain + + # UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, + # the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" + # If the Auto Adjust command is not used, these arguments will have no influence on the other commands. + useLimits_ON = False + freezeRain_ON = False + + # Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. + # The action must come first, and they must be separated by a "@" symbol. + # Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. + actions = ["computeInflow @ Dequeen_Dam", + "cloneInflows @ Dequeen_Dam", + "autoAdjust @ Dequeen_Dam", + "computeInflow @ Dierks_Dam", + "cloneInflows @ Dierks_Dam", + "autoAdjust @ Dierks_Dam", + "computeInflow @ Gillham_Dam", + "cloneInflows @ Gillham_Dam", + "autoAdjust @ Gillham_Dam", + "computeInflow @ Millwood_Dam", + "cloneInflows @ Millwood_Dam", + "autoAdjust @ Millwood_Dam", + ] + + for command in actions: + location = command.split('@')[1].strip() + function = command.split('@')[0].strip() + print("") + print("Now running", function, "at", location) + print("") + inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/WhiteR-GateFlow.py b/district-scripts/SWL/WhiteR-GateFlow.py index 1cce0db..270a0f4 100644 --- a/district-scripts/SWL/WhiteR-GateFlow.py +++ b/district-scripts/SWL/WhiteR-GateFlow.py @@ -1,137 +1,147 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) -startCal.set(Calendar.MILLISECOND, 0) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -# endCal.clear() -##################endCal.add(Calendar.DAY_OF_MONTH, 5) -#endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = False -flowGroup = "ConduitGate_Total" -locationList = ["ACTT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True -FlowGroupList = ["Beaver_Dam", - "Table_Rock_Dam", - "Bull_Shoals_Dam", - "Norfork_Dam", - "GreersFerry_Dam", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + startCal = Calendar.getInstance(timeZone) + # startCal.clear() + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + # startCal.set(Calendar.YEAR, 2015) + # startCal.set(Calendar.MONTH, 9) + startCal.set(Calendar.MILLISECOND, 0) + + # create a java Calendar object that will be used to create the end Date + endCal = Calendar.getInstance(timeZone) + # endCal.clear() + ##################endCal.add(Calendar.DAY_OF_MONTH, 5) + #endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + # endCal.set(Calendar.YEAR, 2015) + # endCal.set(Calendar.MONTH, 11) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + # By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out + # or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate + # by changing the "flowGroup" variable. + calculateSingleFlowGroups = False + flowGroup = "ConduitGate_Total" + locationList = ["ACTT2", + # "MSDT2", + ] + + # the calculation can also be performed for all the associated groups + # the computeAll method takes: + # officeId + # projectId + # startDate + # endDate + # By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. + # Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. + + calculateAllFlowGroups = True + FlowGroupList = ["Beaver_Dam", + "Table_Rock_Dam", + "Bull_Shoals_Dam", + "Norfork_Dam", + "GreersFerry_Dam", + ] + + + if calculateSingleFlowGroups: + for location in locationList: + print("Now Running", location, "SINGLE") + compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) + + if calculateAllFlowGroups: + for location in FlowGroupList: + print("Now Running", location, "GROUP") + compute_All_Flowgroups(officeID, location, startCal, endCal) + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWL/WhiteR-InflowCalcMultipleActions.py b/district-scripts/SWL/WhiteR-InflowCalcMultipleActions.py index eb1fd6c..a92dbef 100644 --- a/district-scripts/SWL/WhiteR-InflowCalcMultipleActions.py +++ b/district-scripts/SWL/WhiteR-InflowCalcMultipleActions.py @@ -1,131 +1,141 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): - # Takes in locations defined by user in group and computes the given command at the given station. - try: - if function.lower() == "cloneinflows": - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - elif function.lower() == "computeinflow": - inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) - elif function.lower() == "zeronegatives": - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - elif function.lower() == "balanceall": - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - elif function.lower() == "autoadjust": - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) - else: - print "Input command", function, "is not recognized. Please edit your input and try again." - except Exception as e: - print "Error Completing action {0} at {1} {2}".format(function, officeID, location) - print e - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar' -#startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -timeZone = TimeZone.getTimeZone("US/Central") - -#startCal.clear() -#startCal.set(Calendar.YEAR, 2015) -#startCal.set(Calendar.MONTH, 4) - -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -7) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -endCal = Calendar.getInstance(timeZone) -endCal.add(Calendar.DAY_OF_MONTH, 1) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -officeID = "SWL" - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" -# If the Auto Adjust command is not used, these arguments will have no influence on the other commands. -useLimits_ON = True -freezeRain_ON = True - -# Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. -# The action must come first, and they must be separated by a "@" symbol. -# Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. -actions = ["computeInflow @ Beaver_Dam", - "cloneInflows @ Beaver_Dam", - "autoAdjust @ Beaver_Dam", - "computeInflow @ Table_Rock_Dam", - "cloneInflows @ Table_Rock_Dam", - "autoAdjust @ Table_Rock_Dam", - "computeInflow @ Bull_Shoals_Dam", - "cloneInflows @ Bull_Shoals_Dam", - "autoAdjust @ Bull_Shoals_Dam", - "computeInflow @ Norfork_Dam", - "cloneInflows @ Norfork_Dam", - "autoAdjust @ Nofork_Dam", - "computeInflow @ GreersFerry_Dam", - "cloneInflows @ GreersFerry_Dam", - "autoAdjust @ GreersFerry_Dam", - ] - -for command in actions: - location = command.split('@')[1].strip() - function = command.split('@')[0].strip() - print "" - print "Now running", function, "at", location - print "" - inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + # the java Calendar class is used to create java Date objects + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def inflow_Actions(function, officeID, location, startCal, endCal, uselimits, freezerain): + # Takes in locations defined by user in group and computes the given command at the given station. + try: + if function.lower() == "cloneinflows": + inflowCalc.cloneInflows(officeID, location, startCal.getTime()) + elif function.lower() == "computeinflow": + inflowCalc.computeInflow(officeID, location, startCal.getTime(), endCal.getTime()) + elif function.lower() == "zeronegatives": + inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) + elif function.lower() == "balanceall": + inflowCalc.balanceAll(officeID, location, startCal.getTime()) + elif function.lower() == "autoadjust": + inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) + else: + print("Input command", function, "is not recognized. Please edit your input and try again.") + except Exception as e: + print("Error Completing action {0} at {1} {2}".format(function, officeID, location)) + print(e) + print("") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # this gets a scriptable Pool Percent object + inflowCalc = registry.getCalculation(1.0, "Inflow") + + # configure the start calendar' + #startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + timeZone = TimeZone.getTimeZone("US/Central") + + #startCal.clear() + #startCal.set(Calendar.YEAR, 2015) + #startCal.set(Calendar.MONTH, 4) + + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -7) + startCal.set(Calendar.HOUR_OF_DAY, 0) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + endCal = Calendar.getInstance(timeZone) + endCal.add(Calendar.DAY_OF_MONTH, 1) + endCal.set(Calendar.HOUR_OF_DAY, 0) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + officeID = "SWL" + + # inflowCalc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + + # Each method takes the following arguments: + # officeId + # locationId + # startDate + + # autoAdjust also takes booleans: + # useLimits + # freezeRain + + # UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, + # the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" + # If the Auto Adjust command is not used, these arguments will have no influence on the other commands. + useLimits_ON = True + freezeRain_ON = True + + # Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. + # The action must come first, and they must be separated by a "@" symbol. + # Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. + actions = ["computeInflow @ Beaver_Dam", + "cloneInflows @ Beaver_Dam", + "autoAdjust @ Beaver_Dam", + "computeInflow @ Table_Rock_Dam", + "cloneInflows @ Table_Rock_Dam", + "autoAdjust @ Table_Rock_Dam", + "computeInflow @ Bull_Shoals_Dam", + "cloneInflows @ Bull_Shoals_Dam", + "autoAdjust @ Bull_Shoals_Dam", + "computeInflow @ Norfork_Dam", + "cloneInflows @ Norfork_Dam", + "autoAdjust @ Nofork_Dam", + "computeInflow @ GreersFerry_Dam", + "cloneInflows @ GreersFerry_Dam", + "autoAdjust @ GreersFerry_Dam", + ] + + for command in actions: + location = command.split('@')[1].strip() + function = command.split('@')[0].strip() + print("") + print("Now running", function, "at", location) + print("") + inflow_Actions(function, officeID, location, startCal, endCal, useLimits_ON, freezeRain_ON) + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup1.py b/district-scripts/SWT/GateFlowGroup1.py index b457d09..9018dc7 100644 --- a/district-scripts/SWT/GateFlowGroup1.py +++ b/district-scripts/SWT/GateFlowGroup1.py @@ -1,146 +1,156 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - -# -# GROUP 1 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN THE FIRST 2 MINUTES OF THE TOP OF THE HOUR) -# - -#FOSS -gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Project_Total") -gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Gated_Total") - -#FCOB -gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Project_Total") -gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Gated_Total") - -#SKIA -gateCalc.computeFlowGroup("SWT", "SKIA", startCal.getTime(), endCal.getTime(), "Flow.SKIA.Project_Total") -gateCalc.computeFlowGroup("SWT", "SKIA", startCal.getTime(), endCal.getTime(), "Flow.SKIA.Gated_Total") - -#HEYB -gateCalc.computeFlowGroup("SWT", "HEYB", startCal.getTime(), endCal.getTime(), "Flow.HEYB.Project_Total") -gateCalc.computeFlowGroup("SWT", "HEYB", startCal.getTime(), endCal.getTime(), "Flow.HEYB.Gated_Total") - -#KAWL -gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Project_Total") -gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Gated_Total") -gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Turbine_Total") - -#OOLO -gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Project_Total") -gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Gated_Total") - -#COPA -gateCalc.computeFlowGroup("SWT", "COPA", startCal.getTime(), endCal.getTime(), "Flow.COPA.Project_Total") -gateCalc.computeFlowGroup("SWT", "COPA", startCal.getTime(), endCal.getTime(), "Flow.COPA.Gated_Total") - -#HULA -gateCalc.computeFlowGroup("SWT", "HULA", startCal.getTime(), endCal.getTime(), "Flow.HULA.Project_Total") -gateCalc.computeFlowGroup("SWT", "HULA", startCal.getTime(), endCal.getTime(), "Flow.HULA.Gated_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + # + # GROUP 1 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN THE FIRST 2 MINUTES OF THE TOP OF THE HOUR) + # + + #FOSS + gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Project_Total") + gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Gated_Total") + + #FCOB + gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Project_Total") + gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Gated_Total") + + #SKIA + gateCalc.computeFlowGroup("SWT", "SKIA", startCal.getTime(), endCal.getTime(), "Flow.SKIA.Project_Total") + gateCalc.computeFlowGroup("SWT", "SKIA", startCal.getTime(), endCal.getTime(), "Flow.SKIA.Gated_Total") + + #HEYB + gateCalc.computeFlowGroup("SWT", "HEYB", startCal.getTime(), endCal.getTime(), "Flow.HEYB.Project_Total") + gateCalc.computeFlowGroup("SWT", "HEYB", startCal.getTime(), endCal.getTime(), "Flow.HEYB.Gated_Total") + + #KAWL + gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Project_Total") + gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Gated_Total") + gateCalc.computeFlowGroup("SWT", "KAWL", startCal.getTime(), endCal.getTime(), "Flow.KAWL.Turbine_Total") + + #OOLO + gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Project_Total") + gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Gated_Total") + + #COPA + gateCalc.computeFlowGroup("SWT", "COPA", startCal.getTime(), endCal.getTime(), "Flow.COPA.Project_Total") + gateCalc.computeFlowGroup("SWT", "COPA", startCal.getTime(), endCal.getTime(), "Flow.COPA.Gated_Total") -#ELKC -gateCalc.computeFlowGroup("SWT", "ELKC", startCal.getTime(), endCal.getTime(), "Flow.ELKC.Project_Total") -gateCalc.computeFlowGroup("SWT", "ELKC", startCal.getTime(), endCal.getTime(), "Flow.ELKC.Gated_Total") + #HULA + gateCalc.computeFlowGroup("SWT", "HULA", startCal.getTime(), endCal.getTime(), "Flow.HULA.Project_Total") + gateCalc.computeFlowGroup("SWT", "HULA", startCal.getTime(), endCal.getTime(), "Flow.HULA.Gated_Total") -#FALL -gateCalc.computeFlowGroup("SWT", "FALL", startCal.getTime(), endCal.getTime(), "Flow.FALL.Project_Total") -gateCalc.computeFlowGroup("SWT", "FALL", startCal.getTime(), endCal.getTime(), "Flow.FALL.Gated_Total") + #ELKC + gateCalc.computeFlowGroup("SWT", "ELKC", startCal.getTime(), endCal.getTime(), "Flow.ELKC.Project_Total") + gateCalc.computeFlowGroup("SWT", "ELKC", startCal.getTime(), endCal.getTime(), "Flow.ELKC.Gated_Total") + #FALL + gateCalc.computeFlowGroup("SWT", "FALL", startCal.getTime(), endCal.getTime(), "Flow.FALL.Project_Total") + gateCalc.computeFlowGroup("SWT", "FALL", startCal.getTime(), endCal.getTime(), "Flow.FALL.Gated_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup2.py b/district-scripts/SWT/GateFlowGroup2.py index acb3122..8beac17 100644 --- a/district-scripts/SWT/GateFlowGroup2.py +++ b/district-scripts/SWT/GateFlowGroup2.py @@ -1,123 +1,133 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - -# -# GROUP 2 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN THE FIRST 2 - 4 MINUTES OF THE TOP OF THE HOUR) -# - -#ARCA -gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Project_Total") -gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Gated_Total") - -#ARBU -gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Project_Total") -gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Gated_Total") - -#BIRC -gateCalc.computeFlowGroup("SWT", "BIRC", startCal.getTime(), endCal.getTime(), "Flow.BIRC.Project_Total") -gateCalc.computeFlowGroup("SWT", "BIRC", startCal.getTime(), endCal.getTime(), "Flow.BIRC.Gated_Total") - -#ROBE -gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Project_Total") -gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Gated_Total") -gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Turbine_Total") - -#WAUR -gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Project_Total") -gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Gated_Total") - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + # + # GROUP 2 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN THE FIRST 2 - 4 MINUTES OF THE TOP OF THE HOUR) + # + + #ARCA + gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Project_Total") + gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Gated_Total") + + #ARBU + gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Project_Total") + gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Gated_Total") + + #BIRC + gateCalc.computeFlowGroup("SWT", "BIRC", startCal.getTime(), endCal.getTime(), "Flow.BIRC.Project_Total") + gateCalc.computeFlowGroup("SWT", "BIRC", startCal.getTime(), endCal.getTime(), "Flow.BIRC.Gated_Total") + + #ROBE + gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Project_Total") + gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Gated_Total") + gateCalc.computeFlowGroup("SWT", "ROBE", startCal.getTime(), endCal.getTime(), "Flow.ROBE.Turbine_Total") + + #WAUR + gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Project_Total") + gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Gated_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup3.py b/district-scripts/SWT/GateFlowGroup3.py index 7b962f6..cf5a667 100644 --- a/district-scripts/SWT/GateFlowGroup3.py +++ b/district-scripts/SWT/GateFlowGroup3.py @@ -1,134 +1,144 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.DAY_OF_MONTH, -12) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - -# -# GROUP 3 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 5 TO 8 MINUTES OF THE TOP OF THE HOUR) -# - -#COUN -gateCalc.computeFlowGroup("SWT", "COUN", startCal.getTime(), endCal.getTime(), "Flow.COUN.Project_Total") -gateCalc.computeFlowGroup("SWT", "COUN", startCal.getTime(), endCal.getTime(), "Flow.COUN.Gated_Total") - -#HUGO -gateCalc.computeFlowGroup("SWT", "HUGO", startCal.getTime(), endCal.getTime(), "Flow.HUGO.Project_Total") -gateCalc.computeFlowGroup("SWT", "HUGO", startCal.getTime(), endCal.getTime(), "Flow.HUGO.Gated_Total") - -#MARI -gateCalc.computeFlowGroup("SWT", "MARI", startCal.getTime(), endCal.getTime(), "Flow.MARI.Project_Total") -gateCalc.computeFlowGroup("SWT", "MARI", startCal.getTime(), endCal.getTime(), "Flow.MARI.Gated_Total") - -#PATM -gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Project_Total") -gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Gated_Total") - -#FSUP -gateCalc.computeFlowGroup("SWT", "FSUP", startCal.getTime(), endCal.getTime(), "Flow.FSUP.Project_Total") -gateCalc.computeFlowGroup("SWT", "FSUP", startCal.getTime(), endCal.getTime(), "Flow.FSUP.Gated_Total") - -#CANT -gateCalc.computeFlowGroup("SWT", "CANT", startCal.getTime(), endCal.getTime(), "Flow.CANT.Project_Total") -gateCalc.computeFlowGroup("SWT", "CANT", startCal.getTime(), endCal.getTime(), "Flow.CANT.Gated_Total") - -#HUDS -gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Project_Total") -gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Gated_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.DAY_OF_MONTH, -12) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + # + # GROUP 3 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 5 TO 8 MINUTES OF THE TOP OF THE HOUR) + # + + #COUN + gateCalc.computeFlowGroup("SWT", "COUN", startCal.getTime(), endCal.getTime(), "Flow.COUN.Project_Total") + gateCalc.computeFlowGroup("SWT", "COUN", startCal.getTime(), endCal.getTime(), "Flow.COUN.Gated_Total") + + #HUGO + gateCalc.computeFlowGroup("SWT", "HUGO", startCal.getTime(), endCal.getTime(), "Flow.HUGO.Project_Total") + gateCalc.computeFlowGroup("SWT", "HUGO", startCal.getTime(), endCal.getTime(), "Flow.HUGO.Gated_Total") + + #MARI + gateCalc.computeFlowGroup("SWT", "MARI", startCal.getTime(), endCal.getTime(), "Flow.MARI.Project_Total") + gateCalc.computeFlowGroup("SWT", "MARI", startCal.getTime(), endCal.getTime(), "Flow.MARI.Gated_Total") + + #PATM + gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Project_Total") + gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Gated_Total") + + #FSUP + gateCalc.computeFlowGroup("SWT", "FSUP", startCal.getTime(), endCal.getTime(), "Flow.FSUP.Project_Total") + gateCalc.computeFlowGroup("SWT", "FSUP", startCal.getTime(), endCal.getTime(), "Flow.FSUP.Gated_Total") + + #CANT + gateCalc.computeFlowGroup("SWT", "CANT", startCal.getTime(), endCal.getTime(), "Flow.CANT.Project_Total") + gateCalc.computeFlowGroup("SWT", "CANT", startCal.getTime(), endCal.getTime(), "Flow.CANT.Gated_Total") + + #HUDS + gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Project_Total") + gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Gated_Total") + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup4.py b/district-scripts/SWT/GateFlowGroup4.py index 0a52c7e..c42c619 100644 --- a/district-scripts/SWT/GateFlowGroup4.py +++ b/district-scripts/SWT/GateFlowGroup4.py @@ -1,128 +1,138 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - - -# -# GROUP 4 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 8 TO 9 MINUTES PAST THE TOP OF THE HOUR) -# - -#DENI -gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Project_Total") -gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Gated_Total") - -#PINE -gateCalc.computeFlowGroup("SWT", "PINE", startCal.getTime(), endCal.getTime(), "Flow.PINE.Project_Total") -gateCalc.computeFlowGroup("SWT", "PINE", startCal.getTime(), endCal.getTime(), "Flow.PINE.Gated_Total") - -#BROK -gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Project_Total") -gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Gated_Total") - -#SARD -gateCalc.computeFlowGroup("SWT", "SARD", startCal.getTime(), endCal.getTime(), "Flow.SARD.Project_Total") -gateCalc.computeFlowGroup("SWT", "SARD", startCal.getTime(), endCal.getTime(), "Flow.SARD.Gated_Total") - -#EUFA -gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Project_Total") -gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Gated_Total") - - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + + # + # GROUP 4 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 8 TO 9 MINUTES PAST THE TOP OF THE HOUR) + # + + #DENI + gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Project_Total") + gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "DENI", startCal.getTime(), endCal.getTime(), "Flow.DENI.Gated_Total") + + #PINE + gateCalc.computeFlowGroup("SWT", "PINE", startCal.getTime(), endCal.getTime(), "Flow.PINE.Project_Total") + gateCalc.computeFlowGroup("SWT", "PINE", startCal.getTime(), endCal.getTime(), "Flow.PINE.Gated_Total") + + #BROK + gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Project_Total") + gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "BROK", startCal.getTime(), endCal.getTime(), "Flow.BROK.Gated_Total") + + #SARD + gateCalc.computeFlowGroup("SWT", "SARD", startCal.getTime(), endCal.getTime(), "Flow.SARD.Project_Total") + gateCalc.computeFlowGroup("SWT", "SARD", startCal.getTime(), endCal.getTime(), "Flow.SARD.Gated_Total") + + #EUFA + gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Project_Total") + gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "EUFA", startCal.getTime(), endCal.getTime(), "Flow.EUFA.Gated_Total") + + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup5.py b/district-scripts/SWT/GateFlowGroup5.py index 88d9996..f0133ba 100644 --- a/district-scripts/SWT/GateFlowGroup5.py +++ b/district-scripts/SWT/GateFlowGroup5.py @@ -1,113 +1,123 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - -# -# GROUP 5 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 19 TO 21 MINUTES PAST THE TOP OF THE HOUR) -# - -#MCGE -gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Project_Total") -gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Gated_Total") - -#BIGH -gateCalc.computeFlowGroup("SWT", "BIGH", startCal.getTime(), endCal.getTime(), "Flow.BIGH.Project_Total") -gateCalc.computeFlowGroup("SWT", "BIGH", startCal.getTime(), endCal.getTime(), "Flow.BIGH.Gated_Total") - -#KEMP -gateCalc.computeFlowGroup("SWT", "KEMP", startCal.getTime(), endCal.getTime(), "Flow.KEMP.Project_Total") -gateCalc.computeFlowGroup("SWT", "KEMP", startCal.getTime(), endCal.getTime(), "Flow.KEMP.Gated_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + # + # GROUP 5 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 19 TO 21 MINUTES PAST THE TOP OF THE HOUR) + # + + #MCGE + gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Project_Total") + gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Gated_Total") + + #BIGH + gateCalc.computeFlowGroup("SWT", "BIGH", startCal.getTime(), endCal.getTime(), "Flow.BIGH.Project_Total") + gateCalc.computeFlowGroup("SWT", "BIGH", startCal.getTime(), endCal.getTime(), "Flow.BIGH.Gated_Total") + + #KEMP + gateCalc.computeFlowGroup("SWT", "KEMP", startCal.getTime(), endCal.getTime(), "Flow.KEMP.Project_Total") + gateCalc.computeFlowGroup("SWT", "KEMP", startCal.getTime(), endCal.getTime(), "Flow.KEMP.Gated_Total") + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup6.py b/district-scripts/SWT/GateFlowGroup6.py index b3e4b90..933592d 100644 --- a/district-scripts/SWT/GateFlowGroup6.py +++ b/district-scripts/SWT/GateFlowGroup6.py @@ -1,146 +1,156 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -#startCal.set(Calendar.YEAR, 2025) -#startCal.set(Calendar.MONTH, 0) #e.g. 6 ==July -#startCal.set(Calendar.DAY_OF_MONTH, 14) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - - -# -# GROUP 6 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 30 TO 33 MINUTES PAST THE TOP OF THE HOUR) -# - -#WDMA -gateCalc.computeFlowGroup("SWT", "WDMA", startCal.getTime(), endCal.getTime(), "Flow.WDMA.Project_Total") -gateCalc.computeFlowGroup("SWT", "WDMA", startCal.getTime(), endCal.getTime(), "Flow.WDMA.Gated_Total") - -#WEBB -gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Project_Total") -gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Gated_Total") - -#WIST -gateCalc.computeFlowGroup("SWT", "WIST", startCal.getTime(), endCal.getTime(), "Flow.WIST.Project_Total") -gateCalc.computeFlowGroup("SWT", "WIST", startCal.getTime(), endCal.getTime(), "Flow.WIST.Gated_Total") - -#TENK -gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Project_Total") -gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Gated_Total") - -#FGIB -gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Project_Total") -gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Gated_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + #startCal.set(Calendar.YEAR, 2025) + #startCal.set(Calendar.MONTH, 0) #e.g. 6 ==July + #startCal.set(Calendar.DAY_OF_MONTH, 14) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + + # + # GROUP 6 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 30 TO 33 MINUTES PAST THE TOP OF THE HOUR) + # + + #WDMA + gateCalc.computeFlowGroup("SWT", "WDMA", startCal.getTime(), endCal.getTime(), "Flow.WDMA.Project_Total") + gateCalc.computeFlowGroup("SWT", "WDMA", startCal.getTime(), endCal.getTime(), "Flow.WDMA.Gated_Total") + + #WEBB + gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Project_Total") + gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "WEBB", startCal.getTime(), endCal.getTime(), "Flow.WEBB.Gated_Total") + + #WIST + gateCalc.computeFlowGroup("SWT", "WIST", startCal.getTime(), endCal.getTime(), "Flow.WIST.Project_Total") + gateCalc.computeFlowGroup("SWT", "WIST", startCal.getTime(), endCal.getTime(), "Flow.WIST.Gated_Total") + + #TENK + gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Project_Total") + gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "TENK", startCal.getTime(), endCal.getTime(), "Flow.TENK.Gated_Total") + + #FGIB + gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Project_Total") + gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "FGIB", startCal.getTime(), endCal.getTime(), "Flow.FGIB.Gated_Total") -#THUN -gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Project_Total") -gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Gated_Total") + #THUN + gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Project_Total") + gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Gated_Total") -#GSAL -gateCalc.computeFlowGroup("SWT", "GSAL", startCal.getTime(), endCal.getTime(), "Flow.GSAL.Project_Total") -gateCalc.computeFlowGroup("SWT", "GSAL", startCal.getTime(), endCal.getTime(), "Flow.GSAL.Gated_Total") + #GSAL + gateCalc.computeFlowGroup("SWT", "GSAL", startCal.getTime(), endCal.getTime(), "Flow.GSAL.Project_Total") + gateCalc.computeFlowGroup("SWT", "GSAL", startCal.getTime(), endCal.getTime(), "Flow.GSAL.Gated_Total") -#PENS -gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Project_Total") -gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Gated_Total") + #PENS + gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Project_Total") + gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "PENS", startCal.getTime(), endCal.getTime(), "Flow.PENS.Gated_Total") + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup7.py b/district-scripts/SWT/GateFlowGroup7.py index dcd3f19..21a0f89 100644 --- a/district-scripts/SWT/GateFlowGroup7.py +++ b/district-scripts/SWT/GateFlowGroup7.py @@ -1,139 +1,149 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -#remove or comment out the next line when done!! it was for a big backload ajm -#startCal.add(Calendar.MONTH, -10) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - - -# -# GROUP 7 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 33 TO 36 MINUTES PAST THE TOP OF THE HOUR) -# - -#CHOU -gateCalc.computeFlowGroup("SWT", "CHOU", startCal.getTime(), endCal.getTime(), "Flow.CHOU.Project_Total") -gateCalc.computeFlowGroup("SWT", "CHOU", startCal.getTime(), endCal.getTime(), "Flow.CHOU.Gated_Total") - -#NEWT -gateCalc.computeFlowGroup("SWT", "NEWT", startCal.getTime(), endCal.getTime(), "Flow.NEWT.Project_Total") -gateCalc.computeFlowGroup("SWT", "NEWT", startCal.getTime(), endCal.getTime(), "Flow.NEWT.Gated_Total") - -#TOMS -gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Project_Total") -gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Gated_Total") - -#TORO -gateCalc.computeFlowGroup("SWT", "TORO", startCal.getTime(), endCal.getTime(), "Flow.TORO.Project_Total") -gateCalc.computeFlowGroup("SWT", "TORO", startCal.getTime(), endCal.getTime(), "Flow.TORO.Gated_Total") - -#ALTU -gateCalc.computeFlowGroup("SWT", "ALTU", startCal.getTime(), endCal.getTime(), "Flow.ALTU.Project_Total") -gateCalc.computeFlowGroup("SWT", "ALTU", startCal.getTime(), endCal.getTime(), "Flow.ALTU.Gated_Total") - -#ELDR -gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Project_Total") -gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Gated_Total") - -#CHEN -gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Project_Total") -gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Gated_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + #remove or comment out the next line when done!! it was for a big backload ajm + #startCal.add(Calendar.MONTH, -10) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + + # + # GROUP 7 PROJECTS (SELF-TIMED TRANSMISSIONS WITHIN 33 TO 36 MINUTES PAST THE TOP OF THE HOUR) + # + + #CHOU + gateCalc.computeFlowGroup("SWT", "CHOU", startCal.getTime(), endCal.getTime(), "Flow.CHOU.Project_Total") + gateCalc.computeFlowGroup("SWT", "CHOU", startCal.getTime(), endCal.getTime(), "Flow.CHOU.Gated_Total") + + #NEWT + gateCalc.computeFlowGroup("SWT", "NEWT", startCal.getTime(), endCal.getTime(), "Flow.NEWT.Project_Total") + gateCalc.computeFlowGroup("SWT", "NEWT", startCal.getTime(), endCal.getTime(), "Flow.NEWT.Gated_Total") + + #TOMS + gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Project_Total") + gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Gated_Total") + + #TORO + gateCalc.computeFlowGroup("SWT", "TORO", startCal.getTime(), endCal.getTime(), "Flow.TORO.Project_Total") + gateCalc.computeFlowGroup("SWT", "TORO", startCal.getTime(), endCal.getTime(), "Flow.TORO.Gated_Total") + + #ALTU + gateCalc.computeFlowGroup("SWT", "ALTU", startCal.getTime(), endCal.getTime(), "Flow.ALTU.Project_Total") + gateCalc.computeFlowGroup("SWT", "ALTU", startCal.getTime(), endCal.getTime(), "Flow.ALTU.Gated_Total") + + #ELDR + gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Project_Total") + gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Gated_Total") -#JOHN -gateCalc.computeFlowGroup("SWT", "JOHN", startCal.getTime(), endCal.getTime(), "Flow.JOHN.Project_Total") -gateCalc.computeFlowGroup("SWT", "JOHN", startCal.getTime(), endCal.getTime(), "Flow.JOHN.Gated_Total") + #CHEN + gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Project_Total") + gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Gated_Total") + #JOHN + gateCalc.computeFlowGroup("SWT", "JOHN", startCal.getTime(), endCal.getTime(), "Flow.JOHN.Project_Total") + gateCalc.computeFlowGroup("SWT", "JOHN", startCal.getTime(), endCal.getTime(), "Flow.JOHN.Gated_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup8.py b/district-scripts/SWT/GateFlowGroup8.py index 965ff26..83c0b4b 100644 --- a/district-scripts/SWT/GateFlowGroup8.py +++ b/district-scripts/SWT/GateFlowGroup8.py @@ -1,107 +1,117 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - - -# -# GROUP 8 PROJECTS (SELF-TIMED TRANSMISSIONS FROM 42 MINUTES PAST THE TOP OF THE HOUR TO THE END OF THE HOUR) -# - -#MERE -gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Project_Total") -gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Gated_Total") - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + + # + # GROUP 8 PROJECTS (SELF-TIMED TRANSMISSIONS FROM 42 MINUTES PAST THE TOP OF THE HOUR TO THE END OF THE HOUR) + # + + #MERE + gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Project_Total") + gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Gated_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowGroup9.py b/district-scripts/SWT/GateFlowGroup9.py index 057e5d3..44550e5 100644 --- a/district-scripts/SWT/GateFlowGroup9.py +++ b/district-scripts/SWT/GateFlowGroup9.py @@ -1,108 +1,118 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.add(Calendar.HOUR, -7) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - - -# -# GROUP 9 PROJECTS (SELF-TIMED TRANSMISSIONS FROM 42 MINUTES PAST THE TOP OF THE HOUR TO THE END OF THE HOUR) -# - -#KEYS -gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Project_Total") -gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Turbine_Total") -gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Gated_Total") - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.add(Calendar.HOUR, -7) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + + # + # GROUP 9 PROJECTS (SELF-TIMED TRANSMISSIONS FROM 42 MINUTES PAST THE TOP OF THE HOUR TO THE END OF THE HOUR) + # + + #KEYS + gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Project_Total") + gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Turbine_Total") + gateCalc.computeFlowGroup("SWT", "KEYS", startCal.getTime(), endCal.getTime(), "Flow.KEYS.Gated_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/GateFlowHUDS-WS.py b/district-scripts/SWT/GateFlowHUDS-WS.py index bf31415..4332238 100644 --- a/district-scripts/SWT/GateFlowHUDS-WS.py +++ b/district-scripts/SWT/GateFlowHUDS-WS.py @@ -1,105 +1,115 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.add(Calendar.DAY_OF_MONTH, -5) -startCal.add(Calendar.HOUR, -7) -#remove or comment out the next line when done!! it was for a big backload ajm -#startCal.add(Calendar.MONTH, -5) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) -#endCal.add(Calendar.MONTH, -3) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") - -#HUDS -gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Pump_Out_Total") -gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Pump_In_Total") - - +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from java.util import TimeZone + from usace.rowcps.headless import LoggingOptions + + def compute_All_Flowgroups(officeID, location, startCal, endCal): + # Takes in locations defined by user in group and computes all flow groups + try: + gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) + except Exception as e: + print("Error Computing all Flow Groups at {0} {1}".format(officeID, location)) + print(e) + print('') + + + def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): + try: + gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) + except Exception as e: + print("Error Computing Flow Group {0} at {1}".format(officeID, location)) + print(e) + print('') + + # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + # LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # Time zone must be set because the Solaris time zone is UTC + timeZone = TimeZone.getTimeZone("US/Central") + + # Defaults to start of the day 5 days ago, and ends at the top of the current hour today + # configure the start calendar + startCal = Calendar.getInstance(timeZone) + startCal.add(Calendar.DAY_OF_MONTH, -5) + startCal.add(Calendar.HOUR, -7) + #remove or comment out the next line when done!! it was for a big backload ajm + #startCal.add(Calendar.MONTH, -5) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + + # configure the end calendar + endCal = Calendar.getInstance(timeZone) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + #endCal.add(Calendar.MONTH, -3) + + # Calendar can be adjusted using the following functions: + # startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. + # startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) + # startCal.set(Calendar.YEAR, 2020) # Sets the year + # startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) + + officeID = "SWT" + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + # gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") + + #HUDS + gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Pump_Out_Total") + gateCalc.computeFlowGroup("SWT", "HUDS", startCal.getTime(), endCal.getTime(), "Flow.HUDS.Pump_In_Total") + + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/SWT/WaterSupplyFlowGroup.py b/district-scripts/SWT/WaterSupplyFlowGroup.py index 79cc59e..8a7bb02 100644 --- a/district-scripts/SWT/WaterSupplyFlowGroup.py +++ b/district-scripts/SWT/WaterSupplyFlowGroup.py @@ -1,130 +1,140 @@ -from java.util import Calendar -from usace.rowcps.headless import LoggingOptions - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -#LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -# -# use the current date minus 5 days. -# -startCal = Calendar.getInstance() -#startCal.clear() -#startCal.set(Calendar.YEAR, 2016) -#startCal.set(Calendar.MONTH, 8) -startCal.add(Calendar.DAY_OF_MONTH, -5) -#startCal.set(Calendar.HOUR, 0) -#startCal.add(Calendar.HOUR, -4) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -print "this is the place to write the startCal!" -print startCal.getTime().toString() - -# create a java Calendar object that will be used to create the end Date -# use the current date. -# -endCal = Calendar.getInstance() -#remove the next line when the headless time options are fixed -#endCal.add(Calendar.DAY_OF_MONTH, 1) -#endCal.set(Calendar.HOUR, 16) -#endCal.set(Calendar.YEAR, 2018) -#endCal.set(Calendar.MONTH, 6) -#endCal.set(Calendar.DAY_OF_MONTH, 6) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -print "this is the place to write the endCal!" -print endCal.getTime().toString() - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate - - -# -# PROJECTS WITH WATER SUPPLY WITHDRAWS/RELEASES -# - - -#ARBU -gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Pump_Out_Total") - -#ARCA -gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Pump_Out_Total") - -#CHEN -gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Pump_Out_Total") - -#ELDR -gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Pump_Out_Total") - -#FCOB -gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Pump_Out_Total") - -#FOSS -gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Pump_Out_Total") - -#MCGE -gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Pump_Out_Total") - -#MERE -gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Pump_Out_Total") - -#OOLO -gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Pump_Out_Total") +from regi_python import regi_session, run_headless + + +def run_calculations(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar + from usace.rowcps.headless import LoggingOptions + + # Description of: LoggingOptions.setDbMessageLevel(int level) + # + # Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended + # level is 2, as this provides basic information about the time series + # retrieval/storage. + # + # Message Level | Description + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + # <=0 | Default value, does not do anything. Lower values do not change behavior. | + # 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | + # 2 | Adds message with name of time series, and the units to retrieve/store. | + # 3 | Adds message with the current time. | + # 4 | Adds message with first 10 dates and values from each time series. | + # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | + # --------------|-------------------------------------------------------------------------------------------------------------------------------| + + LoggingOptions.setDbMessageLevel(2) + + + # Description of: LoggingOptions.setMetricsEnabled(boolean value) + # + # Enables or disables the storage of REGI's Metric data pertaining to the + # performance of the application. This is incredibly helpful for identifying + # issues where the application takes an excessive amount of time to operate. + # + # Metrics also log the location of the files as an INFO message if they are + # enabled. + # + # By default, Metrics are disabled. + + #LoggingOptions.setMetricsEnabled(True) + + # not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of + # the implemented scriptable calculations + names = registry.getNames(1.0) + + # this retrieves a Gate Flow calculation object + gateCalc = registry.getCalculation(1.0, "Gate Flow") + + # the gate flow calculations requires a start and end time. + # here we create a java Calendar object that will be used to create the start Date + # + # use the current date minus 5 days. + # + startCal = Calendar.getInstance() + #startCal.clear() + #startCal.set(Calendar.YEAR, 2016) + #startCal.set(Calendar.MONTH, 8) + startCal.add(Calendar.DAY_OF_MONTH, -5) + #startCal.set(Calendar.HOUR, 0) + #startCal.add(Calendar.HOUR, -4) + startCal.set(Calendar.MINUTE, 0) + startCal.set(Calendar.SECOND, 0) + startCal.set(Calendar.MILLISECOND, 0) + + print("this is the place to write the startCal!") + print(startCal.getTime().toString()) + + # create a java Calendar object that will be used to create the end Date + # use the current date. + # + endCal = Calendar.getInstance() + #remove the next line when the headless time options are fixed + #endCal.add(Calendar.DAY_OF_MONTH, 1) + #endCal.set(Calendar.HOUR, 16) + #endCal.set(Calendar.YEAR, 2018) + #endCal.set(Calendar.MONTH, 6) + #endCal.set(Calendar.DAY_OF_MONTH, 6) + endCal.set(Calendar.MINUTE, 0) + endCal.set(Calendar.SECOND, 0) + endCal.set(Calendar.MILLISECOND, 0) + + print("this is the place to write the endCal!") + print(endCal.getTime().toString()) + + # the gateCalc object can perform its calculation for a single flow group + # the computeFlowGroup method takes: + # officeId + # projectId + # startDate + # endDate + + + # + # PROJECTS WITH WATER SUPPLY WITHDRAWS/RELEASES + # + + + #ARBU + gateCalc.computeFlowGroup("SWT", "ARBU", startCal.getTime(), endCal.getTime(), "Flow.ARBU.Pump_Out_Total") + + #ARCA + gateCalc.computeFlowGroup("SWT", "ARCA", startCal.getTime(), endCal.getTime(), "Flow.ARCA.Pump_Out_Total") + + #CHEN + gateCalc.computeFlowGroup("SWT", "CHEN", startCal.getTime(), endCal.getTime(), "Flow.CHEN.Pump_Out_Total") + + #ELDR + gateCalc.computeFlowGroup("SWT", "ELDR", startCal.getTime(), endCal.getTime(), "Flow.ELDR.Pump_Out_Total") + + #FCOB + gateCalc.computeFlowGroup("SWT", "FCOB", startCal.getTime(), endCal.getTime(), "Flow.FCOB.Pump_Out_Total") + + #FOSS + gateCalc.computeFlowGroup("SWT", "FOSS", startCal.getTime(), endCal.getTime(), "Flow.FOSS.Pump_Out_Total") + + #MCGE + gateCalc.computeFlowGroup("SWT", "MCGE", startCal.getTime(), endCal.getTime(), "Flow.MCGE.Pump_Out_Total") + + #MERE + gateCalc.computeFlowGroup("SWT", "MERE", startCal.getTime(), endCal.getTime(), "Flow.MERE.Pump_Out_Total") -#PATM -gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Pump_Out_Total") + #OOLO + gateCalc.computeFlowGroup("SWT", "OOLO", startCal.getTime(), endCal.getTime(), "Flow.OOLO.Pump_Out_Total") -#THUN -gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Pump_Out_Total") - -#TOMS -gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Pump_Out_Total") - -#WAUR -gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Pump_Out_Total") + #PATM + gateCalc.computeFlowGroup("SWT", "PATM", startCal.getTime(), endCal.getTime(), "Flow.PATM.Pump_Out_Total") + #THUN + gateCalc.computeFlowGroup("SWT", "THUN", startCal.getTime(), endCal.getTime(), "Flow.THUN.Pump_Out_Total") + + #TOMS + gateCalc.computeFlowGroup("SWT", "TOMS", startCal.getTime(), endCal.getTime(), "Flow.TOMS.Pump_Out_Total") + + #WAUR + gateCalc.computeFlowGroup("SWT", "WAUR", startCal.getTime(), endCal.getTime(), "Flow.WAUR.Pump_Out_Total") + + + +if __name__ == "__main__": + with regi_session(): + run_headless(run_calculations) diff --git a/district-scripts/legacy-examples/solaris/GateFlow.py b/district-scripts/legacy-examples/solaris/GateFlow.py deleted file mode 100644 index ef36bec..0000000 --- a/district-scripts/legacy-examples/solaris/GateFlow.py +++ /dev/null @@ -1,195 +0,0 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -# startCal.clear() -startCal.add(Calendar.DAY_OF_MONTH, -6) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -# startCal.set(Calendar.YEAR, 2015) -# startCal.set(Calendar.MONTH, 9) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -# endCal.clear() -endCal.add(Calendar.DAY_OF_MONTH, 5) -endCal.set(Calendar.HOUR_OF_DAY, 0) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -# endCal.set(Calendar.YEAR, 2015) -# endCal.set(Calendar.MONTH, 11) - -officeID = "SWF" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = True -flowGroup = "ConduitGate_Total" -locationList = ["ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "CLDL1", - "DAWT2", -# "GGLT2", -# "GNGT2", -# "GPVT2", -# "HORT2", -# "JFNT2", -# "JPLT2", -# "JSPT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "BPRT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "TBLT2", -# "TBRT2", -# "GPET2", -# "BSLT2", -# "SAGT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True -FlowGroupList = ["ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "DAWT2", - "GGLT2", -# "GNGT2", -# "GPVT2", -# "HORT2", -# "JPLT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "SAGT2", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - diff --git a/district-scripts/legacy-examples/solaris/GateSettings.py b/district-scripts/legacy-examples/solaris/GateSettings.py deleted file mode 100644 index e061cbd..0000000 --- a/district-scripts/legacy-examples/solaris/GateSettings.py +++ /dev/null @@ -1,75 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Gate Settings object -gateSettings = registry.getCalculation(1.0, "Gate Settings") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.clear() -endCal.set(Calendar.YEAR, 2015) -endCal.set(Calendar.MONTH, 6) - - -# gateSettings contains four callable methods -# void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; -# void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; -# void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; -# void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the specified input time series. -gateSettings.createGateSettingsOutletFromTs("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1", "WTYT2-TG1.Opening-Spillway_Gate.Const.0.0.MANUAL" ) - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the regi association configured input time series. -gateSettings.createGateSettingsOutlet("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1") - -# This is an example of a call that would create gate settings at all outlets at WTYT2 which are in the TainterGateWTY group from the association configured time series. -gateSettings.createGateSettingsGroup("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "WTYT2-TainterGateWTY" ) - -# This is an example of a call that would create gate settings for every outlet in a rating group at WTYT2. -gateSettings.createGateSettings("SWF", "WTYT2", startCal.getTime(), endCal.getTime() ) - - - diff --git a/district-scripts/legacy-examples/solaris/GateSettings.sh b/district-scripts/legacy-examples/solaris/GateSettings.sh deleted file mode 100644 index e33d758..0000000 --- a/district-scripts/legacy-examples/solaris/GateSettings.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//GateSettings.py diff --git a/district-scripts/legacy-examples/solaris/InflowAutoAdjust.sh b/district-scripts/legacy-examples/solaris/InflowAutoAdjust.sh deleted file mode 100644 index 482bf5a..0000000 --- a/district-scripts/legacy-examples/solaris/InflowAutoAdjust.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcAutoAdjust.py diff --git a/district-scripts/legacy-examples/solaris/InflowBalanceAll.sh b/district-scripts/legacy-examples/solaris/InflowBalanceAll.sh deleted file mode 100644 index 971daf8..0000000 --- a/district-scripts/legacy-examples/solaris/InflowBalanceAll.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcBalanceAll.py diff --git a/district-scripts/legacy-examples/solaris/InflowCalcAutoAdjust.py b/district-scripts/legacy-examples/solaris/InflowCalcAutoAdjust.py deleted file mode 100644 index f35ac31..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcAutoAdjust.py +++ /dev/null @@ -1,98 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - - -def auto_Adjust(officeID, location, startCal, useLimits, freezeRain): - # Takes in locations defined by user in group and adjusts the selected inflow. If a location fails or has an error, the script will continue. check the console log - # for any further information. - try: - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), useLimits, freezeRain) - except Exception as e: - print "Error Adjusting Values at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar - -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoAdjusts for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additional stations can be added -# to the end provided they follow the same format. UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" - -officeID = "SWF" -useLimits_ON = False -freezeRain_ON = False -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - auto_Adjust(officeID, location, startCal, useLimits_ON, freezeRain_ON) - - - diff --git a/district-scripts/legacy-examples/solaris/InflowCalcBalanceAll.py b/district-scripts/legacy-examples/solaris/InflowCalcBalanceAll.py deleted file mode 100644 index 895c5ff..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcBalanceAll.py +++ /dev/null @@ -1,91 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def balance_all(officeID, location, startCal): - # Takes in locations defined by user in group and balances the selected inflow - try: - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - except Exception as e: - print "Error Computing Balance all at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar - -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 1) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additonial stations can be added -# to the end provided they follow the same format. -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - balance_all(officeID, location, startCal) - - diff --git a/district-scripts/legacy-examples/solaris/InflowCalcClone.py b/district-scripts/legacy-examples/solaris/InflowCalcClone.py deleted file mode 100644 index 2207b7c..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcClone.py +++ /dev/null @@ -1,90 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def clone_Inflows(officeID, location, startCal): - # Takes in locations defined by user in group and clones the selected inflow - try: - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - except Exception as e: - print "Error Cloning Inflows at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar - -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 3) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This clones inflow for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additional stations can be added -# to the end provided they follow the same format. -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - ] -for location in locationList: - print "Now Running", location - clone_Inflows(officeID, location, startCal) - - diff --git a/district-scripts/legacy-examples/solaris/InflowCalcComputeEvapAsFlow.py b/district-scripts/legacy-examples/solaris/InflowCalcComputeEvapAsFlow.py deleted file mode 100644 index 3ab7b56..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcComputeEvapAsFlow.py +++ /dev/null @@ -1,23 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) - -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) - -# This computes and saves evap as flow for EUFA in May 2018 -inflowCalc.computeEvapAsFlow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) \ No newline at end of file diff --git a/district-scripts/legacy-examples/solaris/InflowCalcComputedInflow.py b/district-scripts/legacy-examples/solaris/InflowCalcComputedInflow.py deleted file mode 100644 index faf1ce4..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcComputedInflow.py +++ /dev/null @@ -1,25 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) - -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) - -# This computes and saves inflow for EUFA in May 2018 -# computeInflow saves the Computed Inflow, Evaporation as Flow, and Project Total Flow Group time series data -inflowCalc.computeInflow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) diff --git a/district-scripts/legacy-examples/solaris/InflowCalcMultipleActions.py b/district-scripts/legacy-examples/solaris/InflowCalcMultipleActions.py deleted file mode 100644 index e73296b..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcMultipleActions.py +++ /dev/null @@ -1,106 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def inflow_Actions(function, officeID, location, startCal, uselimits, freezerain): - # Takes in locations defined by user in group and computes the given command at the given station. - try: - if function.lower() == "cloneinflows": - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - elif function.lower() == "zeronegatives": - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - elif function.lower() == "balanceall": - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - elif function.lower() == "autoadjust": - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) - else: - print "Input command", function, "is not recognized. Please edit your input and try again." - except Exception as e: - print "Error Completing action {0} at {1} {2}".format(function, officeID, location) - print e - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar' -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) - -officeID = "SWF" - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" -# If the Auto Adjust command is not used, these arguments will have no influence on the other commands. -useLimits_ON = False -freezeRain_ON = False - -# Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. -# The action must come first, and they must be separated by a "@" symbol. -# Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. -actions = ["cloneInflows @ ALAT2", - "zeroNegatives @ ALAT2", - "cloneInflows @ ALAT2", - "balanceAll @ ALAT2", - "cloneInflows @ ALAT2", - "autoAdjust @ ALAT2", - ] - -for command in actions: - location = command.split('@')[1].strip() - function = command.split('@')[0].strip() - print "" - print "Now running", function, "at", location - print "" - inflow_Actions(function, officeID, location, startCal, useLimits_ON, freezeRain_ON) diff --git a/district-scripts/legacy-examples/solaris/InflowCalcZeroNegative.py b/district-scripts/legacy-examples/solaris/InflowCalcZeroNegative.py deleted file mode 100644 index 59f5e30..0000000 --- a/district-scripts/legacy-examples/solaris/InflowCalcZeroNegative.py +++ /dev/null @@ -1,93 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def zero_Negatives(officeID, location, startCal): - # Takes in locations defined by user in group and turns all negative values to 0 for the selected inflow. If a location fails or has an error, the script will continue. check the console log - # for any further information. - try: - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - except Exception as e: - print "Error Computing Zero Negatives at {0} {1}".format(officeID, location) - print e - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar - -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 1) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This zeroes any negatives for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additional stations can be added -# to the end provided they follow the same format. - -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - zero_Negatives(officeID, location, startCal) - - - diff --git a/district-scripts/legacy-examples/solaris/InflowClone.sh b/district-scripts/legacy-examples/solaris/InflowClone.sh deleted file mode 100644 index 0d790af..0000000 --- a/district-scripts/legacy-examples/solaris/InflowClone.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcClone.py diff --git a/district-scripts/legacy-examples/solaris/InflowComputed.sh b/district-scripts/legacy-examples/solaris/InflowComputed.sh deleted file mode 100644 index 4132189..0000000 --- a/district-scripts/legacy-examples/solaris/InflowComputed.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcComputedInflow.py diff --git a/district-scripts/legacy-examples/solaris/InflowEvapAsFlow.sh b/district-scripts/legacy-examples/solaris/InflowEvapAsFlow.sh deleted file mode 100644 index 5aa3868..0000000 --- a/district-scripts/legacy-examples/solaris/InflowEvapAsFlow.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcComputeEvapAsFlow.py diff --git a/district-scripts/legacy-examples/solaris/InflowMultiAction.sh b/district-scripts/legacy-examples/solaris/InflowMultiAction.sh deleted file mode 100644 index 9a1790a..0000000 --- a/district-scripts/legacy-examples/solaris/InflowMultiAction.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcMultipleActions.py diff --git a/district-scripts/legacy-examples/solaris/InflowZeroNegative.sh b/district-scripts/legacy-examples/solaris/InflowZeroNegative.sh deleted file mode 100644 index 001e661..0000000 --- a/district-scripts/legacy-examples/solaris/InflowZeroNegative.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//InflowCalcZeroNegative.py diff --git a/district-scripts/legacy-examples/solaris/RunHeadlessJython.sh b/district-scripts/legacy-examples/solaris/RunHeadlessJython.sh deleted file mode 100644 index cf1da70..0000000 --- a/district-scripts/legacy-examples/solaris/RunHeadlessJython.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -NOT_FOUND="notFound" - -PROGRAM_ROOT=$(realpath ..) -JAR_DIR=$PROGRAM_ROOT/lib -SYS=$JAR_DIR/sys -CWMS=$JAR_DIR/cwms -REGI=$JAR_DIR/regi -LIBRARY_PATH=$PROGRAM_ROOT/lib64 -JAVA_EXE=$PROGRAM_ROOT/jre64/bin/java -ARGS=("$@") - -export LD_LIBRARY_PATH=$LIBRARY_PATH:$LD_LIBRARY_PATH -echo "LD_LIBRARY_PATH updated to $LD_LIBRARY_PATH" - -ORACLE_URL=$(getProp cwms.dbi.ConnectUsingUrl @${NOT_FOUND} dbi.properties|cut -d@ -f2) -if [ $ORACLE_URL = $NOT_FOUND ] -then - echo "Unable to locate Oracle URL from Cwms configuration. Will be taken from credentials.properties" -fi - -echo "Found Oracle URL: $ORACLE_URL" - -# Get the office id from cwms.properties using the CWMS getProp script -OFFICE_ID=$(getProp cwms.OfficeID ${NOT_FOUND} cwms.properties $CWMS_HOME/config/properties) -if [ $OFFICE_ID = $NOT_FOUND ] -then - echo "Unable to locate OfficeID from Cwms configuration. Will be taken from credentials.properties" -fi - -echo "Found Office ID: $OFFICE_ID" - -# The password file is expected to be at the following (full) path. -PASSWORD_FILE=$CWMS_HOME/config/properties/dbi.conf -if [ ! -f $PASSWORD_FILE ] -then - echo "Unable to locate password file in Cwms configuration. Will be taken from credentials.properties" -fi - -SCRIPT="" -NAME_FOUND=false - -for ((i=0; i < ${#ARGS[@]}; i++)) -do - PARAM_NAME=$(echo "${ARGS[$i]}" | tr '[:lower:]' '[:upper:]') - - if [ "$NAME_FOUND" = true ] ; then - # Use the script name as the base file name for the log file - BASENAME="$(basename "${ARGS[$i]}")" # Get only the base file name. - SCRIPT="${BASENAME%%.*}" # Remove the extension - break - elif [ "$PARAM_NAME" = "-F" ] ; then - NAME_FOUND=true - fi -done - - - -JAVA_COMMAND="-cp $JAR_DIR/*:$REGI/*:$CWMS/*:$SYS/*:"\ -" -Doracle.url=jdbc:oracle:thin:@${ORACLE_URL}"\ -" -Doracle.officeId=$OFFICE_ID"\ -" -Dhec.passwd=$PASSWORD_FILE"\ -" -Djava.library.path=$LIBRARY_PATH"\ -" -DPLUGINS=$EXT"\ -" -Doracle.metrics.clientid=\"CWMS REGI-Headless-v5.0\""\ -" -Djava.util.logging.config.file=../config/properties/logging.properties"\ -" -Drowcps.timezone=America/Chicago"\ -" usace.rowcps.headless.RegiCLI"\ -" -p ..//examples//credentials.properties"\ -" ${ARGS[*]}" - -LOG_FILE=$CWMS_HOME/cronjobs/headless/logs/$(getStartFN regi-headless-"$SCRIPT") - -echo "Running jython $SCRIPT" -echo "Output going to: $LOG_FILE" -echo "Java Command:" -echo "$JAVA_EXE $JAVA_COMMAND" -eval "$JAVA_EXE" $JAVA_COMMAND &> "$LOG_FILE" -STATUS=$? - -echo "$SCRIPT process exited with code $STATUS" \ No newline at end of file diff --git a/district-scripts/legacy-examples/solaris/__init__.py b/district-scripts/legacy-examples/solaris/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/district-scripts/legacy-examples/solaris/flow.sh b/district-scripts/legacy-examples/solaris/flow.sh deleted file mode 100644 index cc017e5..0000000 --- a/district-scripts/legacy-examples/solaris/flow.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./RunHeadlessJython.sh -f ..//examples//GateFlow.py diff --git a/district-scripts/legacy-examples/windows/GateFlow.py b/district-scripts/legacy-examples/windows/GateFlow.py deleted file mode 100644 index ba56125..0000000 --- a/district-scripts/legacy-examples/windows/GateFlow.py +++ /dev/null @@ -1,196 +0,0 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -startCal.add(Calendar.DATE, -5) - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWF" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = True -flowGroup = "ConduitGate_Total" -locationList = ["ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "CLDL1", - "DAWT2", -# "GGLT2", -# "GNGT2", -# "GPVT2", -# "HORT2", -# "JFNT2", -# "JPLT2", -# "JSPT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "BPRT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "TBLT2", -# "TBRT2", -# "GPET2", -# "BSLT2", -# "SAGT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = True -FlowGroupList = ["ACTT2", - "ALAT2", - "BDWT2", - "BLNT2", - "BNBT2", - "DAWT2", - "GGLT2", -# "GNGT2", -# "GPVT2", -# "HORT2", -# "JPLT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "SAGT2", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - diff --git a/district-scripts/legacy-examples/windows/GateSettings.bat b/district-scripts/legacy-examples/windows/GateSettings.bat deleted file mode 100644 index 529540a..0000000 --- a/district-scripts/legacy-examples/windows/GateSettings.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\GateSettings.py diff --git a/district-scripts/legacy-examples/windows/GateSettings.py b/district-scripts/legacy-examples/windows/GateSettings.py deleted file mode 100644 index ff4cfcc..0000000 --- a/district-scripts/legacy-examples/windows/GateSettings.py +++ /dev/null @@ -1,86 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Gate Settings object -gateSettings = registry.getCalculation(1.0, "Gate Settings") - - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -startCal.add(Calendar.DATE, -5) - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - - -# gateSettings contains four callable methods -# void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; -# void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; -# void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; -# void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the specified input time series. -gateSettings.createGateSettingsOutletFromTs("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1", "WTYT2-TG1.Opening-Spillway_Gate.Const.0.0.MANUAL" ) - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the regi association configured input time series. -gateSettings.createGateSettingsOutlet("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1") - -# This is an example of a call that would create gate settings at all outlets at WTYT2 which are in the TainterGateWTY group from the association configured time series. -gateSettings.createGateSettingsGroup("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "WTYT2-TainterGateWTY" ) - -# This is an example of a call that would create gate settings for every outlet in a rating group at WTYT2. -gateSettings.createGateSettings("SWF", "WTYT2", startCal.getTime(), endCal.getTime() ) - - - diff --git a/district-scripts/legacy-examples/windows/InflowAutoAdjust.bat b/district-scripts/legacy-examples/windows/InflowAutoAdjust.bat deleted file mode 100644 index 49cb2d4..0000000 --- a/district-scripts/legacy-examples/windows/InflowAutoAdjust.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcAutoAdjust.py diff --git a/district-scripts/legacy-examples/windows/InflowBalanceAll.bat b/district-scripts/legacy-examples/windows/InflowBalanceAll.bat deleted file mode 100644 index 56d0265..0000000 --- a/district-scripts/legacy-examples/windows/InflowBalanceAll.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcBalanceAll.py diff --git a/district-scripts/legacy-examples/windows/InflowCalcAutoAdjust.py b/district-scripts/legacy-examples/windows/InflowCalcAutoAdjust.py deleted file mode 100644 index 508c05b..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcAutoAdjust.py +++ /dev/null @@ -1,104 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - - -def auto_Adjust(officeID, location, startCal, useLimits, freezeRain): - # Takes in locations defined by user in group and adjusts the selected inflow. If a location fails or has an error, the script will continue. check the console log - # for any further information. - try: - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), useLimits, freezeRain) - except Exception as e: - print "Error Adjusting Values at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Defaults to day one of the current month at 0000 -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.set(Calendar.DATE, 1) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoAdjusts for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additional stations can be added -# to the end provided they follow the same format. UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" - -officeID = "SWF" -useLimits_ON = False -freezeRain_ON = False -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - auto_Adjust(officeID, location, startCal, useLimits_ON, freezeRain_ON) - - - diff --git a/district-scripts/legacy-examples/windows/InflowCalcBalanceAll.py b/district-scripts/legacy-examples/windows/InflowCalcBalanceAll.py deleted file mode 100644 index 70eb4b2..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcBalanceAll.py +++ /dev/null @@ -1,97 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def balance_all(officeID, location, startCal): - # Takes in locations defined by user in group and balances the selected inflow - try: - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - except Exception as e: - print "Error Computing Balance all at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Defaults to day one of the current month at 0000 -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.set(Calendar.DATE, 1) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additonial stations can be added -# to the end provided they follow the same format. -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - balance_all(officeID, location, startCal) - - diff --git a/district-scripts/legacy-examples/windows/InflowCalcClone.py b/district-scripts/legacy-examples/windows/InflowCalcClone.py deleted file mode 100644 index fa068be..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcClone.py +++ /dev/null @@ -1,96 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def clone_Inflows(officeID, location, startCal): - # Takes in locations defined by user in group and clones the selected inflow - try: - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - except Exception as e: - print "Error Cloning Inflows at {0} {1}".format(officeID, location) - print e - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Defaults to day one of the current month at 0000 -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.set(Calendar.DATE, 1) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This clones inflow for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any order. Additional stations can be added -# to the end provided they follow the same format. -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", -# "BLNT2", -# "BNBT2", -# "CLDL1", -# "DAWT2", - "ACTT2", - ] -for location in locationList: - print "Now Running", location - clone_Inflows(officeID, location, startCal) - - diff --git a/district-scripts/legacy-examples/windows/InflowCalcComputeEvapAsFlow.py b/district-scripts/legacy-examples/windows/InflowCalcComputeEvapAsFlow.py deleted file mode 100644 index 356037b..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcComputeEvapAsFlow.py +++ /dev/null @@ -1,33 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -startCal.add(Calendar.DATE, -5) - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -# This computes and saves evap as flow for EUFA in May 2018 -inflowCalc.computeEvapAsFlow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) diff --git a/district-scripts/legacy-examples/windows/InflowCalcComputedInflow.py b/district-scripts/legacy-examples/windows/InflowCalcComputedInflow.py deleted file mode 100644 index dbdec6e..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcComputedInflow.py +++ /dev/null @@ -1,35 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") - -# Defaults to start of the day 5 days ago, and ends at the top of the current hour today -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) -startCal.add(Calendar.DATE, -5) - -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.set(Calendar.MINUTE, 0) -endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -# This computes and saves inflow for EUFA in May 2018 -# computeInflow saves the Computed Inflow, Evaporation as Flow, and Project Total Flow Group time series data -inflowCalc.computeInflow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) diff --git a/district-scripts/legacy-examples/windows/InflowCalcMultipleActions.py b/district-scripts/legacy-examples/windows/InflowCalcMultipleActions.py deleted file mode 100644 index 8722aa8..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcMultipleActions.py +++ /dev/null @@ -1,115 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions -import traceback - -def inflow_Actions(function, officeID, location, startCal, uselimits, freezerain): - # Takes in locations defined by user in group and computes the given command at the given station. - try: - if function.lower() == "cloneinflows": - inflowCalc.cloneInflows(officeID, location, startCal.getTime()) - elif function.lower() == "zeronegatives": - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - elif function.lower() == "balanceall": - inflowCalc.balanceAll(officeID, location, startCal.getTime()) - elif function.lower() == "autoadjust": - inflowCalc.autoAdjust(officeID, location, startCal.getTime(), uselimits, freezerain) - else: - print "Input command", function, "is not recognized. Please edit your input and try again." - except: - print "Error Completing action {0} at {1} {2}".format(function, officeID, location) - traceback.print_exc() - print "" -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Defaults to day one of the current month at 0000 -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.set(Calendar.DATE, 1) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -officeID = "SWF" - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# UseLimits and FreezeRain are also controllable arguments for AutoAdjust. By setting "useLimits_ON" to True, -# the function will use the "useLimits command. By setting it to "False", it will be turned off. This functions the same way for "freezeRain_ON" -# If the Auto Adjust command is not used, these arguments will have no influence on the other commands. -useLimits_ON = False -freezeRain_ON = False - -# Commands can be input in a list format as seen below. The format is as follows "[ACTION] @ [LOCATION]", reading like "Perform [ACITON] at [LOCATION]. -# The action must come first, and they must be separated by a "@" symbol. -# Spaces between the Action/Location and "@" symbol can vary, although 1 space is recommended for readability. Lines can be commented out as needed. -actions = ["cloneInflows @ ALAT2", - "zeroNegatives @ ALAT2", - "cloneInflows @ ALAT2", - "balanceAll @ ALAT2", - "cloneInflows @ ALAT2", - "autoAdjust @ ALAT2", - ] - -for command in actions: - location = command.split('@')[1].strip() - function = command.split('@')[0].strip() - print "" - print "Now running", function, "at", location - print "" - inflow_Actions(function, officeID, location, startCal, useLimits_ON, freezeRain_ON) diff --git a/district-scripts/legacy-examples/windows/InflowCalcZeroNegative.py b/district-scripts/legacy-examples/windows/InflowCalcZeroNegative.py deleted file mode 100644 index 8b93c2c..0000000 --- a/district-scripts/legacy-examples/windows/InflowCalcZeroNegative.py +++ /dev/null @@ -1,97 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions -import traceback - - -def zero_Negatives(officeID, location, startCal): - # Takes in locations defined by user in group and turns all negative values to 0 for the selected inflow. If a location fails or has an error, the script will continue. check the console log - # for any further information. - try: - inflowCalc.zeroNegatives(officeID, location, startCal.getTime()) - except: - print "Error Computing Zero Negatives at {0} {1}".format(officeID, location) - traceback.print_exc() - print "" - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - - -LoggingOptions.setDbMessageLevel(2) - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# Defaults to day one of the current month at 0000 -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -startCal.set(Calendar.DATE, 1) -startCal.set(Calendar.HOUR_OF_DAY, 0) -startCal.set(Calendar.MINUTE, 0) -startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.MILLISECOND, 0) - -# Calendar can be adjusted using the following functions: -# startCal.set(Calendar.DATE, 1) # Sets the date of the calendar. -# startCal.set(Calendar.HOUR_OF_DAY, 1) # Sets the hour of the day to 0100 (1-24) -# startCal.set(Calendar.YEAR, 2020) # Sets the year -# startCal.set(Calendar.MONTH, 4) # Sets the month (month 4 means May to Java) - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This zeroes any negatives for ACTT2 and ALAT2. Several locations are commented out and can be commented back in any -# order. Additional stations can be added to the end provided they follow the same format. - -officeID = "SWF" -locationList = ["ACTT2", - "ALAT2", - "TXKT2", - ] -for location in locationList: - print "Now Running", location - # Performs MonUtl function for the entire month - zero_Negatives(officeID, location, startCal) - - - diff --git a/district-scripts/legacy-examples/windows/InflowClone.bat b/district-scripts/legacy-examples/windows/InflowClone.bat deleted file mode 100644 index 33d5a7f..0000000 --- a/district-scripts/legacy-examples/windows/InflowClone.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcClone.py diff --git a/district-scripts/legacy-examples/windows/InflowComputed.bat b/district-scripts/legacy-examples/windows/InflowComputed.bat deleted file mode 100644 index 4e063c0..0000000 --- a/district-scripts/legacy-examples/windows/InflowComputed.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcComputedInflow.py diff --git a/district-scripts/legacy-examples/windows/InflowEvapAsFlow.bat b/district-scripts/legacy-examples/windows/InflowEvapAsFlow.bat deleted file mode 100644 index 3a55d38..0000000 --- a/district-scripts/legacy-examples/windows/InflowEvapAsFlow.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcComputeEvapAsFlow.py diff --git a/district-scripts/legacy-examples/windows/InflowMultiAction.bat b/district-scripts/legacy-examples/windows/InflowMultiAction.bat deleted file mode 100644 index 89b033f..0000000 --- a/district-scripts/legacy-examples/windows/InflowMultiAction.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcMultipleActions.py diff --git a/district-scripts/legacy-examples/windows/InflowZeroNegative.bat b/district-scripts/legacy-examples/windows/InflowZeroNegative.bat deleted file mode 100644 index bbfb3a6..0000000 --- a/district-scripts/legacy-examples/windows/InflowZeroNegative.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\InflowCalcZeroNegative.py diff --git a/district-scripts/legacy-examples/windows/RunHeadlessJython.bat b/district-scripts/legacy-examples/windows/RunHeadlessJython.bat deleted file mode 100644 index 1b5af80..0000000 --- a/district-scripts/legacy-examples/windows/RunHeadlessJython.bat +++ /dev/null @@ -1,47 +0,0 @@ -:: The headless scripts can also be executed from a bat file as demonstrated below -@echo off -setlocal enabledelayedexpansion - -set next_is_target=0 -for %%a in (%*) do ( - if !next_is_target! == 1 ( - set f_value=%%a - for %%b in ("!f_value!") do set "SCRIPT=%%~nb" - set next_is_target=0 - ) else ( - if "%%a"=="-f" ( - set next_is_target=1 - ) - ) -) - -set PROGRAM_ROOT=.. -set JAR_DIR=%PROGRAM_ROOT%\lib -set SYS=%JAR_DIR%\sys -set CWMS=%JAR_DIR%\cwms -set REGI=%JAR_DIR%\regi -set LIBRARY_PATH=%PROGRAM_ROOT%\lib64 -set JAVA_EXE=%PROGRAM_ROOT%\jre64\bin\java.exe -set ARGS=%* -for /F "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set DATE_TIME=%%I -set DATE_TIME=%DATE_TIME:~0,4%.%DATE_TIME:~4,2%.%DATE_TIME:~6,2%.%DATE_TIME:~8,2%.%DATE_TIME:~10,2% -set LOG_FILE=%CWMS_HOME%\cronjobs\headless\logs\regi-headless-%SCRIPT%.start.%DATE_TIME%.utc - -set JAVA_COMMAND=-cp %JAR_DIR%\*;%REGI%\*;%CWMS%\*;%SYS%\*; ^ --Dhec.passwd=%CWMS_HOME%\config\properties\dbi.conf ^ --Djava.library.path=%LIBRARY_PATH% ^ --DPLUGINS=%JAR_DIR%\ext ^ --Doracle.metrics.clientid="CWMS REGI-Headless-v5.0" ^ --Djava.util.logging.config.file=%PROGRAM_ROOT%\config\properties\logging.properties ^ --Drowcps.timezone=America\Chicago ^ -usace.rowcps.headless.RegiCLI ^ --p %PROGRAM_ROOT%\examples\credentials.properties ^ -%ARGS% - -echo Running CWMS-REGI Headless script %SCRIPT% -echo Output going to: %LOG_FILE% -echo Java command: -echo %JAVA_EXE% %JAVA_COMMAND% -%JAVA_EXE% %JAVA_COMMAND% > %LOG_FILE% 2>&1 -echo Status: %ERRORLEVEL% >> %LOG_FILE% -endlocal \ No newline at end of file diff --git a/district-scripts/legacy-examples/windows/__init__.py b/district-scripts/legacy-examples/windows/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/district-scripts/legacy-examples/windows/flow.bat b/district-scripts/legacy-examples/windows/flow.bat deleted file mode 100644 index b49557d..0000000 --- a/district-scripts/legacy-examples/windows/flow.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -:: The headless scripts can also be executed from a bat file as demonstrated below -RunHeadlessJython.bat -f ..\\examples\\GateFlow.py diff --git a/regi-headless/build.gradle b/regi-headless/build.gradle index c4a6bf1..fe64972 100644 --- a/regi-headless/build.gradle +++ b/regi-headless/build.gradle @@ -1,6 +1,9 @@ +import com.pswidersk.gradle.python.VenvTask + plugins { id 'regi-headless.deps-conventions' id 'regi-headless.java-conventions' + id 'com.pswidersk.python-plugin' version '3.2.16' } dependencies { @@ -45,6 +48,143 @@ jar { } } -test { - useJUnitPlatform() +pythonPlugin { + pythonVersion = "3.11.15" + condaVersion = "26.3.2-2" + condaInstaller = "Miniforge3" + installDir = file(layout.buildDirectory.dir("python")) +} + +tasks.register('installPythonBuildTools', VenvTask) { + group = 'build setup' + description = 'Installs Python packages needed to build and test the wheel.' + + venvExec = 'pip' + args = ['install', '--upgrade', 'pip', 'build', 'pytest'] + + outputs.file(layout.buildDirectory.file("python-build-tools/install.marker")) + + doLast { + def markerFile = layout.buildDirectory.file("python-build-tools/install.marker").get().asFile + markerFile.parentFile.mkdirs() + markerFile.text = "pip build pytest installed\n" + } +} + +tasks.register('bundlePython', Sync) { + description = 'Bundles Python scripts and creates the java_lib directory' + + dependsOn jar + + into layout.buildDirectory.dir("install/regi_python") + + inputs.dir("src/main/python") + inputs.file(jar.archiveFile) + inputs.files(configurations.runtimeClasspath) + inputs.property("version", project.version.toString()) + + from('src/main/python') { + include 'pyproject.toml' + filter { line -> line.replaceAll('@VERSION@', project.version.toString()) } + } + + from('src/main/python') { + exclude 'pyproject.toml' + } + + into('regi_python/lib') { + from configurations.runtimeClasspath + from jar.archiveFile + exclude "**/*.nbm" + } +} + +tasks.register('buildPythonWheel', VenvTask) { + group = "distribution" + description = "Builds a Python .whl file using the Gradle-managed Python environment." + + dependsOn bundlePython + dependsOn installPythonBuildTools + + workingDir = layout.buildDirectory.dir("install/regi_python").get().asFile + venvExec = "python" + args = ["-m", "build", "--wheel"] + + inputs.files(fileTree(layout.buildDirectory.dir("install/regi_python")) { + exclude "dist/**" + exclude "build/**" + exclude "*.egg-info/**" + }) + inputs.property("version", project.version.toString()) + outputs.dir(layout.buildDirectory.dir("install/regi_python/dist")) + + doFirst { + delete layout.buildDirectory.dir("install/regi_python/dist") + } + + doLast { + println "Python Wheel built in: ${workingDir}/dist" + } +} + +tasks.register('installPythonWheelForSmokeTest', VenvTask) { + group = 'verification' + description = 'Installs the built Python wheel into the Gradle-managed Python environment.' + + dependsOn buildPythonWheel + + venvExec = 'pip' + + inputs.files(fileTree(dir: "${buildDir}/install/regi_python/dist", include: '*.whl')) + outputs.file(layout.buildDirectory.file("test-python-wheel/install.marker")) + + doFirst { + def wheelFile = fileTree(dir: "${buildDir}/install/regi_python/dist", include: '*.whl').singleFile + args = ['install', '--force-reinstall', wheelFile.absolutePath] + } + + doLast { + def wheelFile = fileTree(dir: "${buildDir}/install/regi_python/dist", include: '*.whl').singleFile + def markerFile = layout.buildDirectory.file("test-python-wheel/install.marker").get().asFile + markerFile.parentFile.mkdirs() + markerFile.text = "${wheelFile.name}\n${wheelFile.length()} bytes\n" + } +} +tasks.register('testPythonWheel', VenvTask) { + group = 'verification' + description = 'Runs pytest against the installed Python wheel.' + + dependsOn installPythonWheelForSmokeTest + + venvExec = 'python' + args = ['-m', 'pytest', 'src/test/python'] + + inputs.files(fileTree(dir: 'src/test/python', include: '**/*.py')) + outputs.upToDateWhen { false } +} + +tasks.register('smokeTestDistrictScripts', VenvTask) { + group = 'verification' + description = 'Validates migrated district and example scripts against the Python entrypoint shape and Java scriptable APIs.' + + dependsOn installPythonBuildTools + + venvExec = 'python' + args = [ + '-m', 'pytest', + '-o', 'log_cli=true', + '--log-cli-level=INFO', + 'src/test/python/test_district_scripts.py' + ] + + inputs.files(fileTree(dir: '../district-scripts', include: '**/*.py')) + inputs.files(fileTree(dir: 'src/test/resources/usace/rowcps/headless/examples', include: '**/*.py')) + inputs.files(fileTree(dir: 'src/main/java/usace/rowcps/headless', include: '**/*.java')) + inputs.file('src/test/python/test_district_scripts.py') + outputs.upToDateWhen { false } +} + +check { + dependsOn testPythonWheel + dependsOn smokeTestDistrictScripts } diff --git a/regi-headless/src/main/java/usace/rowcps/headless/CLIOptions.java b/regi-headless/src/main/java/usace/rowcps/headless/CLIOptions.java deleted file mode 100644 index bf6a1f6..0000000 --- a/regi-headless/src/main/java/usace/rowcps/headless/CLIOptions.java +++ /dev/null @@ -1,341 +0,0 @@ -package usace.rowcps.headless; - -import hec.lang.PasswordFileEntry; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TimeZone; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.kohsuke.args4j.CmdLineException; -import org.kohsuke.args4j.Option; -import rma.services.ServiceLookup; -import rma.services.tz.TimeZoneDisplayService; - -/** - * - * @author ryan - */ -public class CLIOptions -{ - private static final Logger logger = Logger.getLogger(CLIOptions.class.getName()); - //public String rowcpsTimezone; - //public String oracleUrl; - //public String oracleUser; - //public String oraclePassword; - //private Map properties = new HashMap(); - Properties props; - - public final static String URL = "oracle.url"; - public final static String USER = "oracle.user"; - public final static String PASSWORD = "oracle.password"; - public final static String OFFICEID = "oracle.officeId"; - - public final static String TIMEZONE = "rowcps.timezone"; - public final static String PROJ_DIR = "rowcps.projectDir"; - public final static String PROJ_NAME = "rowcps.projectName"; - - public final static String HEC_PASSWD_FILE = "hec.passwd"; - - public CLIOptions() - { - this(System.getProperties()); - } - - public CLIOptions(Properties defaultProperties) - { - props = new Properties(defaultProperties); - } - - @Option(name = "-D", metaVar = "=", usage = "use value for given property") - private void setProperty(final String property) throws CmdLineException - { - String[] arr = property.split("="); - setProperty(arr); - } - - public void setProperty(String[] arr) throws CmdLineException - { - if (arr.length != 2) { - throw new CmdLineException("Properties must be specified in the form:" + - "="); - } - props.setProperty(arr[0], arr[1]); - //properties.put(arr[0], arr[1]); - } - - public Object getProperty(String key) - { - return props.get(key); - } - - /** - * @return the rowcpsTimezone - */ - public String getRowcpsTimezone() - { - return props.getProperty(TIMEZONE); - //return rowcpsTimezone; - } - - public File getRowcpsProjectDir() - { - File retval = null; - - String path = props.getProperty(PROJ_DIR); - if(path != null){ - retval = new File(path); - } - - return retval; - } - - @Option(name = "-D" + PROJ_DIR, metaVar = "", usage = "directory containing Regi project") - public void setRowcpsProjectDir(String filepath) - { - props.setProperty(PROJ_DIR, filepath); - } - - @Option(name = "-D" + HEC_PASSWD_FILE, metaVar = "", usage = "directory containing Regi project") - public void setHecPasswordFilepath(String filepath) - { - props.setProperty(HEC_PASSWD_FILE, filepath); - } - - public String getHecPasswordFilepath(){ - return props.getProperty(HEC_PASSWD_FILE); - } - - public PasswordFileEntry getHecPasswordFileEntry() - { - PasswordFileEntry retval = null; - - // String office = System.getProperty("cwms.dbi.OfficeId"); - String dburl = getOracleUrl(); - if (dburl != null && !dburl.isEmpty()) { - String instance = dburl; - - int idx = dburl.indexOf("@"); - if (idx != -1) { - instance = dburl.substring(idx + 1); - } - - hec.io.PasswordFile passwordFile = null; - try { - String filePath = getHecPasswordFilepath(); - passwordFile = new hec.io.PasswordFile(filePath, false); - retval = passwordFile.getEntry(instance); - - if (retval == null) { - /* - * System.out.println( - * "getConnectionInfo: Failed to find Password Entry for instance " - * + instance); - */ - logger.severe("getConnectionInfo: Failed to find Password Entry for instance " + instance); - - } -// // _connectionInfo = new -// // ConnectionInfo(office,dburl,entry.getUserName(),entry.getPassword()); -// _connectionLoginInfo = new ConnectionLoginInfoImpl(dburl, entry.getUserName(), entry.getPassword(), -// getOfficeId()); - } catch (java.io.IOException ioe) { - /* - * System.out.println( - * "getConnectionInfo: Error reading password file " + ioe); - */ - logger.severe("getConnectionInfo: Error reading password file " + ioe); - - } finally { - if (passwordFile != null) { - passwordFile.close(); - } - } - } - - return retval; - } - - - public String getRowcpsProjectName() - { - return props.getProperty(PROJ_NAME); - } - - @Option(name = "-D" + PROJ_NAME, usage = "name of Regi project") - public void setRowcpsProjectName(String name) - { - props.setProperty(PROJ_NAME, name); - } - - public String getOracleOfficeId() - { - return props.getProperty(OFFICEID); - } - - @Option(name = "-D" + OFFICEID, usage = "office id") - public void setOracleOfficeId(String id) - { - props.setProperty(OFFICEID, id); - } - - /** - * @param rowcpsTimezone the rowcpsTimezone to set - */ - @Option(name = "-D" + TIMEZONE) - public void setRowcpsTimezone(String rowcpsTimezone) throws CmdLineException - { - setProperty(new String[]{TIMEZONE, rowcpsTimezone}); - TimeZone timeZone = TimeZone.getTimeZone(rowcpsTimezone); - if(timeZone == null) - { - timeZone = TimeZone.getDefault(); - Logger.getLogger(CLIOptions.class.getName()).log(Level.WARNING, "Attempted to set invalid time zone to Regi Domain: "+rowcpsTimezone); - } - TimeZoneDisplayService timeZoneDisplayService = ServiceLookup.getTimeZoneDisplayService(); - timeZoneDisplayService.setTimeZone(timeZone); - } - - /** - * @return the oracleUrl - */ - public String getOracleUrl() - { - return props.getProperty(URL); - //return oracleUrl; - } - - /** - * @param oracleUrl the oracleUrl to set - */ - @Option(name = "-D" + URL) - public void setOracleUrl(String oracleUrl) throws CmdLineException - { - //this.oracleUrl = oracleUrl; - setProperty(new String[]{URL, oracleUrl}); - } - - /** - * @return the oracleUser - */ - public String getOracleUser() - { - String user = props.getProperty(USER); - - if (user == null) { - - PasswordFileEntry entry = getHecPasswordFileEntry(); - if (entry != null) { - user = entry.getUserName(); - } - - } - return user; - //return oracleUser; - } - - /** - * @param oracleUser the oracleUser to set - */ - @Option(name = "-D" + USER) - public void setOracleUser(String oracleUser) throws CmdLineException - { - //this.oracleUser = oracleUser; - setProperty(new String[]{USER, oracleUser}); - } - - /** - * @return the oraclePassword - */ - public char[] getOraclePassword() - { - char[] pass = null; - //return oraclePassword; - String passStr = props.getProperty(PASSWORD); - if (passStr != null) { - pass = passStr.toCharArray(); - } else { - PasswordFileEntry entry = getHecPasswordFileEntry(); - if(entry != null){ - pass = entry.getPassword().toCharArray(); - } - } - - return pass; - } - - /** - * @param oraclePassword the oraclePassword to set - */ - @Option(name = "-D" + PASSWORD) - public void setOraclePassword(String oraclePassword) throws CmdLineException - { - setProperty(new String[]{PASSWORD, oraclePassword}); - //this.oraclePassword = oraclePassword; - } - - @Option(name = "-p", aliases = {"-properties"}, metaVar = "", - usage = "import properties from given file") - public void importProperties(File file) - { - if (file != null && file.exists()) { - Properties fileProps = new Properties(); - - try (BufferedReader br = new BufferedReader(new FileReader(file))) { - fileProps.load(br); - - Set> entrySet = fileProps.entrySet(); - for (Map.Entry entry : entrySet) { - Object keyObj = entry.getKey(); - Object valueObj = entry.getValue(); - - if (keyObj != null && valueObj != null) { - props.put(keyObj, valueObj); - } - } - } catch (FileNotFoundException ex) { - Logger.getLogger(CLIOptions.class.getName()).log(Level.SEVERE, null, ex); - } catch (IOException ex) { - Logger.getLogger(CLIOptions.class.getName()).log(Level.SEVERE, null, ex); - } - } - else{ - Logger.getLogger(CLIOptions.class.getName()).log(Level.SEVERE, "Unable to find credentials file at: "+(file ==null ? "null" : file)); - } - } - - @Option(name = "-f", aliases = {"-file"}, metaVar = "", - usage = "script file to execute") - public void setScriptFile(File file) - { - props.setProperty("script", file.getAbsolutePath()); - } - - public String getScriptPath() - { - return props.getProperty("script"); - } - - public File getScriptFile() - { - File retval = null; - String scriptPath = getScriptPath(); - if (scriptPath != null && !scriptPath.isEmpty()) { - File afile = new File(scriptPath); - if (afile.exists()) { - retval = afile; - } - } - return retval; - } - - Properties getProperties() { - return new Properties(props); - } - -} diff --git a/regi-headless/src/main/java/usace/rowcps/headless/HeadlessRegiDomainFactory.java b/regi-headless/src/main/java/usace/rowcps/headless/HeadlessRegiDomainFactory.java index b2cff43..1b4f073 100644 --- a/regi-headless/src/main/java/usace/rowcps/headless/HeadlessRegiDomainFactory.java +++ b/regi-headless/src/main/java/usace/rowcps/headless/HeadlessRegiDomainFactory.java @@ -27,10 +27,6 @@ import usace.rowcps.regi.model.ManagerId; import usace.rowcps.regi.model.RegiDomain; -/** - * - * @author ryan - */ public class HeadlessRegiDomainFactory { @@ -40,11 +36,11 @@ public class HeadlessRegiDomainFactory public RegiDomain createDomain() throws DbConnectionException, DbPluginNotFoundException, IOException { - Path projectDir = Paths.get("regi-projects", "regi-cli"); + Path projectDir = Paths.get("regi-projects", "regi-python"); logger.log(Level.INFO, "Creating project dir: "+ projectDir); Files.createDirectories(projectDir); - Path projectFile = projectDir.resolve("regi-cli.prj"); + Path projectFile = projectDir.resolve("regi-python.prj"); if(!Files.exists(projectFile)) { Files.createFile(projectFile); } @@ -66,15 +62,15 @@ public RegiDomain createDomain() throws DbConnectionException, } String cdaUrl = System.getenv("CDA_URL"); - String apiKey = System.getenv("API_KEY"); + String apiKey = System.getenv("CDA_API_KEY"); String officeId = System.getenv("OFFICE_ID"); CdaAuthenticationSource cdaAuthenticationSource = new CdaAuthenticationSource("", cdaUrl, officeId, new CwmsApiKeyAuthExtension(apiKey)); try { - ServerSuite serverSuite = ServerSuiteUtil.login("REGI CLI", cdaAuthenticationSource, false, false, false); + ServerSuite serverSuite = ServerSuiteUtil.login("regi-python", cdaAuthenticationSource, false, false, false); DataAccessFactory dataAccessFactory = serverSuite.getDataAccessFactory(); - try(var key = dataAccessFactory.getDataAccessKey("REGI CLI")) { + try(var key = dataAccessFactory.getDataAccessKey("regi-python")) { String username = dataAccessFactory.getDao(CwmsSecurityDao.class).getCurrentUserId(key); connectionManager.setUsername(username); } diff --git a/regi-headless/src/main/java/usace/rowcps/headless/PythonEvaluator.java b/regi-headless/src/main/java/usace/rowcps/headless/PythonEvaluator.java deleted file mode 100644 index a40a329..0000000 --- a/regi-headless/src/main/java/usace/rowcps/headless/PythonEvaluator.java +++ /dev/null @@ -1,72 +0,0 @@ -package usace.rowcps.headless; - -import usace.rowcps.headless.interfaces.ScriptEvaluator; -import java.io.Reader; -import java.util.Map; -import javax.script.Bindings; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import javax.script.SimpleScriptContext; - -/** - * - * @author ryan - */ -public class PythonEvaluator implements ScriptEvaluator -{ - - public final static String ENGINE_NAME = "python"; - private static final String REFERENCE_ERROR = "ReferenceError"; - private static final String NAME_ERROR = "NameError"; - - @Override - public Object evaluateExpression(Reader reader, Map variables) - { - - // I think this would let us restrict the classes loadable by python. - ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader(); - - ScriptEngineManager scriptManager = new ScriptEngineManager(ctxtLoader); - ScriptEngine pythonEngine = scriptManager.getEngineByName(ENGINE_NAME); - - SimpleScriptContext context = (SimpleScriptContext) pythonEngine.getContext(); - - Object javaValue = null; - try { - Bindings bindings = populateBingings(pythonEngine, variables); // fyi bindings actually SimpleBindings - javaValue = pythonEngine.eval(reader, bindings); - } catch (ScriptException e) { - handleException(e, variables); - } - return javaValue; - } - - private static Bindings populateBingings(ScriptEngine engine, Map variables) - { - Bindings bindings = engine.createBindings(); - for (Map.Entry entrySet : variables.entrySet()) { - String name = entrySet.getKey(); - Object value = entrySet.getValue(); - bindings.put(name, value); - } - - return bindings; - } - - private static Object handleException(ScriptException exception, Map variables) - { - if (isReferenceError(exception)) { - throw new IllegalArgumentException("Couldn't resolve some variables in expression with vars " + variables. - keySet(), exception); - } - throw new RuntimeException(exception); - } - - private static boolean isReferenceError(ScriptException exception) - { - String message = exception.getMessage(); - return message.startsWith(REFERENCE_ERROR); - } - -} diff --git a/regi-headless/src/main/java/usace/rowcps/headless/PythonJulHandler.java b/regi-headless/src/main/java/usace/rowcps/headless/PythonJulHandler.java new file mode 100644 index 0000000..532f277 --- /dev/null +++ b/regi-headless/src/main/java/usace/rowcps/headless/PythonJulHandler.java @@ -0,0 +1,47 @@ +package usace.rowcps.headless; + +import java.util.logging.ErrorManager; +import java.util.logging.Formatter; +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +public final class PythonJulHandler extends Handler { + + private final PythonLogSink sink; + + private final Formatter messageFormatter = new Formatter() { + @Override + public String format(LogRecord record) { + return formatMessage(record); + } + }; + + public PythonJulHandler(PythonLogSink sink) { + this.sink = sink; + } + + @Override + public void publish(LogRecord record) { + if (record == null || !isLoggable(record)) { + return; + } + + try { + String message = messageFormatter.format(record); + sink.log(record, message); + } catch (RuntimeException ex) { + // Safeguard against failures in Python log handling. + reportError("Failed to publish JUL record to Python logging.", ex, ErrorManager.WRITE_FAILURE); + } + } + + @Override + public void flush() { + // No-op. Python logging handlers manage their own flushing. + } + + @Override + public void close() { + // No-op. + } +} diff --git a/regi-headless/src/main/java/usace/rowcps/headless/PythonLogSink.java b/regi-headless/src/main/java/usace/rowcps/headless/PythonLogSink.java new file mode 100644 index 0000000..70a2ea0 --- /dev/null +++ b/regi-headless/src/main/java/usace/rowcps/headless/PythonLogSink.java @@ -0,0 +1,7 @@ +package usace.rowcps.headless; + +import java.util.logging.LogRecord; + +public interface PythonLogSink { + void log(LogRecord record, String message); +} diff --git a/regi-headless/src/main/java/usace/rowcps/headless/RegiCLI.java b/regi-headless/src/main/java/usace/rowcps/headless/RegiCLI.java deleted file mode 100644 index 17dc332..0000000 --- a/regi-headless/src/main/java/usace/rowcps/headless/RegiCLI.java +++ /dev/null @@ -1,152 +0,0 @@ -package usace.rowcps.headless; - -import java.io.IOException; -import usace.rowcps.headless.interfaces.ScriptEvaluator; -import hec.db.DbConnectionException; -import hec.db.DbIoException; -import hec.db.DbPluginNotFoundException; -import hec.db.InvalidDbConnectionException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.kohsuke.args4j.CmdLineException; -import org.kohsuke.args4j.CmdLineParser; -import usace.rowcps.metrics.RegiMetricsService; -import usace.rowcps.regi.factories.RowcpsExecutorService; -import usace.rowcps.regi.model.ManagerId; -import usace.rowcps.regi.model.RegiDomain; -import usace.rowcps.regi.preferences.RegiPreferences; - -/** - * - * @author ryan - */ -public class RegiCLI -{ - - private static final Logger LOGGER = Logger.getLogger(RegiCLI.class.getName()); - - static - { - RegiMetricsService.init(RegiPreferences.getClientNode().node("Metrics"), "REGI Headless"); - } - - public static void main(String[] args) - { - CLIOptions opt = new CLIOptions(System.getProperties()); - CmdLineParser parser = new CmdLineParser(opt); - - try - { - runHeadless(parser, args, opt); - } - catch (DbConnectionException | DbPluginNotFoundException | InvalidDbConnectionException | IOException ex) - { - LOGGER.log(Level.SEVERE, "Headless error connecting to database.", ex); - System.exit(-1); - return; - } - catch (CmdLineException | RuntimeException e) - { - LOGGER.log(Level.SEVERE, "Error running headless", e); - System.err.println("java -jar myprogram.jar [options...] arguments..."); - parser.printUsage(System.err); - System.exit(-1); - return; - } - - LOGGER.info("Exiting."); - System.exit(0); - } - - /** - * Used by TestHeadless unit test class to run headless without calling System.exit(0) - * - * @param args - * @throws DbConnectionException - * @throws InvalidDbConnectionException - * @throws CmdLineException - * @throws DbPluginNotFoundException - */ - static void runHeadlessTest(String[] args) - throws DbConnectionException, InvalidDbConnectionException, CmdLineException, DbPluginNotFoundException, - IOException { - CLIOptions opt = new CLIOptions(System.getProperties()); - CmdLineParser parser = new CmdLineParser(opt); - runHeadless(parser, args, opt); - } - - private static void runHeadless(CmdLineParser parser, String[] args, CLIOptions opt) - throws DbConnectionException, InvalidDbConnectionException, CmdLineException, DbPluginNotFoundException, - IOException { - parser.parseArgument(args); - System.setProperties(opt.getProperties()); - - HeadlessRegiDomainFactory factory = new HeadlessRegiDomainFactory(); - ManagerId managerId = factory.getManagerId(); - RegiDomain regiDomain = factory.createDomain(); - - if (regiDomain != null) - { - ScriptEvaluator pe = new PythonEvaluator(); - Map vars = new HashMap<>(); - - RegiCalcRegistry reg = new RegiCalcRegistry(regiDomain, managerId); - vars.put("registry", reg); - - File scriptFile = opt.getScriptFile(); - - try - { - FileReader fr = new FileReader(scriptFile); - LOGGER.info("Evaluating script file"); - Object retval = pe.evaluateExpression(fr, vars); - - LOGGER.info("Jython script completed normally, commiting data."); - regiDomain.commitData(managerId); - LOGGER.info("RegiDomain committed data."); - } - catch (DbConnectionException | DbIoException | FileNotFoundException ex) - { - LOGGER.log(Level.SEVERE, "Exception occurred while evaluating Jython file:" + System.lineSeparator() + scriptFile, ex); - } - finally - { - LOGGER.info("RegiDomain closing."); - shutdownRowcpsAccessFactory(managerId); - regiDomain.closing(); - } - } - } - - private static void shutdownRowcpsAccessFactory(ManagerId managerId) - { - LOGGER.log(Level.INFO, "Shutting down RowcpsExecutorService for {0}", managerId); - RowcpsExecutorService res = RowcpsExecutorService.getInstance(managerId); - - res.shutdown(); // signal shutdown - this will stop accepting new jobs and allow existing jobs to complete. - boolean exitted = false; - try - { - // We are willing to wait a little to achieve a clean shutdown. - exitted = res.awaitTermination(3000, TimeUnit.MILLISECONDS); - - } - catch (InterruptedException ie) - { - Thread.currentThread().interrupt(); - } - if (!exitted) - { - // Some of the running tasks didn't exit in the time we were willing to wait. - List wereWaiting = res.shutdownNow(); // This will interrupt them if they support interruption. - } - LOGGER.log(Level.INFO, "RowcpsExecutorService for {0} shutdown complete.", managerId); - } -} diff --git a/regi-headless/src/main/python/pyproject.toml b/regi-headless/src/main/python/pyproject.toml new file mode 100644 index 0000000..48db039 --- /dev/null +++ b/regi-headless/src/main/python/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "regi-python" +version = "@VERSION@" +description = "USACE REGI Python Bridge" +dependencies = [ + "JPype1>=1.4.1", +] + +[tool.setuptools] +packages = ["regi_python"] + +[tool.setuptools.package-data] +"regi_python" = ["lib/*.jar"] \ No newline at end of file diff --git a/regi-headless/src/main/python/regi_python/__init__.py b/regi-headless/src/main/python/regi_python/__init__.py new file mode 100644 index 0000000..9bc0c71 --- /dev/null +++ b/regi-headless/src/main/python/regi_python/__init__.py @@ -0,0 +1,12 @@ +"""Public package surface for the REGI Python bridge.""" + +from .regi_python import regi_session, run_headless +from importlib.metadata import version, PackageNotFoundError + +__all__ = ["regi_session", "run_headless"] + +try: + __version__ = version("regi_python") +except PackageNotFoundError: + # package is not installed + __version__ = "unknown" diff --git a/regi-headless/src/main/python/regi_python/regi_python.py b/regi-headless/src/main/python/regi_python/regi_python.py new file mode 100644 index 0000000..f0a5ac3 --- /dev/null +++ b/regi-headless/src/main/python/regi_python/regi_python.py @@ -0,0 +1,89 @@ +"""Runtime bridge for executing REGI calculations from Python.""" + +import os +import jpype +import jpype.imports +from contextlib import contextmanager +from .regi_python_logging import configure_logging, configure_jul_to_python_logging + +logger = configure_logging() + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +LIB_PATH = os.path.join(BASE_DIR, "lib", "*") + +@contextmanager +def regi_session(): + """ + Start the JVM on entry and shut it down when the context exits. + """ + started_jvm = False + if not jpype.isJVMStarted(): + _prepend_java_home_to_path() + logger.info("Starting JVM...") + jpype.startJVM( + jpype.getDefaultJVMPath(), + convertStrings=True, + classpath=[LIB_PATH] + ) + configure_jul_to_python_logging(logger) + started_jvm = True + + try: + yield + finally: + if started_jvm and jpype.isJVMStarted(): + logger.info("Shutting down JVM...") + jpype.shutdownJVM() + +def run_headless(calculation_callback): + """Run a callback against a headless REGI domain.""" + _require_environment_variables("CDA_URL", "CDA_API_KEY", "OFFICE_ID") + + # Import these only after the JVM has started. + from usace.rowcps.headless import HeadlessRegiDomainFactory, RegiCalcRegistry + from usace.rowcps.regi.factories import RowcpsExecutorService + from java.util.concurrent import TimeUnit + factory = HeadlessRegiDomainFactory() + logger.info("Attempting to create RegiDomain...") + regi_domain = factory.createDomain() + manager_id = factory.getManagerId() + registry = RegiCalcRegistry(regi_domain, manager_id) + + try: + logger.info("Executing callback...") + calculation_callback(registry) + regi_domain.commitData(manager_id) + except Exception as e: + logger.error("Execution failed.", exc_info=True) + raise + finally: + _shutdown_executor(manager_id) + regi_domain.closing() + + +def _require_environment_variables(*variable_names): + missing = [name for name in variable_names if not os.environ.get(name)] + if missing: + raise RuntimeError( + "Missing required environment variables: " + ", ".join(missing) + ) + + +def _prepend_java_home_to_path(): + java_home = os.environ.get("JAVA_HOME") + if not java_home: + return + + java_bin = os.path.join(java_home, "bin") + path = os.environ.get("PATH", "") + if java_bin not in path: + os.environ["PATH"] = java_bin + os.pathsep + path + + +def _shutdown_executor(manager_id): + from usace.rowcps.regi.factories import RowcpsExecutorService + from java.util.concurrent import TimeUnit + res = RowcpsExecutorService.getInstance(manager_id) + res.shutdown() + if not res.awaitTermination(3000, TimeUnit.MILLISECONDS): + res.shutdownNow() diff --git a/regi-headless/src/main/python/regi_python/regi_python_logging.py b/regi-headless/src/main/python/regi_python/regi_python_logging.py new file mode 100644 index 0000000..e0b6099 --- /dev/null +++ b/regi-headless/src/main/python/regi_python/regi_python_logging.py @@ -0,0 +1,129 @@ +"""Logging helpers for the REGI Python bridge.""" + +import os +import logging +from jpype import JImplements, JOverride + +_java_log_sink = None + + +def _get_log_level(): + log_level_name = os.environ.get("REGI_LOG_LEVEL", "INFO").upper() + log_level = getattr(logging, log_level_name, None) + invalid_log_level = not isinstance(log_level, int) + if invalid_log_level: + log_level = logging.INFO + return log_level, invalid_log_level, log_level_name + + +def configure_logging(): + """Configure the bridge logger.""" + log_level, invalid_log_level, log_level_name = _get_log_level() + + log_format = os.environ.get( + "REGI_LOG_FORMAT", + "%(asctime)s %(levelname)s %(name)s " + "[job=%(aws_batch_job_id)s attempt=%(aws_batch_job_attempt)s] - %(message)s", + ) + + class AwsBatchFilter(logging.Filter): + def filter(self, record): + record.aws_batch_job_id = os.environ.get("AWS_BATCH_JOB_ID", "-") + record.aws_batch_job_attempt = os.environ.get("AWS_BATCH_JOB_ATTEMPT", "-") + return True + + handler = logging.StreamHandler() + handler.setLevel(log_level) + handler.setFormatter(logging.Formatter(log_format)) + handler.addFilter(AwsBatchFilter()) + + logger = logging.getLogger("regi-launcher") + logger.setLevel(log_level) + logger.handlers.clear() + logger.addHandler(handler) + logger.propagate = False + + if invalid_log_level: + logger.warning("Invalid REGI_LOG_LEVEL '%s'; using INFO.", log_level_name) + + return logger + + +def configure_jul_to_python_logging(python_logger): + """Forward Java JUL records into Python logging.""" + global _java_log_sink + + from java.util.logging import Logger + from usace.rowcps.headless import PythonJulHandler + + java_level = _python_level_to_jul_level(python_logger.getEffectiveLevel()) + + root_logger = Logger.getLogger("") + root_logger.setLevel(java_level) + + for handler in root_logger.getHandlers(): + root_logger.removeHandler(handler) + + PythonLogSink = _create_python_log_sink_class() + _java_log_sink = PythonLogSink(python_logger) + + handler = PythonJulHandler(_java_log_sink) + handler.setLevel(java_level) + + root_logger.addHandler(handler) + + +def _python_level_to_jul_level(python_level): + from java.util.logging import Level + + if python_level <= logging.NOTSET: + return Level.ALL + if python_level <= logging.DEBUG: + return Level.FINE + if python_level <= logging.INFO: + return Level.INFO + if python_level <= logging.WARNING: + return Level.WARNING + if python_level <= logging.CRITICAL: + return Level.SEVERE + return Level.OFF + + +def _jul_level_to_python_level(jul_level_name): + mapping = { + "SEVERE": logging.ERROR, + "WARNING": logging.WARNING, + "INFO": logging.INFO, + "CONFIG": logging.INFO, + "FINE": logging.DEBUG, + "FINER": logging.DEBUG, + "FINEST": logging.DEBUG, + "ALL": logging.NOTSET, + "OFF": logging.CRITICAL + 10, + } + return mapping.get(str(jul_level_name), logging.INFO) + + +def _create_python_log_sink_class(): + # JPype resolves @JImplements interfaces immediately, so define this class only + # after the JVM has started; otherwise importing this module would fail. + from jpype import JImplements, JOverride + + @JImplements("usace.rowcps.headless.PythonLogSink") + class PythonLogSink: + def __init__(self, python_logger): + self._logger = python_logger + + @JOverride + def log(self, record, message): + level = _jul_level_to_python_level(record.getLevel().getName()) + name = str(record.getLoggerName() or "java") + message = str(message) + + thrown = record.getThrown() + if thrown is not None: + message = f"{message}\n{thrown}" + + self._logger.log(level, "[%s] %s", name, message) + + return PythonLogSink diff --git a/regi-headless/src/main/resources/usace/rowcps/headless/sigstages/retrieve/xmlmodel/HydroGenData.xsd b/regi-headless/src/main/resources/usace/rowcps/headless/sigstages/retrieve/xmlmodel/HydroGenData.xsd deleted file mode 100644 index e1bb1ea..0000000 --- a/regi-headless/src/main/resources/usace/rowcps/headless/sigstages/retrieve/xmlmodel/HydroGenData.xsd +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/regi-headless/src/test/java/usace/rowcps/headless/TestFrame.java b/regi-headless/src/test/java/usace/rowcps/headless/TestFrame.java deleted file mode 100644 index 2b46ad7..0000000 --- a/regi-headless/src/test/java/usace/rowcps/headless/TestFrame.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2018 - * United States Army Corps of Engineers - Hydrologic Engineering Center (USACE/HEC) - * All Rights Reserved. USACE PROPRIETARY/CONFIDENTIAL. - * Source may not be released without written approval from HEC - */ -package usace.rowcps.headless; - -import java.awt.GridLayout; -import java.awt.HeadlessException; -import java.awt.event.ActionEvent; -import java.io.IOException; -import java.nio.file.FileVisitOption; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.List; -import java.util.ArrayList; -import static java.util.stream.Collectors.toList; -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; - -/** - * - * @author @author Ryan A. Miles (ryanm@rmanet.com) - */ -public class TestFrame extends JFrame -{ - private static final Logger LOGGER = Logger.getLogger(TestFrame.class.getName()); - private final ExecutorService _executor = Executors.newSingleThreadExecutor(); - private final List _buttons = new ArrayList<>(); - - public TestFrame() throws HeadlessException - { - buildComponents(); - } - - public static void main(String[] args) - { - TestFrame frame = new TestFrame(); - frame.pack(); - frame.setDefaultCloseOperation(EXIT_ON_CLOSE); - frame.setMinimumSize(frame.getPreferredSize()); - frame.setVisible(true); - } - - private void buildComponents() - { - setLayout(new GridLayout(0, 3, 2, 2)); - - String[] files = readFilesInTestFolder(); - - for (String testData : files) - { - JButton btn = new JButton(new ButtonAction(testData, testData)); - _buttons.add(btn); - add(btn); - } - } - - private String[] readFilesInTestFolder() - { - Path path = Paths.get(TestHeadless.getJythonTestFolder()); - List paths = new ArrayList<>(); - try - { - paths.addAll(Files.walk(path, FileVisitOption.FOLLOW_LINKS) - .map(Path::getFileName) - .map(Path::toString) - .filter(file -> file.endsWith("py")) - .collect(toList())); - } - catch (IOException | RuntimeException ex) - { - - } - - return paths.toArray(new String[0]); - } - - private void performHeadless(String file) - { - disableButtons(); - - _executor.submit(() -> - { - String[] args = TestHeadless.getArgsForFile(file); - try - { - RegiCLI.runHeadlessTest(args); - //Reset logging options - LoggingOptions.disableFlowGroupCompLogging(); - LoggingOptions.setMetricsEnabled(false); - LoggingOptions.setDbMessageLevel(0); - } - catch (Throwable ex) - { - logThrowable(ex); - } - - SwingUtilities.invokeLater(this::enableButtons); - }); - } - - private void logThrowable(Throwable ex) - { - if (ex.getCause() != null) - { - logThrowable(ex.getCause()); - } - LOGGER.log(Level.SEVERE, "Exception occurred", ex); - } - - private void disableButtons() - { - for (JButton btn : _buttons) - { - btn.setEnabled(false); - } - } - - private void enableButtons() - { - for (JButton btn : _buttons) - { - btn.setEnabled(true); - } - } - - private class ButtonAction extends AbstractAction - { - private final String _file; - public ButtonAction(String name, String file) - { - super(name); - _file = file; - } - - @Override - public void actionPerformed(ActionEvent e) - { - performHeadless(_file); - } - } -} diff --git a/regi-headless/src/test/java/usace/rowcps/headless/TestHeadless.java b/regi-headless/src/test/java/usace/rowcps/headless/TestHeadless.java deleted file mode 100644 index 4cf8ac7..0000000 --- a/regi-headless/src/test/java/usace/rowcps/headless/TestHeadless.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2018 - * United States Army Corps of Engineers - Hydrologic Engineering Center (USACE/HEC) - * All Rights Reserved. USACE PROPRIETARY/CONFIDENTIAL. - * Source may not be released without written approval from HEC - */ -package usace.rowcps.headless; - -import java.util.TimeZone; -import usace.rowcps.headless.tests.TestVariables; - -/** - * This class is intended for use by developers to run headless after making changes. Run a single test at a time - * otherwise it might be a while... - * - * All files are relative to the JYTHON_FILE_ROOT variable, which should be in this same folder. - * - * @author @author Ryan A. Miles (ryanm@rmanet.com) - */ -public class TestHeadless -{ - static final String JYTHON_FILE_ROOT = "src\\test\\java\\usace\\rowcps\\headless\\"; - static final String CREDENTIALS_FILE = "usace/rowcps/headless/credentials.properties"; - - //I'd like this to be the office, but we haven't connected yet. - //Could get it from the credentials probably. - static final String SUB_FOLDER = "tests"; - -// @Test //23-001 - migration - public void testAssoc_DBExport() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("Assoc_DBExport.py")); - } - -// @Test //23-001 - migration - public void testBasinPieExport() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("BasinPieExport.py")); - } - -// @Test //23-001 - migration - public void testGateFlowPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("GateFlow.py")); - } - -// @Test //23-001 - migration - public void testGateFlowCalcPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("GateFlowCalc.py")); - } - -// @Test //23-001 - migration - public void testGateSettingsPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("GateSettings.py")); - } - -// @Test //23-001 - migration - public void testInflowCalcAutoAdjustPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcAutoAdjust.py")); - } - -// @Test //23-001 - migration - public void testInflowCalcBalanceAllPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcBalanceAll.py")); - } - -// @Test //23-001 - migration - public void testInflowCalcClonePy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcClone.py")); - } - -// @Test //23-001 - migration - public void testInflowCalcComputeEvapAsFlowPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcComputeEvapAsFlow.py")); - } - - -// @Test //23-001 - migration - public void testInflowCalcComputedInflowPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcComputedInflow.py")); - } - -// @Test //23-001 - migration - public void testInflowCalcZeroNegativePy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("InflowCalcZeroNegative.py")); - } - -// @Test //23-001 - migration - public void testPoolPercentCalcPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("PoolPercentCalc.py")); - } - -// @Test //23-001 - migration - public void testSigstages_DBExportPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("Sigstages_DBExport.py")); - } - -// @Test //23-001 - migration - public void testSigstages_DBImportPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("Sigstages_DBImport.py")); - } - -// @Test //23-001 - migration - public void testSigstages_DownloadPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("Sigstages_Download.py")); - } - -// @Test //23-001 - migration - public void testStatusDemoPy() throws Exception - { - RegiCLI.runHeadlessTest(getArgsForFile("StatusDemo.py")); - } - - static String[] getArgsForFile(String file) - { - return getArgsForFileAndTimeZone(SUB_FOLDER + "\\" + file, TimeZone.getTimeZone("US/Central")); - } - - static String getJythonTestFolder() - { - return JYTHON_FILE_ROOT + SUB_FOLDER; - } - - private static String[] getArgsForFileAndTimeZone(String file, TimeZone tz) - { - TestVariables.init(); - String[] args = new String[] - { - "-Drowcps.timezone=" + tz.getID(), - "-p", JYTHON_FILE_ROOT + CREDENTIALS_FILE, - "-f", JYTHON_FILE_ROOT + file, - }; - - return args; - } -} diff --git a/regi-headless/src/test/java/usace/rowcps/headless/tests/TestVariables.java b/regi-headless/src/test/java/usace/rowcps/headless/tests/TestVariables.java deleted file mode 100644 index 417caeb..0000000 --- a/regi-headless/src/test/java/usace/rowcps/headless/tests/TestVariables.java +++ /dev/null @@ -1,39 +0,0 @@ -package usace.rowcps.headless.tests; - -/** - * I couldn't get this into a python file...it kept saying it couldn't find the module. I think it's because the - * evaluator only takes in one file? - * - * Anyway, this is intended to provide the global test information for all of the python scripts. I set this up for the - * SWT office and locations. I've also updated these tests to use an output file location that we can get all our files - * to so it's not so scattered. - * - * @author Ryan A. Miles (ryanm@rmanet.com) - */ -public final class TestVariables -{ - - //Office ID for current tests. - public static final String OFFICE_ID = "SWT"; - //These are intended to be unique, please don't use the same variables. - public static final String GATE_LOCATION = "FGIB"; - public static final String INFLOW_LOCATION = "EUFA"; - public static final String POOL_LOCATION = "ARBU"; - public static final String LOCATION_4 = "ALTU"; - public static final String[] ALL_PROJECTS = new String[] - { - GATE_LOCATION, INFLOW_LOCATION, POOL_LOCATION, LOCATION_4 - }; - public static final String STREAM_GAGE_LOCATION = "RIPL"; - public static final String HEADLESS_FILE_LOCATION = "C:\\Temp\\Headless\\"; - - public static void init() - { - - } - - private TestVariables() - { - throw new AssertionError("Don't instantiate this class"); - } -} diff --git a/regi-headless/src/test/python/test_district_scripts.py b/regi-headless/src/test/python/test_district_scripts.py new file mode 100644 index 0000000..44704d4 --- /dev/null +++ b/regi-headless/src/test/python/test_district_scripts.py @@ -0,0 +1,244 @@ +import importlib.util +import io +import logging +import re +import sys +import types +from contextlib import redirect_stdout +from pathlib import Path + + +MODULE_ROOT = Path(__file__).resolve().parents[3] +REPOSITORY_ROOT = MODULE_ROOT.parent +DISTRICT_SCRIPTS_ROOT = REPOSITORY_ROOT / "district-scripts" +EXAMPLE_SCRIPTS_ROOT = MODULE_ROOT / "src" / "test" / "resources" / "usace" / "rowcps" / "headless" / "examples" +JAVA_SOURCE_ROOT = MODULE_ROOT / "src" / "main" / "java" + + +JAVA_METHOD_PATTERN = re.compile( + r"\bpublic\s+(?:static\s+)?(?:[\w<>\[\], ?]+\s+)+(?P[A-Za-z_]\w*)\s*\(" +) +LOGGER = logging.getLogger(__name__) + + +def test_migrated_scripts_only_call_known_scriptable_api(monkeypatch): + java_api = _load_java_api() + _install_fake_modules(monkeypatch, java_api) + + _validate_scripts("district", DISTRICT_SCRIPTS_ROOT, _district_scripts(), java_api) + _validate_scripts("example", EXAMPLE_SCRIPTS_ROOT, _example_scripts(), java_api) + + +def _validate_scripts(label, root, scripts, java_api): + assert scripts, f"No {label} scripts found under {root}" + LOGGER.info("Validating %s %s script(s)", len(scripts), label) + + failures = [] + for script in scripts: + relative_script = script.relative_to(REPOSITORY_ROOT) + LOGGER.info("Validating %s script: %s", label, relative_script) + try: + module = _load_script(script) + with redirect_stdout(io.StringIO()): + _script_callback(module)(FakeRegistry(java_api)) + except Exception as exc: + failures.append(f"{relative_script}: {type(exc).__name__}: {exc}") + else: + LOGGER.info("Validated %s script: %s", label, relative_script) + + assert not failures, f"{label.title()} script API validation failed:\n" + "\n".join(failures) + + +def _district_scripts(): + return sorted( + path + for path in DISTRICT_SCRIPTS_ROOT.rglob("*.py") + if path.name != "__init__.py" + ) + + +def _example_scripts(): + return sorted( + path + for path in EXAMPLE_SCRIPTS_ROOT.rglob("*.py") + if path.name != "__init__.py" + ) + + +def _script_callback(module): + for name in ( + "run_calculations", + "calculate_inflow", + "calculate_gate_flow", + "calculate_gate_settings", + "configure_logging_options", + ): + callback = getattr(module, name, None) + if callback is not None: + return callback + raise AssertionError(f"No migrated script callback found in {module.__file__}") + + +def _load_java_api(): + return { + "Inflow": _java_methods( + "usace/rowcps/headless/calculator/inflow/ScriptableInflowImpl.java" + ), + "Gate Flow": _java_methods( + "usace/rowcps/headless/calculator/flowgroup/ScriptableGateFlowImpl.java" + ), + "Gate Settings": _java_methods( + "usace/rowcps/headless/calculator/gatesettings/ScriptableGateSettingsImpl.java" + ), + "LoggingOptions": _java_methods("usace/rowcps/headless/LoggingOptions.java"), + } + + +def _java_methods(relative_path): + source = (JAVA_SOURCE_ROOT / relative_path).read_text(encoding="utf-8") + return { + match.group("name") + for match in JAVA_METHOD_PATTERN.finditer(_strip_java_comments(source)) + } + + +def _strip_java_comments(source): + source = re.sub(r"/\*.*?\*/", "", source, flags=re.DOTALL) + return re.sub(r"//.*", "", source) + + +def _load_script(path): + module_name = "district_script_" + re.sub(r"\W+", "_", str(path.relative_to(REPOSITORY_ROOT))) + spec = importlib.util.spec_from_file_location(module_name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def _install_fake_modules(monkeypatch, java_api): + modules = {} + + def module(name): + value = modules.get(name) + if value is None: + value = types.ModuleType(name) + modules[name] = value + monkeypatch.setitem(sys.modules, name, value) + if "." in name: + parent_name, child_name = name.rsplit(".", 1) + setattr(module(parent_name), child_name, value) + return value + + regi_python = module("regi_python") + regi_python.regi_session = _fake_regi_session + regi_python.run_headless = lambda callback: callback(FakeRegistry(java_api)) + + java_util = module("java.util") + java_util.Calendar = FakeCalendar + java_util.TimeZone = FakeTimeZone + + java_lang = module("java.lang") + java_lang.System = FakeSystem + + headless = module("usace.rowcps.headless") + headless.LoggingOptions = type( + "LoggingOptions", + (), + {name: staticmethod(_noop) for name in java_api["LoggingOptions"]}, + ) + + inflow = module("usace.rowcps.headless.calculator.inflow") + inflow.InflowComputationStorageOption = types.SimpleNamespace( + EVAP_AS_FLOW="EVAP_AS_FLOW", + PROJECT_RELEASES="PROJECT_RELEASES", + ) + + +class _fake_regi_session: + def __enter__(self): + return None + + def __exit__(self, exc_type, exc, traceback): + return False + + +class FakeRegistry: + def __init__(self, java_api): + self._java_api = java_api + + def getNames(self, version): + return ["Inflow", "Gate Flow", "Gate Settings"] + + def getCalculation(self, version, name): + if name not in self._java_api: + raise AssertionError(f"Unknown calculation requested: {name!r}") + return FakeJavaObject(name, self._java_api[name]) + + +class FakeJavaObject: + def __init__(self, display_name, method_names): + self._display_name = display_name + self._method_names = method_names + + def __getattr__(self, name): + if name not in self._method_names: + raise AttributeError(f"{self._display_name} has no Java method {name!r}") + return _noop + + +class FakeTimeZone: + @staticmethod + def getTimeZone(name): + return FakeTimeZone() + + +class FakeSystem: + @staticmethod + def getProperty(name): + return "" + + +class FakeCalendar: + DATE = 1 + DAY_OF_MONTH = 2 + HOUR = 3 + HOUR_OF_DAY = 4 + MILLISECOND = 5 + MINUTE = 6 + MONTH = 7 + SECOND = 8 + YEAR = 9 + + @staticmethod + def getInstance(time_zone=None): + return FakeCalendar() + + def add(self, field, amount): + return None + + def clear(self): + return None + + def getTime(self): + return FakeDate() + + def getTimeInMillis(self): + return 0 + + def get(self, field): + return 0 + + def set(self, field, value): + return None + + +class FakeDate: + def getTime(self): + return 0 + + def toString(self): + return "FakeDate" + + +def _noop(*args, **kwargs): + return None diff --git a/regi-headless/src/test/python/test_regi_python.py b/regi-headless/src/test/python/test_regi_python.py new file mode 100644 index 0000000..81b9bb2 --- /dev/null +++ b/regi-headless/src/test/python/test_regi_python.py @@ -0,0 +1,84 @@ +# Copyright (c) 2026 +# United States Army Corps of Engineers - Hydrologic Engineering Center (USACE/HEC) +# All Rights Reserved. USACE PROPRIETARY/CONFIDENTIAL. +# Source may not be released without written approval from HEC + +import importlib.metadata +import importlib +from pathlib import Path + + +def test_wheel_distribution_metadata_is_installed(): + dist = importlib.metadata.distribution("regi-python") + + assert dist.metadata["Name"] == "regi-python" + assert dist.version + + +def test_wheel_can_import_top_level_package(): + import regi_python + + assert regi_python is not None + + +def test_public_api_is_exposed(): + import regi_python + + assert callable(regi_python.regi_session) + assert callable(regi_python.run_headless) + + +def test_run_headless_requires_cda_environment(monkeypatch): + import regi_python + + monkeypatch.delenv("CDA_URL", raising=False) + monkeypatch.delenv("CDA_API_KEY", raising=False) + monkeypatch.delenv("OFFICE_ID", raising=False) + + try: + regi_python.run_headless(lambda registry: None) + except RuntimeError as exc: + assert str(exc) == ( + "Missing required environment variables: CDA_URL, CDA_API_KEY, OFFICE_ID" + ) + else: + raise AssertionError("run_headless should fail when CDA env vars are missing") + + +def test_bundled_java_libraries_are_present(): + import regi_python + package_dir = Path(regi_python.__file__).parent + lib_dir = package_dir / "lib" + + assert lib_dir.is_dir() + assert any(lib_dir.glob("*.jar")) + + +def test_bridge_import_does_not_require_java_home(monkeypatch): + import regi_python.regi_python as bridge + + monkeypatch.delenv("JAVA_HOME", raising=False) + + reloaded = importlib.reload(bridge) + + assert reloaded is bridge + + +def test_regi_session_only_shuts_down_jvm_it_started(monkeypatch): + import regi_python.regi_python as bridge + + started = [] + stopped = [] + jul_configured = [] + + monkeypatch.setattr(bridge.jpype, "isJVMStarted", lambda: True) + monkeypatch.setattr(bridge.jpype, "startJVM", lambda *args, **kwargs: started.append((args, kwargs))) + monkeypatch.setattr(bridge.jpype, "shutdownJVM", lambda: stopped.append(True)) + monkeypatch.setattr(bridge, "configure_jul_to_python_logging", lambda logger: jul_configured.append(logger)) + + with bridge.regi_session(): + pass + + assert started == [] + assert stopped == [] + assert jul_configured == [] diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/credentials.properties b/regi-headless/src/test/resources/usace/rowcps/headless/credentials.properties deleted file mode 100644 index ee2dba3..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/credentials.properties +++ /dev/null @@ -1,9 +0,0 @@ -rowcps.projectDir=C:\\Users\\ryanm\\Documents\\Regi Base\\ -rowcps.projectName=bang - -oracle.url=jdbc:oracle:thin:@10.0.0.36:1539:V122SWT1811REGI -oracle.user=m5hectest -oracle.password=swt1811db -oracle.officeId=SWT - -hec.passwd=src\\test\\java\\usace\\rowcps\\headless\\hec.passwd \ No newline at end of file diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc.py index 7fcc9f4..8bcbab8 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc.py @@ -1,103 +1,49 @@ -from hec.data import Duration -from hec.data import Interval -from hec.data import ParameterType -from hec.data import Version -from hec.data.location import LocationTemplate -from java.lang import System -from java.util import Calendar -from java.util import Collections -from java.util import List -from java.util import TimeZone import os.path import sys -from usace.rowcps.computation.flowgroup import FlowGroupCalc -from usace.rowcps.regi.model import AtFlowGroupManager -from usace.rowcps.regi.model import AtManagerType -from usace.rowcps.regi.model import AtOutletManager -from usace.rowcps.regi.model import AtProjectManager -from usace.rowcps.regi.model import CacheUsage +from regi_python import regi_session, run_headless -print "Now executing GateFlowCalc.py" -print "os.arch:", System.getProperty("os.arch") -print "sys.path", sys.path -#curDir = open(".") -print "Working dir:", os.path.abspath(".") +def calculate_gate_flow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.lang import System + from java.util import Calendar, TimeZone -property = System.getProperty("java.library.path") -print "Library path: ", property + print("Now executing GateFlowCalc.py") + print("os.arch:", System.getProperty("os.arch")) + print("sys.path", sys.path) + print("Working dir:", os.path.abspath(".")) + print("Library path:", System.getProperty("java.library.path")) -sys.stdout.flush() + sys.stdout.flush() -print "regiDomain.getName()", regiDomain.getName() + gate_calc = registry.getCalculation(1.0, "Gate Flow") -#print AtManagerType -#print AtManagerType.DATABASE -#RegiDomain regiDomain = getRegiDomain() + office_id = "SWF" + project_id = "LEWT2" + flow_group_id = "Flow.LEWT2.ConduitGate_Total" -#lets get a lot of managers. remember that the managers can be pulled from regidomain thru the following: -# -#regiDomain.getAtProjectManager() -# -#but its coded below to make sure that we have the Oracle manager. -projManager = regiDomain.getAtManager(managerId, AtManagerType.DATABASE, AtProjectManager.AT_PROJECT_MANAGER_NAME, AtProjectManager) -# -outletManager = regiDomain.getAtManager(managerId, AtManagerType.DATABASE, AtOutletManager.AT_OUTLET_MANAGER_NAME, AtOutletManager) -## -flowGroupManager = regiDomain.getAtManager(managerId, AtManagerType.DATABASE, AtFlowGroupManager.AT_FLOW_GROUP_MANAGER_NAME, AtFlowGroupManager) + # Time zone must be set because the Solaris time zone is UTC + time_zone = TimeZone.getTimeZone("US/Central") + start_cal = Calendar.getInstance(time_zone) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2015) + start_cal.set(Calendar.MONTH, 1) -#our office -officeId = "SWF" -#this stuff would be grabbed from the project descriptor. -projectId = "LEWT2" -projectLocRef = LocationTemplate(officeId, projectId, None) -cg1LocRef = LocationTemplate(officeId, projectId + "-CG1", None) + end_cal = Calendar.getInstance(time_zone) + end_cal.clear() + end_cal.set(Calendar.YEAR, 2013) + end_cal.set(Calendar.MONTH, 1) -conduitGateFlowGroupMap = flowGroupManager.retrieveFlowGroups(projectLocRef, None, CacheUsage.NORMAL) -entrySet = conduitGateFlowGroupMap.entrySet() + gate_calc.computeFlowGroup( + office_id, + project_id, + start_cal.getTimeInMillis(), + end_cal.getTimeInMillis(), + flow_group_id, + ) -conduitGateFlowGroup = None -for entry in entrySet: - key = entry.getKey() - value = entry.getValue() - if "ConduitGate_Total" in key.getId(): - conduitGateFlowGroup = key - break - -if conduitGateFlowGroup is None: -# Assert.fail("Couldnt find conduit gate flow group") - print "Couldnt find conduit gate flow group" -else: - # Time zone must be set because the Solaris time zone is UTC - timeZone = TimeZone.getTimeZone("US/Central") - startCal = Calendar.getInstance(timeZone) - startCal.clear() - startCal.set(Calendar.YEAR, 2015) - startCal.set(Calendar.MONTH, 1) - startTime = startCal.getTimeInMillis() - - #this could be INST too. - parameterType = ParameterType(ParameterType.AVE) - interval = Interval("5Minutes") - duration = Duration("5Minutes") - version = Version("CALC") - intervalOffsetSeconds = 0 - newFlowGroupTimeSeries = conduitGateFlowGroup.newFlowGroupTimeSeries(parameterType, interval, duration, version, intervalOffsetSeconds, startCal.getTime(), None) - - flowGroupCalc = FlowGroupCalc() - outputTimeSeriesList = Collections.singletonList(newFlowGroupTimeSeries) - - endCal = Calendar.getInstance(timeZone) - endCal.clear() - endCal.set(Calendar.YEAR, 2013) - endCal.set(Calendar.MONTH, 1) - endTime = endCal.getTimeInMillis() - - calcTimeSeries = flowGroupCalc.calcTimeSeries(managerId, conduitGateFlowGroup, startTime, endTime, outputTimeSeriesList) - computationResult = calcTimeSeries.get(newFlowGroupTimeSeries) - #it could also be an error - computationData = computationResult - timeSeriesData = computationData.getTimeSeriesData() - timeSeriesData.tabulateValues() \ No newline at end of file +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_gate_flow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2.py index e5d6542..1eca4b1 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateFlowCalc2.py @@ -1,25 +1,30 @@ -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -names = registry.getNames(1.0) -print "names", names -gateCalc = registry.getCalculation(1.0, "Gate Flow") +def calculate_gate_flow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) + names = registry.getNames(1.0) + print("names", names) -endCal = Calendar.getInstance(timeZone) -endCal.clear() -endCal.set(Calendar.YEAR, 2015) -endCal.set(Calendar.MONTH, 6) + gate_calc = registry.getCalculation(1.0, "Gate Flow") -#gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTimeInMillis(), endCal.getTimeInMillis(), "Flow.LEWT2.ConduitGate_Total") + # Time zone must be set because the Solaris time zone is UTC + time_zone = TimeZone.getTimeZone("US/Central") + start_cal = Calendar.getInstance(time_zone) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2015) + start_cal.set(Calendar.MONTH, 4) -gateCalc.computeAll("SWF", "LEWT2", startCal.getTimeInMillis(), endCal.getTimeInMillis()) + end_cal = Calendar.getInstance(time_zone) + end_cal.clear() + end_cal.set(Calendar.YEAR, 2015) + end_cal.set(Calendar.MONTH, 6) + gate_calc.computeAll("SWF", "LEWT2", start_cal.getTimeInMillis(), end_cal.getTimeInMillis()) + +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_gate_flow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateSettings.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateSettings.py index fd0512f..b1d4121 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateSettings.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/GateSettings.py @@ -1,42 +1,46 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a scriptable Gate Settings object -gateSettings = registry.getCalculation(1.0, "Gate Settings") -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) +def calculate_gate_settings(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -# configure the end calendar -endCal = Calendar.getInstance(timeZone) -endCal.clear() -endCal.set(Calendar.YEAR, 2015) -endCal.set(Calendar.MONTH, 6) + # this gets a scriptable Gate Settings object + gate_settings = registry.getCalculation(1.0, "Gate Settings") + # Time zone must be set because the Solaris time zone is UTC + time_zone = TimeZone.getTimeZone("US/Central") + # configure the start calendar + start_cal = Calendar.getInstance(time_zone) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2015) + start_cal.set(Calendar.MONTH, 4) -# gateSettings contains four callable methods -# void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; -# void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; -# void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; -# void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; + # configure the end calendar + end_cal = Calendar.getInstance(time_zone) + end_cal.clear() + end_cal.set(Calendar.YEAR, 2015) + end_cal.set(Calendar.MONTH, 6) -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the specified input time series. -gateSettings.createGateSettingsOutletFromTs("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1", "WTYT2-TG1.Opening-Spillway_Gate.Const.0.0.MANUAL" ) + # gate_settings contains four callable methods + # void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; + # void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; + # void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; + # void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the regi association configured input time series. -gateSettings.createGateSettingsOutlet("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "TG1") + # This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the specified input time series. + gate_settings.createGateSettingsOutletFromTs("SWF", "WTYT2", start_cal.getTime(), end_cal.getTime(), "TG1", "WTYT2-TG1.Opening-Spillway_Gate.Const.0.0.MANUAL") -# This is an example of a call that would create gate settings at all outlets at WTYT2 which are in the TainterGateWTY group from the association configured time series. -gateSettings.createGateSettingsGroup("SWF", "WTYT2", startCal.getTime(), endCal.getTime(), "WTYT2-TainterGateWTY" ) + # This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the regi association configured input time series. + gate_settings.createGateSettingsOutlet("SWF", "WTYT2", start_cal.getTime(), end_cal.getTime(), "TG1") -# This is an example of a call that would create gate settings for every outlet in a rating group at WTYT2. -gateSettings.createGateSettings("SWF", "WTYT2", startCal.getTime(), endCal.getTime() ) + # This is an example of a call that would create gate settings at all outlets at WTYT2 which are in the TainterGateWTY group from the association configured time series. + gate_settings.createGateSettingsGroup("SWF", "WTYT2", start_cal.getTime(), end_cal.getTime(), "WTYT2-TainterGateWTY") + # This is an example of a call that would create gate settings for every outlet in a rating group at WTYT2. + gate_settings.createGateSettings("SWF", "WTYT2", start_cal.getTime(), end_cal.getTime()) +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_gate_settings) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalc.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalc.py index 2f26e26..8e4df61 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalc.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalc.py @@ -1,34 +1,40 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") +from regi_python import regi_session, run_headless -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives + # this gets a scriptable Pool Percent object + inflow_calc = registry.getCalculation(1.0, "Inflow") -# Each method takes the followind arguments: -# officeId -# locationId -# startDate + # Time zone must be set because the Solaris time zone is UTC + time_zone = TimeZone.getTimeZone("US/Central") + # configure the start calendar + start_cal = Calendar.getInstance(time_zone) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2015) + start_cal.set(Calendar.MONTH, 4) -# autoAdjust also takes booleans: -# useLimits -# freezeRain + # inflow_calc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives -# This autoBalances ALAT2 -inflowCalc.autoAdjust("SWF", "ALAT2", startCal.getTime(), False, False) + # Each method takes the following arguments: + # officeId + # locationId + # startDate + # autoAdjust also takes booleans: + # useLimits + # freezeRain + # This autoBalances ALAT2 + inflow_calc.autoAdjust("SWF", "ALAT2", start_cal.getTime(), False, False) + + +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcAutoAdjust.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcAutoAdjust.py index c60eb8f..5825fa1 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcAutoAdjust.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcAutoAdjust.py @@ -1,36 +1,38 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 6) -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 7) + # inflow_calc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + # Each method takes the following arguments: + # officeId + # locationId + # startDate -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives + # autoAdjust also takes booleans: + # useLimits + # freezeRain -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.autoAdjust("SWF", "ALAT2", startCal.getTime(), False, False) + # This autoBalances ALAT2 + inflow_calc.autoAdjust("SWF", "ALAT2", start_cal.getTime(), False, False) +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcBalanceAll.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcBalanceAll.py index 88b6219..a9cb225 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcBalanceAll.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcBalanceAll.py @@ -1,36 +1,38 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 7) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) + # inflow_calc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + # Each method takes the following arguments: + # officeId + # locationId + # startDate -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives + # autoAdjust also takes booleans: + # useLimits + # freezeRain -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.balanceAll("SWF", "ALAT2", startCal.getTime()) + # This autoBalances ALAT2 + inflow_calc.balanceAll("SWF", "ALAT2", start_cal.getTime()) +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcClone.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcClone.py index 57609b7..d3590d5 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcClone.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcClone.py @@ -1,36 +1,38 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 7) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) + # inflow_calc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + # Each method takes the following arguments: + # officeId + # locationId + # startDate -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives + # autoAdjust also takes booleans: + # useLimits + # freezeRain -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.cloneInflows("SWF", "ALAT2", startCal.getTime()) + # This autoBalances ALAT2 + inflow_calc.cloneInflows("SWF", "ALAT2", start_cal.getTime()) +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputeEvapAsFlow.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputeEvapAsFlow.py index 3ab7b56..8f5bce3 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputeEvapAsFlow.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputeEvapAsFlow.py @@ -1,23 +1,29 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 4) -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) + end_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + end_cal.clear() + end_cal.set(Calendar.YEAR, 2018) + end_cal.set(Calendar.MONTH, 4) + end_cal.set(Calendar.DAY_OF_MONTH, 4) -# This computes and saves evap as flow for EUFA in May 2018 -inflowCalc.computeEvapAsFlow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) \ No newline at end of file + # This computes and saves evap as flow for EUFA in May 2018 + inflow_calc.computeEvapAsFlow("SWT", "EUFA", start_cal.getTime(), end_cal.getTime()) + + +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputedInflow.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputedInflow.py index 9def655..591325f 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputedInflow.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcComputedInflow.py @@ -1,24 +1,29 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption +from regi_python import regi_session, run_headless -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 4) -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) + end_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + end_cal.clear() + end_cal.set(Calendar.YEAR, 2018) + end_cal.set(Calendar.MONTH, 4) + end_cal.set(Calendar.DAY_OF_MONTH, 4) -# This computes and saves inflow for EUFA in May 2018 given the computation options set above -inflowCalc.computeInflow("SWT", "EUFA", startCal.getTime(), endCal.getTime()) + # This computes and saves inflow for EUFA in May 2018 given the computation options set above + inflow_calc.computeInflow("SWT", "EUFA", start_cal.getTime(), end_cal.getTime()) + + +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcZeroNegative.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcZeroNegative.py index ca1e5a0..b0e85ad 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcZeroNegative.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/InflowCalcZeroNegative.py @@ -1,36 +1,38 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone +from regi_python import regi_session, run_headless -# this gets a scriptable Pool Percent object -inflowCalc = registry.getCalculation(1.0, "Inflow") -# configure the start calendar +def calculate_inflow(registry): + # Java imports must happen after regi_session starts the JVM. + from java.util import Calendar, TimeZone -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) + # this gets a ScriptableInflow instance. + inflow_calc = registry.getCalculation(1.0, "Inflow") + # configure the start calendar + start_cal = Calendar.getInstance(TimeZone.getTimeZone("US/Central")) + start_cal.clear() + start_cal.set(Calendar.YEAR, 2018) + start_cal.set(Calendar.MONTH, 7) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) + # inflow_calc contains 4 callable methods: + # autoAdjust + # balanceAll + # cloneInflows + # zeroNegatives + # Each method takes the following arguments: + # officeId + # locationId + # startDate -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives + # autoAdjust also takes booleans: + # useLimits + # freezeRain -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.zeroNegatives("SWF", "ALAT2", startCal.getTime()) + # This autoBalances ALAT2 + inflow_calc.zeroNegatives("SWF", "ALAT2", start_cal.getTime()) +if __name__ == "__main__": + with regi_session(): + run_headless(calculate_inflow) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/examples/LoggingOptionsExamples.py b/regi-headless/src/test/resources/usace/rowcps/headless/examples/LoggingOptionsExamples.py index 139adba..cd5db36 100644 --- a/regi-headless/src/test/resources/usace/rowcps/headless/examples/LoggingOptionsExamples.py +++ b/regi-headless/src/test/resources/usace/rowcps/headless/examples/LoggingOptionsExamples.py @@ -1,4 +1,4 @@ -from usace.rowcps.headless import LoggingOptions +from regi_python import regi_session, run_headless # Description of: LoggingOptions.setDbMessageLevel(int level) # @@ -16,7 +16,11 @@ # >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | # --------------|-------------------------------------------------------------------------------------------------------------------------------| -LoggingOptions.setDbMessageLevel(2) +def configure_logging_options(registry): + # Java imports must happen after regi_session starts the JVM. + from usace.rowcps.headless import LoggingOptions + + LoggingOptions.setDbMessageLevel(2) # Description of: LoggingOptions.setMetricsEnabled(boolean value) @@ -30,4 +34,45 @@ # # By default, Metrics are disabled. -LoggingOptions.setMetricsEnabled(True) \ No newline at end of file + LoggingOptions.setMetricsEnabled(True) + +# Description of: LoggingOptions.enableAbridgedFlowGroupCompLogging() +# +# Enables the abridged flow group computation logging. This only applies to flow group computations, and will log +# information similar to a non-verbose REGI computation log. +# +# Example Output: +# Flow Group: Gated_Total 30Jun2018 2400 CDT 90.00 (cfs) +# Primary Time Series: SKIA.Flow-Controlled.Inst.1Hour.0.Rev-Regi-Flowgroup 90.00 (cfs) External Time Series: none Flow Group Computation: Total: 90.00 (cfs) +# +# By default flow group computation logging is disabled. + + LoggingOptions.enableAbridgedFlowGroupCompLogging() + +# Description of: LoggingOptions.enableAbridgedFlowGroupCompLogging() +# +# Enables the full flow group computation logging. This only applies to flow group computations, and will log +# information similar to a verbose REGI computation log. +# +# Example Output: +# Primary Time Series: +# TXKT2-Gated_Total.Flow-Out.Inst.1Hour.0.Rev-SWF-REGI 87.00 (cfs) * External Time Series: none Flow Group Computation: Total: 87.00 (cfs) | Merge Rule: Replace All Override Protection: false +# +# +# +# By default flow group computation logging is disabled. + + LoggingOptions.enableFullFlowGroupCompLogging() + +# Description of: LoggingOptions.disableFlowGroupCompLogging() +# +# Disables the logging of flow group computations. This is the default state of the LoggingOptions and does not need +# to be called unless LoggingOptions.enableAbridgedFlowGroupCompLogging() or LoggingOptions.enableFullFlowGroupCompLogging() +# have been called. + + LoggingOptions.disableFlowGroupCompLogging() + + +if __name__ == "__main__": + with regi_session(): + run_headless(configure_logging_options) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/hec.passwd b/regi-headless/src/test/resources/usace/rowcps/headless/hec.passwd deleted file mode 100644 index 5b27e06..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/hec.passwd +++ /dev/null @@ -1,2 +0,0 @@ -v2.0 -bang:1521:v11203swf02|QZg5V85RPTaV2ew1XkEVhBd/vHtxTr/rsDmgHyBfSoD= diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlow.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlow.py deleted file mode 100644 index 32926c3..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlow.py +++ /dev/null @@ -1,187 +0,0 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless import LoggingOptions - -def compute_All_Flowgroups(officeID, location, startCal, endCal): - # Takes in locations defined by user in group and computes all flow groups - try: - gateCalc.computeAll(officeID, location, startCal.getTime(), endCal.getTime()) - except Exception as e: - print "Error Computing all Flow Groups at {0} {1}".format(officeID, location) - print e - print '' - - -def compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup): - try: - gateCalc.computeFlowGroup(officeID, location, startCal.getTime(), endCal.getTime(), "Flow.{0}.{1}".format(location, flowGroup)) - except Exception as e: - print "Error Computing Flow Group {0} at {1}".format(officeID, location) - print e - print '' - - # #gateCalc.computeFlowGroup("SWF", "ACTT2", startCal.getTime(), endCal.getTime(), "Flow.ACTT2.Pump_Out_Total") -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(0) -LoggingOptions.enableAbridgedFlowGroupCompLogging() - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -# LoggingOptions.setMetricsEnabled(True) - -# not all of Regi is scriptable, registry is an object created by the java class RegiCLI that contains a list of -# the implemented scriptable calculations -names = registry.getNames(1.0) - -# this retrieves a Gate Flow calculation object -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# the gate flow calculations requires a start and end time. -# here we create a java Calendar object that will be used to create the start Date -startCal = Calendar.getInstance(timeZone) -startCal.clear() -#startCal.add(Calendar.DAY_OF_MONTH, -6) -#startCal.set(Calendar.HOUR, 0) -#startCal.set(Calendar.MINUTE, 0) -#startCal.set(Calendar.MILLISECOND, 0) -#startCal.set(Calendar.SECOND, 0) -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 5) - -# create a java Calendar object that will be used to create the end Date -endCal = Calendar.getInstance(timeZone) -endCal.clear() -#endCal.add(Calendar.DAY_OF_MONTH, 5) -#endCal.set(Calendar.HOUR, 0) -#endCal.set(Calendar.MINUTE, 0) -#endCal.set(Calendar.MILLISECOND, 0) -#endCal.set(Calendar.SECOND, 0) -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 6) - -officeID = "SWT" - -# the gateCalc object can perform its calculation for a single flow group -# the computeFlowGroup method takes: -# officeId -# projectId -# startDate -# endDate -# gateCalc.computeFlowGroup("SWF", "LEWT2", startCal.getTime(), endCal.getTime(), "Flow.LEWT2.ConduitGate_Total") -# By setting the following parameter to True, the following flow groups in the list FlowGroupList will all be calculated. Items can be commented out -# or commented back in individually. To turn this option off, set the following parameter to False. User can determine which flow group they want to calculate -# by changing the "flowGroup" variable. -calculateSingleFlowGroups = True -flowGroup = "Gated_Total" -locationList = ["SKIA", - "FGIB" -# "GGLT2", -# "GNGT2", -# "GPVT2", -# "HORT2", -# "JFNT2", -# "JPLT2", -# "JSPT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "BPRT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "TBLT2", -# "TBRT2", -# "GPET2", -# "BSLT2", -# "SAGT2", -# "MSDT2", - ] - -# the calculation can also be performed for all the associated groups -# the computeAll method takes: -# officeId -# projectId -# startDate -# endDate -# By setting the following parameter to True, all of the following flow groups in each location in the list locationList will all be calculated. -# Items can be commented out or commented back in individually. To turn this option off, set the following parameter to False. - -calculateAllFlowGroups = False -FlowGroupList = ["FGIB", - "SKIA", -# "GPVT2", -# "HORT2", -# "JPLT2", -# "LEWT2", -# "LVNT2", -# "PCTT2", -# "RRLT2", -# "FRHT2", -# "SCLT2", -# "SMCT2", -# "SOMT2", -# "STIT2", -# "TXKT2", -# "WTYT2", -# "TRNT2", -# "FFLT2", -# "EAMT2", -# "FLWT2", -# "LLST2", -# "GBYT2", -# "PSMT2", -# "SAGT2", - ] - - -if calculateSingleFlowGroups: - for location in locationList: - print "Now Running", location, "SINGLE" - compute_Single_Flowgroup(officeID, location, startCal, endCal, flowGroup) - -if calculateAllFlowGroups: - for location in FlowGroupList: - print "Now Running", location, "GROUP" - compute_All_Flowgroups(officeID, location, startCal, endCal) - - - diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlowCalc.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlowCalc.py deleted file mode 100644 index c32a4d1..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateFlowCalc.py +++ /dev/null @@ -1,22 +0,0 @@ -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -names = registry.getNames(1.0) -print "names", names - -gateCalc = registry.getCalculation(1.0, "Gate Flow") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) - -endCal = Calendar.getInstance(timeZone) -endCal.clear() -endCal.set(Calendar.YEAR, 2015) -endCal.set(Calendar.MONTH, 6) - -gateCalc.computeAll(TestVariables.OFFICE_ID, TestVariables.GATE_LOCATION, startCal.getTimeInMillis(), endCal.getTimeInMillis()) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateSettings.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateSettings.py deleted file mode 100644 index c3594dd..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/GateSettings.py +++ /dev/null @@ -1,45 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone - -# this gets a scriptable Gate Settings object -gateSettings = registry.getCalculation(1.0, "Gate Settings") - -# Time zone must be set because the Solaris time zone is UTC -timeZone = TimeZone.getTimeZone("US/Central") -# configure the start calendar -startCal = Calendar.getInstance(timeZone) -startCal.clear() -startCal.set(Calendar.YEAR, 2015) -startCal.set(Calendar.MONTH, 4) - -# configure the end calendar -endCal = Calendar.getInstance() -endCal.clear() -endCal.set(Calendar.YEAR, 2015) -endCal.set(Calendar.MONTH, 6) - - -# gateSettings contains four callable methods -# void createGateSettings(String officeId, String locationStr, Date startDate, Date end) throws Exception; -# void createGateSettingsGroup(String officeId, String locationStr, Date startDate, Date end, String groupId) throws Exception; -# void createGateSettingsOutlet(String officeId, String locationStr, Date startDate, Date end, String outletId) throws Exception; -# void createGateSettingsOutletFromTs(String officeId, String locationStr, Date startDate, Date end, String outletId, String tsId) throws Exception; - -office = TestVariables.OFFICE_ID -loc = TestVariables.GATE_LOCATION - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the specified input time series. -gateSettings.createGateSettingsOutletFromTs(office, loc, startCal.getTime(), endCal.getTime(), "TG1", loc + "-TG1.Opening-Spillway_Gate.Const.0.0.MANUAL" ) - -# This is an example of a call that would create gate settings at TainterGate 1 at WTYT2 from the regi association configured input time series. -gateSettings.createGateSettingsOutlet(office, loc, startCal.getTime(), endCal.getTime(), "TG1") - -# This is an example of a call that would create gate settings at all outlets at WTYT2 which are in the TainterGateWTY group from the association configured time series. -gateSettings.createGateSettingsGroup(office, loc, startCal.getTime(), endCal.getTime(), loc + "-TainterGate" ) - -# This is an example of a call that would create gate settings for every outlet in a rating group at WTYT2. -gateSettings.createGateSettings(office, loc, startCal.getTime(), endCal.getTime() ) - - - diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcAutoAdjust.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcAutoAdjust.py deleted file mode 100644 index b505c9b..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcAutoAdjust.py +++ /dev/null @@ -1,36 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 6) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.autoAdjust(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime(), False, False) - - diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcBalanceAll.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcBalanceAll.py deleted file mode 100644 index 8d91e5f..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcBalanceAll.py +++ /dev/null @@ -1,36 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 7) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.balanceAll(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime()) - - diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcClone.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcClone.py deleted file mode 100644 index f45eee8..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcClone.py +++ /dev/null @@ -1,34 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 7) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the followind arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.cloneInflows(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime()) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputeEvapAsFlow.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputeEvapAsFlow.py deleted file mode 100644 index 3a79f06..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputeEvapAsFlow.py +++ /dev/null @@ -1,23 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) - -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) - -# This computes and saves evap as flow for EUFA in May 2018 -inflowCalc.computeEvapAsFlow(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime(), endCal.getTime()) \ No newline at end of file diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputedInflow.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputedInflow.py deleted file mode 100644 index 4cd6e5a..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcComputedInflow.py +++ /dev/null @@ -1,37 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.calculator.inflow import InflowComputationStorageOption -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 4) - -endCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) -endCal.clear() -endCal.set(Calendar.YEAR, 2018) -endCal.set(Calendar.MONTH, 4) -endCal.set(Calendar.DAY_OF_MONTH, 4) - - -# This code has been deprecated, but the API must exist. -storageOptionsSet = False -try: - inflowCalc.setComputationStorageOptions(InflowComputationStorageOption.EVAP_AS_FLOW, InflowComputationStorageOption.PROJECT_RELEASES) - storageOptionsSet = True -except: - print "Exception occurred during setComputationStorageOptions, this is expected" - -if storageOptionsSet: - throw Exception("ScriptableInflow::setComputationStorageOptions should not be working") - -# This computes and saves inflow for EUFA in May 2018 given the computation options set above -inflowCalc.computeInflow(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime(), endCal.getTime()) diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcZeroNegative.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcZeroNegative.py deleted file mode 100644 index 5e33586..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/InflowCalcZeroNegative.py +++ /dev/null @@ -1,34 +0,0 @@ -# the java Calendar class is used to create java Date objects -from java.util import Calendar -from java.util import TimeZone -from usace.rowcps.headless.tests import TestVariables - -# this gets a ScriptableInflow instance. -inflowCalc = registry.getCalculation(1.0, "Inflow") - -# configure the start calendar -startCal = Calendar.getInstance(TimeZone.getTimeZone('US/Central')) - -startCal.clear() -startCal.set(Calendar.YEAR, 2018) -startCal.set(Calendar.MONTH, 7) - - -# inflowCalc contains 4 callable methods: -# autoAdjust -# balanceAll -# cloneInflows -# zeroNegatives - -# Each method takes the following arguments: -# officeId -# locationId -# startDate - -# autoAdjust also takes booleans: -# useLimits -# freezeRain - -# This autoBalances ALAT2 -inflowCalc.zeroNegatives(TestVariables.OFFICE_ID, TestVariables.INFLOW_LOCATION, startCal.getTime()) - diff --git a/regi-headless/src/test/resources/usace/rowcps/headless/tests/LoggingOptionsExamples.py b/regi-headless/src/test/resources/usace/rowcps/headless/tests/LoggingOptionsExamples.py deleted file mode 100644 index 61835bf..0000000 --- a/regi-headless/src/test/resources/usace/rowcps/headless/tests/LoggingOptionsExamples.py +++ /dev/null @@ -1,69 +0,0 @@ -from usace.rowcps.headless import LoggingOptions - -# Description of: LoggingOptions.setDbMessageLevel(int level) -# -# Adds Time Series logging messages in the OracleTimeSeriesDaoImpl. Recommended -# level is 2, as this provides basic information about the time series -# retrieval/storage. -# -# Message Level | Description -# --------------|-------------------------------------------------------------------------------------------------------------------------------| -# <=0 | Default value, does not do anything. Lower values do not change behavior. | -# 1 | Logs message when no data is found. Logs message when data is found, how much was retrieved or stored, and how long it took. | -# 2 | Adds message with name of time series, and the units to retrieve/store. | -# 3 | Adds message with the current time. | -# 4 | Adds message with first 10 dates and values from each time series. | -# >4 | Same as 4, but shows all values retrieved from each time series. Higher values do not change behavior. | -# --------------|-------------------------------------------------------------------------------------------------------------------------------| - -LoggingOptions.setDbMessageLevel(2) - - -# Description of: LoggingOptions.setMetricsEnabled(boolean value) -# -# Enables or disables the storage of REGI's Metric data pertaining to the -# performance of the application. This is incredibly helpful for identifying -# issues where the application takes an excessive amount of time to operate. -# -# Metrics also log the location of the files as an INFO message if they are -# enabled. -# -# By default, Metrics are disabled. - -LoggingOptions.setMetricsEnabled(True) - -# Description of: LoggingOptions.enableAbridgedFlowGroupCompLogging() -# -# Enables the abridged flow group computation logging. This only applies to flow group computations, and will log -# information similar to a non-verbose REGI computation log. -# -# Example Output: -# Flow Group: Gated_Total 30Jun2018 2400 CDT 90.00 (cfs) -# Primary Time Series: SKIA.Flow-Controlled.Inst.1Hour.0.Rev-Regi-Flowgroup 90.00 (cfs) External Time Series: none Flow Group Computation: Total: 90.00 (cfs) -# -# By default flow group computation logging is disabled. - -LoggingOptions.enableAbridgedFlowGroupCompLogging() - -# Description of: LoggingOptions.enableAbridgedFlowGroupCompLogging() -# -# Enables the full flow group computation logging. This only applies to flow group computations, and will log -# information similar to a verbose REGI computation log. -# -# Example Output: -# Primary Time Series: -# TXKT2-Gated_Total.Flow-Out.Inst.1Hour.0.Rev-SWF-REGI 87.00 (cfs) * External Time Series: none Flow Group Computation: Total: 87.00 (cfs) | Merge Rule: Replace All Override Protection: false -# -# -# -# By default flow group computation logging is disabled. - -LoggingOptions.enableFullFlowGroupCompLogging() - -# Description of: LoggingOptions.disableFlowGroupCompLogging() -# -# Disables the logging of flow group computations. This is the default state of the LoggingOptions and does not need -# to be called unless LoggingOptions.enableAbridgedFlowGroupCompLogging() or LoggingOptions.enableFullFlowGroupCompLogging() -# have been called. - -LoggingOptions.disableFlowGroupCompLogging() \ No newline at end of file