0

I'm trying to implement an algorithm using values from an arcpy module. Here is my equation written into code. I need for the initial value of the variables St and Yt to start off at zero. After the first time running through the loop I need the previous values of Yt,Qt,and St to be used for the next calculation. I havn't been able to figure out how to get to this to work.

V=0.416395
Dt= 0.5560694202
cursor = arcpy.da.SearchCursor(shapefile,mathlist)
for row in cursor:
    for i in range(1:len(mathlist))
        Yt = min(Dt,St)
        St = min(St+Qt-Yt,V)
        Qt = .82 * row[0] *row[i]
3

If you want those variables set to zero for each row in shapefile, your code should look like this:

V=0.416395
Dt= 0.5560694202
cursor = arcpy.da.SearchCursor(shapefile,mathlist)
for row in cursor:
    St = 0
    Yt = 0
    Qt = 0
    for i in range(1:len(mathlist))
        Yt = min(Dt,St)
        St = min(St+Qt-Yt,V)
        Qt = .82 * row[0] *row[i]

'Qt' also needs to be assigned a value before it can be used in an expression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.