KMarkert / servir-vic-training

Training materials for the VIC hydrologic model setup developed for the @SERVIR program
GNU General Public License v3.0
36 stars 32 forks source link

maxbands variable issue in format_snow_params.py #28

Closed Saadi4469 closed 3 years ago

Saadi4469 commented 3 years ago

Hello,

In line 146 of the code:

# calculate the mean elevation for each band and write to file
                                for c in range(maxbands):

Can you please tell me where is the variable maxbands first defined? Because before this line, maxbands is no where to be found, and Spyder is raising an error that maxbands is not not defined.

Thank you,

KMarkert commented 3 years ago

This script performs two passes. The first one loops through the grid cells to find the maximum number of elevation intervals (ie. the maxbands variable). The second pass then gets the actual elevation band values and fractional coverage for those bands. The number of bands are needed for writing the parameter file because VIC expects each cell to have the same number of band information written even though there may not be that many bands in a grid cell.

maxbands is calculated at the end of the first pass then the script moves to the second pass.

Hopefully, this provides some insight into how/where/why the variable is calculated.

Saadi4469 commented 3 years ago

Thank you sir