LSDTopoTools
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Protected Attributes | List of all members
LSDChiNetwork Class Reference

This object is used to examine a network of channels in chi space. More...

#include <LSDChiNetwork.hpp>

Public Member Functions

 LSDChiNetwork (string channel_network_fname)
 Crate routine to make a LSDChiNetwork object. More...
 
 LSDChiNetwork (LSDFlowInfo &FlowInfo, int SourceNode, int OutletNode, LSDRaster &Elevation, LSDRaster &FlowDistance, LSDRaster &DrainageArea)
 
 LSDChiNetwork (LSDFlowInfo &FlowInfo, int SourceNode, int OutletNode, LSDRaster &Elevation, LSDRaster &FlowDistance, LSDRaster &DrainageArea, LSDRaster &Chi)
 
int get_n_channels ()
 
int get_NRows () const
 
int get_NCols () const
 
float get_XMinimum () const
 
float get_YMinimum () const
 
float get_DataResolution () const
 
int get_NoDataValue () const
 
void print_channel_details_to_screen (int channel_number)
 Print channel details to screen for bug checking. More...
 
void print_channel_details_to_file (string fname, float A_0, float m_over_n)
 Print channel details to file for bug checking. More...
 
void print_channel_details_to_file_full_fitted (string fname)
 This function prints the details of all channels to a file. More...
 
void print_channel_details_to_file_full_fitted_for_ArcMap (string fname)
 This function prints the details of all channels to a csv file that can be ingested by ArcMap. More...
 
void print_channel_details_to_file_full_fitted (string fname, int target_nodes, int minimum_segment_length)
 This function prints the details of all channels to a file. More...
 
void extend_tributaries_to_outlet ()
 This extends the tributary channels all the way to the outlet. More...
 
Array2D< float > data_to_array (int data_member)
 Routine for returning calculated data to an array. More...
 
void slope_area_extraction_vertical_intervals (float interval, float area_thin_fraction, string fname)
 Extract slope over fixed vertical intervals. More...
 
void slope_area_extraction_horizontal_intervals (float interval, float area_thin_fraction, string fname)
 Extract slope over fixed horizontal intervals. More...
 
void calculate_chi (float A_0, float m_over_n)
 This function calculates the chi values for the channel network using the rectangle rule. More...
 
float calculate_optimal_chi_spacing (int target_nodes)
 This function calucaltes the chi spacing of the main stem channel (the longest channel). More...
 
int calculate_skip (int target_nodes)
 This function calucaltes the skip parameter of the main stem (the longest channel). More...
 
int calculate_skip (int target_nodes, vector< float > &sorted_chis)
 This function calucaltes the skip parameter based on a vector of chi values. More...
 
int calculate_skip (int target_nodes, int channel_number)
 This function calucaltes the skip parameter of a give channel. More...
 
void find_most_likeley_segments (int channel, int minimum_segment_length, float sigma, int N, vector< float > &b_vec, vector< float > &m_vec, vector< float > &r2_vec, vector< float > &DW_vec, vector< float > &thinned_chi, vector< float > &thinned_elev, vector< float > &fitted_elev, vector< int > &node_reference, vector< int > &these_segment_lengths, float &this_MLE, int &this_n_segments, int &n_data_nodes, float &this_AIC, float &this_AICc)
 This function gets the most likely channel segments for a particular channel. More...
 
void find_most_likeley_segments_dchi (int channel, int minimum_segment_length, float sigma, float dchi, vector< float > &b_vec, vector< float > &m_vec, vector< float > &r2_vec, vector< float > &DW_vec, vector< float > &thinned_chi, vector< float > &thinned_elev, vector< float > &fitted_elev, vector< int > &node_reference, vector< int > &these_segment_lengths, float &this_MLE, int &this_n_segments, int &n_data_nodes, float &this_AIC, float &this_AICc)
 This function gets the most likely channel segments for a particular channel. More...
 
void find_most_likeley_segments_monte_carlo (int channel, int minimum_segment_length, float sigma, int mean_skip, int skip_range, vector< float > &b_vec, vector< float > &m_vec, vector< float > &r2_vec, vector< float > &DW_vec, vector< float > &thinned_chi, vector< float > &thinned_elev, vector< float > &fitted_elev, vector< int > &node_reference, vector< int > &these_segment_lengths, float &this_MLE, int &this_n_segments, int &n_data_nodes, float &this_AIC, float &this_AICc)
 This gets the most likely segments but uses the monte carlo data thinning method. More...
 
void find_most_likeley_segments_monte_carlo_dchi (int channel, int minimum_segment_length, float sigma, float mean_dchi, float variation_dchi, vector< float > &b_vec, vector< float > &m_vec, vector< float > &r2_vec, vector< float > &DW_vec, vector< float > &thinned_chi, vector< float > &thinned_elev, vector< float > &fitted_elev, vector< int > &node_reference, vector< int > &these_segment_lengths, float &this_MLE, int &this_n_segments, int &n_data_nodes, float &this_AIC, float &this_AICc)
 This gets the most likely segments but uses the monte carlo data thinning method. More...
 
float search_for_best_fit_m_over_n_dchi (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_nodes_mainstem, string fname)
 The master routine for calculating the best fit m over n values for a channel network, based on a fixed value of dchi. More...
 
float search_for_best_fit_m_over_n (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_nodes_mainstem, string fname)
 The master routine for calculating the best fit m over n values for a channel network. More...
 
