VirtualWatershed / prms-vegetation-scenarios

Online tool for PRMS modeling of multiple vegetation scenarios
BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Create three sample scenarios for development #30

Closed mt-digital closed 8 years ago

mt-digital commented 8 years ago

For development it would be useful to have more scenarios available at startup, especially for #24.

To do this, we can look at line 77 of api/views.py to see that when GET /api/scenarios is called, there is a call to _init_dev_db.

_init_dev_db creates a Scenario instance and saves them (see app/models.py for the class definition). We create a fake hydrograph by first creating two water years' worth of dates starting from 1 October 2010 and going to 30 September 2012.

A hydrograph is characterized by a peak flow, as in how much water volume per unit time flows past a measurement device at a gage station. As climate change causes snow to melt sooner, the peak flow in a hydrograph will get earlier and earlier. For development, our current fake hydrograph are exponential functions centered at the 200th day of the year. They are generated as follows:

# create two water years of fake data starting from 1 Oct 2010
begin_date = datetime.datetime(2010, 10, 1, 0)
time_array = [begin_date + datetime.timedelta(days=x) for x in range(365*2)]

# use simple exponentials as the prototype data
x = range(365)
streamflow_array = [pow(math.e, -pow(((i - 200.0)/100.0), 2)) for i in x]

Please create two more fake hydrographs for two new scenarios, making three total scenarios. Much of the data for these can be the same. You'll need to change the title and the centers of the hydrographs. Make the other two to be centered at day 150 and day 100 of the year, i.e. change this:

streamflow_array = [pow(math.e, -pow(((i - 200.0)/100.0), 2)) for i in x]

to this for peaking at 150 days

#  i - 200 => i - 150
streamflow_array = [pow(math.e, -pow(((i - 150.0)/100.0), 2)) for i in x]

and this for peaking at 100 days

#  i - 200 => i - 100
streamflow_array = [pow(math.e, -pow(((i - 100.0)/100.0), 2)) for i in x]

Please contact me by email or slack or ask @itsrifat for help.