Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Stream Totaling for Staging Compatibility #2817

Merged
merged 1 commit into from May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/mmw/apps/modeling/calcs.py
Expand Up @@ -6,7 +6,6 @@
import json

from copy import deepcopy
from collections import namedtuple

from django.conf import settings
from django.db import connection
Expand Down Expand Up @@ -108,16 +107,14 @@ def apply_subbasin_gwlfe_modifications(gms, modifications,


def sum_subbasin_stream_lengths(gmss):
stream_length_summary = namedtuple('StreamLengthSummary',
['ag', 'urban'])
ag = sum([gms['AgLength'] for gms in gmss.itervalues()])
urban = sum([gms['StreamLength'] - gms['AgLength']
for gms in gmss.itervalues()])

def add_stream_length(summary, gms):
ag = summary.ag + gms['AgLength']
urban = summary.urban + gms['StreamLength'] - gms['AgLength']
return stream_length_summary(ag=ag, urban=urban)

return reduce(add_stream_length, gmss.itervalues(),
stream_length_summary(0, 0))
return {
'ag': ag,
'urban': urban
}


def get_layer_shape(table_code, id):
Expand Down