What is the issue or question you have?
The SDR model does not output two files I was expecting, and I don’t know why. Maybe I need to adjust my expectations?
I run the SDR model in python like this:
import logging
import sys
import numpy as np
import natcap.invest.sdr.sdr
import natcap.invest.utils
import os
os.chdir('C:\\Users\\spatial_data\\THE_FILES_I_MODEL')
# import multiprocessing
LOGGER = logging.getLogger(__name__)
root_logger = logging.getLogger()
handler = logging.StreamHandler(sys.stdout)
handler = logging.FileHandler("C:\\Users\\sdr\\allowed_to_model\\run_7_lmax\\logfile.txt")
formatter = logging.Formatter(
fmt=natcap.invest.utils.LOG_FMT,
datefmt='%m/%d/%Y %H:%M:%S ')
handler.setFormatter(formatter)
logging.basicConfig(level=logging.INFO, handlers=[handler])
args = {
'biophysical_table_path': 'allowed_to_model\\lulu.csv',
'dem_path': 'Hydro_Enforced_1_Second_DEM_4268398\\hydro_dem_10m_qgis.tif',
'drainage_path': '',
'erodibility_path': 'USLE\\rusle_k_utm_56s.tif',
'erosivity_path': 'USLE\\rusle_r_utm_56s.tif',
'ic_0_param': 0.5,
'k_param': 2,
'l_max': 122,
'lulc_path': 'allowed_to_model\\2013_landuse.tif',
'n_workers': '-1', # 2*multiprocessing.cpu_count(), default is '-1'
'results_suffix': 'TESTER',
'sdr_max': 0.8,
'threshold_flow_accumulation': 200,
# 'watersheds_path': 'delineate_watersheds\\watershed_utm_56s.shp',
'watersheds_path': 'delineate_watersheds\\watershed_10m\\watersheds.gpkg',
'workspace_dir': 'C:\\Users\\Documents',
}
# if __name__ == '__main__':
# natcap.invest.sdr.sdr.execute(args)
x = np.array([(k, i, s) for k in np.linspace(1.6,2.2,6) for i in np.linspace(0.3,0.7,6) for s in np.linspace(0.6, 0.9, 6)])
# open file with write access and write the array contents
with open('C:\\Users\\allowed_to_model\\run_2013_update_11\\a1_run_param.csv', 'w') as my_file:
for i in x:
np.savetxt(my_file, i)
if __name__ == '__main__':
#Loops through the values 1,11,21,... 101
for ii in range(148,150):
# k = x[ii,0]
# i = x[ii,1]
# s = x[ii,2]
# # l = x[ii,3]
# print(k,i,s)
# args['l_max'] = x[ii,3]
args['ic_0_param'] = x[ii,1]
args['k_param'] = x[ii,0]
args['sdr_max'] = x[ii,2]
args['results_suffix'] = 'dem_10m_qgis_lulu_10m_watershed_' + str(ii)
args['workspace_dir'] = 'C:\\allowed_to_model\\run_2013_update_11'
natcap.invest.sdr.sdr.execute(args)
What do you expect to happen?
I expected to find these two files among the output:
avoided_erosion.tif
avoided_export.tif
but I did not. I wonder if anyone knows why not?
Attach the logfile here:
files.txt (8.7 KB)
in fact, I don’t know how to get the logfile running well either. The logfile returned is empty. Instead, I have attached a recursive dir command so you can see all the files outputted