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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid soil class over some HRUs #87

Open
guoqiang-tang opened this issue Jun 24, 2021 · 0 comments
Open

Invalid soil class over some HRUs #87

guoqiang-tang opened this issue Jun 24, 2021 · 0 comments

Comments

@guoqiang-tang
Copy link
Contributor

The soil class could be -999 for in some HRUs, which will cause an error FATAL ERROR: summa_paramSetup/pOverwrite/index for soil type must be > 0 when running SUMMA. The corresponding vegTypeIndex is 17, indicating water bodies. Two example basins with this problem are CAMELS 05062500 and 05129115, based on limited testing.

There are two problems needing to be solved:
(1) The judgement of tmp_hist will break if all its values are zero, because the largest value is always the first value according to numpy. A possible way is to useif np.all(np.array(tmp_hist[1:]) == 0) or shp['USGS_' + str(tmp_sc)][shp_mask].values != tmp_hist[tmp_sc]: to replace if shp['USGS_' + str(tmp_sc)][shp_mask].values != tmp_hist[tmp_sc]:
The two lines need modification:
https://github.com/CH-Earth/summaWorkflow_public/blob/master/5_model_input/SUMMA/1f_attributes/2b_insert_landclass_from_hist_into_attributes.py#L116
https://github.com/CH-Earth/summaWorkflow_public/blob/master/5_model_input/SUMMA/1f_attributes/2a_insert_soilclass_from_hist_into_attributes.py#L117

image

(2) The fill value of -999 could cause an error in summa. In my cases, those HRUs are water bodies, while it is still possible in some regions, we have unpredicted data bias. A possible and safe way is to assign the most frequent soil class and vegetation class over the basin to the problematic HRU, and then print the warning of the value replacement. It could be more ideal to search nearby HRUs but I am not sure if the increased time cost and complexity are preferred. The below are example soil codes, which can be inserted after Line 84 and 120 in 2a_insert_soilclass_from_hist_into_attributes.py, respectively.

# find the most frequent class
basin_hist = [-1]
for j in range(1, 13):
    if 'USGS_' + str(j) in shp.columns:
        basin_hist.append(shp['USGS_' + str(j)].sum())
    else:
        basin_hist.append(0)
basinmax_sc = np.argmax(np.asarray(basin_hist))  
if tmp_sc == -999:
    tmp_sc = basinmax_sc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant