-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/jpype script migration #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.