#NEWLINE# def updateVariable( model , state , x , xa , alat , alon , agid , veg , bands , nlayer , varname ) : #NEWLINE# #INDENT# 'Updates variable in VIC initial state.' #NEWLINE# updatefun = { #NEWLINE# #INDENT# 'swe' : _updateSwe , #NEWLINE# 'soil_moist' : _updateSoilMoist , #NEWLINE# 'snow_cover' : _updateScf , #NEWLINE# #UNINDENT# } #NEWLINE# if ( len ( x . shape ) > 1 ) : #NEWLINE# #INDENT# x = x . reshape ( len ( x ) ) #NEWLINE# #UNINDENT# for i in range ( len ( alat ) ) : #NEWLINE# #INDENT# k = model . lgid [ ( alat [ i ] , alon [ i ] ) ] #NEWLINE# nveg = len ( veg [ k ] ) #NEWLINE# nbands = len ( bands [ k ] ) #NEWLINE# for vi in range ( ( nveg + 1 ) ) : #NEWLINE# #INDENT# for bi in range ( varname ) : #NEWLINE# #INDENT# cell = state [ k ] [ ( ( 1 + ( vi * nbands ) ) + bi ) ] #NEWLINE# if ( vi < nveg ) : #NEWLINE# #INDENT# state [ k ] [ ( ( 1 + ( vi * nbands ) ) + bi ) ] = updatefun [ varname ] ( x [ i ] , xa [ i ] , cell , nlayer , False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# state [ k ] [ ( ( 1 + ( vi * nbands ) ) + bi ) ] = updatefun [ varname ] ( x [ i ] , xa [ i ] , cell , nlayer , True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return state