Input file
==========

Here we explain the input file used to control Detrital MC, where all parameters for a Detrital MC model and the locations of input data files are specified.
The `input file <https://github.com/HUGG/Detrital-MC/blob/master/input/det_mc_input.txt>`_ is located in the ``input`` subdirectory.
Note that you can freely add comments in your copies of the Detrital MC input file by starting lines with the ``$`` character.

Below, we desribe the different sections of the Detrital MC input file and how they work.
The general format of this documentation gives information about what should be listed on each line of each section of the input file.
The sections and lines are given by number, while the values on each line are given using letters.
An example of two lines containing 3 and 5 values is given below.

.. code-block:: none
    :caption: Example format of the Detrital MC input file.

    $=== [3] - Section name ========================================================
    VALUE_A VALUE_B VALUE_C
    VALUE_A VALUE_B VALUE_C VALUE_D VALUE_E

Please check the rest of the documentation for more detailed explanations of how other parts the software operate.

Section 1: Basin summary information
------------------------------------

The first section of the Detrital MC input file is for specifying how many basins are being analyzed, and the names, formats, and associated parameters for the input data files.
The input values are described in more detail below.

.. code-block:: none
    :caption: Section 1 of the Detrital MC input file (without comments)

    $=== [1] - Basin summary information ===========================================
    1
    BH398-AFT 3 BH398_WB009-1km_Pecube_and_topometrics_250m 8 97 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1

Section 1, line 1 (1 required value)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- **Value a**: Number of basins to analyze. Type: ``int``

    The only input value here is the number of basins to analyze.

Section 1, line 2+ (4+ required values)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In section 1, the remaining line(s) are used to provide information about each of the basins that should be analyzed.
You should use one line per basin.

- **Value a**: Name of the observed age data file in the ``data/observed_ages`` subdirectory. Type: ``char``

    Listing ``ba1`` would tell Detrital MC to read measured ages from the ``data/observed_ages/ba1.dat`` file.
    This should be a character string.

- **Value b**: Predicted age file format. Type: ``int``

    .. note:: Values c, d, ... differ depending on the value selected for value 2 on this line.
        As a result, we list the corresponding descriptions of those values below each number below.

    If value b = ``1``: ``Comparison.txt`` file generated by `HUGG version of Pecube <https://github.com/HUGG/Pecube-HUGG>`_. Complete this line with the following values:

    - **Value c**: Name of the Pecube model run output directory (e.g., ``RUN00``) in the ``data`` subdirectory. Type: ``char`` 
    - **Value d**: The predicted thermochronometer age system to use (``1`` = AHe, ``2`` = AFT, ``3`` = ZHe, ``4`` = ZFT, ``5`` = MAr). Type: ``int``

    If value b = ``2``: Generic CSV file. Complete this line with the following values:

    - **Value c**: Name of the predicted age file in the data subdirectory (e.g., ``DW001`` for ``DW001.csv``). Type: ``char``
    - **Value d**: The number of the column containing predicted ages in the CSV file. Type: ``int``
    - **Value e**: The number of the column containing predicted erosion rates in the CSV file. Type: ``int``

        .. note:: If value e is equal to ``16``, ``17``, ``18``, ``19``, ``98``, or ``99``, additional information is required.

        If value e = ``16``:

        - **Value f**: Bedrock fertility scaling factor 1 (TSS). Type: ``float``
        - **Value g**: Bedrock fertility scaling factor 2 (GHS). Type: ``float``
        - **Value h**: Bedrock fertility scaling factor 3 (LHS). Type: ``float``
        - **Value i**: Bedrock fertility scaling factor 4 (Siwaliks). Type: ``float``
        - **Value j**: Bedrock fertility scaling factor 5 (Leucogranites). Type: ``float``
        - **Value k**: Bedrock fertility scaling factor 6 (LHS-C). Type: ``float``
        - **Value l**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

        If value e = ``17``:

        - **Value f**: Glacier scaling factor 1 (Glacier-covered areas). Type: ``float``
        - **Value g**: Glacier scaling factor 1 (Glacier-free areas). Type: ``float``
        - **Value h**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

        If value e = ``18``:

        - **Value f**: Moraine scaling factor 1 (Moraine-covered areas). Type: ``float``
        - **Value g**: Moraine scaling factor 1 (Moraine-free areas). Type: ``float``
        - **Value h**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

        If value e = ``19``:

        - **Value f**: Rock glacier scaling factor 1 (Rock glacier-covered areas). Type: ``float``
        - **Value g**: Rock glacier scaling factor 1 (Rock glacier-free areas). Type: ``float``
        - **Value h**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

        If value e = ``98``:

        - **Value f**: Bedrock fertility scaling factor 1 (Checkha/TSS). Type: ``float``
        - **Value g**: Bedrock fertility scaling factor 2 (GHS). Type: ``float``
        - **Value h**: Bedrock fertility scaling factor 3 (LHS). Type: ``float``
        - **Value i**: Bedrock fertility scaling factor 4 (Siwaliks). Type: ``float``
        - **Value j**: Bedrock fertility scaling factor 5 (Leucogranites). Type: ``float``
        - **Value k**: Bedrock fertility scaling factor 6 (Paro). Type: ``float``
        - **Value l**: Glacier scaling factor (Glacier-covered areas). Type: ``float``
        - **Value m**: Moraine scaling factor (Moraine-covered areas). Type: ``float``
        - **Value n**: Rock glacier scaling factor (Rock glacier-covered areas). Type: ``float``
        - **Value o**: Non-glacial scaling factor (Areas free of glacial formations). Type: ``float``
        - **Value p**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

        If value e = ``99``:

        - **Value f**: Glacier scaling factor (Glacier-covered areas). Type: ``float``
        - **Value g**: Moraine scaling factor (Moraine-covered areas). Type: ``float``
        - **Value h**: Rock glacier scaling factor (Rock glacier-covered areas). Type: ``float``
        - **Value i**: Non-glacial scaling factor (Areas free of glacial formations). Type: ``float``
        - **Value j**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

    If value b = ``3``: Newer generic CSV file. Listed values are the same as for Value b = ``2``, with the addition below:

        .. note:: If value e is equal to ``97``, additional information is required.

        If value e = ``97``:

        - **Value f**: Bedrock fertility scaling factor 1 (Checkha/TSS). Type: ``float``
        - **Value g**: Bedrock fertility scaling factor 2 (GHS). Type: ``float``
        - **Value h**: Bedrock fertility scaling factor 3 (LHS). Type: ``float``
        - **Value i**: Bedrock fertility scaling factor 4 (Siwaliks). Type: ``float``
        - **Value j**: Bedrock fertility scaling factor 5 (Leucogranites). Type: ``float``
        - **Value k**: Bedrock fertility scaling factor 6 (Paro). Type: ``float``
        - **Value l**: Glacier scaling factor (Glacier-covered areas). Type: ``float``
        - **Value m**: Moraine scaling factor (Moraine-covered areas). Type: ``float``
        - **Value n**: Rock glacier scaling factor (Rock glacier-covered areas). Type: ``float``
        - **Value o**: Non-glacial scaling factor (Areas free of glacial formations). Type: ``float``
        - **Value p**: Scaling factor for regions with hillslopes >30 degrees. Type: ``float``
        - **Value q**: Scaling factor for regions with hillslopes <10 degrees. Type: ``float``
        - **Value r**: Erosion scaling factor. Type: ``int``

            - ``0``: None
            - ``1``: Instantaneous exhumation rates from Pecube
            - ``2``: Normalized channel steepness
            - ``3``: Specific stream power

Section 2: Number of grains to consider in predicted age PDFs
-------------------------------------------------------------

The second section of the Detrital MC input file contains information about the number of "samples" to consider when calculating age distributions.
The input values are described in more detail below.

.. code-block:: none
    :caption: Section 2 of the Detrital MC input file (without comments)

    $=== [2] - Number of grains to consider in predicted age PDFs ==================
    0
    0

Section 2, line 1 (1 required value)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- **Value a**: Number of different sample sizes to consider. Type: ``int``

    Detrital MC has the option to calculate age distributions using different numbers of ages in the distribution.

    - If a < 1, the code will use the number in the observed age file
    - If a > 0, you should list the number of different samples sizes on the second line

Section 2, line 2 (1 required value, additional optional values)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- **Value a**: Number of 'grains' in each sample, separated by a single space. Type: ``int [int int ...]``

    If value a on line one of this section is less than 1, this value is read, but ignored

Section 3: PDFs to calculate
----------------------------

Section three of the Detrital MC input file contains flags for which age distributions should be calculated.
The input values are described in more detail below.

.. code-block:: none
    :caption: Section 3 of the Detrital MC input file (without comments)

    $=== [3] - PDF generation ======================================================
    1 0 1

Section 3, line 1 (3 required values)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- **Value a**: Flag for whether or not to calculate age distributions for the observed age data. Type: ``int``

    The input value must be either ``1`` or ``0``.

    - 1 = yes
    - 0 = no

- **Value b**: Flag for whether or not to calculate age distributions for the entire predicted age population. Type: ``int``

    The input value must be either ``1`` or ``0``.

    - 1 = yes
    - 0 = no

- **Value c**: Flag for whether or not to calculate age distributions from Monte Carlo random samples from the predicted age population. Type: ``int``

    The input value must be either ``1`` or ``0``.

    - 1 = yes
    - 0 = no

