waternumbers / dynatop

Dynamic TOPMODEL
https://waternumbers.github.io/dynatop/
3 stars 6 forks source link

Channel routing erroring #18

Closed octopusann closed 5 years ago

octopusann commented 5 years ago

I have corrected the original error by turning hillslope_out into and xts object however I am now getting a subscript out of bounds error in compute_time_delay at line 60. I think it maybe because there is only one river reach but my attempts to correct it haven't worked.

for(ii in 1:nrow(model$gauge)){
    gr <- paste(model$gauge$channel_id[ii])

    ##           for(jj in 1:nrow(model$point_inflow))    
    for(jj in seq_along(model$point_inflow)){   
        ir <- paste(model$point_inflow$channel_id[jj])
        **point_to_gauge[ii,jj] <- head_to_head[ir,gr] +**
            (model$gauge$fraction[ii]*reach_time[gr]) -
            (model$point_inflow$fraction[jj]*reach_time[ir])
    }

}
for(ii in 1:nrow(model$gauge)){
  • gr <- paste(model$gauge$channel_id[ii])
  • for(jj in 1:nrow(model$point_inflow))

    _+ for(jj in seq_along(model$pointinflow)){

  • ir <- paste(model$point_inflow$channel_id[jj])
  • point_to_gauge[ii,jj] <- head_to_head[ir,gr] +
  • (model$gauge$fraction[ii]*reach_time[gr]) -
  • (model$point_inflow$fraction[jj]*reach_time[ir])
  • }
  • } Error in head_to_head[ir, gr] : subscript out of bounds

I changed line line in italics in my version but the error is the same

octopusann commented 5 years ago

Sware_zip contains the code with paths, filenames used Sware_Gill zip contains input and output files

Sware_zip.zip Sware_Gill.zip

It all seemed to run fine until the very last couple of lines of the script running the channel routing. I converted the hillslope_out to an xts object which it was then happy with but then fell over in time_delay_routing. I traced the problem to compute_time_delay somewhere in the 'for jj' block. I think that the for statement is running from 1:0 - I changed the for statement to use seq_along but the error stayed the same - see above.

Let me know if you need more info or I've missed any files.

waternumbers commented 5 years ago

Committed fix to github. Thanks for the example.