Skip to content

Commit

Permalink
0.5.1 documentation fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinperaza committed Jul 30, 2023
1 parent 0d6378a commit 2db1680
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 100 deletions.
20 changes: 12 additions & 8 deletions build/lib/crnpy/crnpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,12 +1215,16 @@ def rover_centered_coordinates(x, y):
def uncertainty_counts(raw_counts, metric="std", fp=1, fw=1, fi=1):
"""Function to estimate the uncertainty of raw counts.
Measurements of a proportional neutron detector system are governed by counting statistics that follow a Poissonian probability distribution (Zreda et al., 2012).
The expected uncertainty in the neutron count rate N is defined by the standard deviation $ \sqrt{N} $. (Jakobi et al., 2020)
It can be expressed as CV% as $ N^{-1/2} $
Measurements of proportional neutron detector systems are governed by counting statistics that follow a Poissonian probability distribution (Zreda et al., 2012).
The expected uncertainty in the neutron count rate $N$ is defined by the standard deviation $ \sqrt{N} $ (Jakobi et al., 2020).
The CV% can be expressed as $ N^{-1/2} $
Args:
raw_counts (array): Raw neutron counts.
metric (str): Either 'std' or 'cv' for standard deviation or coefficient of variation.
fp (float): Pressure correction factor.
fw (float): Humidity correction factor.
fi (float): Incoming neutron flux correction factor.
Returns:
uncertainty (float): Uncertainty of raw counts.
Expand Down Expand Up @@ -1248,18 +1252,18 @@ def uncertainty_vwc(raw_counts, N0, bulk_density, fp=1, fw=1, fi=1, a0=0.0808,a1
r"""Function to estimate the uncertainty propagated to volumetric water content.
The uncertainty of the volumetric water content is estimated by propagating the uncertainty of the raw counts.
Following Eq. 10 in Jakobi et al. (2020), the uncertainty of the volumetric water content is estimated as:
Following Eq. 10 in Jakobi et al. (2020), the uncertainty of the volumetric water content can be expressed as:
$$
\sigma_{\theta_g}(N) = \sigma_N \frac{a_0 N_0}{(N_{cor} - a_1 N_0)^4} \sqrt{(N_{cor} - a_1 N_0)^4 + 8 \sigma_N^2 (N_{cor} - a_1 N_0)^2 + 15 \sigma_N^4}
$$
Args:
raw_counts (array): Raw neutron counts.
N0 (float): Calibration parameter N0.
bulk_density (float): Bulk density in kg/m3.
fp (float): Calibration parameter fp.
fw (float): Calibration parameter fw.
fi (float): Calibration parameter fi.
bulk_density (float): Bulk density in g cm-3.
fp (float): Pressure correction factor.
fw (float): Humidity correction factor.
fi (float): Incoming neutron flux correction factor.
Returns:
sigma_VWC (float): Uncertainty in terms of volumetric water content.
Expand Down
8 changes: 3 additions & 5 deletions docs/examples/calibration/calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,6 @@
}
],
"source": [
"# Select station data only until the calibration date\n",
"\n",
"# Define date in which the probe was deployed in the field (i.e., first record)\n",
"deployment_date = df_station['timestamp'].iloc[0]\n",
"\n",
Expand Down Expand Up @@ -764,7 +762,7 @@
"source": [
"# Incoming neutron flux correction\n",
"\n",
"# Download data for the reference neutron monitor and add to the DataFrame\n",
"# Download data for the reference neutron monitor and add it to the DataFrame\n",
"nmdb = crnpy.get_incoming_neutron_flux(deployment_date,\n",
" calibration_end,\n",
" station=\"DRBS\",\n",
Expand Down Expand Up @@ -797,7 +795,7 @@
"source": [
"### Determine field-average soil moisture and bulk density\n",
"\n",
"Using the function [`nrad_weight()`](../../../reference/#crnpy.crnpy.nrad_weight) the weights corresponding to each soil sample will be computed considering air-humidity, sample depth, distance from station and bulk density.\n"
"Using the function [`nrad_weight()`](../../../reference/#crnpy.crnpy.nrad_weight) the weights corresponding to each soil sample will be computed considering air-humidity, sample depth, and distance from station and bulk density.\n"
]
},
{
Expand Down Expand Up @@ -846,7 +844,7 @@
"source": [
"## Solving for $N_0$\n",
"\n",
"Previous steps estimated the a field volumetric water content of `0.263` and an average neutron count of `1542`. Using [`scipy.optimize.root()`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html) $N_0$ is estimated given the observed value of $\\theta_v$ and neutron counts."
"Previous steps estimated the field volumetric water content of `0.263` and an average neutron count of `1542`. Using [`scipy.optimize.root()`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html) $N_0$ is estimated given the observed value of $\\theta_v$ and neutron counts."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/rover/Hydroinnova_rover_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
"# Estimate lattice water based on texture\n",
"lattice_water = crnpy.lattice_water(clay_content=0.35)\n",
"\n",
"# Estimate Soil Columetric Water Content\n",
"# Estimate Soil Volumetric Water Content\n",
"df['VWC'] = crnpy.counts_to_vwc(df['corrected_neutrons_smoothed'], N0=550, bulk_density=1.3, Wlat=lattice_water, Wsoc=0.01)\n",
"\n",
"# Drop VWC NaN values before interpolating values\n",
Expand Down
34 changes: 19 additions & 15 deletions docs/examples/stationary/example_RDT_station.ipynb

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions site/examples/calibration/calibration/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2097,9 +2097,7 @@ <h2 id="read-data-from-crnp">Read data from CRNP<a class="anchor-link" href="#re
</div>
</clipboard-copy>
</div>
<div class="highlight-ipynb hl-python "><pre><span></span><span class="c1"># Select station data only until the calibration date</span>

<span class="c1"># Define date in which the probe was deployed in the field (i.e., first record)</span>
<div class="highlight-ipynb hl-python "><pre><span></span><span class="c1"># Define date in which the probe was deployed in the field (i.e., first record)</span>
<span class="n">deployment_date</span> <span class="o">=</span> <span class="n">df_station</span><span class="p">[</span><span class="s1">&#39;timestamp&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

<span class="c1"># Filter station data from the first record to the end of the field survey calibration</span>
Expand All @@ -2108,9 +2106,7 @@ <h2 id="read-data-from-crnp">Read data from CRNP<a class="anchor-link" href="#re
<span class="n">df_station</span> <span class="o">=</span> <span class="n">df_station</span><span class="p">[</span><span class="n">idx_period</span><span class="p">]</span>
<span class="n">df_station</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
<div id="cell-5" class="clipboard-copy-txt"># Select station data only until the calibration date

# Define date in which the probe was deployed in the field (i.e., first record)
<div id="cell-5" class="clipboard-copy-txt"># Define date in which the probe was deployed in the field (i.e., first record)
deployment_date = df_station['timestamp'].iloc[0]

# Filter station data from the first record to the end of the field survey calibration
Expand Down Expand Up @@ -2552,7 +2548,7 @@ <h2 id="correct-neutron-counts">Correct neutron counts<a class="anchor-link" hre
</div>
<div class="highlight-ipynb hl-python "><pre><span></span><span class="c1"># Incoming neutron flux correction</span>

<span class="c1"># Download data for the reference neutron monitor and add to the DataFrame</span>
<span class="c1"># Download data for the reference neutron monitor and add it to the DataFrame</span>
<span class="n">nmdb</span> <span class="o">=</span> <span class="n">crnpy</span><span class="o">.</span><span class="n">get_incoming_neutron_flux</span><span class="p">(</span><span class="n">deployment_date</span><span class="p">,</span>
<span class="n">calibration_end</span><span class="p">,</span>
<span class="n">station</span><span class="o">=</span><span class="s2">&quot;DRBS&quot;</span><span class="p">,</span>
Expand All @@ -2567,7 +2563,7 @@ <h2 id="correct-neutron-counts">Correct neutron counts<a class="anchor-link" hre
</pre></div>
<div id="cell-9" class="clipboard-copy-txt"># Incoming neutron flux correction

# Download data for the reference neutron monitor and add to the DataFrame
# Download data for the reference neutron monitor and add it to the DataFrame
nmdb = crnpy.get_incoming_neutron_flux(deployment_date,
calibration_end,
station="DRBS",
Expand Down Expand Up @@ -2631,7 +2627,7 @@ <h2 id="correct-neutron-counts">Correct neutron counts<a class="anchor-link" hre
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<h3 id="determine-field-average-soil-moisture-and-bulk-density">Determine field-average soil moisture and bulk density<a class="anchor-link" href="#determine-field-average-soil-moisture-and-bulk-density">&#182;</a></h3><p>Using the function <a href="../../../reference/#crnpy.crnpy.nrad_weight"><code>nrad_weight()</code></a> the weights corresponding to each soil sample will be computed considering air-humidity, sample depth, distance from station and bulk density.</p>
<h3 id="determine-field-average-soil-moisture-and-bulk-density">Determine field-average soil moisture and bulk density<a class="anchor-link" href="#determine-field-average-soil-moisture-and-bulk-density">&#182;</a></h3><p>Using the function <a href="../../../reference/#crnpy.crnpy.nrad_weight"><code>nrad_weight()</code></a> the weights corresponding to each soil sample will be computed considering air-humidity, sample depth, and distance from station and bulk density.</p>

</div>
</div>
Expand Down Expand Up @@ -2751,7 +2747,7 @@ <h3 id="determine-field-average-soil-moisture-and-bulk-density">Determine field-
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<h2 id="solving-for-n_0">Solving for $N_0$<a class="anchor-link" href="#solving-for-n_0">&#182;</a></h2><p>Previous steps estimated the a field volumetric water content of <code>0.263</code> and an average neutron count of <code>1542</code>. Using <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html"><code>scipy.optimize.root()</code></a> $N_0$ is estimated given the observed value of $\theta_v$ and neutron counts.</p>
<h2 id="solving-for-n_0">Solving for $N_0$<a class="anchor-link" href="#solving-for-n_0">&#182;</a></h2><p>Previous steps estimated the field volumetric water content of <code>0.263</code> and an average neutron count of <code>1542</code>. Using <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html"><code>scipy.optimize.root()</code></a> $N_0$ is estimated given the observed value of $\theta_v$ and neutron counts.</p>

</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions site/examples/rover/Hydroinnova_rover_example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ <h4 id="atmospheric-correction">Atmospheric correction<a class="anchor-link" hre
<span class="c1"># Estimate lattice water based on texture</span>
<span class="n">lattice_water</span> <span class="o">=</span> <span class="n">crnpy</span><span class="o">.</span><span class="n">lattice_water</span><span class="p">(</span><span class="n">clay_content</span><span class="o">=</span><span class="mf">0.35</span><span class="p">)</span>

<span class="c1"># Estimate Soil Columetric Water Content</span>
<span class="c1"># Estimate Soil Volumetric Water Content</span>
<span class="n">df</span><span class="p">[</span><span class="s1">&#39;VWC&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">crnpy</span><span class="o">.</span><span class="n">counts_to_vwc</span><span class="p">(</span><span class="n">df</span><span class="p">[</span><span class="s1">&#39;corrected_neutrons_smoothed&#39;</span><span class="p">],</span> <span class="n">N0</span><span class="o">=</span><span class="mi">550</span><span class="p">,</span> <span class="n">bulk_density</span><span class="o">=</span><span class="mf">1.3</span><span class="p">,</span> <span class="n">Wlat</span><span class="o">=</span><span class="n">lattice_water</span><span class="p">,</span> <span class="n">Wsoc</span><span class="o">=</span><span class="mf">0.01</span><span class="p">)</span>

<span class="c1"># Drop VWC NaN values before interpolating values</span>
Expand All @@ -2422,7 +2422,7 @@ <h4 id="atmospheric-correction">Atmospheric correction<a class="anchor-link" hre
# Estimate lattice water based on texture
lattice_water = crnpy.lattice_water(clay_content=0.35)

# Estimate Soil Columetric Water Content
# Estimate Soil Volumetric Water Content
df['VWC'] = crnpy.counts_to_vwc(df['corrected_neutrons_smoothed'], N0=550, bulk_density=1.3, Wlat=lattice_water, Wsoc=0.01)

# Drop VWC NaN values before interpolating values
Expand Down
52 changes: 30 additions & 22 deletions site/examples/stationary/example_RDT_station/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit 2db1680

Please sign in to comment.