AmericasWater / awash

America's Water AWASH Model
GNU General Public License v3.0
4 stars 6 forks source link

Statelevelmodeling #27

Closed LaurelineJ closed 7 years ago

LaurelineJ commented 7 years ago

I have modified any place where US-wide data is loaded so that if one wants to run a simulation or optimization at the state level, the relevant data is loaded. It would probably be more elegant to load the USGS recorded withdrawals only once, select the relevant rows and save the state specific input, but it is not what I have done. @jrising What do you think ?

Additional changes: Allocation.jl

jrising commented 7 years ago

You end up using an essentially identical block of code many times, for filtering the data. That's could make things more difficult when we want to change them-- like if we rename "filterstate" or otherwise change how the configuration system works.

Can we replace these with a common function, in the datastore.jl file? Something like

function getfilteredtable(datapath)
    recorded = readtable(datapath(datapath))
    if get(config, "filterstate", nothing) != nothing
        recorded = recorded[find(floor(recorded[:FIPS]/1e3) .== parse(Int64,config["filterstate"])),:]
    end
    recorded
end
LaurelineJ commented 7 years ago

Definitely ! While we are at it, do we want to centralize the loading of water demand data so that we don't have to change the filename everywhere ? We could also have a function that computes the total water demand so that we don't have exceeding balance values ?

jrising commented 7 years ago

Following on our discussion, I think this can be a wrapper on configdata. Something like

function waterdemanddata(sector::Symbol)
    # Use cache if it's available, filter if it's not, but when read it use:
    configdata("waterdemand", datapath("extraction/USGS-2010.csv"), sector2column[sector], :fips)
end

where sector2column is a Dict{Symbol, Symbol} that gives the right column for a universal sector name.

LaurelineJ commented 7 years ago

Thanks for the suggestion, I am going to work on that Thursday

On 15 October 2016 at 21:56, James Rising notifications@github.com wrote:

Following on our discussion, I think this can be a wrapper on configdata. Something like

function waterdemanddata(sector::Symbol)

Use cache if it's available, filter if it's not, but when read it use:

configdata("waterdemand", datapath("extraction/USGS-2010.csv"), sector2column[sector], :fips)

end

where sector2column is a Dict{Symbol, Symbol} that gives the right column for a universal sector name.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AmericasWater/awash/pull/27#issuecomment-254022295, or mute the thread https://github.com/notifications/unsubscribe-auth/APozsnAwMizLZfrPiA2iCdF7otJPsBZRks5q0YQ3gaJpZM4KWRlB .

jrising commented 7 years ago

Okay, this is up and running! I'm going to merge it in, before more things change.