ucd-cws / calvin-network-tools

Command line tools for calvin-network-data and calvin-network-app. Includes prm tool for export PRI and DSS files
MIT License
3 stars 5 forks source link

Matrix Export [Continued] #54

Open mlmaskey opened 4 years ago

mlmaskey commented 4 years ago

Thank you, Mustafa, for your help, Yesterday. With the file, you gave me worked for one time. Unfortunately, you need to restart the computer for the second case. While I ran the model for the second time I got a similar message as before,

Mahesh@Dell MINGW64 ~/documents/github/calvin (master) $ cnf matrix --verbose --format=csv --start=2001-10 --stop=2002-09 --ts=. --fs=, --to=linksWY2002 --outnodes=nodes --max-ub=1000000000 D17 SR_FOL D9 D85 D64 C7 C8 C104 D44 U204 D503 D511 D507 D509 D541 C173 A207 C37

matrix Input Parameters { "0": "Documents\GitHub\CALVIN\calvin-network-tools\bin\cli.js", "_": [ "matrix" ], "help": false, "no-header": false, "N": false, "noHeader": false, "verbose": true, "v": true, "format": "csv", "f": "csv", "start": "2001-10", "s": "2001-10", "stop": "2002-09", "t": "2002-09", "ts": ".", "S": ".", "fs": ",", "F": ",", "to": "linksWY2002", "T": "linksWY2002", "outnodes": "nodes", "max-ub": 1000000000, "M": 1000000000, "maxUb": 1000000000, "config": "C:\Users\Mahesh", "c": "C:\Users\Mahesh", "$0": "......\AppData\Roaming\npm\node_modules\calvin-network-tools\bin\cli.js", "data": "C:\Users\Mahesh\Documents\GitHub\CALVIN\calvin-network-data\data", "nodes": [ "D17", "SR_FOL", "D9", "D85", "D64", "C7", "C8", "C104", "D44", "U204", "D503", "D511", "D507", "D509", "D541", "C173", "A207", "C37" ], "runtime": "C:\Users\Mahesh\Documents\GitHub\CALVIN\calvin-network-tools\HEC_Runtime" }

undefined:2 calvin-network-tools@3.0.5 | ISC | deps: 20 | versions: 66 ^

SyntaxError: Invalid or unexpected token at C:\Users\Mahesh\AppData\Roaming\npm\node_modules\calvin-network-tools\nodejs\lib\checkVersion.js:30:33 at ChildProcess.exithandler (child_process.js:294:7) at ChildProcess.emit (events.js:311:20) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

Mahesh@Dell MINGW64 ~/documents/github/calvin (master)

Most interesting thing is that on another computer at the Lab did not run despite I modified the prmconf. file at all. The message in that computer looks like: Water Management Lab@DESKTOP-D3ODFAQ MINGW64 ~/documents/github $ cnf matrix --verbose --format=csv --start=2002-10 --stop=2003-09 --ts=. --fs=, --to=linkWY2003 --outnodes=nodes --max-ub=1000000000 D17 SR_FOL D9 D85 D64

matrix Input Parameters { "_": [ "matrix" ], "help": false, "no-header": false, "N": false, "noHeader": false, "verbose": true, "v": true, "format": "csv", "f": "csv", "start": "2002-10", "s": "2002-10", "stop": "2003-09", "t": "2003-09", "ts": ".", "S": ".", "fs": ",", "F": ",", "to": "linkWY2003", "T": "linkWY2003", "outnodes": "nodes", "max-ub": 1000000000, "M": 1000000000, "maxUb": 1000000000, "config": "C:\Users\Water Management Lab", "c": "C:\Users\Water Management Lab", "$0": "....\AppData\Roaming\npm\node_modules\calvin-network-tools\bin\cli.js", "data": "C:\Users\Water Management Lab\Documents\GitHub\calvin-network-data\data", "nodes": [ "D17", "SR_FOL", "D9", "D85", "D64" ], "runtime": "C:\Users\Water Management Lab\Documents\GitHub\calvin-network-tools\HEC_Runtime" }

undefined:2 calvin-network-tools@3.0.5 | ISC | deps: 20 | versions: 66 ^

SyntaxError: Invalid or unexpected token at C:\Users\Water Management Lab\AppData\Roaming\npm\node_modules\calvin-network-tools\nodejs\lib\checkVersion.js:30:33 at ChildProcess.exithandler (child_process.js:294:7) at ChildProcess.emit (events.js:321:20) at maybeClose (internal/child_process.js:1026:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

Water Management Lab@DESKTOP-D3ODFAQ MINGW64 ~/documents/github

Could you please let me know what could be the reason for this. I confgure two files as below: 1 In my laptop: {"0": "Documents\GitHub\CALVIN\calvin-network-tools\bin\cli.js","data":"C:\Users\Mahesh\Documents\GitHub\CALVIN\calvin-network-data\data","runtime":"C:\Users\Mahesh\Documents\GitHub\CALVIN\calvin-network-tools\HEC_Runtime"} or {"data":"C:\Users\Mahesh\Documents\GitHub\CALVIN\calvin-network-data\data","runtime":"C:\Users\Mahesh\GitHub\CALVIN\calvin-network-tools\HEC_Runtime"} 2> In the lab: {"data":"C:\Users\Water Management Lab\Documents\GitHub\calvin-network-data\data","runtime":"C:\Users\Water Management Lab\Documents\GitHub\calvin-network-tools\HEC_Runtime"}

I appreciate your help.

Best regards Mahesh

msdogan commented 4 years ago

@mlmaskey

I don't know what is causing this. I also got a similar error. Then, restarted my PC and the command worked fine. When you get that error, restart your PC and then try again. Hopefully it will work.

jrmerz commented 4 years ago

At first glance, it looks like npm info needs to be replaced with npm view --json. Then the eval call can be replaced with json.parse in nodjs/lib/checkVersion.js

You could also look to skip this step, it's non-essential. Used to notify users if a new version of the library is ready.

mlmaskey commented 4 years ago

@msdogan Thanks for your suggestions. Yes, it is true that you can run once at a time but only after restarting the PC. But the problem is updating the data. Does command automatically update and run hec-prm if you replaced link or node data from some other models?

@jrmerz I tried to run npm view --json but it also gives the error message below. There is no such steps where you can interactively update npm info. $ npm view --json

npm ERR! Invalid package.json
{
  "error": {
    "summary": "Invalid package.json",
    "detail": ""
  }
}

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mahesh\AppData\Roaming\npm-cache\_logs\2020-03-02T16_57_04_173Z-debug.log

All these issues, I think, are related to the system or compatibility of Java version. @jrmerz or @qjhart, Your help will be appreciated, if you could provide me a couple of hours of the session for setting up the logistics for CALVIN to run. This will help me to figure out the CALVIN independently since this is not just Python.

Thank you all.

msdogan commented 4 years ago

@mlmaskey hec-prm is old way of running CALVIN model. We now export the data as a network matrix and run the python script. If you make changes to calvin-network-data repo (or better you create a copy or your own branch), you should be able to export the modified network. If you store your copied data in a different path, you can point to data location while exporting network with --data \path\to\data\data command. Full list of matrix export commands are below:

(base) C:\Users\PC>cnf matrix --help
AppData\Roaming\npm\node_modules\calvin-network-tools\bin\cli.js matrix
[nodes...]

Options:
  --help                  Show help                                    [boolean]
  --format, -f            Output Format, dot | png (graphviz required)
                          [choices: "csv", "tsv", "dot", "png"] [default: "csv"]
  --no-header, -N         Supress CSV/TSV Header                       [boolean]
  --ts, -S                <sep> Time step separator               [default: "@"]
  --fs, -F                <sep> Field Separator                   [default: ","]
  --start, -s             [YYYY-MM] Specify start date for TimeSeries data
  --stop, -t              [YYYY-MM] Specify stop date for TimeSeries data
  --max-ub, -M            Replace null upperbound with a big number.  Like
                          1000000                                       [number]
  --debug, -D             Set debug nodes.  Either "ALL", "*" or comma seperated
                          list of prmnames (no spaces)
  --to, -T                <filename> Send matrix to filename [default: "STDOUT"]
  --dump-nodes, -O        <filename> Send list of nodes to filename, default=no
                          output, can use STDOUT
  --outbound-penalty, -p  <json> Specify a penalty function for outbound
                          boundary conditions. eg.
                          [[10000,"-10%"],[0,0],[-10000,"10%"]]
  --regions, -r           Specify a list of regions to include.  All nodes
                          within the regions will be added to the NODES list.
                          Comma seperate
  --config, -c            [path] Path to .prmconf file.
                                                      [default: "C:\\Users\\PC"]
  --data, -d              [repo/path/data] path to Calvin Network /data folder.
  --verbose, -v           Verbose output, including hec-dss library output for
                          hec-prm cmds.                                [boolean]
mlmaskey commented 4 years ago

At first glance, it looks like npm info needs to be replaced with npm view --json. Then the eval call can be replaced with json.parse in nodjs/lib/checkVersion.js

You could also look to skip this step, it's non-essential. Used to notify users if a new version of the library is ready.

@jrmerz It worked now just changing line 19 in checkVersion.js as: exec('npm view --json calvin-network-tools', {},

Thanks for a hint.