Skip to content

Commit

Permalink
Add --D48 to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaeron committed Jul 20, 2023
1 parent a541e62 commit 12b3b7b
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 177 deletions.
51 changes: 45 additions & 6 deletions D47crunch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__copyright__ = 'Copyright (c) 2023 Mathieu Daëron'
__license__ = 'Modified BSD License - https://opensource.org/licenses/BSD-3-Clause'
__date__ = '2023-07-20'
__version__ = '2.2.0'
__version__ = '2.2.1'

import os
import numpy as np
Expand Down Expand Up @@ -3249,6 +3249,7 @@ def _cli(
exclude: Annotated[str, typer.Option('--exclude', '-e', help = 'The path of a file specifying UIDs and/or Samples to exclude')] = 'none',
anchors: Annotated[str, typer.Option('--anchors', '-a', help = 'The path of a file specifying custom anchors')] = 'none',
output_dir: Annotated[str, typer.Option('--output-dir', '-o', help = 'Specify the output directory')] = 'output',
run_D48: Annotated[bool, typer.Option('--D48', help = 'Also standardize D48')] = False,
):
"""
Process raw D47 data and return standardized results.
Expand Down Expand Up @@ -3290,13 +3291,51 @@ def _cli(
data.crunch()
data.standardize()
data.summary(dir = output_dir)
data.table_of_samples(dir = output_dir)
data.table_of_sessions(dir = output_dir)
data.plot_sessions(dir = output_dir)
data.plot_residuals(dir = output_dir, filename = 'D47_residuals.pdf', kde = True)
data.table_of_analyses(dir = output_dir)
data.plot_distribution_of_analyses(dir = output_dir)
data.plot_bulk_compositions(dir = output_dir + '/bulk_compositions')
data.plot_sessions(dir = output_dir)

if not run_D48:
data.table_of_samples(dir = output_dir)
data.table_of_analyses(dir = output_dir)
data.table_of_sessions(dir = output_dir)


if run_D48:
data2 = D48data()
data2.read(rawdata)

data2 = D48data([r for r in data2 if r['UID'] not in exclude_uid and r['Sample'] not in exclude_sample])

if anchors != 'none':
data2.Nominal_d13C_VPDB = {
_['Sample']: _['d13C_VPDB']
for _ in anchors
if 'd13C_VPDB' in _
}
data2.Nominal_d18O_VPDB = {
_['Sample']: _['d18O_VPDB']
for _ in anchors
if 'd18O_VPDB' in _
}
data2.Nominal_D4x = {
_['Sample']: _['D48']
for _ in anchors
if 'D48' in _
}

data2.refresh()
data2.wg()
data2.crunch()
data2.standardize()
data2.summary(dir = output_dir)
data2.plot_sessions(dir = output_dir)
data2.plot_residuals(dir = output_dir, filename = 'D48_residuals.pdf', kde = True)
data2.plot_distribution_of_analyses(dir = output_dir)

table_of_analyses(data, data2, dir = output_dir)
table_of_samples(data, data2, dir = output_dir)
table_of_sessions(data, data2, dir = output_dir)

def __cli():
_app()
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v2.2.1
*Released on 2023-07-20*

### New feature

* The CLI now processes Δ48 as well as Δ47 data, thanks to the `--D48` option.


## v2.2.0
*Released on 2023-07-20*

Expand Down
116 changes: 58 additions & 58 deletions code_examples/virtual_data/output.txt

Large diffs are not rendered by default.

Binary file modified docs/D47_plot_Session_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/D47_plot_Session_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 3. Command-Line Interface (CLI)

Instead of writing Python code, you may directly use the CLI to process raw D47 data using reasonable defaults. The simplest way is simply to call
Instead of writing Python code, you may directly use the CLI to process raw Δ47 and Δ48 data using reasonable defaults. The simplest way is simply to call:

```txt
D47crunch rawdata.csv
Expand Down Expand Up @@ -62,3 +62,5 @@ The `--output-dir` or `-o` option may be used to specify a custom directory name
```txt
D47crunch -o `date "+%Y-%M-%d-%Hh%M"` rawdata.csv
```

To process Δ48 as well as Δ47, just add the `--D48` option.
263 changes: 152 additions & 111 deletions docs/index.html

Large diffs are not rendered by default.

Binary file modified docs/residuals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/time_distribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Python library for processing and standardizing carbonate clumped-isotope analyses, from low-level data out of a dual-inlet mass spectrometer to final, “absolute” Δ<sub>47</sub> and Δ<sub>48</sub> values with fully propagated analytical error estimates.

This also provides a command-line interface making it possible to process a multi-session Δ<sub>47</sub> dataset by simply calling `D47crunch rawdata.csv`. See the [CLI documentation](https://mdaeron.github.io/D47crunch/#3-command-line-interface-cli) for more options.
This also provides a command-line interface making it possible to process a multi-session Δ<sub>47</sub> (and potentially Δ<sub>48</sub>) dataset by simply calling `D47crunch rawdata.csv`. See the [CLI documentation](https://mdaeron.github.io/D47crunch/#3-command-line-interface-cli) for more options.

## Documentation

Expand Down

0 comments on commit 12b3b7b

Please sign in to comment.