float search_for_best_fit_m_over_n_seperate_ms_and_tribs (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_nodes_mainstem, string fname)
 Routine for calculating the best fit m over n values for a channel network, but calculates the mainstem and the tributaries seperately. More...
 
float search_for_best_fit_m_over_n_colinearity_test (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_nodes, int n_iterations, vector< float > &m_over_n_values, vector< float > &AICc_mean, vector< float > &AICc_sdtd)
 This function looks for the best fit values of m over n by simply testing for the least variation in the tributaries. More...
 
float search_for_best_fit_m_over_n_colinearity_test_with_breaks (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_skip, int target_nodes, int n_iterations, vector< float > &m_over_n_values, vector< float > &AICc_mean, vector< float > &AICc_sdtd, int Monte_Carlo_switch)
 This function calculeates best fit m/n using the collinearity test
these channels are ones with breaks. More...
 
float search_for_best_fit_m_over_n_individual_channels_with_breaks (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_skip, int target_nodes, int n_iterations, vector< float > &m_over_n_values, vector< vector< float > > &AICc_vals)
 This function calculeates best fit m/n for each channel these channels are ones with breaks. More...
 
float search_for_best_fit_m_over_n_individual_channels_with_breaks_monte_carlo (float A_0, int n_movern, float d_movern, float start_movern, int minimum_segment_length, float sigma, int target_skip, int target_nodes, int n_iterations, vector< float > &m_over_n_values, vector< vector< float > > &AICc_means, vector< vector< float > > &AICc_stddev)
 This gets the best fit m over n values of all the individual tributaries. More...
 
void monte_carlo_sample_river_network_for_best_fit_dchi (float A_0, float m_over_n, int n_iterations, float fraction_dchi_for_variation, int minimum_segment_length, float sigma, int target_nodes_mainstem)
 This routine uses a monte carlo approach to repeatedly sampling all the data in the channel network. More...
 
void monte_carlo_sample_river_network_for_best_fit (float A_0, float m_over_n, int n_iterations, int mean_skip, int skip_range, int minimum_segment_length, float sigma)
 Monte carlo segment fitter. More...
 
void monte_carlo_sample_river_network_for_best_fit_after_breaks (float A_0, float m_over_n, int n_iterations, int skip, int minimum_segment_length, float sigma)
 This function samples the river network using monte carlo samplig but after breaking the channels. More...
 
void monte_carlo_split_channel (float A_0, float m_over_n, int n_iterations, int target_skip, int target_nodes, int minimum_segment_length, float sigma, int chan, vector< int > &break_nodes)
 Monte carlo segment fitter. More...
 
void monte_carlo_split_channel_colinear (float A_0, float m_over_n, int n_iterations, int target_skip, int target_nodes, int minimum_segment_length, float sigma, vector< float > reverse_Chi, vector< float > reverse_Elevation, vector< int > &break_nodes)
 This function uses a monte carlo sampling approach to try and split channels. More...
 
void split_all_channels (float A_0, float m_over_n, int n_iterations, int target_skip, int target_nodes, int minimum_segment_length, float sigma)
 This function splits all the channels in one go. More...
 
float calculate_AICc_after_breaks (float A_0, float m_over_n, int skip, int minimum_segment_length, float sigma, int chan, vector< int > break_nodes, int &n_total_segments, int &n_total_nodes, float &cumulative_MLE)
 This function gets the AICc after breaking the channel. More...
 
vector< float > calculate_AICc_after_breaks_monte_carlo (float A_0, float m_over_n, int target_skip, int minimum_segment_length, float sigma, int chan, vector< int > break_nodes, int &n_total_segments, int &n_total_nodes, float &cumulative_MLE, int n_iterations)
 This function gets the AICc after breaking the channel. More...
 
float calculate_AICc_after_breaks_colinear (float A_0, float m_over_n, int skip, int minimum_segment_length, float sigma, vector< float > reverse_chi, vector< float > reverse_elevation, vector< int > break_nodes, int &n_total_segments, int &n_total_nodes, float &cumulative_MLE)
 This function gets the AICc after breaking the channelwith a colinear dataset. More...
 
vector< float > calculate_AICc_after_breaks_colinear_monte_carlo (float A_0, float m_over_n, int skip, int minimum_segment_length, float sigma, vector< float > reverse_Chi, vector< float > reverse_Elevation, vector< int > break_nodes, int &n_total_segments, int &n_total_nodes, float &cumulative_MLE, int n_iterations)
 This function gets the AICc after breaking the channelwith a colinear dataset. More...
 
void is_channel_long_enough_test (int minimum_segment_length, int N)
 This routine tests to see if channels are long enough to get a decent fitting from the segment finding algorithms. More...
 
Array2D< float > calculate_channel_heads (int min_seg_length_for_channel_heads)
 this function fits 2 segments to the chi-elevation data from first order basins and calculates the most likely position of the channel head - added by FC 28/06/13 More...
 
vector< vector< float > > get_m_means ()
 This gets the m_means for the channel network. More...
 
vector< vector< float > > get_m_standard_deviations ()
 This gets the m_means for the channel network. More...
 
vector< vector< float > > get_b_means ()
 This gets the b_means for the channel network. More...
 
vector< vector< float > > get_b_standard_deviations ()
 This gets the b_standard deviations for the channel network. More...
 
