diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..5171767
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ target-branch: "develop"
+ schedule:
+ interval: "monthly"
+ groups:
+ github-actions:
+ patterns:
+ - "*"
\ No newline at end of file
diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml
new file mode 100644
index 0000000..4fd795a
--- /dev/null
+++ b/.github/workflows/publish-to-pypi.yml
@@ -0,0 +1,150 @@
+name: Build, test, and deploy
+
+on:
+ push:
+ branches: [develop, main]
+ pull_request:
+ branches: [develop, main]
+ release:
+ types: [published]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ name: Lint and check formatting
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+
+ - name: Check code with ruff
+ uses: astral-sh/ruff-action@v3
+ with:
+ version: "0.16.9"
+ args: check
+
+ - name: Check formatting with ruff
+ uses: astral-sh/ruff-action@v3
+ with:
+ version: "0.16.9"
+ args: format --check
+
+ build:
+ name: Build distributions
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+
+ - uses: actions/setup-python@v7
+ with:
+ python-version: "3.14"
+
+ - name: Check release tag matches package version
+ if: github.event_name == 'release'
+ shell: bash
+ run: |
+ version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
+ tag="${GITHUB_REF_NAME#v}"
+ if [ "$tag" != "$version" ]; then
+ echo "::error::Release tag ($GITHUB_REF_NAME) does not match version in pyproject.toml ($version)"
+ exit 1
+ fi
+
+ - name: Build sdist and wheel
+ run: pipx run build
+
+ - name: Check distribution metadata
+ run: pipx run twine check --strict dist/*
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: dist
+ path: dist/
+
+ test:
+ name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
+ needs: build
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ # macos-15-intel is an Intel runner, macos-15 is Apple silicon
+ os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-15]
+ python-version: ["3.10", "3.15"]
+ exclude:
+ # NumPy and SciPy do not provide Windows ARM64 packages for Python 3.10
+ - os: windows-11-arm
+ python-version: "3.10"
+ include:
+ # Test the intermediate Python versions on Linux only
+ - os: ubuntu-latest
+ python-version: "3.11"
+ - os: ubuntu-latest
+ python-version: "3.12"
+ - os: ubuntu-latest
+ python-version: "3.13"
+ - os: ubuntu-latest
+ python-version: "3.14"
+
+ steps:
+ # Checkout is only needed for the tests and sample data; the package is
+ # installed from the built wheel so the tests check what gets published
+ - uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+
+ - uses: actions/setup-python@v7
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - uses: actions/download-artifact@v8
+ with:
+ name: dist
+ path: dist
+
+ - name: Install tcplotter wheel and test dependencies
+ shell: bash
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install dist/*.whl pytest
+
+ - name: Run tests
+ run: python -m pytest -v
+
+ upload_testpypi:
+ name: Publish to TestPyPI
+ needs: [lint, build, test]
+ runs-on: ubuntu-latest
+ environment: testpypi
+ permissions:
+ id-token: write
+ if: github.event_name == 'workflow_dispatch'
+ steps:
+ - uses: actions/download-artifact@v8
+ with:
+ name: dist
+ path: dist
+ - uses: pypa/gh-action-pypi-publish@release/v1
+ with:
+ repository-url: https://test.pypi.org/legacy/
+
+ upload_pypi:
+ name: Publish to PyPI
+ needs: [lint, build, test]
+ runs-on: ubuntu-latest
+ environment: pypi
+ permissions:
+ id-token: write
+ if: github.event_name == 'release' && github.event.action == 'published'
+ steps:
+ - uses: actions/download-artifact@v8
+ with:
+ name: dist
+ path: dist
+ - uses: pypa/gh-action-pypi-publish@release/v1
diff --git a/.gitignore b/.gitignore
index e946c42..2820620 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,9 @@ __pycache__
.pixi/*
!.pixi/config.toml
.DS_Store
+
+# Build and test output
+build/
+dist/
+*.egg-info/
+.pytest_cache/
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
index ade0e40..1b00017 100644
--- a/.readthedocs.yaml
+++ b/.readthedocs.yaml
@@ -6,7 +6,7 @@ version: 2
# Set the OS, Python version and other tools you might need
build:
- os: ubuntu-22.04
+ os: ubuntu-24.04
tools:
python: "3.12"
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 0000000..c401af6
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,38 @@
+cff-version: 1.2.0
+message: "If you use tcplotter in your work, please cite it as below."
+type: software
+title: "tcplotter: a Python package for creating and customizing thermochronometer age and closure temperature plots"
+authors:
+ - family-names: Whipp
+ given-names: David M.
+ affiliation: University of Helsinki, Finland
+ - family-names: Ketcham
+ given-names: Richard A.
+ affiliation: University of Texas at Austin, USA
+version: 0.5.0
+doi: 10.5281/zenodo.5958939
+license: GPL-3.0-or-later
+repository-code: "https://github.com/HUGG/tcplotter"
+url: "https://tcplotter.readthedocs.io/"
+keywords:
+ - thermochronology
+ - geology
+ - geophysics
+references:
+ - type: article
+ title: "Short communication: Modeling competing effects of cooling rate, grain size, and radiation damage in low-temperature thermochronometers"
+ authors:
+ - family-names: Whipp
+ given-names: David M.
+ - family-names: Kellett
+ given-names: Dawn A.
+ - family-names: Coutand
+ given-names: Isabelle
+ - family-names: Ketcham
+ given-names: Richard A.
+ journal: Geochronology
+ volume: 4
+ start: 143
+ end: 152
+ year: 2022
+ doi: 10.5194/gchron-4-143-2022
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 12beda5..f288702 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,674 @@
-MIT License
-
-Copyright (c) 2021-2022 David Whipp
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
index 5c954cd..43ea5ab 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,13 @@
# Tcplotter code description and instructions for use
[](https://zenodo.org/badge/latestdoi/444915688)
+[](https://github.com/HUGG/tcplotter/actions/workflows/publish-to-pypi.yml)
+[](https://github.com/astral-sh/ruff)
+[](https://pypi.org/project/tcplotter/)
[](https://pypi.org/project/tcplotter/)
[](https://anaconda.org/conda-forge/tcplotter)
[](https://tcplotter.readthedocs.io/en/latest/?badge=latest)
-[](https://opensource.org/licenses/MIT)
+[](https://www.gnu.org/licenses/gpl-3.0)
[](https://mybinder.org/v2/gh/HUGG/tcplotter/HEAD?urlpath=lab/tree/notebooks/tcplotter.ipynb)
Tcplotter is a Python package for creating and customizing thermochronometer age and closure temperature plots presented in the article [Short communication: Modelling competing effects of cooling rate, grain size and radiation damage in low temperature thermochronometers](https://doi.org/10.5194/gchron-2021-29) by D. Whipp, D. Kellett, I. Coutand, and R. Ketcham.
@@ -26,7 +29,9 @@ pip install tcplotter
You can also find installation instructions on the [Tcplotter documentation page](https://tcplotter.readthedocs.io/en/latest/installation.html#installing-the-latest-version-of-t-sub-c-sub-plotter-from-github).
-**Note**: In order for Tcplotter to work properly you will also need to install the thermochronometer age prediction programs available in the [Tccore package](https://github.com/HUGG/Tc_core/).
+Installing Tcplotter also installs [Tcages](https://github.com/HUGG/tcages), which provides the thermochronometer age prediction codes. Pre-built packages are available for Linux, macOS and Windows, so no compilers are needed.
+
+**Note**: Tcplotter versions up to 0.4.0 required installing separate age prediction programs from the Tccore package. This is no longer necessary from version 0.5.0 onwards.
## Usage
@@ -91,7 +96,11 @@ You're also welcome to cite the manuscript related to Tcplotter when
### How to cite related articles
-The age prediction software used for calculating apatite and zircon (U-Th)/He and apatite fission-track ages was written by Richard Ketcham at the University of Texas, USA. Results published using this software should also cite the articles below:
+The age prediction software used for calculating apatite and zircon (U-Th)/He and apatite fission-track ages (provided by [Tcages](https://github.com/HUGG/tcages)) was written by Richard Ketcham at the University of Texas, USA. Results published using this software should also cite the articles below:
+
+- Flowers, R. M., Ketcham, R. A., Shuster, D. L., and Farley, K. A.: Apatite (U-Th)/He thermochronometry using a radiation damage accumulation and annealing model, Geochimica et Cosmochimica Acta, 73, 2347–2365, doi: [10.1016/j.gca.2009.01.015](https://doi.org/10.1016/j.gca.2009.01.015), 2009.
+
+- Guenthner, W. R., Reiners, P. W., Ketcham, R. A., Nasdala, L., and Giester, G.: Helium diffusion in natural zircon: Radiation damage, anisotropy, and the interpretation of zircon (U-Th)/He thermochronology, American Journal of Science, 313, 145–198, doi: [10.2475/03.2013.01](https://doi.org/10.2475/03.2013.01), 2013.
- Ketcham, R. A., Donelick, R. A., & Carlson, W. D.: Variability of apatite fission-track annealing kinetics III: Extrapolation to geological time scales. American Mineralogist, 84, 1235-1255, doi: [10.2138/am-1999-0903](https://doi.org/10.2138/am-1999-0903), 1999.
@@ -99,4 +108,5 @@ The age prediction software used for calculating apatite and zircon (U-Th)/He an
## License
-The Tcplotter software is licensed under an MIT License: [Tcplotter software license](LICENSE)
+Tcplotter is distributed under the [GNU General Public License v3.0 or later](LICENSE).
+Versions up to 0.4.0 were released under the MIT License.
diff --git a/docs/conf.py b/docs/conf.py
index 95b17e9..566e618 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,12 +14,18 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))
+import tcplotter
+
# -- Project information -----------------------------------------------------
-project = 'tcplotter'
-copyright = '2022, David Whipp, University of Helsinki'
-author = 'David Whipp'
+project = "tcplotter"
+copyright = "2022-2026, David Whipp, University of Helsinki"
+author = "David Whipp"
+
+# Version info
+release = tcplotter.__version__
+version = release
# -- General configuration ---------------------------------------------------
@@ -35,7 +41,7 @@
]
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -47,12 +53,12 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-html_theme = 'sphinx_book_theme'
+html_theme = "sphinx_book_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-#html_static_path = ['_static']
+# html_static_path = ['_static']
# HTML theme options
html_theme_options = {
@@ -72,7 +78,7 @@
}
# HTML context
-#html_context = {
+# html_context = {
# # Enable the "Edit in GitHub link within the header of each page.
# "display_github": True,
# # Set the following variables to generate the resulting github URL for each page.
@@ -81,7 +87,7 @@
# "github_repo": "pyrosm",
# "github_version": "master/",
# "conf_py_path": "/docs/",
-#}
+# }
# The master toctree document.
master_doc = "index"
@@ -96,10 +102,10 @@
pygments_style = "sphinx"
# Allow errors
-execution_allow_errors = True
+nb_execution_allow_errors = True
# Do not execute cells
-jupyter_execute_notebooks = "off"
+nb_execution_mode = "off"
# Allow myst admonition style
myst_admonition_enable = True
diff --git a/docs/installation.ipynb b/docs/installation.ipynb
index 495871c..e3940c3 100644
--- a/docs/installation.ipynb
+++ b/docs/installation.ipynb
@@ -13,48 +13,37 @@
"pip install tcplotter\n",
"```\n",
"\n",
- "**Note**: In order for Tcplotter to work properly you will also need to install the thermochronometer age prediction programs available in the [Tccore package](https://github.com/HUGG/Tc_core/).\n",
+ "This also installs [Tcages](https://github.com/HUGG/tcages), which provides the thermochronometer age prediction codes used by Tcplotter. Pre-built packages are available for Linux, macOS and Windows, so no compilers are needed.\n",
"\n",
- "## Installing the latest version of Tcplotter from GitHub (not recommended)\n",
+ "**Note**: Tcplotter versions up to 0.4.0 required installing separate age prediction programs. This is no longer necessary from version 0.5.0 onwards.\n",
"\n",
- "Below you will find the steps to install the latest version of the Tcplotter package from GitHub. If you have difficulty with the installation, we recommend [using Binder](https://mybinder.org/v2/gh/HUGG/tcplotter/HEAD?urlpath=lab/tree/notebooks/tcplotter.ipynb) to create and save plots using Tcplotter.\n",
+ "## Installing the latest version of Tcplotter from GitHub\n",
"\n",
- "1. First, you will need the several items in order to compile the software used for thermochronometer age and closure temperature calculations.\n",
+ "You can install the latest development version of Tcplotter directly from GitHub using `pip`:\n",
"\n",
- " - [cmake](https://cmake.org/)\n",
- " - a compatible C compiler\n",
- " - a compatible C++ compiler\n",
- "\n",
- " You can find more information about which compilers can be used with cmake from the [cmake documentation page](https://cmake.org/documentation/).\n",
- "\n",
- "2. In addition, Tcplotter requires Python >= 3.10 with the following Python libraries:\n",
- "\n",
- " - `numpy`\n",
- " - `matplotlib-base`\n",
- " - `scipy`\n",
- "\n",
- "3. Once the required Python libraries have been installed, you can download the Tcplotter code from GitHub by visiting the [Tcplotter GitHub page](https://github.com/HUGG/tcplotter), clicking on the **Code** button on the upper right side of the page, and selecting **Download ZIP**. After the download completes, you can extract the files using your preferred software.\n",
- "\n",
- "4. At this point, you will need to compile the software for calculating the thermochronometer ages using cmake. You can find instructions about how to do this on the [Tccore package GitHub page](https://github.com/HUGG/Tc_core/).\n",
+ "```bash\n",
+ "pip install git+https://github.com/HUGG/tcplotter.git\n",
+ "```\n",
"\n",
- "5. You can now do a local install of Tcplotter using `pip` by navigating to the bast `tcplotter` directory in a terminal and running the following:\n",
+ "Tcplotter requires Python >= 3.10. All required Python libraries (`matplotlib`, `numpy`, `scipy` and `tcages`) are installed automatically.\n",
"\n",
- " ```bash\n",
- " pip install -e .\n",
- " ```\n",
+ "If you would like to modify the code, you can instead clone the repository and do an editable install:\n",
"\n",
- " This will install Tcplotter locally for your use.\n",
+ "```bash\n",
+ "git clone https://github.com/HUGG/tcplotter.git\n",
+ "cd tcplotter\n",
+ "pip install -e .\n",
+ "```\n",
"\n",
"### Testing the installation\n",
"\n",
- "At this point you should have a working Tcplotter installation. You can test it by running on of the Tcplotter command-line programs. For example, you could run the following in a terminal where Tcplotter is installed:\n",
+ "At this point you should have a working Tcplotter installation. You can test it by running one of the Tcplotter command-line programs. For example, you could run the following in a terminal where Tcplotter is installed:\n",
"\n",
"```bash\n",
"eu-vs-radius\n",
"```\n",
"\n",
- "This should produce a contour plot of cooling ages and closure temperatures for a range of effective uranium and grain radius values.\n",
- "\n"
+ "This should produce a contour plot of cooling ages and closure temperatures for a range of effective uranium and grain radius values."
]
},
{
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 65bb9d6..d666fcd 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,14 +1,8 @@
-numpydoc
-sphinx-book-theme
-nbsphinx
+sphinx-book-theme==1.2.0
ipython
-jupyter-book
myst-parser
myst-nb
-sphinx_copybutton
sphinx
-sphinx-thebe
-sphinx-togglebutton
matplotlib
numpy
scipy
diff --git a/environment.yml b/environment.yml
index 7c11640..af0a78a 100644
--- a/environment.yml
+++ b/environment.yml
@@ -2,10 +2,11 @@ name: tcplotter-binder
channels:
- conda-forge
dependencies:
+ - ipywidgets
- matplotlib >= 3.8
- numpy
- scipy
- python >= 3.10
- pip
- pip:
- - tcplotter
\ No newline at end of file
+ - tcplotter>=0.5
diff --git a/notebooks/tcplotter.ipynb b/notebooks/tcplotter.ipynb
index 7ce6fbf..c89a581 100644
--- a/notebooks/tcplotter.ipynb
+++ b/notebooks/tcplotter.ipynb
@@ -409,7 +409,7 @@
" use_widget=True,\n",
" cooling_rate=1.0,\n",
" plot_type=3,\n",
- " age_data_file=\"sample_data.csv\",\n",
+ " age_data_file=\"../data/sample_data.csv\",\n",
" calc_misfit=True,\n",
")"
]
diff --git a/postBuild b/postBuild
deleted file mode 100644
index cca166c..0000000
--- a/postBuild
+++ /dev/null
@@ -1,8 +0,0 @@
-# Compile codes for (U-Th)/He and FT age prediction
-git clone https://github.com/HUGG/Tc_core.git
-cd Tc_core/src/ketch_aft
-make && make install
-cd ..
-cd RDAAM_He
-make && make install
-cd ../../..
diff --git a/pyproject.toml b/pyproject.toml
index 0ac0285..d6285fa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "tcplotter"
-version = "0.4.0"
+version = "0.5.0.dev1"
authors = [
{name = "Dave Whipp", email = "david.whipp@helsinki.fi"},
]
@@ -29,8 +29,8 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
+ "Programming Language :: Python :: 3.15",
"Programming Language :: Python :: 3 :: Only",
- "Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
]
@@ -38,8 +38,13 @@ dependencies = [
"matplotlib",
"numpy",
"scipy",
+ "tcages>=0.3",
]
+[project.optional-dependencies]
+lint = ["ruff"]
+tests = ["pytest"]
+
[project.urls]
homepage = "https://tcplotter.readthedocs.io/"
repository = "https://github.com/HUGG/tcplotter"
@@ -50,3 +55,17 @@ time-vs-temp = "tcplotter.time_vs_temp:main"
eu-vs-radius = "tcplotter.eu_vs_radius:main"
rate-vs-radius-eu = "tcplotter.rate_vs_radius_eu:main"
rate-vs-age-tc = "tcplotter.rate_vs_age_tc:main"
+
+[tool.pytest.ini_options]
+testpaths = ["tests"]
+
+[tool.ruff]
+line-length = 88
+target-version = "py310"
+
+[tool.ruff.lint]
+# Pyflakes (F) and a subset of pycodestyle (E) errors, as used for Tc1D
+select = ["E4", "E7", "E9", "F"]
+
+[tool.ruff.format]
+quote-style = "double"
diff --git a/src/tcplotter/__init__.py b/src/tcplotter/__init__.py
index 390bc90..1310f4e 100644
--- a/src/tcplotter/__init__.py
+++ b/src/tcplotter/__init__.py
@@ -2,3 +2,13 @@
from .tcplotter import eu_vs_radius
from .tcplotter import rate_vs_radius_eu
from .tcplotter import rate_vs_age_tc
+
+__all__ = ["time_vs_temp", "eu_vs_radius", "rate_vs_radius_eu", "rate_vs_age_tc"]
+
+from importlib.metadata import PackageNotFoundError, version
+
+try:
+ __version__ = version("tcplotter")
+except PackageNotFoundError:
+ # Package is not installed (e.g. running from a source checkout)
+ __version__ = "dev"
diff --git a/src/tcplotter/rate_vs_age_tc.py b/src/tcplotter/rate_vs_age_tc.py
index 6eb04b5..8a21a32 100755
--- a/src/tcplotter/rate_vs_age_tc.py
+++ b/src/tcplotter/rate_vs_age_tc.py
@@ -223,7 +223,7 @@ def main():
parser.add_argument(
"--no-clean-up-files",
dest="no_clean_up_files",
- help="Do not delete temporary files",
+ help="Deprecated and has no effect (no temporary files are created)",
action="store_true",
default=False,
)
diff --git a/src/tcplotter/tcplotter.py b/src/tcplotter/tcplotter.py
index 15e5406..36ab911 100644
--- a/src/tcplotter/tcplotter.py
+++ b/src/tcplotter/tcplotter.py
@@ -4,8 +4,8 @@
import numpy as np
from pathlib import Path
from scipy.interpolate import interp1d, RegularGridInterpolator
-import shutil
-import subprocess
+import tcages
+import warnings
# Define function for calculating effective uranium concentration
@@ -14,20 +14,6 @@ def calc_eu(uranium, thorium):
return uranium + 0.238 * thorium
-def check_execs() -> None:
- """Checks whether all required executables exist."""
-
- # Check that executables are in $PATH
- for executable in ("RDAAM_He", "ketch_aft"):
- exec_path = shutil.which(executable)
- if exec_path is None:
- raise FileNotFoundError(
- f"{executable} executable not found. See instructions at https://github.com/HUGG/Tc_core to fix this."
- )
-
- return None
-
-
def create_output_directory(wd, dir=""):
"""Creates a new directory in working directory."""
newdir = wd / dir
@@ -66,7 +52,7 @@ def read_age_data(file, ap_x, ap_y, zr_x, zr_y):
f"Warning: eU concentration for {data[i][0].lower()} age on line {i + 1} not within modelled range."
)
print(
- f" This age will be excluded from plotting and the misfit calculation."
+ " This age will be excluded from plotting and the misfit calculation."
)
# Check if value is not within radius range
elif not (min(ap_y) <= float(data[i][4]) <= max(ap_y)):
@@ -74,7 +60,7 @@ def read_age_data(file, ap_x, ap_y, zr_x, zr_y):
f"Warning: Grain radius for {data[i][0].lower()} age on line {i + 1} not within modelled range."
)
print(
- f" This age will be excluded from plotting and the misfit calculation."
+ " This age will be excluded from plotting and the misfit calculation."
)
else:
ahe_age.append(float(data[i][1]))
@@ -90,7 +76,7 @@ def read_age_data(file, ap_x, ap_y, zr_x, zr_y):
f"Warning: eU concentration for {data[i][0].lower()} age {i + 1} not within modelled range."
)
print(
- f" This age will be excluded from plotting and the misfit calculation."
+ " This age will be excluded from plotting and the misfit calculation."
)
# Check if value is not within radius range
elif not (min(zr_y) <= float(data[i][4]) <= max(zr_y)):
@@ -98,7 +84,7 @@ def read_age_data(file, ap_x, ap_y, zr_x, zr_y):
f"Warning: Grain radius for {data[i][0].lower()} age {i + 1} not within modelled range."
)
print(
- f" This age will be excluded from plotting and the misfit calculation."
+ " This age will be excluded from plotting and the misfit calculation."
)
else:
zhe_age.append(float(data[i][1]))
@@ -118,7 +104,7 @@ def read_age_data(file, ap_x, ap_y, zr_x, zr_y):
print(
f"Warning: {data[i][0].lower()} age on line {i + 1} missing radius value."
)
- print(f" Age will not be plotted.")
+ print(" Age will not be plotted.")
# Create new lists with data file values
n_ahe = len(ahe_age)
n_zhe = len(zhe_age)
@@ -151,7 +137,6 @@ def calculate_misfit(age_data, age_list, param_x, param_y):
std_dev.append(age_data[1][i])
# Calculate misfit
misfit = chi_squared(measured_ages, predicted_ages, std_dev)
- n_ages = len(measured_ages)
return misfit[0]
@@ -454,9 +439,6 @@ def eu_vs_radius(
)
use_widget = False
- # Define location of RDAAM executable
- rdaam_path = shutil.which("RDAAM_He")
-
# Define working directory
wd = Path.cwd()
@@ -500,9 +482,6 @@ def eu_vs_radius(
else:
raise ValueError("Bad value for plot_type. Should be 1, 2, or 3.")
- # Define time-temperature history filename
- tt_filename = "simple_time_temp.txt"
-
# Set plot style
plt.style.use(plot_style)
@@ -563,11 +542,6 @@ def eu_vs_radius(
input_tt_path = wd / input_tt_file
time_hist, temp_hist = read_tt_history(input_tt_path)
- # Write cooling history points to file
- with open(tt_filename, "w") as f:
- for i in range(len(time_hist)):
- f.write(f"{time_hist[i]:.4f},{temp_hist[i]:.1f}\n")
-
# Echo total model run time and cooling rate
if verbose and cooling_hist_type == 1:
print(
@@ -612,52 +586,35 @@ def eu_vs_radius(
zr_y_list.append(zr_radius)
# Calculate (U-Th)/He ages
- command = (
- rdaam_path
- + " "
- + tt_filename
- + " "
- + str(ap_radius)
- + " "
- + str(ap_uranium)
- + " "
- + str(ap_thorium)
- + " "
- + str(zr_radius)
- + " "
- + str(zr_uranium)
- + " "
- + str(zr_thorium)
- )
- p = subprocess.Popen(
- command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ he_ages = tcages.he_ages(
+ time_hist,
+ temp_hist,
+ ap_rad=ap_radius,
+ ap_u=ap_uranium,
+ ap_th=ap_thorium,
+ zr_rad=zr_radius,
+ zr_u=zr_uranium,
+ zr_th=zr_thorium,
)
-
- # Parse output for ages
- stdout = p.stdout.readlines()
- corr_ahe_age = stdout[0].split()[7].decode("UTF-8")
- corr_zhe_age = stdout[1].split()[7].decode("UTF-8")
+ corr_ahe_age = he_ages.ahe_corr
+ corr_zhe_age = he_ages.zhe_corr
# Find closure temperatures from cooling ages and thermal history
tc_interp = interp1d(time_hist, temp_hist)
- ahe_tc = tc_interp(float(corr_ahe_age))
- zhe_tc = tc_interp(float(corr_zhe_age))
+ ahe_tc = tc_interp(corr_ahe_age)
+ zhe_tc = tc_interp(corr_zhe_age)
# Add closure temperatures, ages to lists
ahe_tc_list.append(ahe_tc)
- ahe_age_list.append(float(corr_ahe_age))
+ ahe_age_list.append(corr_ahe_age)
zhe_tc_list.append(zhe_tc)
- zhe_age_list.append(float(corr_zhe_age))
+ zhe_age_list.append(corr_zhe_age)
if verbose:
print(
- f"AHe: {float(corr_ahe_age):.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {float(corr_zhe_age):.2f} Ma (Tc: {zhe_tc:.1f}°C)"
+ f"AHe: {corr_ahe_age:.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {corr_zhe_age:.2f} Ma (Tc: {zhe_tc:.1f}°C)"
)
- # Clean up Tt file
- tt_file = Path(wd, tt_filename)
- tt_file.unlink()
-
# Calculate age misfits if age data file is used and option is selected
if calc_misfit:
if (num_ahe_age_data > 0) or (num_zhe_age_data > 0):
@@ -675,9 +632,9 @@ def eu_vs_radius(
)
else:
print(
- f"Warning: Misfit calculation requested, but no AHe or ZHe ages found in data file."
+ "Warning: Misfit calculation requested, but no AHe or ZHe ages found in data file."
)
- print(f" Misfit will not be calculated.")
+ print(" Misfit will not be calculated.")
# Apatite eU versus radius
if plot_type == 1:
@@ -690,7 +647,7 @@ def eu_vs_radius(
age_max = max(ahe_age_list)
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_age = ax[0].tricontour(
+ ax[0].tricontour(
ap_x_list,
ap_y_list,
ahe_age_list,
@@ -702,7 +659,7 @@ def eu_vs_radius(
linewidths=2.0,
)
# Create age contour fill
- ap_contourf_age = ax[0].tricontourf(
+ ax[0].tricontourf(
ap_x_list,
ap_y_list,
ahe_age_list,
@@ -753,7 +710,7 @@ def eu_vs_radius(
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc = ax[1].tricontour(
+ ax[1].tricontour(
ap_x_list,
ap_y_list,
ahe_tc_list,
@@ -803,7 +760,7 @@ def eu_vs_radius(
age_max = max(zhe_age_list)
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_age = ax[0].tricontour(
+ ax[0].tricontour(
zr_x_list,
zr_y_list,
zhe_age_list,
@@ -815,7 +772,7 @@ def eu_vs_radius(
linewidths=2.0,
)
# Create age contour fill
- zr_contourf_age = ax[0].tricontourf(
+ ax[0].tricontourf(
zr_x_list,
zr_y_list,
zhe_age_list,
@@ -866,7 +823,7 @@ def eu_vs_radius(
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc = ax[1].tricontour(
+ ax[1].tricontour(
zr_x_list,
zr_y_list,
zhe_tc_list,
@@ -916,7 +873,7 @@ def eu_vs_radius(
age_max = max(ahe_age_list)
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_age = ax[0][0].tricontour(
+ ax[0][0].tricontour(
ap_x_list,
ap_y_list,
ahe_age_list,
@@ -928,7 +885,7 @@ def eu_vs_radius(
linewidths=2.0,
)
# Create age contour fill
- ap_contourf_age = ax[0][0].tricontourf(
+ ax[0][0].tricontourf(
ap_x_list,
ap_y_list,
ahe_age_list,
@@ -979,7 +936,7 @@ def eu_vs_radius(
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc = ax[0][1].tricontour(
+ ax[0][1].tricontour(
ap_x_list,
ap_y_list,
ahe_tc_list,
@@ -1027,7 +984,7 @@ def eu_vs_radius(
age_max = max(zhe_age_list)
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_age = ax[1][0].tricontour(
+ ax[1][0].tricontour(
zr_x_list,
zr_y_list,
zhe_age_list,
@@ -1039,7 +996,7 @@ def eu_vs_radius(
linewidths=2.0,
)
# Create age contour fill
- zr_contourf_age = ax[1][0].tricontourf(
+ ax[1][0].tricontourf(
zr_x_list,
zr_y_list,
zhe_age_list,
@@ -1090,7 +1047,7 @@ def eu_vs_radius(
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc = ax[1][1].tricontour(
+ ax[1][1].tricontour(
zr_x_list,
zr_y_list,
zhe_tc_list,
@@ -1380,9 +1337,6 @@ def rate_vs_radius_eu(
)
use_widget = False
- # Define location of RDAAM executable
- rdaam_path = shutil.which("RDAAM_He")
-
# Define working directory
wd = Path.cwd()
@@ -1403,7 +1357,7 @@ def rate_vs_radius_eu(
# Calculate effective uranium
ap_eu = calc_eu(ap_u, ap_thorium)
- zr_eu = calc_eu(zr_u, zr_thorium)
+ calc_eu(zr_u, zr_thorium)
# Total number of models
total_models = len(ap_u) * len(rates) + len(ap_rad) * len(rates)
@@ -1418,9 +1372,6 @@ def rate_vs_radius_eu(
else:
raise ValueError("Bad value for parameter plot_type. Must be 1, 2, or 3.")
- # Define time-temperature history filename
- tt_filename = "simple_time_temp.txt"
-
# Set plot style
plt.style.use(plot_style)
@@ -1433,12 +1384,8 @@ def rate_vs_radius_eu(
# Set plot loop variables
ap_x1 = rates
ap_y1 = ap_rad
- zr_x1 = rates
- zr_y1 = zr_rad
ap_x2 = rates
ap_y2 = ap_eu
- zr_x2 = rates
- zr_y2 = zr_eu
# Create lists for storing closure temperatures, ages
ahe_tc_list1 = []
@@ -1492,11 +1439,10 @@ def rate_vs_radius_eu(
ap_y_list1.append(ap_radius)
zr_y_list1.append(zr_radius)
- # Write synthetic cooling history points to file
+ # Define synthetic cooling history
start_time = temp_max / rate
- with open(tt_filename, "w") as f:
- f.write("0.0,0.0\n")
- f.write("{0:.4f},{1:.1f}".format(start_time, temp_max))
+ time_hist = [0.0, start_time]
+ temp_hist = [0.0, temp_max]
# Screen output
if verbose:
@@ -1505,36 +1451,23 @@ def rate_vs_radius_eu(
)
# Calculate (U-Th)/He ages
- command = (
- rdaam_path
- + " "
- + tt_filename
- + " "
- + str(ap_radius)
- + " "
- + str(ap_uranium)
- + " "
- + str(ap_thorium)
- + " "
- + str(zr_radius)
- + " "
- + str(zr_uranium)
- + " "
- + str(zr_thorium)
- )
- p = subprocess.Popen(
- command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ he_ages = tcages.he_ages(
+ time_hist,
+ temp_hist,
+ ap_rad=ap_radius,
+ ap_u=ap_uranium,
+ ap_th=ap_thorium,
+ zr_rad=zr_radius,
+ zr_u=zr_uranium,
+ zr_th=zr_thorium,
)
-
- # Parse output for ages
- stdout = p.stdout.readlines()
- corr_ahe_age = stdout[0].split()[7].decode("UTF-8")
- corr_zhe_age = stdout[1].split()[7].decode("UTF-8")
+ corr_ahe_age = he_ages.ahe_corr
+ corr_zhe_age = he_ages.zhe_corr
# Find closure temperatures from cooling ages and thermal history
- tc_interp = interp1d([0.0, start_time], [0.0, temp_max])
- ahe_tc = tc_interp(float(corr_ahe_age))
- zhe_tc = tc_interp(float(corr_zhe_age))
+ tc_interp = interp1d(time_hist, temp_hist)
+ ahe_tc = tc_interp(corr_ahe_age)
+ zhe_tc = tc_interp(corr_zhe_age)
# Add closure temperatures to lists
ahe_tc_list1.append(ahe_tc)
@@ -1542,7 +1475,7 @@ def rate_vs_radius_eu(
if verbose:
print(
- f"AHe: {float(corr_ahe_age):.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {float(corr_zhe_age):.2f} Ma (Tc: {zhe_tc:.1f}°C)"
+ f"AHe: {corr_ahe_age:.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {corr_zhe_age:.2f} Ma (Tc: {zhe_tc:.1f}°C)"
)
# Loop over plotables - loop 2: rate versus eU
@@ -1569,11 +1502,10 @@ def rate_vs_radius_eu(
ap_y_list2.append(ap_uranium)
zr_y_list2.append(zr_uranium)
- # Write synthetic cooling history points to file
+ # Define synthetic cooling history
start_time = temp_max / rate
- with open(tt_filename, "w") as f:
- f.write("0.0,0.0\n")
- f.write("{0:.4f},{1:.1f}".format(start_time, temp_max))
+ time_hist = [0.0, start_time]
+ temp_hist = [0.0, temp_max]
# Screen output
if verbose:
@@ -1582,36 +1514,23 @@ def rate_vs_radius_eu(
)
# Calculate (U-Th)/He ages
- command = (
- rdaam_path
- + " "
- + tt_filename
- + " "
- + str(ap_radius)
- + " "
- + str(ap_uranium)
- + " "
- + str(ap_thorium)
- + " "
- + str(zr_radius)
- + " "
- + str(zr_uranium)
- + " "
- + str(zr_thorium)
+ he_ages = tcages.he_ages(
+ time_hist,
+ temp_hist,
+ ap_rad=ap_radius,
+ ap_u=ap_uranium,
+ ap_th=ap_thorium,
+ zr_rad=zr_radius,
+ zr_u=zr_uranium,
+ zr_th=zr_thorium,
)
- p = subprocess.Popen(
- command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
- )
-
- # Parse output for ages
- stdout = p.stdout.readlines()
- corr_ahe_age = stdout[0].split()[7].decode("UTF-8")
- corr_zhe_age = stdout[1].split()[7].decode("UTF-8")
+ corr_ahe_age = he_ages.ahe_corr
+ corr_zhe_age = he_ages.zhe_corr
# Find closure temperatures from cooling ages and thermal history
- tc_interp = interp1d([0.0, start_time], [0.0, temp_max])
- ahe_tc = tc_interp(float(corr_ahe_age))
- zhe_tc = tc_interp(float(corr_zhe_age))
+ tc_interp = interp1d(time_hist, temp_hist)
+ ahe_tc = tc_interp(corr_ahe_age)
+ zhe_tc = tc_interp(corr_zhe_age)
# Add closure temperatures to lists
ahe_tc_list2.append(ahe_tc)
@@ -1619,19 +1538,15 @@ def rate_vs_radius_eu(
if verbose:
print(
- f"AHe: {float(corr_ahe_age):.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {float(corr_zhe_age):.2f} Ma (Tc: {zhe_tc:.1f}°C)"
+ f"AHe: {corr_ahe_age:.2f} Ma (Tc: {ahe_tc:.1f}°C); ZHe: {corr_zhe_age:.2f} Ma (Tc: {zhe_tc:.1f}°C)"
)
- # Clean up temporary tt file
- tt_file = Path(wd, tt_filename)
- tt_file.unlink()
-
# Plot only values for apatite (U-Th)/He
if plot_type == 1:
# --- Apatite cooling rate versus radius ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc1 = ax[0].tricontour(
+ ax[0].tricontour(
ap_x_list1,
ap_y_list1,
ahe_tc_list1,
@@ -1641,7 +1556,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- ap_contourf_tc1 = ax[0].tricontourf(
+ ax[0].tricontourf(
ap_x_list1,
ap_y_list1,
ahe_tc_list1,
@@ -1666,7 +1581,7 @@ def rate_vs_radius_eu(
# --- Apatite cooling rate versus eU plot ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc2 = ax[1].tricontour(
+ ax[1].tricontour(
ap_x_list2,
ap_y_list2,
ahe_tc_list2,
@@ -1676,7 +1591,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- ap_contourf_tc2 = ax[1].tricontourf(
+ ax[1].tricontourf(
ap_x_list2,
ap_y_list2,
ahe_tc_list2,
@@ -1703,7 +1618,7 @@ def rate_vs_radius_eu(
# --- Zircon cooling rate versus radius ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc1 = ax[0].tricontour(
+ ax[0].tricontour(
zr_x_list1,
zr_y_list1,
zhe_tc_list1,
@@ -1713,7 +1628,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- zr_contourf_tc1 = ax[0].tricontourf(
+ ax[0].tricontourf(
zr_x_list1,
zr_y_list1,
zhe_tc_list1,
@@ -1738,7 +1653,7 @@ def rate_vs_radius_eu(
# --- Zircon cooling rate versus eU plot ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc2 = ax[1].tricontour(
+ ax[1].tricontour(
zr_x_list2,
zr_y_list2,
zhe_tc_list2,
@@ -1748,7 +1663,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- zr_contourf_tc2 = ax[1].tricontourf(
+ ax[1].tricontourf(
zr_x_list2,
zr_y_list2,
zhe_tc_list2,
@@ -1775,7 +1690,7 @@ def rate_vs_radius_eu(
# --- Apatite cooling rate versus radius ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc1 = ax[0][0].tricontour(
+ ax[0][0].tricontour(
ap_x_list1,
ap_y_list1,
ahe_tc_list1,
@@ -1785,7 +1700,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- ap_contourf_tc1 = ax[0][0].tricontourf(
+ ax[0][0].tricontourf(
ap_x_list1,
ap_y_list1,
ahe_tc_list1,
@@ -1810,7 +1725,7 @@ def rate_vs_radius_eu(
# --- Apatite cooling rate versus eU plot ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- ap_contour_tc2 = ax[0][1].tricontour(
+ ax[0][1].tricontour(
ap_x_list2,
ap_y_list2,
ahe_tc_list2,
@@ -1820,7 +1735,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- ap_contourf_tc2 = ax[0][1].tricontourf(
+ ax[0][1].tricontourf(
ap_x_list2,
ap_y_list2,
ahe_tc_list2,
@@ -1845,7 +1760,7 @@ def rate_vs_radius_eu(
# --- Zircon cooling rate versus radius plot ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc1 = ax[1][0].tricontour(
+ ax[1][0].tricontour(
zr_x_list1,
zr_y_list1,
zhe_tc_list1,
@@ -1855,7 +1770,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- zr_contourf_tc1 = ax[1][0].tricontourf(
+ ax[1][0].tricontourf(
zr_x_list1,
zr_y_list1,
zhe_tc_list1,
@@ -1880,7 +1795,7 @@ def rate_vs_radius_eu(
# --- Zircon cooling rate versus eU plot ---
# Create colored contour lines to fill gaps between filled contours in pdf files
if save_plot and plot_file_format == "pdf":
- zr_contour_tc2 = ax[1][1].tricontour(
+ ax[1][1].tricontour(
zr_x_list2,
zr_y_list2,
zhe_tc_list2,
@@ -1890,7 +1805,7 @@ def rate_vs_radius_eu(
linewidths=2.0,
)
# Create closure temperature contour fill
- zr_contourf_tc2 = ax[1][1].tricontourf(
+ ax[1][1].tricontourf(
zr_x_list2,
zr_y_list2,
zhe_tc_list2,
@@ -2100,7 +2015,7 @@ def rate_vs_age_tc(
display_plot : bool, default=True
Flag for whether to display the plot.
clean_up_files : bool, default=True
- Flag for whether to delete temporary output files after the code has run.
+ Deprecated and has no effect. Temporary files are no longer created.
verbose : bool, default=False
Enable/disable verbose output.
use_widget : bool, default=False
@@ -2131,11 +2046,13 @@ def rate_vs_age_tc(
)
use_widget = False
- # Define location of RDAAM executable
- rdaam_path = shutil.which("RDAAM_He")
-
- # Define location of ketch_aft executable
- ketch_path = shutil.which("ketch_aft")
+ # Warn about use of deprecated clean_up_files parameter
+ if not clean_up_files:
+ warnings.warn(
+ "clean_up_files is deprecated and has no effect, as temporary files are no longer created. It will be removed in a future version.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
# Define working directory
wd = Path.cwd()
@@ -2168,9 +2085,6 @@ def rate_vs_age_tc(
f"High eU (ap={ap_u_list[2]:.1f}, zr={zr_u_list[2]:.1f} ppm)",
]
- # Define time-temperature history filename
- tt_filename = "simple_time_temp.txt"
-
# Calculate total number of models that will be run
total_models = len(ap_u_list) * len(rates)
@@ -2231,66 +2145,45 @@ def rate_vs_age_tc(
# Define thermal history
start_time = temp_max / rate
- with open(tt_filename, "w") as f:
- f.write("0.0,0.0\n")
- f.write("{0:.4f},{1:.1f}".format(start_time, temp_max))
+ time_hist = [0.0, start_time]
+ temp_hist = [0.0, temp_max]
# Calculate He ages
- command = (
- rdaam_path
- + " "
- + tt_filename
- + " "
- + str(ap_rad)
- + " "
- + str(ap_uranium)
- + " "
- + str(ap_thorium)
- + " "
- + str(zr_rad)
- + " "
- + str(zr_uranium)
- + " "
- + str(zr_thorium)
- )
- p = subprocess.Popen(
- command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ he_ages = tcages.he_ages(
+ time_hist,
+ temp_hist,
+ ap_rad=ap_rad,
+ ap_u=ap_uranium,
+ ap_th=ap_thorium,
+ zr_rad=zr_rad,
+ zr_u=zr_uranium,
+ zr_th=zr_thorium,
)
-
- # Parse output for ages
- stdout = p.stdout.readlines()
- corr_ahe_age = stdout[0].split()[7].decode("UTF-8")
- corr_zhe_age = stdout[1].split()[7].decode("UTF-8")
+ corr_ahe_age = he_ages.ahe_corr
+ corr_zhe_age = he_ages.zhe_corr
# Calculate AFT age
- command = ketch_path + " " + tt_filename
- p = subprocess.Popen(
- command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
- )
-
- # Parse output for AFT age
- stdout = p.stdout.readlines()
- aft_age = stdout[0].split()[4][:-1].decode("UTF-8")
+ aft_age = tcages.aft_age(time_hist, temp_hist).age
# Use predicted ages to get closure temperature
- tc_interp = interp1d([0.0, start_time], [0.0, temp_max])
- ahe_tc = tc_interp(float(corr_ahe_age))
- aft_tc = tc_interp(float(aft_age))
- zhe_tc = tc_interp(float(corr_zhe_age))
+ tc_interp = interp1d(time_hist, temp_hist)
+ ahe_tc = tc_interp(corr_ahe_age)
+ aft_tc = tc_interp(aft_age)
+ zhe_tc = tc_interp(corr_zhe_age)
# Add current iteration values to plotable lists
rate_list.append(rate)
ahe_tc_list.append(ahe_tc)
aft_tc_list.append(aft_tc)
zhe_tc_list.append(zhe_tc)
- ahe_age_list.append(float(corr_ahe_age))
- aft_age_list.append(float(aft_age))
- zhe_age_list.append(float(corr_zhe_age))
+ ahe_age_list.append(corr_ahe_age)
+ aft_age_list.append(aft_age)
+ zhe_age_list.append(corr_zhe_age)
# Echo ages for this iteration
if verbose:
print(
- f"AHe: {float(corr_ahe_age):.2f} Ma (Tc: {ahe_tc:.1f}°C); AFT: {float(aft_age):.2f} Ma (Tc: {aft_tc:.1f}°C); ZHe: {float(corr_zhe_age):.2f} Ma (Tc: {zhe_tc:.1f}°C) -- total time: {start_time:.1f} Myr"
+ f"AHe: {corr_ahe_age:.2f} Ma (Tc: {ahe_tc:.1f}°C); AFT: {aft_age:.2f} Ma (Tc: {aft_tc:.1f}°C); ZHe: {corr_zhe_age:.2f} Ma (Tc: {zhe_tc:.1f}°C) -- total time: {start_time:.1f} Myr"
)
# Assign uncertainties if plotting ages
@@ -2447,14 +2340,6 @@ def rate_vs_age_tc(
else:
ax[i].legend()
- # Delete temporary tt file
- if clean_up_files:
- tt_file = Path(wd, tt_filename)
- tt_file.unlink()
- ft_path = Path(wd, "ft_length.csv")
- if ft_path.exists():
- ft_path.unlink()
-
# Use tight layout
plt.tight_layout()
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..fd209f7
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,15 @@
+import matplotlib
+
+# Use a non-interactive backend so tests run without a display
+matplotlib.use("Agg")
+
+import matplotlib.pyplot as plt # noqa: E402
+import pytest # noqa: E402
+
+
+@pytest.fixture(autouse=True)
+def run_in_tmp_path(tmp_path, monkeypatch):
+ """Run each test in an empty temporary directory and close figures afterwards."""
+ monkeypatch.chdir(tmp_path)
+ yield tmp_path
+ plt.close("all")
diff --git a/tests/test_tcplotter.py b/tests/test_tcplotter.py
new file mode 100644
index 0000000..a695ca0
--- /dev/null
+++ b/tests/test_tcplotter.py
@@ -0,0 +1,123 @@
+import re
+from pathlib import Path
+
+import pytest
+
+import tcplotter
+from tcplotter.tcplotter import calc_eu
+
+DATA_DIR = Path(__file__).resolve().parents[1] / "data"
+
+# Ages from rate_vs_age_tc(num_points=5, plot_type=3, verbose=True), as calculated
+# by the RDAAM_He and ketch_aft executables used by tcplotter 0.4.0 (2 decimals).
+# Rows: low, intermediate and high eU; each row is (AHe, AFT, ZHe) for 5 cooling rates.
+REFERENCE_AGES = [
+ (317.15, 716.28, 1313.11),
+ (67.92, 149.78, 209.10),
+ (15.59, 30.87, 33.97),
+ (3.45, 6.27, 5.50),
+ (0.74, 1.26, 0.92),
+ (595.03, 716.28, 1468.25),
+ (91.93, 149.78, 279.64),
+ (15.97, 30.87, 47.12),
+ (3.45, 6.27, 7.80),
+ (0.74, 1.26, 1.27),
+ (763.16, 716.28, 0.00),
+ (128.91, 149.78, 140.03),
+ (20.69, 30.87, 58.31),
+ (3.55, 6.27, 10.37),
+ (0.74, 1.26, 1.74),
+]
+
+
+def test_calc_eu():
+ assert calc_eu(10.0, 40.0) == pytest.approx(19.52)
+
+
+def test_rate_vs_age_tc_matches_reference(capsys):
+ """Predicted ages match those from the original age prediction executables."""
+ tcplotter.rate_vs_age_tc(
+ num_points=5, plot_type=3, display_plot=False, verbose=True
+ )
+ out = capsys.readouterr().out
+ ages = re.findall(r"AHe: ([\d.]+) Ma.*AFT: ([\d.]+) Ma.*ZHe: ([\d.]+) Ma", out)
+ assert len(ages) == len(REFERENCE_AGES)
+ for predicted, expected in zip(ages, REFERENCE_AGES):
+ assert [float(a) for a in predicted] == pytest.approx(expected, abs=0.011)
+
+
+def test_time_vs_temp():
+ tcplotter.time_vs_temp(display_plot=False)
+
+
+@pytest.mark.parametrize("plot_type", [1, 2, 3])
+def test_eu_vs_radius_plot_types(plot_type):
+ tcplotter.eu_vs_radius(num_points=3, plot_type=plot_type, display_plot=False)
+
+
+def test_eu_vs_radius_custom_history():
+ tcplotter.eu_vs_radius(
+ num_points=3,
+ cooling_hist_type=2,
+ time_hist=[0.0, 10.0, 30.0],
+ temp_hist=[0.0, 80.0, 200.0],
+ display_plot=False,
+ tt_plot=True,
+ )
+
+
+def test_eu_vs_radius_history_from_file(tmp_path):
+ tt_file = tmp_path / "tt.csv"
+ tt_file.write_text(
+ "Time (Ma),Temperature (C)\n0.0,10.0\n5.0,60.0\n20.0,90.0\n40.0,250.0\n"
+ )
+ tcplotter.eu_vs_radius(
+ num_points=3, cooling_hist_type=3, input_tt_file="tt.csv", display_plot=False
+ )
+
+
+def test_eu_vs_radius_misfit(capsys):
+ tcplotter.eu_vs_radius(
+ num_points=3,
+ age_data_file=str(DATA_DIR / "sample_data.csv"),
+ calc_misfit=True,
+ display_plot=False,
+ )
+ assert "Total misfit" in capsys.readouterr().out
+
+
+@pytest.mark.parametrize("plot_type", [1, 2, 3])
+def test_rate_vs_radius_eu(plot_type):
+ tcplotter.rate_vs_radius_eu(num_points=3, plot_type=plot_type, display_plot=False)
+
+
+@pytest.mark.parametrize("plot_type", [1, 2, 3])
+def test_rate_vs_age_tc_plot_types(plot_type):
+ tcplotter.rate_vs_age_tc(num_points=3, plot_type=plot_type, display_plot=False)
+
+
+def test_no_temporary_files_left(tmp_path):
+ tcplotter.eu_vs_radius(num_points=3, display_plot=False)
+ tcplotter.rate_vs_radius_eu(num_points=3, display_plot=False)
+ tcplotter.rate_vs_age_tc(num_points=3, display_plot=False)
+ assert list(tmp_path.iterdir()) == []
+
+
+def test_save_plot(tmp_path):
+ tcplotter.rate_vs_age_tc(
+ num_points=3,
+ display_plot=False,
+ save_plot=True,
+ plot_file_format="png",
+ plot_dpi=50,
+ )
+ assert len(list((tmp_path / "png").glob("*.png"))) == 1
+
+
+def test_clean_up_files_is_deprecated():
+ with pytest.warns(DeprecationWarning, match="clean_up_files"):
+ tcplotter.rate_vs_age_tc(num_points=3, display_plot=False, clean_up_files=False)
+
+
+def test_version():
+ assert tcplotter.__version__ not in ("", "dev")