<jupyter_start><jupyter_text>Using the ChiFinder ComponentThe `ChiFinder` component creates a map of the $\chi$ drainage network index from a digital elevation model. The $\chi$ index, described by Perron and Royden (2013), is a function of drainage area, $A$, and elevation, $\eta$:$$\chi = \int\limits_{x_b}^{x} \left(\frac{A_0}{A(x)}\right)^\theta dx$$where $x_b$ is the location of the outlet of a watershed of interest, $x$ is a position on a channel somewhere upstream, $A_0$ is a drainage area scale, and $\theta$ is the concavity index parameter, often taken to be $\approx$0.5.This tutorial shows briefly how to use the `ChiFinder` on natural or synthetic data.  Imports and inline docsFirst, import what we'll need:<jupyter_code>import copy
import numpy as np
import matplotlib as mpl
from landlab import RasterModelGrid, imshow_grid
from landlab.io import read_esri_ascii
from landlab.components import FlowAccumulator, ChiFinder<jupyter_output><empty_output><jupyter_text>The docstring describes the component and provides some simple examples:<jupyter_code>print(ChiFinder.__doc__)<jupyter_output><empty_output><jupyter_text>ExampleIn this example, we read in a small digital elevation model (DEM) from NASADEM for an area on the Colorado high plains (USA) that includes a portion of an escarpment along the west side of a drainage known as West Bijou Creek (see Rengers & Tucker, 2014).The DEM file is in ESRI Ascii format, but is in a geographic projection, with horizontal units of decimal degrees. To calculate slope gradients properly, we'll first read the DEM into a Landlab grid object that has this geographic projec. Then we'll create a second grid with 30 m cell spacing (approximately equal to the NASADEM's resolution), and copy the elevation field from the geographic DEM. This isn't a proper projection of course, but it will do for purposes of this example.<jupyter_code># read the DEM
(grid_geog, elev) = read_esri_ascii('west_bijou_escarpment_snippet.asc')
grid = RasterModelGrid((grid_geog.number_of_node_rows,
                        grid_geog.number_of_node_columns), xy_spacing=30.0)
grid.add_field('topographic__elevation', elev, at='node')
cmap = copy.copy(mpl.cm.get_cmap("pink"))
imshow_grid(grid, elev, cmap=cmap, colorbar_label='Elevation (m)')<jupyter_output><empty_output><jupyter_text>The `ChiFinder` needs to have drainage areas pre-calculated. We'll do that with the `FlowAccumulator` component. We'll have the component do D8 flow routing (each DEM cell drains to whichever of its 8 neighbors lies in the steepest downslope direction), and fill pits (depressions in the DEM that would otherwise block the flow) using the `LakeMapperBarnes` component. The latter two arguments below tell the lake mapper to update the flow directions and drainage areas after filling the pits.<jupyter_code>fa = FlowAccumulator(grid,
                     flow_director='FlowDirectorD8',       # use D8 routing
                     depression_finder='LakeMapperBarnes', # pit filler
                     method='D8',                          # pit filler use D8 too
                     redirect_flow_steepest_descent=True,  # re-calculate flow dirs
                     reaccumulate_flow=True,               # re-calculate drainagea area
                    )
fa.run_one_step() # run the flow accumulator
cmap = copy.copy(mpl.cm.get_cmap("Blues"))
imshow_grid(grid,
            np.log10(grid.at_node['drainage_area'] + 1.0), # sq root helps show drainage
            cmap=cmap,
            colorbar_label='Log10(drainage area (m2))'
           )<jupyter_output><empty_output><jupyter_text>Now run the `ChiFinder` and display the map of $\chi$ values:<jupyter_code>cf = ChiFinder(grid,
               reference_concavity=0.5, 
               min_drainage_area=1.0,
               clobber=True,
              )
cf.calculate_chi()
cmap = copy.copy(mpl.cm.get_cmap("viridis"))
imshow_grid(grid,
            grid.at_node['channel__chi_index'],
            cmap=cmap,
            colorbar_label='Chi index',
           )<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08055009823182711, 'fraction_numerical': 0.008349705304518664, 'mean_word_length': 3.825829383886256, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '62602', 'license': 'MIT', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1176, 'n_words': 421, 'path': 'notebooks/tutorials/terrain_analysis/chi_finder/chi_finder.ipynb', 'repo_name': 'CannedIce/landlab', 'size': '4072'}