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

prototype route for retrieving hydrograph #14

Closed mt-digital closed 8 years ago

mt-digital commented 8 years ago

Eventually we need a way to retrieve the hydrograph for a single model run, but shorter term, we need to first figure out how to serve a hydrograph. A hydrograph is a simple timeseries,

Please make this an API route, so in app/api/views.py add a route like this:

# not sure if these paths will work; just for demonstration
DEFAULT_PRMS_STATVAR = netCDF4.Dataset('static/data/statvar.nc')

@api.route('/api/hydrograph')
def get_hydrograph():
    data = _get_hydrograph(DEFAULT_PRMS_STATVAR)
    return jsonify(data)

def _get_hydrograph(prms_stat_nc):
    """
    Extract the hydrograph from the PRMS stat netCDF and format for display in frontend plot
    """
    # this data will need to be extracted from netCDF statvar dataset
    data = {
        # consult @ruiwu1990 for how time should be formatted: UNIX Epoch, ISO 8601 string, etc
        'time': ['2010-10-01T00:00:00', '2010-10-02T00:00:00', ...],
        # not sure what reasonable numbers are, just using these as an example
        'streamflow': [23.55, 33.24, 55.56, .... ]
    }
    return data

Please communicate with @ruiwu1990 to determine the best format to serve the hydrograph.

mt-digital commented 8 years ago

this actually is done with 7627dc5d2118e676fba525fa6770baee5f87c645. Hydrograph is included with the data returned from /api/scenarios and /api/scenarios/{scenario_id} in the hydrograph property of the JSON data. Required for #20