vector< vector< int > > get_node_indices ()
 This gets the node_indices for the channel network. More...
 
vector< vector< float > > get_chis ()
 This gets the chi coordinates for the channel network. More...
 

Protected Attributes

int NRows
 Number of rows.
 
int NCols
 Number of columns.
 
float XMinimum
 Minimum X coordinate.
 
float YMinimum
 Minimum Y coordinate.
 
float DataResolution
 Data resolution.
 
int NoDataValue
 No data value.
 
bool I_should_calculate_chi
 This boolean lets the routine know if it is to calculate chi.
 
vector< vector< int > > node_indices
 Node indices: used in conjunction with other LSD topographic tool objects and not necessary for standalone program.
 
vector< vector< int > > row_indices
 Row indices: used in conjunction with other LSD topographic tool objects and not necessary for standalone program.
 
vector< vector< int > > col_indices
 Column indices: used in conjunction with other LSD topographic tool objects and not necessary for standalone program.
 
vector< vector< float > > elevations
 The elevations along the channels.
 
vector< vector< float > > flow_distances
 Flow distances along channels. Used to integrate to arrive at chi.
 
vector< vector< float > > drainage_areas
 Drainage areas.
 
vector< vector< float > > chis
 The chi values for the channels. This data will be overwritten as m_over_n changes.
 
vector< int > node_on_receiver_channel
 This is the node on the reciever channel where the tributary enters the channel. Used to find the downstream chi value of a channel.
 
vector< int > receiver_channel
 This is the channel that the tributary enters.
 
float m_over_n_for_fitted_data
 This stores the m over n value use to generate the means and standard deviations of the network properties.
 
float A_0_for_fitted_data
 This stored the A_0 value.
 
vector< int > is_tributary_long_enough
 This vector is the same size as the number of channels and is 1 if the channel analysis n_nodes > 3* minimum_segment_length.
 
vector< vector< float > > chi_m_means
 Vector of chi_m means.
 
vector< vector< float > > chi_m_standard_deviations
 Vector of chi_m standard deviations.
 
vector< vector< float > > chi_m_standard_errors
 Vector of chi_m standard errors.
 
vector< vector< float > > chi_b_means
 Vector of chi_b means.
 
vector< vector< float > > chi_b_standard_deviations
 Vector of chi_b standard deviations.
 
vector< vector< float > > chi_b_standard_errors
 Vector of chi_b standard errors.
 
vector< vector< float > > all_fitted_elev_means
 Vector of fitted elevation means.
 
vector< vector< float > > all_fitted_elev_standard_deviations
 Vector of fitted elevation standard deviations.
 
vector< vector< float > > all_fitted_elev_standard_errors
 Vector of fitted elevation standard errors.
 
vector< vector< float > > chi_DW_means
 Vector of Durbin-Watson means.
 
vector< vector< float > > chi_DW_standard_deviations
 Vector of Durbin-Watson standard deviations.
 
vector< vector< float > > chi_DW_standard_errors
 Vector of Durbin-Watson standard errors.
 
vector< vector< int > > n_data_points_used_in_stats
 The parameters are generated using a monte carlo approach and not all nodes will have the same number of data points, so the number of data points is stored.
 
vector< vector< int > > break_nodes_vecvec
 This vector holds the vectors containing the node locations of breaks in the segments.
 

Detailed Description

This object is used to examine a network of channels in chi space.

Constructor & Destructor Documentation

LSDChiNetwork::LSDChiNetwork ( string  channel_network_fname)
inline

Crate routine to make a LSDChiNetwork object.

Parameters
channel_network_fnameFilename.

Member Function Documentation

float LSDChiNetwork::calculate_AICc_after_breaks ( float  A_0,
float  m_over_n,
int  skip,
int  minimum_segment_length,
float  sigma,
int  chan,
vector< int >  break_nodes,
int &  n_total_segments,
int &  n_total_nodes,
float &  cumulative_MLE 
)

This function gets the AICc after breaking the channel.

Parameters
A_0
m_over_n
skip
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
chan
break_nodes
n_total_segments
n_total_nodes
cumulative_MLE
Returns
AICc value
Author
SMM
Date
01/06/13
float LSDChiNetwork::calculate_AICc_after_breaks_colinear ( float  A_0,
float  m_over_n,
int  skip,
int  minimum_segment_length,
float  sigma,
vector< float >  reverse_chi,
vector< float >  reverse_elevation,
vector< int >  break_nodes,
int &  n_total_segments,
int &  n_total_nodes,
float &  cumulative_MLE 
)

This function gets the AICc after breaking the channelwith a colinear dataset.

The reverse_chi and reverse_elevation data has to be provided.

Parameters
A_0
m_over_n
skip
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
reverse_chi
reverse_elevation
break_nodes
n_total_segments
n_total_nodes
cumulative_MLE
Returns
AICc value
Author
SMM
Date
01/06/13
vector< float > LSDChiNetwork::calculate_AICc_after_breaks_colinear_monte_carlo ( float  A_0,
float  m_over_n,
int  skip,
int  minimum_segment_length,
float  sigma,
vector< float >  reverse_Chi,
vector< float >  reverse_Elevation,
vector< int >  break_nodes,
int &  n_total_segments,
int &  n_total_nodes,
float &  cumulative_MLE,
int  n_iterations 
)

This function gets the AICc after breaking the channelwith a colinear dataset.

