Current capabilities:
- calculate mean discharge and Q95 from MGB-AS outputs
- "downscale" to ANA's Base Hidrografica Ottocodificada (BHO 2017 5K)
- discharge binary (e.g. "QTUDO.BIN")
- local runoff binary (e.g. "QITUDO.BIN" or "QCEL.BIN")
- mgb-bho-ds repository
- Base Hidrografica Ottocodificada Multiescalas 2017 5k
- [recommended: pre-processed files at @... (to skip step 3.2)](TODO: upload and link)
Use your favorite python 3.7+ environment/IDE. I like Spyder!
Required packages:
matplotlib numpy pandas geopandas fiona openpyxl
(Example) Setting environment with Miniconda/Anaconda
conda create -n mgbbho python3 -c conda-forge matplotlib numpy pandas geopandas fiona openpyxl spyder
Use the following commands/scripts OR run through your favorite IDE (e.g. Spyder)
conda activate mgbbho
Recommended: download optional pre-processed files (MGB-SA -> BHO5k2017 compatible) and skip to 3.3
python mgbbhods_0_prepro.py
python mgbbhods_1_matlab.py
python mgbbhods_2_main.py
python mgbbhods_solver_base.py
Two-steps to adapt the downscaling to a customized MGB-AS version:
- Update mgb info at mgbsa_default at funcs_solver.py
def mgbsa_default(version = '1979'):
""" Default settings for MGB-SA """
if version == '1990':
nc = 33749
nt = 7305
dstart = datetime(1990,1,1)
file_qtudo = 'QTUDO_1990.MGB'
file_qcel = 'QITUDO_1990.MGB'
# customized version
if version == 'custom':
nc = 33749 #number of mgb catchments
nt = 7305 #number of time steps
dstart = datetime(1990,1,1)
file_qtudo = 'QTUDO_CUSTOM.MGB'
file_qcel = 'QITUDO_CUSTOM.MGB'
...
- Update argument at mgbbhods_solver_base.py
version = 'custom'
nt, nc, dstart, file_qtudo, file_qcel = funcs_solver.mgbsa_default(version)
...
# main path
PATH_MAIN = './'
PATH_INPUT = PATH_MAIN + 'input/'
# table mgb topology
FILE_MINI = PATH_INPUT + 'mini.xlsx'
# geopackage BHO drainage
FILE_GDF_BHO = PATH_INPUT + 'geoft_bho_2017_5k_trecho_drenagem.gpkg'
# shapefile MGB
FILE_MGB_CATCHMENTS_SHP = PATH_INPUT + 'mgb_sa_unit_catchments_sirgas2000.shp'
# update fields for products.
python version_field_update.py
python mgbbhods_solver_timeseries.py