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

Dereference $ref calls when reading a sink in a node. #27

Closed qjhart closed 8 years ago

qjhart commented 8 years ago

Mustafa has documented some errors with the code at: https://github.com/msdogan/HOBBEStoPRMcomparison/issues/1

Regarding the missing 'BL' line: The reason for the missing BL link in the sink is due to the recursive nature of the writeLink() function in the file calvin-network-tools/nodejs/pri/format/link.js. In the if (np.sinks) function, if a sink is found, it calls a new writeLink() function. However, the CSV links are not dereferenced. As a result, the bounds are not filled out, and a BL line is not created. Example: /data/south-lahontan/mono-owens-area/sr_ol/node.geojson

jrmerz commented 8 years ago

Should be fixed. The upper and lower bounds CSV files are parsed after the initial crawl (which is preformed w/o $ref file read) but before the formatters here. This loop now checks for sinks, then looks through and checks for bounds within the sinks as well, adding all sink-bounds to the list of $ref objects to be read.

FYI, the hobbes-network-format now exposes a readFile method, which takes a parent object, attribute and callback, then reads in the $ref. so...

var parent = {
  type : 'LMB',
  bound : {
    $ref : '/path/to/csv/data.csv'
  }
}

hnf.readFile(parent, 'bound', () => {}) 

returns:

 {
   type : 'LMB',
   bound : [[],[],[]...]
}
jrmerz commented 8 years ago

@qjhart @msdogan This fix has been pushed to v1.0.30 let me know how things look.

Also, v1.0.30 has a --no-descriptions for the build command. This flag will leave off the LD descriptions from the pri file. Use if your build is failing with the full buffer error.

msdogan commented 8 years ago

@jrmerz version 1.0.30 seems to fix constrained flow bug, but this time prm build --prefix test command didn't generate testPD.dss and testTS.dss files. It only created .pri file.

jrmerz commented 8 years ago

@msdogan can you provide OS? I have tested on OSX and win 7 and both are generating dss files for 1.0.30.

msdogan commented 8 years ago

@jrmerz I am using Windows 7. dssWriterParams appears but it does not save dss files.

jrmerz commented 8 years ago

Can you run with --verbose flag, dump the output to a file and send it to me?

jrmerz commented 8 years ago

And/or we can schedule a hangout.

msdogan commented 8 years ago

verbose output is saved in verbose.txt, attached here

verbose.txt

jrmerz commented 8 years ago

Ok, the bug is the unescaped spaces in the file path 'Z:\HOBBEStoPRMcomparison (GitHub Desktop)'. I will look to fix, but for now, just run in a folder where there are no spaces in the path.

msdogan commented 8 years ago

okay, yes it worked in a different folder. thanks

jrmerz commented 8 years ago

Cool, created a new ticket to track bug #29

msdogan commented 8 years ago

@jrmerz Can you please make these fixes. I am doing them each time before initiating a run. I tried to fix for example by deleting node 'Sink_C41' in data file (calvin-network-data) but calvin-network-tools complained about that. Here is the issue I opened https://github.com/msdogan/HOBBEStoPRMcomparison/issues/3

jrmerz commented 8 years ago

I can take a look at those issues and you are on the right track, they should be done w/ edits to calvin-network-data repo. Can you post what prm was complaining about?

msdogan commented 8 years ago

I want to delete node Sink_C41. This node is not connected to any node in the system. To do that, I delete the folder containing this node and information (Z:\calvin-network-data\data\san-joaquin-river\sierra-foothills\sink_c41). After that when I run prm build --prefix test command, I get the attached error. sink_c41.txt

msdogan commented 8 years ago

after updating calvin-network-data, do I need to run npm install -g calvin-network-tools and prm init commands again?

msdogan commented 8 years ago

and one more question @jrmerz :) Is there a way to point where the data file is before building a run?

jrmerz commented 8 years ago

Starting new issue for this #30

jrmerz commented 8 years ago

Think this has split out to multiple issues which are being tracked elsewhere.