The reverse_chi and reverse_elevation data has to be provided. It uses a monte carlo scheme and returns a vector with all of the AICc values calcluated from the analyses.

Parameters
A_0
m_over_n
skip
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
reverse_Chi
reverse_Elevation
break_nodes
n_total_segments
n_total_nodes
cumulative_MLE
n_iterations
Returns
AICc value
Author
SMM
Date
01/06/13
vector< float > LSDChiNetwork::calculate_AICc_after_breaks_monte_carlo ( float  A_0,
float  m_over_n,
int  target_skip,
int  minimum_segment_length,
float  sigma,
int  chan,
vector< int >  break_nodes,
int &  n_total_segments,
int &  n_total_nodes,
float &  cumulative_MLE,
int  n_iterations 
)

This function gets the AICc after breaking the channel.

It does this for n_iterations and returns a vector with all of the AICc values for each iteration reported. This can then be used to calculate the statistics of the AICc to tell if the minimum AICc is significantly different from the other AICc values for different values of m/n

Parameters
A_0
m_over_n
target_skip
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
chan
break_nodes
n_total_segments
n_total_nodes
cumulative_MLE
n_iterations
Returns
AICc value
Author
SMM
Date
01/06/13
Array2D< float > LSDChiNetwork::calculate_channel_heads ( int  min_seg_length_for_channel_heads)

this function fits 2 segments to the chi-elevation data from first order basins and calculates the most likely position of the channel head - added by FC 28/06/13

Parameters
min_seg_length_for_channel_headsMinimum number of nodes used for segment fitting
Returns
array with channel head locations
Author
Fiona Clubb
Date
03/09/2013

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Calculate channel head locations using LSDChiNetwork.

Fitting segments to the chi-elevation data of the main stem. We assume that the profile is made up of 2 segments in chi-space: a linear channel segment and a non-linear hillslope segment. We loop through the possible combinations of segment lengths, performing a linear regression to calculate the r^2 and DW of each segment length. We then calculate a test value: r^2 of the channel segment - ((DW of the hillslope segment - 2)/2). This value will vary between 0 and 1. The maximum test_value will give the best fit channel and hillslope segments. Need to get the best fit m_over_n value and calculate the chi profile of the main stem first. Will output the chi and elevation values of the predicted channel head location. Parameters: min_seg_length_for_channel_heads (length used for fitting segments to the chi- elevation profile, a value of 10 is suggested) Return value: Array with channel head locations FC 03/09/2013

void LSDChiNetwork::calculate_chi ( float  A_0,
float  m_over_n 
)

This function calculates the chi values for the channel network using the rectangle rule.

Note: the entire network must be caluculated because the chi values of the tributaries depend on the chi values of the mainstem.

Parameters
A_0A_0 value.
m_over_nm over n ratio.
Author
SMM
Date
01/04/13
float LSDChiNetwork::calculate_optimal_chi_spacing ( int  target_nodes)

This function calucaltes the chi spacing of the main stem channel (the longest channel).

The maximum length of the dataset will be in the main stem so this will determine the target spacing of all the tributaries.

Parameters
target_nodesNode index of the target node.
Returns
Optimal chi spacing.
Author
SMM
Date
01/04/13
int LSDChiNetwork::calculate_skip ( int  target_nodes)

This function calucaltes the skip parameter of the main stem (the longest channel).

The maximum length of the dataset will be in the main stem so this will determine the target spacing of all the tributaries.

Parameters
target_nodesNode index of the target node.
Returns
Skip value.
Author
SMM
Date
01/06/13
int LSDChiNetwork::calculate_skip ( int  target_nodes,
vector< float > &  sorted_chis 
)

This function calucaltes the skip parameter based on a vector of chi values.

Parameters
target_nodesNode index of the target node.
sorted_chisVector of chi values
Returns
Skip value.
Author
SMM
Date
01/06/13
int LSDChiNetwork::calculate_skip ( int  target_nodes,
int  channel_number 
)

This function calucaltes the skip parameter of a give channel.

The maximum length of the dataset will be in the main stem so this will determine the target spacing of all the tributaries.

Parameters
target_nodesNode index of the target node.
channel_numberThe channel to be analysed.
Returns
Skip value.
Author
SMM
Date
01/04/13
Array2D< float > LSDChiNetwork::data_to_array ( int  data_member)

Routine for returning calculated data to an array.

It includes a switch that tells the function what data member to write to the array code for data members:

1 elevations
2 chis
3 chi_m_means
4 chi_m_standard_deviations
5 chi_m_standard_errors
6 chi_b_means
7 chi_b_standard_deviations
8 chi_b_standard_errors
9 chi_DW_means
10 chi_DW_standard_deviations
11 chi_DW_standard_errors
12 all_fitted_DW_means
13 all_fitted_DW_standard_deviations
14 all_fitted_DW_standard_errors

Parameters
data_memberSwitch to select data to be written.
Returns
Array of data.
Author
SMM
Date
01/04/13
void LSDChiNetwork::extend_tributaries_to_outlet ( )

This extends the tributary channels all the way to the outlet.

In its current version this only works if the tributaries all drain to the mainstem.

