respec / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
43 stars 17 forks source link

Parse UCI without SCHEMATIC and NETWORK blocks #79

Closed rburghol closed 2 years ago

rburghol commented 2 years ago

I am testing with a UCI that lacks both SCHEMATIC & NETWORK (it is from a version of the Chesapeake Bay model land simulation which simply routes output to a UCI via EXT TARGETS block to be later run in a separate river-only UCI). This fails on uci import when calling the panda function concat since both net and sc remain as None. I can get the UCI import to complete by testing for if not ( (net is None) and (sc is None) ): before running the linkage output to the hdf, but wondering if anyone sees a problem with this before I go forward with forking and adding a pull request to the new code.

Basically, I swap out the original (near line 160 in readUCI.py):

        linkage = concat((net, sc), ignore_index=True, sort=True)
        for cname in colnames:
            if cname not in linkage.columns:
                linkage[cname] = ''
        linkage = linkage.sort_values(by=['TVOLNO']).replace('na','')
        linkage.to_hdf(store, '/CONTROL/LINKS', data_columns=True)

For this:

        if not ( (net is None) and (sc is None) ):
            linkage = concat((net, sc), ignore_index=True, sort=True)
            for cname in colnames:
               if cname not in linkage.columns:
                    linkage[cname] = ''
            linkage = linkage.sort_values(by=['TVOLNO']).replace('na','')
            linkage.to_hdf(store, '/CONTROL/LINKS', data_columns=True)

And so, in sum, no /CONTROL/LINKS gets written to the hd5.

PaulDudaRESPEC commented 2 years ago

Hi @rburghol , that seems like an appropriate solution. It's good to have additional testers to find things like this that don't show up in our standard tests!

rburghol commented 2 years ago

Pull request submitted.

aufdenkampe commented 2 years ago

Closing with this PR merge: