Skip to content

Commit

Permalink
Updating source code to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-m-mudd committed Feb 11, 2022
1 parent 2ed75df commit b9e61d0
Show file tree
Hide file tree
Showing 26 changed files with 13,800 additions and 2,800 deletions.
61 changes: 61 additions & 0 deletions src/LSDCRNParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,67 @@ void LSDCRNParameters::set_Braucher_parameters()
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// 10Be production is based on a combination of data from Braucher et al 2011
// and Borchers et al 2016 as transcribed by Mirjam Schaller
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDCRNParameters::set_BraucherBorchers_parameters()
{
//S_t = 1;

// from Vermeesh 2007
// 10Be from Chmeleff/Korschinek 10Be decay constant;
lambda_10Be = 500e-9; // in yr-1
lambda_26Al = 980e-9; // in yr-1
lambda_14C = 121e-6; // in yr-1
lambda_36Cl = 230e-8; // in yr-1

// from the Braucher and Borchers papers
// data compiled by Mirjam Schaller in personal communication
//
// All but 10Be are calibrated to the Stone scaling
// Also linked to the nishizumii standards
P0_10Be = 4.061; // in a/g/yr
P0_26Al = 28.851; // in a/g/yr
P0_14C = 15.21; // in a/g/yr
P0_36Cl = 58.95; // in a/g/yr
P0_21Ne = 18.23; // in a/g/yr
P0_3He = 121.59; // in a/g/yr

// in g/cm^2
Gamma[0] = 160;
Gamma[1] = 1500;
Gamma[2] = 1500;
Gamma[3] = 4320;

// dimensionless
F_10Be[0] = 0.9874;
F_10Be[1] = 0.0030;
F_10Be[2] = 0.0;
F_10Be[3] = 0.0096;

// dimensionless
F_26Al[0] = 0.9681;
F_26Al[1] = 0.0291;
F_26Al[2] = 0.000;
F_26Al[3] = 0.0028;

// dimensionless
F_14C[0] = 0.83;
F_14C[1] = 0.15;
F_14C[2] = 0.0;
F_14C[3] = 0.02;

// dimensionless
F_36Cl[0] = 0.9456;
F_36Cl[1] = 0.0324;
F_36Cl[2] = 0.00;
F_36Cl[3] = 0.022;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// 10Be is set to a new production curve provided by Shasta Marrero
// All others: sets the parameters to those used by Braucher et al 2009
Expand Down
9 changes: 8 additions & 1 deletion src/LSDCRNParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,14 @@ class LSDCRNParameters
/// @author SMM
/// @date 27/01/2015
void set_Braucher_parameters();


/// @brief This resets the F, Gamma and P0 values so that they conform to
/// parameters from Braucher et al 2011 and Brchers et al 2016
/// @detail From personal communication with Mirjam Schaller
/// @author SMM
/// @date 04/02/2022
void set_BraucherBorchers_parameters();

/// @brief This resets the F, Gamma and P0 values
/// For 10Be, these correspond to new production curves provided by Shasta Marerro
// For the rest they conform to
Expand Down
148 changes: 144 additions & 4 deletions src/LSDChiTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11879,6 +11879,139 @@ void LSDChiTools::print_chi_data_map_to_csv(LSDFlowInfo& FlowInfo, string filena
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


void LSDChiTools::print_chi_data_map_to_csv_with_ni(LSDFlowInfo& FlowInfo, string filename)
{

// these are for extracting element-wise data from the channel profiles.
int this_node, row,col;
double latitude,longitude;
LSDCoordinateConverterLLandUTM Converter;

// find the number of nodes
int n_nodes = (node_sequence.size());

// open the data file
ofstream chi_data_out;
chi_data_out.open(filename.c_str());
chi_data_out << "latitude,longitude,NI,chi,elevation,flow_distance,drainage_area,source_key,basin_key" << endl;
if (n_nodes <= 0)
{
cout << "Cannot print since you have not calculated channel properties yet." << endl;
}
else
{
for (int n = 0; n< n_nodes; n++)
{
this_node = node_sequence[n];
FlowInfo.retrieve_current_row_and_col(this_node,row,col);
get_lat_and_long_locations(row, col, latitude, longitude, Converter);

chi_data_out.precision(9);
chi_data_out << latitude << ","
<< longitude << ","
<< this_node << ",";
chi_data_out.precision(5);
chi_data_out << chi_data_map[this_node] << ","
<< elev_data_map[this_node] << ","
<< flow_distance_data_map[this_node] << ","
<< drainage_area_data_map[this_node] << ","
<< source_keys_map[this_node] << ","
<< baselevel_keys_map[this_node];

chi_data_out << endl;
}
}

chi_data_out.close();

}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


void LSDChiTools::print_chi_data_map_to_csv_with_junction_information(LSDFlowInfo& FlowInfo, LSDJunctionNetwork& JN, string filename)
{

// these are for extracting element-wise data from the channel profiles.
int this_node, row,col;
double latitude,longitude;
LSDCoordinateConverterLLandUTM Converter;

// find the number of nodes
int n_nodes = (node_sequence.size());


// Get vectors for making the maps
vector<int> NIvec;
vector<int> SOvec;
vector<int> JIvec;
JN.GetChannelNodesAndJunctions(FlowInfo, NIvec, JIvec, SOvec);

// Turn these into maps
map<int,int> SO_map;
map<int,int> JI_map;

int n_NI = int(NIvec.size());
for(int i = 0; i<n_NI; i++)
{
SO_map[ NIvec[i] ] = SOvec[i];
JI_map[ NIvec[i] ] = JIvec[i];
}

// open the data file
int RJ,UJ,receiver_NI,SO;
ofstream chi_data_out;
chi_data_out.open(filename.c_str());
chi_data_out << "latitude,longitude,NI,receiver_NI,chi,elevation,flow_distance,drainage_area,source_key,basin_key,stream_order,receiver_junction,upstream_junction" << endl;
if (n_nodes <= 0)
{
cout << "Cannot print since you have not calculated channel properties yet." << endl;
}
else
{
for (int n = 0; n< n_nodes; n++)
{
this_node = node_sequence[n];
FlowInfo.retrieve_current_row_and_col(this_node,row,col);
get_lat_and_long_locations(row, col, latitude, longitude, Converter);

// Now get a bunch of information from the junction network
FlowInfo.retrieve_receiver_information(this_node, receiver_NI);
RJ = JN.get_Receiver_of_Junction(JI_map[this_node]);
UJ = JN.find_upstream_junction_from_channel_nodeindex(this_node,FlowInfo);
SO = SO_map[ this_node ];




chi_data_out.precision(9);
chi_data_out << latitude << ","
<< longitude << ","
<< this_node << ","
<< receiver_NI << ",";
chi_data_out.precision(5);
chi_data_out << chi_data_map[this_node] << ","
<< elev_data_map[this_node] << ","
<< flow_distance_data_map[this_node] << ","
<< drainage_area_data_map[this_node] << ","
<< source_keys_map[this_node] << ","
<< baselevel_keys_map[this_node] << ","
<< SO << ","
<< RJ << ","
<< UJ;

chi_data_out << endl;
}
}

chi_data_out.close();

}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Print chi maps to file
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand Down Expand Up @@ -12275,12 +12408,19 @@ void LSDChiTools::print_basins(LSDFlowInfo& FlowInfo, LSDJunctionNetwork& Juncti
int basin_key = -9999;

// need to node index of this junction
int node_of_junction = JunctionNetwork.get_Node_of_Junction( Junctions[BN] );
if ( key_to_baselevel_map.find( node_of_junction) != key_to_baselevel_map.end() )
if( key_to_baselevel_map.size() == 0)
{
basin_key = key_to_baselevel_map[node_of_junction];
basin_key = BN;
}

else
{
int node_of_junction = JunctionNetwork.get_Node_of_Junction( Junctions[BN] );
if ( key_to_baselevel_map.find( node_of_junction) != key_to_baselevel_map.end() )
{
basin_key = key_to_baselevel_map[node_of_junction];
}
}

// get the centroid and outlet locations
centroid_i = thisBasin.get_Centroid_i();
centroid_j = thisBasin.get_Centroid_j();
Expand Down
23 changes: 23 additions & 0 deletions src/LSDChiTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,36 @@ class LSDChiTools
/// @brief This prints a csv file with chi data from the data maps
/// the columns are:
/// latitude,longitude,chi,elevation,flow distance,drainage area,
/// source_key,basin_key,stream_order,receiver_junction,upstream_junction
/// @param FlowInfo an LSDFlowInfo object
/// @param filename The name of the filename to print to (should have full
/// path and the extension .csv
/// @author SMM
/// @date 05/06/2017
void print_chi_data_map_to_csv(LSDFlowInfo& FlowInfo, string filename);

/// @brief This prints a csv file with chi data from the data maps
/// the columns are:
/// latitude,longitude,ni,chi,elevation,flow distance,drainage area,
/// source_key,basin_key,stream_order,receiver_junction,upstream_junction,node_index
/// @param FlowInfo an LSDFlowInfo object
/// @param filename The name of the filename to print to (should have full
/// path and the extension .csv
/// @author SMM
/// @date 05/06/2017
void print_chi_data_map_to_csv_with_ni(LSDFlowInfo& FlowInfo, string filename);

/// @brief This prints a csv file with chi data from the data maps
/// the columns are:
/// latitude,longitude,ni,receiver_ni,chi,elevation,flow distance,drainage area,
/// source_key,basin_key,stream_order,receiver_junction,upstream_junction
/// @param FlowInfo an LSDFlowInfo object
/// @param filename The name of the filename to print to (should have full
/// path and the extension .csv
/// @author SMM
/// @date 05/06/2017
void print_chi_data_map_to_csv_with_junction_information(LSDFlowInfo& FlowInfo, LSDJunctionNetwork& JN, string filename);


/// @brief This prints a csv file with chi data from the data maps for a specific basin
/// the columns are:
Expand Down
34 changes: 28 additions & 6 deletions src/LSDCosmoData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,11 @@ void LSDCosmoData::load_parameters(string filename)
Muon_scaling = "Braucher";
cout << "You have selected Braucher scaling" << endl;
}
if(value.find("braucherborchers") == 0 || value.find("BraucherBorchers") == 0)
{
Muon_scaling = "BraucherBorchers";
cout << "You have selected Braucher/Borchers scaling" << endl;
}
else if(value.find("granger") == 0 || value.find("Granger") == 0)
{
Muon_scaling = "Granger";
Expand Down Expand Up @@ -1238,7 +1243,8 @@ void LSDCosmoData::check_parameter_values()
}

if (Muon_scaling != "Braucher" && Muon_scaling != "Granger" &&
Muon_scaling != "Schaller" && Muon_scaling != "newCRONUS")
Muon_scaling != "Schaller" && Muon_scaling != "newCRONUS" &&
Muon_scaling != "BraucherBorchers")
{
cout << "You have not seleceted a valid scaling. Defaulting to Braucher" << endl;
Muon_scaling = "Braucher";
Expand Down Expand Up @@ -4053,6 +4059,10 @@ vector<double> LSDCosmoData::full_CRN_erosion_analysis_point(double Nuclide_conc
{
LSDCRNP.set_Braucher_parameters();
}
else if (Muon_scaling == "BraucherBorchers" )
{
LSDCRNP.set_BraucherBorchers_parameters();
}
else if (Muon_scaling == "Granger" )
{
LSDCRNP.set_Granger_parameters();
Expand All @@ -4064,7 +4074,7 @@ vector<double> LSDCosmoData::full_CRN_erosion_analysis_point(double Nuclide_conc
else
{
cout << "You didn't set the muon scaling." << endl
<< "Options are Schaller, Braucher, newCRONUS, and Granger." << endl
<< "Options are Schaller, Braucher, newCRONUS, BraucherBorchers, and Granger." << endl
<< "You chose: " << Muon_scaling << endl
<< "Defaulting to Braucher et al (2009) scaling" << endl;
LSDCRNP.set_Braucher_parameters();
Expand Down Expand Up @@ -4226,6 +4236,10 @@ double LSDCosmoData::predict_CRN_erosion_point(double Nuclide_conc, string Nucli
{
LSDCRNP.set_Braucher_parameters();
}
else if (Muon_scaling == "BraucherBorchers" )
{
LSDCRNP.set_BraucherBorchers_parameters();
}
else if (Muon_scaling == "Granger" )
{
LSDCRNP.set_Granger_parameters();
Expand All @@ -4237,7 +4251,7 @@ double LSDCosmoData::predict_CRN_erosion_point(double Nuclide_conc, string Nucli
else
{
cout << "You didn't set the muon scaling." << endl
<< "Options are Schaller, Braucher, newCRONUS and Granger." << endl
<< "Options are Schaller, Braucher, BraucherBorchers, newCRONUS and Granger." << endl
<< "You chose: " << Muon_scaling << endl
<< "Defaulting to Braucher et al (2009) scaling" << endl;
LSDCRNP.set_Braucher_parameters();
Expand Down Expand Up @@ -4440,6 +4454,10 @@ double LSDCosmoData::predict_mean_CRN_conc_point(double eff_erosion_rate, string
{
LSDCRNP.set_Braucher_parameters();
}
else if (Muon_scaling == "BraucherBorchers" )
{
LSDCRNP.set_BraucherBorchers_parameters();
}
else if (Muon_scaling == "Granger" )
{
LSDCRNP.set_Granger_parameters();
Expand All @@ -4451,7 +4469,7 @@ double LSDCosmoData::predict_mean_CRN_conc_point(double eff_erosion_rate, string
else
{
cout << "You didn't set the muon scaling." << endl
<< "Options are Schaller, Braucher, newCRONUS, and Granger." << endl
<< "Options are Schaller, Braucher, BraucherBorchers, newCRONUS, and Granger." << endl
<< "You chose: " << Muon_scaling << endl
<< "Defaulting to Braucher et al (2009) scaling" << endl;
LSDCRNP.set_Braucher_parameters();
Expand Down Expand Up @@ -4973,10 +4991,14 @@ void LSDCosmoData::point_measurements(vector<int> valid_samples,vector<double> s
{
LSDCRNP.set_Schaller_parameters();
}
else if (Muon_scaling == "Braucher" )
else if (Muon_scaling == "Braucher" )
{
LSDCRNP.set_Braucher_parameters();
}
else if (Muon_scaling == "BraucherBorchers" )
{
LSDCRNP.set_BraucherBorchers_parameters();
}
else if (Muon_scaling == "Granger" )
{
LSDCRNP.set_Granger_parameters();
Expand All @@ -4988,7 +5010,7 @@ void LSDCosmoData::point_measurements(vector<int> valid_samples,vector<double> s
else
{
cout << "You didn't set the muon scaling." << endl
<< "Options are Schaller, Braucher, newCRONUS, and Granger." << endl
<< "Options are Schaller, Braucher, BraucherBorchers, newCRONUS, and Granger." << endl
<< "You chose: " << Muon_scaling << endl
<< "Defaulting to Braucher et al (2009) scaling" << endl;
LSDCRNP.set_Braucher_parameters();
Expand Down
Loading

0 comments on commit b9e61d0

Please sign in to comment.