Author
SMM
Date
01/04/13
void LSDChiNetwork::find_most_likeley_segments ( int  channel,
int  minimum_segment_length,
float  sigma,
int  N,
vector< float > &  b_vec,
vector< float > &  m_vec,
vector< float > &  r2_vec,
vector< float > &  DW_vec,
vector< float > &  thinned_chi,
vector< float > &  thinned_elev,
vector< float > &  fitted_elev,
vector< int > &  node_reference,
vector< int > &  these_segment_lengths,
float &  this_MLE,
int &  this_n_segments,
int &  n_data_nodes,
float &  this_AIC,
float &  this_AICc 
)

This function gets the most likely channel segments for a particular channel.

This function replaces the b, m, r2 and DW values of each segment into vectors it also returns the fitted elevation and the index into the original channel (since this is done with thinned data).

Parameters
channelThe index into the channel.
minimum_segment_lengthis how many nodes the mimimum segment will have.
sigmais the standard deviation of error on elevation data
N
b_vec
m_vec
r2_vec
DW_vec
thinned_chi
thinned_elev
fitted_elev
node_reference
these_segment_lengths
this_MLE
this_n_segments
n_data_nodes
this_AIC
this_AICc
Author
SMM
Date
01/04/13
void LSDChiNetwork::find_most_likeley_segments_dchi ( int  channel,
int  minimum_segment_length,
float  sigma,
float  dchi,
vector< float > &  b_vec,
vector< float > &  m_vec,
vector< float > &  r2_vec,
vector< float > &  DW_vec,
vector< float > &  thinned_chi,
vector< float > &  thinned_elev,
vector< float > &  fitted_elev,
vector< int > &  node_reference,
vector< int > &  these_segment_lengths,
float &  this_MLE,
int &  this_n_segments,
int &  n_data_nodes,
float &  this_AIC,
float &  this_AICc 
)

This function gets the most likely channel segments for a particular channel.

This function replaces the b, m, r2 and DW values of each segment into vectors it also returns the fitted elevation and the index into the original channel (since this is done with thinned data).

Parameters
channelThe index into the channel.
minimum_segment_lengthis how many nodes the mimimum segment will have.
sigmais the standard deviation of error on elevation data
dchi
b_vec
m_vec
r2_vec
DW_vec
thinned_chi
thinned_elev
fitted_elev
node_reference
these_segment_lengths
this_MLE
this_n_segments
n_data_nodes
this_AIC
this_AICc
Author
SMM
Date
01/04/13
void LSDChiNetwork::find_most_likeley_segments_monte_carlo ( int  channel,
int  minimum_segment_length,
float  sigma,
int  mean_skip,
int  skip_range,
vector< float > &  b_vec,
vector< float > &  m_vec,
vector< float > &  r2_vec,
vector< float > &  DW_vec,
vector< float > &  thinned_chi,
vector< float > &  thinned_elev,
vector< float > &  fitted_elev,
vector< int > &  node_reference,
vector< int > &  these_segment_lengths,
float &  this_MLE,
int &  this_n_segments,
int &  n_data_nodes,
float &  this_AIC,
float &  this_AICc 
)

This gets the most likely segments but uses the monte carlo data thinning method.

The expectation is that this will be used repeatedly on channels to generate statistics of the best fit segments by individual nodes in the channel network.

Parameters
channelThe index into the channel.
minimum_segment_lengthis how many nodes the mimimum segment will have.
sigmais the standard deviation of error on elevation data
mean_skip
skip_range
b_vec
m_vec
r2_vec
DW_vec
thinned_chi
thinned_elev
fitted_elev
node_reference
these_segment_lengths
this_MLE
this_n_segments
n_data_nodes
this_AIC
this_AICc
Author
SMM
Date
01/04/13
void LSDChiNetwork::find_most_likeley_segments_monte_carlo_dchi ( int  channel,
int  minimum_segment_length,
float  sigma,
float  mean_dchi,
float  variation_dchi,
vector< float > &  b_vec,
vector< float > &  m_vec,
vector< float > &  r2_vec,
vector< float > &  DW_vec,
vector< float > &  thinned_chi,
vector< float > &  thinned_elev,
vector< float > &  fitted_elev,
vector< int > &  node_reference,
vector< int > &  these_segment_lengths,
float &  this_MLE,
int &  this_n_segments,
int &  n_data_nodes,
float &  this_AIC,
float &  this_AICc 
)

This gets the most likely segments but uses the monte carlo data thinning method.

The mean_dchi is the mean value of dchi, and the variation is how much the chi chan vary, such that minimum_dchi = dchi-variation_dchi. The expectation is that this will be used repeatedly on channels to generate statistics of the best fit segments by individual nodes in the channel network.

Parameters
channelThe index into the channel.
minimum_segment_lengthis how many nodes the mimimum segment will have.
sigmais the standard deviation of error on elevation data
mean_dchi
variation_dchi
b_vec
m_vec
r2_vec
DW_vec
thinned_chi
thinned_elev
fitted_elev
node_reference
these_segment_lengths
this_MLE
this_n_segments
n_data_nodes
this_AIC
this_AICc
Author
SMM
Date
01/04/13
vector< vector<float> > LSDChiNetwork::get_b_means ( )
inline

This gets the b_means for the channel network.

Returns
vector of vectors with b means @ author SMM
Date
24/05/16
vector< vector<float> > LSDChiNetwork::get_b_standard_deviations ( )
inline

This gets the b_standard deviations for the channel network.

Returns
vector of vectors with b tandard deviations @ author SMM
Date
24/05/16
vector< vector<float> > LSDChiNetwork::get_chis ( )
inline

