Files missing from output: avoided_erosion.tif avoided_export.tif

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

1 Like

Hi @gismat -

Which version of InVEST are you using? avoided erosion and avoided export were added in version 3.12.0, so if you’re using an older version, you won’t have those outputs.

~ Stacie

Hi @gismat ,

Like Stacie said, be sure you’re running InVEST ≥ 3.12.0. To check the version in Python run:

print(natcap.invest.__version__)

For instructions on how to install newer versions of the InVEST Python package, please review our ReadTheDocs page here. If you do not specify a version, the latest version will be installed.

-Jesse

1 Like

! I am running 3.11

Time to update! Thanks!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.