..
    $=== [4] - PDF comparison ======================================================
    $ Line 1: [int int int int int flt]
    $ (a) Observed age and full predicted age PDFs (yes = 1, no = 0)
    $ (b) Observed age and Monte Carlo predicted age PDFs (yes = 1, no = 0)
    $ (c) Full predicted age and Monte Carlo predicted age PDFs (yes = 1, no = 0)
    $ (d) Use empirical cumulative distribution functions (ECDFs) rather than CSPDFs
    $     for PDF comparisons (Kuiper's test) (yes = 1, no = 0)
    $     NOTE: You must set option (e) below equal to 1 to use ECDFs
    $ (e) Use new Kuiper's test formulation or original? (yes = 1, no = 0)
    $     The differences between the two versions are trivial, but the new version
    $     must be used for comparison of ECDFs.
    $     NOTE: Currently, you must use a fixed age range for the PDFs/CDFs/ECDFs to
    $     use the new Kuiper's test. A fixed age range can be set using (d) and (e)
    $     in section 7 of this file.
    $ (f) Kuiper's test significance level. A value of 0.05 is recommended (95%
    $     confidence interval
    0 1 0 0 1 0.05

    $=== [5] - Landslide PDF options ===============================================
    $ Line 1: [int flt flt flt]
    $ (a) Flag to (=1) enable or (=0) disable landslide erosion
    $ (b) Junk landslide age when there are no landslides within the catchment
    $ (c) Junk landslide erosion rate when there are no landslides within the
    $     catchment
    $ (d) Landslide sediment residence time in years.
    $ (e) Landslide input file format (1 = ASCII, 2 = binary)
    0 1. 5. 100. 2

    $=== [6] - PDF output ==========================================================
    $ Line 1: [int int int int int int int int]
    $ [Age probability density functions]
    $ (a) Observed age PDF (yes = 1, no = 0)
    $ (b) Full predicted age PDF (yes = 1, no = 0)
    $ (c) Monte Carlo predicted age PDFs (yes = 1, no = 0)
    $ (d) Number of Monte Carlo predicted age PDFs to output
    $ [Cumulative age distributions]
    $     NOTE: If option 4 in section 3 (use empirical CDFs) is equal to 1, the
    $     output distributions will be empirical cumulative distribution functions
    $     (ECDFs), otherwise they will be cumulative density functions (CDFs)
    $ (e) Observed age cumulative distribution (yes = 1, no = 0)
    $ (f) Full predicted age cumulative distribution (yes = 1, no = 0)
    $ (g) Monte Carlo predicted age cumulative distribution (yes = 1, no = 0)
    $ (h) Write Tecplot header to output PDFs/CDFs/ECDFs (yes = 1, no = 0)
    $ (i) Write Veusz formatted PDFs/CDFs/ECDFs (yes = 1, no = 0)
    1 0 1 100 1 0 1 0 1

    $=== [7] - Other options =======================================================
    $ Line 1: [int flt int flt flt int flt flt flt int]
    $ (a) Number of Monte Carlo predicted age PDFs to calculate (10000, typically)
    $ (b) Age increment for calculating PDFs (0.01 - 0.001, typically)
    $ (c) Calculate age range for PDFs using data age ranges and uncertainties
    $     (yes = 1, no = 0)
    $ (d) Minimum age for PDF calculation if not using (c)
    $ (e) Maximum age for PDF calculation if not using (c)
    $ (f) Type of age uncertainty to apply if comparing to data
    $  - Mean 1-sigma percent uncertainty in observed ages = 1
    $  - Median 1-sigma percent uncertainty in observed ages = 2
    $  - Standard deviation in 1-sigma percent uncertainty in observed ages = 3
    $  - User-specified percent uncertainty = 4 (using option g below)
    $ (g) Percent age uncertainty to use if not comparing to data or specified above
    $ (h) Approximate number of values in scaled age PDFs (50., unless you know what
    $     you're doing)
    $ (i) alpha, the standard deviation scaling factor (0.6 is a good choice). If
    $     alpha is negative, an optimal alpha value will be calculated using Eq. 18
    $     from Brandon, 1996, Radiation Damage.
    $ (j) Scale input erosion rates? (yes = 1, no = 0)
    $ (k) If yes for (j), what kind of scaling should be done?
    $  - Normalize erosion rates = 1
    $  -
    $ (l) Array size for fixed-size predicted age distributions
    $  - If the value is less than 1, the default scaling will be used
    $  - If the value is positive, a value of 1000000 (one million) is recommended
    10000 0.005 0 0. 20. 1 5.0 50. 0.6 0 3 1000000
