Subject: Creating identical copies of data from one year to be used in subsequent years Posted: 9/21/2010 Viewed: 33251 times
Does anyone know if there is an easy way to specify the exact input data for key assumptions, demands, catchments, hydrology, flow requirements, etc. of a particular year to be used in subsequent years (and override the current data specifications for those subsequent years). The idea here is to develop a model with multiple consecutive “identical” years (e.g., one can examine the effects on water supply of consecutive “average” years for example). Considering the number of different elements in the model I will be working with, it would be very labor intensive to have to specify new input values for each element individually for a set of consecutive years(this would include changing ReadFromFile() .csv data). If someone knows of a script or some other short-cut method of “replicating” specific years of data (any or all of element values from .csv files, expressions, key assumptions, etc.), please share. Thanks.
Mr. Jack Sieber
Subject: Re: Creating identical copies of data from one year to be used in subsequent years Posted: 9/21/2010 Viewed: 33246 times
I don't quite understand what you want. Could you please give a short example illustrating the sequence of values you would like to give?
Mr. Elliott Matchett
Subject: Re: Creating identical copies of data from one year to be used in subsequent years Posted: 9/21/2010 Viewed: 33239 times
Here is an example with some background to help you understand:
Background: A model has already been developed and calibrated for an expansive region and includes
current accounts year: 1990
scenario years: 1991-2005
Available water supplies at nodes of all years are dictated by multiple elements and key assumptions, which are:
1) Key assumptions dealing with parameterizing demands/priorities, hydrology, flow requirements, etc.
2) Catchments (model values calculated by Soil Moisture Model from climate data contained in .csv files);
4) Flow requirements (some based on .cvs files);
5) Groundwater; and
6) Reservoir historical storage data (.cvs files).
7) stream flow historical gauge data (.cvs files)
(but probably leaving a few out.)
All of the same elements are present across the entire time period (1990-2005). Key assumptions probably do not change through time for many of the elements.
Supposing 1990 in the current model is an average year and modeling five consecutive average years with all of the same data parameters is the purpose, the resulting data should look like:
Current accounts year: 1990
Scenario years: 1991-2000 (the current model’s data), 2001-2005 (all data changed so identical to 1990).
So, essentially the key assumptions, catchments, etc. data effectively resembles 1990-2000, 1990, 1990, 1990, 1990, and 1990.
Even better would be if I could control both the number of years simulated and the order that they occur in the sequence. For example: I might just want to remove years 1990-2000 from the sequence of years, but code 2001-2005 all as 1990 as above. In this case, only one of the of original 11 years of data would be used, replicated four more times, and moved to latter position in the sequence of years.
I suspect that there is no easy way to do one or both of these, but am crossing my fingers. I am guessing that I will have to manually rewrite data in the .csv files and check each key assumption, stream flow requirements, etc. and make sure that they are not year-specific. I apologize if my description of the problem was unclear. If you need to know more about why I want to do this I can provide more info. Thanks
Mr. Jack Sieber
Subject: Re: Creating identical copies of data from one year to be used in subsequent years Posted: 9/21/2010 Viewed: 33235 times
You can do this with a simple If expression in WEAP. For example, if your scenario expression is
You can automate this process using a Visual Basic Script (VBS) and the WEAP API. Here is a simple script that goes through every variable in the current area and updates its expression as above.
To test this, save the following lines to a file named test.vbs and then double click on this file to run it. WEAP can be running already or not. I suggest you first create a version of your area as a backup: Menu: Area, Save Version
Copy the following lines to test.vbs
' Change every expression in scenario Reference to use the Current Account value for years after 2000
WEAP.Visible = false ' hide WEAP window so that it doesn't spend time updating
WEAP.ActiveScenario = "Reference"
FOR EACH B in WEAP.Branches
FOR EACH V in B.Variables
IF (not V.IsResultVariable) and (V.Name <> "Method") and (V.Name <> "Startup Year") and (V.Name <> "Read from File") and (V.Name <> "Supply Preference") and (V.Name <> "Sequence") THEN
OldExpression = LTrim(V.Expression(False))
IF INSTR(OldExpression, ";") > 0 THEN ' Need to put any existing comment at the end of new expression
Comment = MID(OldExpression, INSTR(OldExpression, ";"))
OldExpression = LTRIM(LEFT(OldExpression, INSTR(OldExpression, ";") - 1))
Comment = ""
V.Expression = "If(Year > 2000, CurrentAccountsValue, " + OldExpression + ") " + Comment
WEAP.Visible = true
Set WEAP = CreateObject("WEAP.WEAPApplication") ' Start WEAP
WHILE not WEAP.ProgramStarted ' Wait until it's finished loading
WEAP.Verbose = 0 ' Suppress questions and messages
WEAP.Logfile = "WEAPAutomationErrors.txt" ' Report any errors to this text file
WScript.sleep( sec * 1000) ' WScript is the built-in Windows scripting object
Topic "Creating identical copies of data from one year to be used in subsequent years"