This gets the chi coordinates for the channel network.

Returns
vector of vectors with m means @ author DTM
Date
24/03/15
float LSDChiNetwork::get_DataResolution ( ) const
inline
Returns
Data resolution as an integer.
vector< vector< float > > LSDChiNetwork::get_m_means ( )

This gets the m_means for the channel network.

Returns
vector of vectors with m means @ author FJC
Date
04/08/14
vector< vector<float> > LSDChiNetwork::get_m_standard_deviations ( )
inline

This gets the m_means for the channel network.

Returns
vector of vectors with m means @ author FJC
Date
04/08/14
int LSDChiNetwork::get_n_channels ( )
inline
Returns
Number of channels.
int LSDChiNetwork::get_NCols ( ) const
inline
Returns
Number of columns as an integer.
int LSDChiNetwork::get_NoDataValue ( ) const
inline
Returns
No Data Value as an integer.
vector< vector<int> > LSDChiNetwork::get_node_indices ( )
inline

This gets the node_indices for the channel network.

Returns
vector of vectors with m means @ author DTM
Date
24/03/15
int LSDChiNetwork::get_NRows ( ) const
inline
Returns
Number of rows as an integer.
float LSDChiNetwork::get_XMinimum ( ) const
inline
Returns
Minimum X coordinate as an integer.
float LSDChiNetwork::get_YMinimum ( ) const
inline
Returns
Minimum Y coordinate as an integer.
void LSDChiNetwork::is_channel_long_enough_test ( int  minimum_segment_length,
int  N 
)

This routine tests to see if channels are long enough to get a decent fitting from the segment finding algorithms.

Writes to the is_tributary_long_enough vector. If this equals 1, the channel is long enough. If it is zero the channel is not long enough.

Parameters
minimum_segment_lengthHow many nodes the mimimum segment will have.
N
void LSDChiNetwork::monte_carlo_sample_river_network_for_best_fit ( float  A_0,
float  m_over_n,
int  n_iterations,
int  mean_skip,
int  skip_range,
int  minimum_segment_length,
float  sigma 
)

Monte carlo segment fitter.

This takes a fixed m_over_n value and then samples the indivudal nodes in the full channel profile to repeadetly get the best fit segments on thinned data. the m, b fitted elevation, r^2 and DW statistic are all stored for every iteration on every node. These can then be queried later for mean, standard deviation and standard error information

the fraction_dchi_for_variation is the fration of the optimal dchi that dchi can vary over. So for example if this = 0.4 then the variation of dchi will be 0.4*mean_dchi and the minimum dchi will be min_dchi = (1-0.4)*mean_dchi

Note: this is extremely computationally and data intensive.

Parameters
A_0
m_over_n
n_iterations
mean_skip
skip_range
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
Author
SMM
Date
01/04/13
void LSDChiNetwork::monte_carlo_sample_river_network_for_best_fit_after_breaks ( float  A_0,
float  m_over_n,
int  n_iterations,
int  skip,
int  minimum_segment_length,
float  sigma 
)

This function samples the river network using monte carlo samplig but after breaking the channels.

Parameters
A_0
m_over_n
n_iterations
skip
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
Author
SMM
Date
01/04/13
void LSDChiNetwork::monte_carlo_sample_river_network_for_best_fit_dchi ( float  A_0,
float  m_over_n,
int  n_iterations,
float  fraction_dchi_for_variation,
int  minimum_segment_length,
float  sigma,
int  target_nodes_mainstem 
)

This routine uses a monte carlo approach to repeatedly sampling all the data in the channel network.

Uses a reduced number of data elements and then populates each channel node with a distribution of m, b and fitted elevation values. These then can be averaged and details of their variation calculated.
This is based on a fixed value of dchi

Parameters
A_0
m_over_n
n_iterations
fraction_dchi_for_variation
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_nodes_mainstem
Author
SMM
Date
01/04/13
void LSDChiNetwork::monte_carlo_split_channel ( float  A_0,
float  m_over_n,
int  n_iterations,
int  target_skip,
int  target_nodes,
int  minimum_segment_length,
float  sigma,
int  chan,
vector< int > &  break_nodes 
)

Monte carlo segment fitter.

This takes a fixed m_over_n value and then samples the indivudal nodes in the full channel profile to repeadetly get the best fit segments on thinned data. the m, b fitted elevation, r^2 and DW statistic are all stored for every iteration on every node. These can then be queried later for mean, standard deviation and standard error information.

The break nodes vector tells the algorithm where the breaks in the channel occur this function is called repeatedly until the target skip equals the all of the this_skip values.

This function continues to split the channel into segments until the target skip is achieved.

Parameters
A_0
m_over_n
n_iterations
target_skip
target_nodes
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
chan
break_nodes
Author
SMM
Date
01/04/13
void LSDChiNetwork::monte_carlo_split_channel_colinear ( float  A_0,
float  m_over_n,
int  n_iterations,
int  target_skip,
int  target_nodes,
int  minimum_segment_length,
float  sigma,
vector< float >  reverse_Chi,
vector< float >  reverse_Elevation,
vector< int > &  break_nodes 
)

This function uses a monte carlo sampling approach to try and split channels.

The channel is sampled at the target skipping interval. It does it with a colinear dataset.

Parameters
A_0
m_over_n
n_iterations
target_skip
target_nodes
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
reverse_Chi
break_nodes
reverse_Elevation
break_nodes
Author
SMM
Date
01/04/13
void LSDChiNetwork::print_channel_details_to_file ( string  fname,
float  A_0,
float  m_over_n 
)

Print channel details to file for bug checking.

Format of file:

channel_number << " " << receiver_channel[channel_number] << " " << node_on_receiver_channel[channel_number] << " " << node[i] << " " << row[i] << " " << col[i] << " " << flow_distance[i] << " " << chi[i] << " " << elevation[i] << " " << drainage_area[i]

Parameters
fnameOutput filename.
A_0A_0 value.
m_over_nm over n ratio.
Author
SMM
Date
01/04/13
void LSDChiNetwork::print_channel_details_to_file_full_fitted ( string  fname)

This function prints the details of all channels to a file.

It includes data from monte carlo fitting. Format is:

A_0 m_over_n channel_number node_on_receiver_channel node_index row col flow_distance chi elevation darainage_area.

Parameters
fnameOutput filename.
Author
SMM
Date
01/04/13
void LSDChiNetwork::print_channel_details_to_file_full_fitted ( string  fname,
int  target_nodes,
int  minimum_segment_length 
)

This function prints the details of all channels to a file.

It includes data from monte carlo fitting. Format is:

A_0 m_over_n channel_number node_on_receiver_channel node_index row col flow_distance chi elevation darainage_area.

Parameters
fnameOutput filename.
target_nodes
minimum_segment_length
Author
SMM
Date
01/04/13
void LSDChiNetwork::print_channel_details_to_file_full_fitted_for_ArcMap ( string  fname)

This function prints the details of all channels to a csv file that can be ingested by ArcMap.

It includes data from monte carlo fitting.

Parameters
fnameOutput filename, which has _for_Arc automatically appended.
Author
SMM
Date
28/02/14
void LSDChiNetwork::print_channel_details_to_screen ( int  channel_number)

Print channel details to screen for bug checking.

Format of file:

channel_number << " " << receiver_channel[channel_number] << " " << node_on_receiver_channel[channel_number] << " " << node[i] << " " << row[i] << " " << col[i] << " " << flow_distance[i] << " " << chi[i] << " " << elevation[i] << " " << drainage_area[i]

Parameters
channel_numberChannel to examine
Author
SMM
Date
01/04/13
float LSDChiNetwork::search_for_best_fit_m_over_n ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_nodes_mainstem,
string  fname 
)

The master routine for calculating the best fit m over n values for a channel network.

Parameters
A_0
n_movern
d_movern
start_movern
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_nodes_mainstem
fnameOutput filename
Returns
Best fit m over n.
Author
SMM
Date
01/04/13
float LSDChiNetwork::search_for_best_fit_m_over_n_colinearity_test ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_nodes,
int  n_iterations,
vector< float > &  m_over_n_values,
vector< float > &  AICc_mean,
vector< float > &  AICc_sdtd 
)

This function looks for the best fit values of m over n by simply testing for the least variation in the tributaries.

Parameters
A_0
n_movern
d_movern
start_movern
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_nodes
n_iterations
m_over_n_values
AICc_mean
AICc_sdtd
Returns
Best fit m over n.
Author
SMM
Date
01/04/13
float LSDChiNetwork::search_for_best_fit_m_over_n_colinearity_test_with_breaks ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_skip,
int  target_nodes,
int  n_iterations,
vector< float > &  m_over_n_values,
vector< float > &  AICc_mean,
vector< float > &  AICc_sdtd,
int  Monte_Carlo_switch 
)

This function calculeates best fit m/n using the collinearity test
these channels are ones with breaks.

Parameters
A_0float the reference area
n_movernint the number of m over n ratios to iterate through
d_movernfloat the change in m/n in each iterations
start_movernfloat the starting value of m/n
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_skipint the mean skipping value
target_nodesint the target number of nodes in a break
n_iterationsint the number of iterations
m_over_n_valuesvector<float>& this gets written, it contains the m/n values for the run
AICc_meanvector<float> gets written, the mean values of the AICc for each m/n
AICc_sdtdvector<float> gets written, the standard deviation values of the AICc for each m/n
Monte_Carlo_switchint if 1, run the code using the iterative Monte Carlo scheme
Returns
Best fit m over n.
Author
SMM
Date
01/07/13

for (int i = 0; i< int(movn_values.size()); i++)

float LSDChiNetwork::search_for_best_fit_m_over_n_dchi ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_nodes_mainstem,
string  fname 
)

The master routine for calculating the best fit m over n values for a channel network, based on a fixed value of dchi.

Parameters
A_0
n_movern
d_movern
start_movern
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_nodes_mainstem
fnameOutput filename
Returns
Best fit m over n.
Author
SMM
Date
01/04/13
float LSDChiNetwork::search_for_best_fit_m_over_n_individual_channels_with_breaks ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_skip,
int  target_nodes,
int  n_iterations,
vector< float > &  m_over_n_values,
vector< vector< float > > &  AICc_vals 
)

This function calculeates best fit m/n for each channel these channels are ones with breaks.

Parameters
A_0float the reference area

this does not report variability of the AICc values and so should not be used, instead
use the Monte Carlo version
retained in case you want rapid calculation of best fit m/n

Parameters
n_movernint the number of m over n ratios to iterate through
d_movernfloat the change in m/n in each iterations
start_movernfloat the starting value of m/n
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_skipint the mean skipping value
target_nodesint the target number of nodes in a break
n_iterationsint the number of iterations
m_over_n_valuesvector<float>& this gets written, it contains the m/n values for the run
AICc_vals
Returns
Best fit m over n.
Author
SMM
Date
01/04/13
float LSDChiNetwork::search_for_best_fit_m_over_n_individual_channels_with_breaks_monte_carlo ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_skip,
int  target_nodes,
int  n_iterations,
vector< float > &  m_over_n_values,
vector< vector< float > > &  AICc_means,
vector< vector< float > > &  AICc_stddev 
)

This gets the best fit m over n values of all the individual tributaries.

It uses a monte carlo appraoach so all tributaries have both the mean and the variability of the AICc values reported.

Parameters
A_0float the reference area
n_movernint the number of m over n ratios to iterate through
d_movernfloat the change in m/n in each iterations
start_movernfloat the starting value of m/n
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_skipint the mean skipping value
target_nodesint the target number of nodes in a break
n_iterationsint the number of iterations
m_over_n_valuesvector<float>& this gets written, it contains the m/n values for the run
AICc_meansvector<float> gets written, the mean values of the AICc for each m/n
AICc_stddevvector<float> gets written, the standard deviation values of the AICc for each m/n
Returns
Best fit m over n.
Author
SMM
Date
01/07/13
float LSDChiNetwork::search_for_best_fit_m_over_n_seperate_ms_and_tribs ( float  A_0,
int  n_movern,
float  d_movern,
float  start_movern,
int  minimum_segment_length,
float  sigma,
int  target_nodes_mainstem,
string  fname 
)

Routine for calculating the best fit m over n values for a channel network, but calculates the mainstem and the tributaries seperately.

Parameters
A_0
n_movern
d_movern
start_movern
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
target_nodes_mainstem
fnameOutput filename
Returns
Best fit m over n.
Author
SMM
Date
01/04/13
void LSDChiNetwork::slope_area_extraction_horizontal_intervals ( float  interval,
float  area_thin_fraction,
string  fname 
)

Extract slope over fixed horizontal intervals.

This one is the horizontal intervals version: it measures slope over fixed flow distance as used by many authors including DiBiasie et al 2010 and Ouimet et al 2009 This function gets slope data and area data for use in making slope area plots. It generates several data elements, which are written to the file with name fname (passed to function). The file format is for each row:

chan << " " << start_row << " " << mp_row << " " << end_row << " " << start_col << " " << mp_col << " " << end_col << " " << start_interval_elevations << " " << mp_interval_elevations << " " << end_interval_elevations << " " << start_interval_flowdistance << " " << mp_interval_flowdistance << " " << end_interval_flowdistance << " " << start_area << " " << mp_area << " " << end_area << " " << slope << " " << log10(mp_area) << " " << log10(slope)

where start, mp and end denote the start of the interval over which slope is measured, the midpoint and the end.

The area thin fraction is used to thin the data so that segments with large changes in drainage area are not used in the regression (because these will affect the mean slope) the fraction is determined by (downslope_area-upslope_area)/midpoint_area. So if the fraction is 1 it means that the change is area is equal to the area at the midpoint a restictive value is 0.05, you will eliminate major tributaries with a 0.2, and 1 will catch almost all of the data.

Parameters
interval
area_thin_fraction
fnameOutput filename
Author
SMM
Date
01/04/13
void LSDChiNetwork::slope_area_extraction_vertical_intervals ( float  interval,
float  area_thin_fraction,
string  fname 
)

Extract slope over fixed vertical intervals.

This one is the vertical intervals version: it measures slope over fixed vertical intervals as reccomended by Wobus et al 2006. This function gets slope data and area data for use in making slope area plots. It generates several data elements, which are written to the file with name fname (passed to function). The file format is for each row:

chan << " " << start_row << " " << mp_row << " " << end_row << " " << start_col << " " << mp_col << " " << end_col << " " << start_interval_elevations << " " << mp_interval_elevations << " " << end_interval_elevations << " " << start_interval_flowdistance << " " << mp_interval_flowdistance << " " << end_interval_flowdistance << " " << start_area << " " << mp_area << " " << end_area << " " << slope << " " << log10(mp_area) << " " << log10(slope)

where start, mp and end denote the start of the interval over which slope is measured, the midpoint and the end.

The area thin fraction is used to thin the data so that segments with large changes in drainage area are not used in the regression (because these will affect the mean slope) the fraction is determined by (downslope_area-upslope_area)/midpoint_area. So if the fraction is 1 it means that the change is area is equal to the area at the midpoint a restictive value is 0.05, you will eliminate major tributaries with a 0.2, and 1 will catch almost all of the data.

Parameters
interval
area_thin_fraction
fnameOutput filename
Author
SMM
Date
01/04/13
void LSDChiNetwork::split_all_channels ( float  A_0,
float  m_over_n,
int  n_iterations,
int  target_skip,
int  target_nodes,
int  minimum_segment_length,
float  sigma 
)

This function splits all the channels in one go.

Parameters
A_0
m_over_n
n_iterations
target_skip
target_nodes
minimum_segment_lengthHow many nodes the mimimum segment will have.
sigmaStandard deviation of error on elevation data
Author
SMM
Date
01/06/13

The documentation for this class was generated from the following files: