CADWRDeltaModeling / schimpy

Python package for SCHISM
https://cadwrdeltamodeling.github.io/schimpy/
MIT License
9 stars 6 forks source link

param out nml parsing issue #35

Open dwr-psandhu opened 1 year ago

dwr-psandhu commented 1 year ago

Description

param out nml file has a issue parsing arrays https://github.com/CADWRDeltaModeling/BayDeltaSCHISM/issues/37

dwr-psandhu commented 1 year ago

@water-e I think the issue from BayDeltaSchism#37 is a schimpy issue. I have opened this issue and committed a test case and test data using your attachments from that issue. The testcase is passing as it is was meets my expectations. Please modify the testcase and make it fail so I know what to fix. See the commit above.

water-e commented 1 year ago

You are getting the same result as I am. Let me clarify the use case this obstructs.

I hope to diff two nml files. We previously talked about 'iof_hydro(1)' being a kind of text key, and when we parse the sample files from our templates or the schism samples this has a big benefit when it comes ot comments. The line iof_hydro(1) = 1 !0: off; 1: on - elev. [m] {elevation} 2D is very informative and self documenting, for instance.

By contrast, the param.out.nml version of the file looks like this: IOF_HYDRO = 1, 16*0, 2*1, 5*0, 2*1, 14*0, ... and that not only is a different syntax, it produces a different key (iof_hydro vs iof_hydro(1) )

iof_hydro(1) = 1 
iof_hydro(2) = 0
iof_hydro(3) = 0
...

the two are different.

Perhaps we can detect (regex) a value that has commas and and split: `iof_hydro: 1, 20` into the following representation in the dictionary

'iof_hydro(1)' : 1
'iof_hydro(2)' : 0
'iof_hydro(3)' : 0
water-e commented 1 year ago

Or allowing the parameter to be an array and inline comment to be an array would work and perhaps be a better representation.

water-e commented 1 year ago

I agree it is a schimpy issue. I think I've had the wrong web page open for this and some of the others. We can close these out and I'll be more careful.

dwr-psandhu commented 1 year ago

Ok I have got it now