diff --git a/.ci-helpers/get_current_version.py b/.ci-helpers/get_current_version.py index 35aad413593..f628fd4ee2e 100644 --- a/.ci-helpers/get_current_version.py +++ b/.ci-helpers/get_current_version.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys + from setuptools_scm import version_from_scm version = version_from_scm(".").tag.public diff --git a/.ci-helpers/get_min_docstr_cov.py b/.ci-helpers/get_min_docstr_cov.py index bb706250d9c..ffaf19c4a23 100644 --- a/.ci-helpers/get_min_docstr_cov.py +++ b/.ci-helpers/get_min_docstr_cov.py @@ -2,6 +2,7 @@ import os import sys + from parse import * input = sys.stdin.readline() diff --git a/.ci-helpers/get_next_version.py b/.ci-helpers/get_next_version.py index 0be3077414e..af9264564d0 100644 --- a/.ci-helpers/get_next_version.py +++ b/.ci-helpers/get_next_version.py @@ -2,6 +2,7 @@ import sys from datetime import date + from setuptools_scm import version_from_scm from setuptools_scm.version import guess_next_date_ver diff --git a/.ci-helpers/update_credits.py b/.ci-helpers/update_credits.py index 3a59a7dc640..035cc027e26 100644 --- a/.ci-helpers/update_credits.py +++ b/.ci-helpers/update_credits.py @@ -43,7 +43,7 @@ def generate_zenodo(): ) not_found_msg = """ - Couldn"t retrieve the TARDIS software citation from Zenodo. Get it + Couldn"t retrieve the TARDIS software citation from Zenodo. Get it directly from `this link `_ . """ diff --git a/.coveragerc b/.coveragerc index 5a8c5e23e4e..3611c5a793d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -28,7 +28,7 @@ omit = tardis/gui/* tardis/stats/* - + ignore_errors = True [html] diff --git a/.github/actions/setup_env/action.yml b/.github/actions/setup_env/action.yml index 8c64f24dff4..596585448f6 100644 --- a/.github/actions/setup_env/action.yml +++ b/.github/actions/setup_env/action.yml @@ -14,14 +14,14 @@ runs: run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-${{ inputs.os-label }}.lock if: matrix.pip == true shell: bash - + - name: Generate Cache Key - run: | + run: | file_hash=$(cat conda-${{ inputs.os-label }}.lock | shasum -a 256 | cut -d' ' -f1) echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}" id: cache-environment-key shell: bash - + - uses: mamba-org/setup-micromamba@v1 with: environment-file: conda-${{ inputs.os-label }}.lock diff --git a/.github/workflows/archive/update-refdata.yml b/.github/workflows/archive/update-refdata.yml index 6b9f1485c94..38f04df38dd 100644 --- a/.github/workflows/archive/update-refdata.yml +++ b/.github/workflows/archive/update-refdata.yml @@ -34,7 +34,7 @@ jobs: - name: Setup environment uses: ./.github/actions/setup_env - with: + with: os-label: linux-64 - name: Install package diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 9ed9b5581e4..2ff3be6813c 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -16,7 +16,7 @@ on: - labeled # benchmarks label required workflow_dispatch: -env: +env: DEPLOY_BRANCH: main concurrency: @@ -76,8 +76,8 @@ jobs: if: github.event_name != 'pull_request_target' run: | git log -n 4 --pretty=format:"%H" >> tag_commits.txt - asv run -a repeat=1 -a rounds=1 HASHFILE:tag_commits.txt | tee asv-output.log - if grep -q failed asv-output.log; then + asv run -a repeat=1 -a rounds=1 HASHFILE:tag_commits.txt | tee asv-output.log + if grep -q failed asv-output.log; then echo "Some benchmarks have failed!" exit 1 fi @@ -107,8 +107,8 @@ jobs: run: | echo $(git rev-parse HEAD) > commit_hashes.txt echo $(git rev-parse master) >> commit_hashes.txt - asv run -a repeat=2 -a rounds=1 HASHFILE:commit_hashes.txt | tee asv-output-PR.log - if grep -q failed asv-output-PR.log; then + asv run -a repeat=2 -a rounds=1 HASHFILE:commit_hashes.txt | tee asv-output-PR.log + if grep -q failed asv-output-PR.log; then echo "Some benchmarks have failed!" exit 1 fi @@ -195,7 +195,7 @@ jobs: external_repository: tardis-sn/tardis-benchmarks user_name: "TARDIS Bot" user_email: "tardis.sn.bot@gmail.com" - + - name: Find Comment if: always() && github.event_name == 'pull_request_target' uses: peter-evans/find-comment@v1 @@ -214,10 +214,10 @@ jobs: edit-mode: replace body: | *\*beep\* \*bop\** - Hi human, - I ran benchmarks as you asked comparing master (${{ github.event.pull_request.base.sha }}) and the latest commit (${{ github.event.pull_request.head.sha }}). + Hi human, + I ran benchmarks as you asked comparing master (${{ github.event.pull_request.base.sha }}) and the latest commit (${{ github.event.pull_request.head.sha }}). Here are the logs produced by ASV. - Results can also be downloaded as artifacts [**here**](${{ env.URL }}). + Results can also be downloaded as artifacts [**here**](${{ env.URL }}). Significantly changed benchmarks:
@@ -234,7 +234,7 @@ jobs: ```diff ${{ steps.asv_pr_vs_master.outputs.content }} ``` - +
If you want to see the graph of the results, you can check it [**here**](${{ env.URL_PAGES }}) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index bb17c9581f0..8055306aee2 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -90,10 +90,10 @@ jobs: - name: Setup LFS uses: ./.github/actions/setup_lfs - + - name: Setup environment uses: ./.github/actions/setup_env - with: + with: os-label: linux-64 - name: Copy atom_data diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 44bbba992eb..5696c54c77e 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -33,20 +33,20 @@ jobs: - name: Run Black run: black --check tardis - ruff: + ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Download Lock File run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-linux-64.lock - + - name: Generate Cache Key - run: | + run: | file_hash=$(cat conda-linux-64.lock | shasum -a 256 | cut -d' ' -f1) echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}" id: cache-environment-key - + - uses: mamba-org/setup-micromamba@v1 with: environment-file: conda-linux-64.lock @@ -55,15 +55,15 @@ jobs: environment-name: tardis cache-environment: true cache-downloads: true - + - name: Show statistics run: ruff check --statistics --show-fixes . | tee ruff_stats.txt id: ruff_stats - + - name: Show entire output run: ruff check . --output-format=full | tee ruff_full.txt id: ruff_complete - + - name: Find Comment if: always() && github.event_name == 'pull_request_target' uses: peter-evans/find-comment@v1 @@ -71,7 +71,7 @@ jobs: with: issue-number: ${{ github.event.number }} body-includes: I ran ruff on the latest commit - + - name: Post comment if: github.event_name == 'pull_request_target' uses: peter-evans/create-or-update-comment@v2 @@ -82,10 +82,10 @@ jobs: edit-mode: replace body: | *\*beep\* \*bop\** - Hi human, - I ran ruff on the latest commit (${{ github.event.pull_request.head.sha }}). + Hi human, + I ran ruff on the latest commit (${{ github.event.pull_request.head.sha }}). Here are the outputs produced. - Results can also be downloaded as artifacts [**here**](${{ env.URL }}). + Results can also be downloaded as artifacts [**here**](${{ env.URL }}). Summarised output:
@@ -101,11 +101,11 @@ jobs: ```diff ${{ steps.ruff_complete.outputs.content }} ``` - +
env: URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true - + - name: Save results artifact uses: actions/upload-artifact@v4 if: always() @@ -114,5 +114,3 @@ jobs: path: | ruff_full.txt ruff_stats.txt - - diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 173656f951a..30281cd9e19 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -121,7 +121,7 @@ jobs: These are the changes required after the latest TARDIS release. - > :warning: **Warning:** + > :warning: **Warning:** > > The `post_release` workflow waits for a webhook and then updates the citation files. If the file is not modified by this pull request, please check the latest release on [Zenodo's website](https://zenodo.org/record/592480), close this pull request, and [manually run the workflow](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow). > diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 5b24dbfb45b..377e21424d4 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -30,14 +30,14 @@ jobs: - name: Download Lock File run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-linux-64.lock shell: bash - + - name: Generate Cache Key - run: | + run: | file_hash=$(cat conda-linux-64.lock | shasum -a 256 | cut -d' ' -f1) echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}" id: cache-environment-key shell: bash - + - uses: mamba-org/setup-micromamba@v1 with: environment-file: conda-linux-64.lock @@ -95,7 +95,7 @@ jobs:
- > :warning: **WARNING:** + > :warning: **WARNING:** > > This pull request should be auto-merged. **Do not merge manually if any check fails**. > @@ -140,7 +140,7 @@ jobs: compare_refdata: uses: tardis-sn/tardis-refdata/.github/workflows/compare-refdata.yml@master - + pip_tests: uses: ./.github/workflows/tests.yml with: diff --git a/.github/workflows/stardis-tests.yml b/.github/workflows/stardis-tests.yml index fad5fbaa7d9..b8d13f3cbba 100644 --- a/.github/workflows/stardis-tests.yml +++ b/.github/workflows/stardis-tests.yml @@ -14,7 +14,7 @@ on: defaults: run: shell: bash -l {0} - + env: CACHE_NUMBER: 0 # increase to reset cache manually @@ -34,7 +34,7 @@ jobs: name: ${{ matrix.label }} runs-on: ${{ matrix.os }} - steps: + steps: - uses: actions/checkout@v4 with: repository: tardis-sn/stardis @@ -46,29 +46,29 @@ jobs: miniforge-version: latest activate-environment: stardis use-mamba: true - + - name: Cache lockfile uses: actions/cache@v4 with: path: ${{ matrix.prefix }} key: conda-${{ matrix.label }}-${{ hashFiles(format('conda-{0}.lock', matrix.label)) }}-${{ env.CACHE_NUMBER }} id: cache-conda - + - name: Update Conda Environment id: update-env run: | mamba update -n stardis --file conda-${{ matrix.label }}.lock if: steps.cache-conda.outputs.cache-hit != 'true' - + - name: Install tardis id: install-tardis run: | pip install git+https://github.com/tardis-sn/tardis.git@${{ github.sha }} - + - name: Install stardis id: install-stardis run: | pip install -e .[test] - - name: Run stardis tests - run: pytest \ No newline at end of file + - name: Run stardis tests + run: pytest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6ad45cb2015..ec5b4afa4fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,17 +26,17 @@ on: env: CACHE_NUMBER: 0 # increase to reset cache manually - PYTEST_FLAGS: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data --cov=tardis --cov-report=xml --cov-report=html --cov-append + PYTEST_FLAGS: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data --cov=tardis --cov-report=xml --cov-report=html --cov-append CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} defaults: run: shell: bash -l {0} - + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true - + jobs: tests: @@ -65,29 +65,29 @@ jobs: - name: Setup LFS uses: ./.github/actions/setup_lfs - + - name: Setup environment uses: ./.github/actions/setup_env with: os-label: ${{ matrix.label }} - + - name: Install package editable if: ${{ !inputs.pip_git }} run: | pip install -e . --user - + - name: Install package git if: ${{ inputs.pip_git }} run: | pip install git+https://github.com/tardis-sn/tardis.git@master - name: Run tests - run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking" - + run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking" + - name: Refdata Generation tests - run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking" + run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking" if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master' - + - run: mv .coverage .coverage.${{ strategy.job-index }} - uses: actions/upload-artifact@v4 @@ -96,7 +96,7 @@ jobs: path: | .coverage* !.coveragerc - + combine_coverage_reports: needs: [tests] if: github.repository_owner == 'tardis-sn' @@ -110,16 +110,16 @@ jobs: # will download all artifacts(in this case all are coverage reports) - uses: actions/download-artifact@v4 - with: + with: path: . merge-multiple: true - + - name: Combine coverage reports run: | coverage combine coverage xml coverage html - + - name: Print report run: coverage report diff --git a/.zenodo.json b/.zenodo.json index 3090e7f3aa4..33cc3d3e972 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -348,4 +348,4 @@ "name": "Kumar, Atul" } ] -} \ No newline at end of file +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e904a91ac74..4dca620a32d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -10,7 +10,7 @@ As members of the community, * We pledge to welcome those interested in joining the community, and realize that including people with a variety of opinions and backgrounds will only serve to enrich our community. In particular, discussions relating to pros/cons of various technologies, programming languages, and so on are welcome, but these should be done with respect, taking proactive measure to ensure that all participants are heard and feel confident that they can freely express their opinions. * We pledge to welcome questions and answer them respectfully, paying particular attention to those new to the community. We pledge to provide respectful criticisms and feedback in forums, especially in discussion threads resulting from code contributions. * We pledge to be conscientious of the perceptions of the wider community and to respond to criticism respectfully. We will strive to model behaviors that encourage productive debate and disagreement, both within our community and where we are criticized. We will treat those outside our community with the same respect as people within our community. -* We pledge to help the entire community follow the code of conduct, and to not remain silent when we see violations of the code of conduct. We will take action when members of our community violate this code by reporting them using the instructions below. +* We pledge to help the entire community follow the code of conduct, and to not remain silent when we see violations of the code of conduct. We will take action when members of our community violate this code by reporting them using the instructions below. * This code of conduct applies to all community situations online and offline, including mailing lists, forums, social media, conferences, meetings, associated social events, and one-to-one interactions. This code of conduct has been adapted from the Astropy Code of Conduct, which in turn uses parts of the PSF code of conduct. diff --git a/README.rst b/README.rst index fe1b070fbbc..ad6a1a99b7d 100644 --- a/README.rst +++ b/README.rst @@ -242,4 +242,3 @@ the terms of the BSD 3-Clause license. This package is based upon the `Astropy package template `_ which is licensed under the BSD 3-clause license. See the licenses folder for more information. - diff --git a/benchmarks/benchmark_base.py b/benchmarks/benchmark_base.py index 493573839c7..473caf48e4b 100644 --- a/benchmarks/benchmark_base.py +++ b/benchmarks/benchmark_base.py @@ -20,14 +20,12 @@ from tardis.tests.fixtures.regression_data import RegressionData from tardis.transport.montecarlo import RPacket from tardis.transport.montecarlo.configuration import montecarlo_globals -from tardis.transport.montecarlo.configuration.base import ( - MonteCarloConfiguration, -) +from tardis.transport.montecarlo.configuration.base import \ + MonteCarloConfiguration from tardis.transport.montecarlo.estimators import radfield_mc_estimators -from tardis.transport.montecarlo.numba_interface import opacity_state_initialize -from tardis.transport.montecarlo.packet_collections import ( - VPacketCollection, -) +from tardis.transport.montecarlo.numba_interface import \ + opacity_state_initialize +from tardis.transport.montecarlo.packet_collections import VPacketCollection from tardis.transport.montecarlo.packet_trackers import RPacketTracker diff --git a/benchmarks/opacities_opacity_state.py b/benchmarks/opacities_opacity_state.py index ea05e794691..b54ba38c0ac 100644 --- a/benchmarks/opacities_opacity_state.py +++ b/benchmarks/opacities_opacity_state.py @@ -5,8 +5,8 @@ import numpy as np from asv_runner.benchmarks.mark import parameterize -from tardis.opacities.opacity_state import opacity_state_initialize from benchmarks.benchmark_base import BenchmarkBase +from tardis.opacities.opacity_state import opacity_state_initialize class BenchmarkOpacitiesOpacityState(BenchmarkBase): diff --git a/benchmarks/run_tardis.py b/benchmarks/run_tardis.py index e52c615c71d..77dd0bb30f3 100644 --- a/benchmarks/run_tardis.py +++ b/benchmarks/run_tardis.py @@ -5,6 +5,7 @@ from benchmarks.benchmark_base import BenchmarkBase from tardis import run_tardis + class BenchmarkRunTardis(BenchmarkBase): """ Class to benchmark the `run tardis` function. diff --git a/benchmarks/transport_montecarlo_estimators_radfield_estimator_calcs.py b/benchmarks/transport_montecarlo_estimators_radfield_estimator_calcs.py index 45a3b3b8409..4ed30cfaa91 100644 --- a/benchmarks/transport_montecarlo_estimators_radfield_estimator_calcs.py +++ b/benchmarks/transport_montecarlo_estimators_radfield_estimator_calcs.py @@ -2,15 +2,15 @@ Basic TARDIS Benchmark. """ +from asv_runner.benchmarks.mark import parameterize + import tardis.opacities.opacities as opacities import tardis.transport.geometry.calculate_distances as calculate_distances import tardis.transport.montecarlo.r_packet_transport as r_packet_transport import tardis.transport.montecarlo.utils as utils from benchmarks.benchmark_base import BenchmarkBase -from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import ( - update_line_estimators, -) -from asv_runner.benchmarks.mark import parameterize +from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import \ + update_line_estimators class BenchmarkMontecarloMontecarloNumbaPacket(BenchmarkBase): diff --git a/benchmarks/transport_montecarlo_interaction.py b/benchmarks/transport_montecarlo_interaction.py index e89c486aac2..99c7a7a1f16 100644 --- a/benchmarks/transport_montecarlo_interaction.py +++ b/benchmarks/transport_montecarlo_interaction.py @@ -2,12 +2,11 @@ Basic TARDIS Benchmark. """ +from asv_runner.benchmarks.mark import parameterize + import tardis.transport.montecarlo.interaction as interaction from benchmarks.benchmark_base import BenchmarkBase -from tardis.transport.montecarlo.numba_interface import ( - LineInteractionType, -) -from asv_runner.benchmarks.mark import parameterize +from tardis.transport.montecarlo.numba_interface import LineInteractionType class BenchmarkTransportMontecarloInteraction(BenchmarkBase): diff --git a/benchmarks/transport_montecarlo_main_loop.py b/benchmarks/transport_montecarlo_main_loop.py index 19f2106e7a3..597d139ed55 100644 --- a/benchmarks/transport_montecarlo_main_loop.py +++ b/benchmarks/transport_montecarlo_main_loop.py @@ -3,9 +3,8 @@ """ from benchmarks.benchmark_base import BenchmarkBase -from tardis.transport.montecarlo.montecarlo_main_loop import ( - montecarlo_main_loop, -) +from tardis.transport.montecarlo.montecarlo_main_loop import \ + montecarlo_main_loop class BenchmarkTransportMontecarloMontecarloMainLoop(BenchmarkBase): diff --git a/benchmarks/transport_montecarlo_packet_trackers.py b/benchmarks/transport_montecarlo_packet_trackers.py index c4b6c875407..5c272612680 100644 --- a/benchmarks/transport_montecarlo_packet_trackers.py +++ b/benchmarks/transport_montecarlo_packet_trackers.py @@ -2,9 +2,8 @@ Basic TARDIS Benchmark. """ from benchmarks.benchmark_base import BenchmarkBase -from tardis.transport.montecarlo.packet_trackers import ( - rpacket_trackers_to_dataframe, -) +from tardis.transport.montecarlo.packet_trackers import \ + rpacket_trackers_to_dataframe class BenchmarkTransportMontecarloPacketTrackers(BenchmarkBase): diff --git a/benchmarks/transport_montecarlo_single_packet_loop.py b/benchmarks/transport_montecarlo_single_packet_loop.py index 85bc6bbf64f..e4404d159ea 100644 --- a/benchmarks/transport_montecarlo_single_packet_loop.py +++ b/benchmarks/transport_montecarlo_single_packet_loop.py @@ -2,9 +2,10 @@ Basic TARDIS Benchmark. """ +from numba.np.ufunc.parallel import get_num_threads, get_thread_id + from benchmarks.benchmark_base import BenchmarkBase from tardis.transport.montecarlo import single_packet_loop -from numba.np.ufunc.parallel import get_num_threads, get_thread_id class BenchmarkTransportMontecarloSinglePacketLoop(BenchmarkBase): diff --git a/benchmarks/transport_montecarlo_vpacket.py b/benchmarks/transport_montecarlo_vpacket.py index 4de7d198c68..490a4609c05 100644 --- a/benchmarks/transport_montecarlo_vpacket.py +++ b/benchmarks/transport_montecarlo_vpacket.py @@ -6,11 +6,9 @@ from asv_runner.benchmarks.mark import parameterize import tardis.transport.montecarlo.vpacket as vpacket -from tardis.transport.montecarlo.r_packet import RPacket from benchmarks.benchmark_base import BenchmarkBase -from tardis.transport.frame_transformations import ( - get_doppler_factor, -) +from tardis.transport.frame_transformations import get_doppler_factor +from tardis.transport.montecarlo.r_packet import RPacket class BenchmarkMontecarloMontecarloNumbaVpacket(BenchmarkBase): diff --git a/benchmarks/util/base.py b/benchmarks/util/base.py index 7dd61629e3e..b98291a0d6a 100644 --- a/benchmarks/util/base.py +++ b/benchmarks/util/base.py @@ -1,4 +1,4 @@ -from os.path import dirname, realpath, join +from os.path import dirname, join, realpath from pathlib import Path, PosixPath diff --git a/benchmarks/util/nlte.py b/benchmarks/util/nlte.py index 7cfed4ef4dd..c186bc06d9b 100644 --- a/benchmarks/util/nlte.py +++ b/benchmarks/util/nlte.py @@ -5,7 +5,7 @@ from benchmarks.util.base import Base from tardis.io.atom_data import AtomData from tardis.io.configuration.config_reader import Configuration -from tardis.io.util import yaml_load_file, YAMLLoader +from tardis.io.util import YAMLLoader, yaml_load_file from tardis.model import SimulationState diff --git a/docs/_templates/autosummary/base.rst b/docs/_templates/autosummary/base.rst index 9cabaf5238d..16217194a93 100644 --- a/docs/_templates/autosummary/base.rst +++ b/docs/_templates/autosummary/base.rst @@ -1,2 +1,2 @@ {% extends "autosummary_core/base.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file +{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst index 6b214a5c09d..0fa59f28180 100644 --- a/docs/_templates/autosummary/class.rst +++ b/docs/_templates/autosummary/class.rst @@ -1,2 +1,2 @@ {% extends "autosummary_core/class.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file +{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} diff --git a/docs/_templates/autosummary/module.rst b/docs/_templates/autosummary/module.rst index f38315b22a4..230cd6e20dd 100644 --- a/docs/_templates/autosummary/module.rst +++ b/docs/_templates/autosummary/module.rst @@ -1,2 +1,2 @@ {% extends "autosummary_core/module.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file +{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} diff --git a/docs/_templates/sourcelink.html b/docs/_templates/sourcelink.html index 2b83f4e97f8..846a66a6b2b 100644 --- a/docs/_templates/sourcelink.html +++ b/docs/_templates/sourcelink.html @@ -3,4 +3,4 @@ Show on GitHub
  • Edit on GitHub
  • -{% endif %} \ No newline at end of file +{% endif %} diff --git a/docs/conf.py b/docs/conf.py index f8a6d2e6371..e98cc5f36e4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,14 +25,16 @@ # Thus, any C-extensions that are needed to build the documentation will *not* # be accessible, and the documentation will not build correctly. +import datetime import os import sys -import datetime -import tardis # FIXME: this import is required by astropy.constants from importlib import import_module -import toml from pathlib import Path +import toml + +import tardis # FIXME: this import is required by astropy.constants + try: from sphinx_astropy.conf.v1 import * # noqa except ImportError: @@ -136,7 +138,7 @@ nbsphinx_prolog = r""" {% set docname = 'docs/' + env.doc2path(env.docname, base=None) %} .. raw:: html - + - +

    You can interact with this notebook online: Launch notebook

    diff --git a/docs/contributing/development/azure_links.inc b/docs/contributing/development/azure_links.inc index af352a44a42..fe0d0a635d3 100644 --- a/docs/contributing/development/azure_links.inc +++ b/docs/contributing/development/azure_links.inc @@ -12,4 +12,3 @@ .. _error 413: https://developercommunity.visualstudio.com/content/problem/867488/git-lfs-push-got-413-error.html .. vim: ft=rstS - diff --git a/docs/contributing/development/continuous_integration.rst b/docs/contributing/development/continuous_integration.rst index 48298b3848a..b3ed6791925 100644 --- a/docs/contributing/development/continuous_integration.rst +++ b/docs/contributing/development/continuous_integration.rst @@ -40,13 +40,13 @@ Azure Pipelines & GitHub Actions -------------------------------- Currently, we use the `Azure DevOps`_ service to run most of our -pipelines and GitHub Actions for some others (called "workflows"). The +pipelines and GitHub Actions for some others (called "workflows"). The following sections explains briefly the different components of a pipeline/workflow, mostly focused on the Azure service. -A pipeline (or a workflow) is essentially a :term:`YAML` configuration file +A pipeline (or a workflow) is essentially a :term:`YAML` configuration file with different sections such as variables, jobs and steps. These files -run commands or tasks when they are triggered by some event, like a +run commands or tasks when they are triggered by some event, like a commit being pushed to a certain branch. Pipelines on Azure must be created through the web UI for the first time. @@ -64,7 +64,7 @@ to run every time changes are pushed to a branch. .. code-block:: yaml - trigger: + trigger: - master If some trigger is not specified then the default configuration @@ -147,7 +147,7 @@ Usually, we define variables at the top of the YAML file. When a variable is defined at the top of a YAML, it will be available to all jobs and stages in the pipeline as a *global variable*. Variables at the *stage* level override variables at the *root* level, -while variables at the *job* level override variables at the *root* +while variables at the *job* level override variables at the *root* and *stage* level. Also, variables are available to scripts through environment variables. @@ -184,7 +184,7 @@ Predefined variables The most important (and confusing) predefined variables are the ones related to paths in Azure: -* All folders for a given pipeline are created under ``Agent.BuildDirectory`` +* All folders for a given pipeline are created under ``Agent.BuildDirectory`` variable, alias ``Pipeline.Workspace``. This includes subdirectories like ``/s`` for sources or ``/a`` for artifacts. @@ -264,7 +264,7 @@ to start a new pipeline use:: - ``refdataRepo`` (*option*): source of the ``tardis-refdata`` repository, options are ``azure`` (default) or ``github``. - ``useMamba`` (*bool*): use the ``mamba`` package manager instead of ``conda``, - default is ``false``. + default is ``false``. - ``tardisEnv`` (*bool*): setup the TARDIS environment, default is ``true``. **List of predefined custom variables:** @@ -305,7 +305,7 @@ repository if new commiters are found (or author order changes). The rendered notebook is uploaded to the pipeline results as an artifact. .. warning :: Fails if some author name is incomplete (due to an incomplete - GitHub profile) or duplicated (commited with more than one + GitHub profile) or duplicated (commited with more than one email adress). In both cases update ``.mailmap`` to fix it. In the near future we want to auto-update the citation guidelines in the @@ -315,7 +315,7 @@ In the near future we want to auto-update the citation guidelines in the Release pipeline ================ -Publishes a new release of TARDIS every sunday at 00:00 UTC. +Publishes a new release of TARDIS every sunday at 00:00 UTC. Compare reference data pipeline @@ -330,10 +330,10 @@ on a pull request: For brevity, you can comment using ``/azp`` instead of ``/AzurePipelines``. -By default, generates new reference data for the ``HEAD`` of the pull request. Then, +By default, generates new reference data for the ``HEAD`` of the pull request. Then, compares against latest reference data stored in ``tardis-refdata`` repository. If you want to compare two different labels (SHAs, branches, tags, etc.) uncomment and -set the ``ref1.hash`` and ``ref2.hash`` variables in +set the ``ref1.hash`` and ``ref2.hash`` variables in ``.github/workflows/compare-refdata.yml`` on your pull request. For example: .. code-block:: yaml @@ -350,25 +350,25 @@ of developers. Finally, the report is uploaded to the `OpenSupernova.org server `_ -following the ``/`` folder structure. If the pipeline fails, also a report is +following the ``/`` folder structure. If the pipeline fails, also a report is generated, but not necessarily gives useful debug information (depends on which step the pipeline has failed). TARDIS Carsus Compatibility Check ================================= -The TARDIS Carsus Compatibility Check or the "Bridge" compares reference data -generated with different versions of Carsus. It consists of two jobs- a "carsus-build" job to -generate an atomic file with the latest version of Carsus and a "tardis-build" job -to generate a new reference data with it. These two reference data files are compared using the +The TARDIS Carsus Compatibility Check or the "Bridge" compares reference data +generated with different versions of Carsus. It consists of two jobs- a "carsus-build" job to +generate an atomic file with the latest version of Carsus and a "tardis-build" job +to generate a new reference data with it. These two reference data files are compared using the `this notebook `_. -The workflow has a ``workflow_dispatch`` event so that it can be triggered manually, but is also -triggered every week due to the "save-atomic-files" workflow. +The workflow has a ``workflow_dispatch`` event so that it can be triggered manually, but is also +triggered every week due to the "save-atomic-files" workflow. The Save Atomic Files Workflow ============================== The Save Atomic Files workflow runs every week but can also be triggered manually. It runs the "Bridge" and sends an artifact containing the generated atomic data file -and the comparison notebook to Moria. This workflow has a separate job to indicate if the +and the comparison notebook to Moria. This workflow has a separate job to indicate if the bridge has failed. diff --git a/docs/contributing/development/developer_faq.rst b/docs/contributing/development/developer_faq.rst index da321570894..a023795c477 100644 --- a/docs/contributing/development/developer_faq.rst +++ b/docs/contributing/development/developer_faq.rst @@ -10,4 +10,4 @@ Class design and inheritance: * If only constructor changed -> use classmethod * if overriding other methods -> subclass -We use black to check PEP8 compliances. +We use black to check PEP8 compliances. diff --git a/docs/contributing/development/documentation_guidelines.rst b/docs/contributing/development/documentation_guidelines.rst index 49e40822edd..bb627884410 100644 --- a/docs/contributing/development/documentation_guidelines.rst +++ b/docs/contributing/development/documentation_guidelines.rst @@ -41,7 +41,7 @@ Whether your page is written in reStructuredText or as a Jupyter notebook, it mu 3. Include your file in the/a `toctree `_ of the corresponding ``index.rst``. For example, :doc:`../../io/visualization/using_widgets` was included in a toctree of ``docs/io/visualization/index.rst``. .. note:: - + When new functions or classes are added to the code, in addition to documentation, **docstrings** must always be added. Read :ref:`this section ` of our code quality guidelines to understand their importance and how they should be formatted. Sphinx uses these docstrings to auto-generate the `API documentation `_ for entire TARDIS package. Please make sure that you have correctly formatted the docstrings by checking how the corresponding module's API looks once you build the documentation. @@ -55,7 +55,7 @@ To build TARDIS documentation locally, use the following commands: cd docs make html -.. note:: +.. note:: - If you're working on a fresh local copy of the TARDIS repository, you might need to do ``python setup.py develop`` before executing these commands. - Use ``DISABLE_NBSPHINX=1 make html`` to disable notebook rendering (fast mode). diff --git a/docs/contributing/development/git_links.inc b/docs/contributing/development/git_links.inc index 90c2a2fa235..4074a564988 100644 --- a/docs/contributing/development/git_links.inc +++ b/docs/contributing/development/git_links.inc @@ -11,7 +11,7 @@ .. git stuff .. _git: http://git-scm.com/ .. _github: http://github.com -.. _GitHub Help: http://help.github.com +.. _GitHub Help: http://help.github.com .. _msysgit: http://code.google.com/p/msysgit/downloads/list .. _git-osx-installer: http://code.google.com/p/git-osx-installer/downloads/list .. _subversion: http://subversion.tigris.org/ diff --git a/docs/contributing/development/integration.yml b/docs/contributing/development/integration.yml index e638fa3d9dd..9b26f8cb74e 100644 --- a/docs/contributing/development/integration.yml +++ b/docs/contributing/development/integration.yml @@ -14,4 +14,3 @@ reference: "~/projects/tardis/integration/" less_packets: no_of_packets: 400 last_no_of_packets: 1000 - diff --git a/docs/contributing/development/links.inc b/docs/contributing/development/links.inc index 517b1d39948..6aaa3117904 100644 --- a/docs/contributing/development/links.inc +++ b/docs/contributing/development/links.inc @@ -3,4 +3,4 @@ .. include:: this_project.inc .. include:: git_links.inc .. include:: azure_links.inc -.. include:: matterbridge.inc \ No newline at end of file +.. include:: matterbridge.inc diff --git a/docs/contributing/development/matterbridge.rst b/docs/contributing/development/matterbridge.rst index 8648ed953a2..dfe240d617e 100644 --- a/docs/contributing/development/matterbridge.rst +++ b/docs/contributing/development/matterbridge.rst @@ -7,7 +7,7 @@ Overview ======== We use Matterbridge to connect channels across different messaging platforms -such as *Slack*, *Mattermost* and *Gitter*. Matterbridge provides binaries +such as *Slack*, *Mattermost* and *Gitter*. Matterbridge provides binaries for many operating systems. The ``matterbridge`` binary is intended to be used in combination with a :term:`TOML` configuration file:: @@ -18,8 +18,8 @@ The TOML file includes all the parameters required to connect as many messaging platforms as you want, like *tokens* and *passwords*. Once the application is running, messages can be shared between the connected rooms. -Currently, we keep a service running on the `OpenSupernova.org`_ server to -run Matterbridge as a daemon. Our configuration files are stored in a `private +Currently, we keep a service running on the `OpenSupernova.org`_ server to +run Matterbridge as a daemon. Our configuration files are stored in a `private GitHub repository`_, including our custom TOML and the files needed to set up the Linux service. diff --git a/docs/contributing/development/running_tests.rst b/docs/contributing/development/running_tests.rst index 5ae85734861..e6bc1bf05ee 100644 --- a/docs/contributing/development/running_tests.rst +++ b/docs/contributing/development/running_tests.rst @@ -38,7 +38,7 @@ that a preused fixture that is also being used in the current tests is using som refdata. So, it is advised to check for such cases beforehand. After identifying the refdata files to be used in the unit tests, those particular -files can be downloaded using ``git lfs`` +files can be downloaded using ``git lfs`` .. code-block:: shell @@ -61,23 +61,23 @@ Or, to run tests for a particular file or directory > pytest tardis/path/to/test_file_or_directory --tardis-refdata=/path/to/tardis-refdata/ .. warning:: - The `tests workflow `_ runs on - `pull requests `_ and on + The `tests workflow `_ runs on + `pull requests `_ and on `push `_ events. To prevent leaking LFS quota, tests have been disabled on forks. If, by any chance, you need to run tests on your fork, make sure to run the tests workflow on master branch first. - The LFS cache generated in the master branch should be available in all child branches. - You can check if cache was generated by looking in the ``Restore LFS Cache`` step of the workflow run. + The LFS cache generated in the master branch should be available in all child branches. + You can check if cache was generated by looking in the ``Restore LFS Cache`` step of the workflow run. Cache can also be found under the "Management" Section under "Actions" tab. Running Syrupy Tests ====================== -The tests module is currently being restructured to use `Syrupy `_. +The tests module is currently being restructured to use `Syrupy `_. These tests generate individual HDF(for Pandas) and ``.npy`` or ``.npz`` (for NumPy) files(or snapshots) for each test case. -For other objects, the plugin serialises them and saves them as ``.ambr`` files. There is a custom extension in the +For other objects, the plugin serialises them and saves them as ``.ambr`` files. There is a custom extension in the main local `conftest `_ file to get this to work. -The plugin currently only supports ``assert_allclose`` for NumPy and ``assert_series_equal`` and ``assert_frame_equal`` for +The plugin currently only supports ``assert_allclose`` for NumPy and ``assert_series_equal`` and ``assert_frame_equal`` for Pandas. Snapshots can be generated by using the same ``--generate-reference`` flag and are compared automatically. You however need to provide the location to your snapshot directory using the ``--tardis-snapshot-data`` flag. The snapshots are also saved in `tardis-sn/tardis-regressions `_. @@ -89,7 +89,7 @@ You can generate Plasma Reference by the following command: .. code-block:: shell - > pytest -rs tardis/plasma/tests/test_complete_plasmas.py + > pytest -rs tardis/plasma/tests/test_complete_plasmas.py --tardis-refdata="/path/to/tardis-refdata/" --generate-reference Running the Integration Tests diff --git a/docs/contributing/development/this_project.inc b/docs/contributing/development/this_project.inc index d817c3968ce..722678989f0 100644 --- a/docs/contributing/development/this_project.inc +++ b/docs/contributing/development/this_project.inc @@ -1,4 +1,4 @@ .. _`TARDIS`: http://tardis.readthedocs.org .. _`TARDIS Github`: http://github.com/tardis-sn/tardis -.. _`tardis-sn-dev mailing list`: https://groups.google.com/forum/#!forum/tardis-sn-dev \ No newline at end of file +.. _`tardis-sn-dev mailing list`: https://groups.google.com/forum/#!forum/tardis-sn-dev diff --git a/docs/contributing/development/update_refdata.rst b/docs/contributing/development/update_refdata.rst index 1fa151375e2..41efc947f32 100644 --- a/docs/contributing/development/update_refdata.rst +++ b/docs/contributing/development/update_refdata.rst @@ -9,7 +9,7 @@ These tests compares the output of the TARDIS code (mostly arrays) against the i in the reference data files. TARDIS stores reference data in the `tardis-refdata `_ -repository. This repository also has a mirror hosted in Azure Pipelines (synchronized automatically by a +repository. This repository also has a mirror hosted in Azure Pipelines (synchronized automatically by a GitHub workflow) since this Microsoft service does not have limitations in bandwith nor storage. Sometimes, this data needs to be updated. The procedure to update these files manually is not trivial diff --git a/docs/contributing/in_progress/index.rst b/docs/contributing/in_progress/index.rst index a2cabd59cc3..85045fb0375 100644 --- a/docs/contributing/in_progress/index.rst +++ b/docs/contributing/in_progress/index.rst @@ -1,5 +1,5 @@ .. _in-progress: - + ******************** Features In-Progress ******************** diff --git a/docs/contributing/in_progress/nebular_phase/positronium.rst b/docs/contributing/in_progress/nebular_phase/positronium.rst index 443d317d3da..ce83603ad63 100644 --- a/docs/contributing/in_progress/nebular_phase/positronium.rst +++ b/docs/contributing/in_progress/nebular_phase/positronium.rst @@ -10,14 +10,14 @@ In supernovae, Ps can form when :math:`\beta`-decay occurs in the radioactive ma According to :cite:`Jauch1976` the density-dependent reciprocal lifetime :math:`\frac{1}{\tau_2}` (called a "cross-section") of para-Ps is -.. math:: +.. math:: P \equiv \frac{1}{\tau_2} = r_0^2 \pi \rho where :math:`r_0` is the classical electron radius and :math:`\rho` is the electron number density. Note that the units here appear to be inverse length rather than the expected inverse time. -For ortho-Ps, the cross-section is +For ortho-Ps, the cross-section is -.. math:: +.. math:: P \equiv \frac{1}{\tau_3} = \frac{4}{3} (\pi^2-9) \alpha r_0^2 \rho -where :math:`\alpha` is the fine structure constant. This makes the ortho-Ps cross-section (and associated lifetime) roughly 300 times smaller than that of para-Ps. \ No newline at end of file +where :math:`\alpha` is the fine structure constant. This makes the ortho-Ps cross-section (and associated lifetime) roughly 300 times smaller than that of para-Ps. diff --git a/docs/contributing/tools/profiling/index.rst b/docs/contributing/tools/profiling/index.rst index 100b0c5e481..685841f379f 100644 --- a/docs/contributing/tools/profiling/index.rst +++ b/docs/contributing/tools/profiling/index.rst @@ -5,6 +5,6 @@ Profiling Information .. toctree:: :maxdepth: 2 - + profiling_example - tardis_profiling_threads \ No newline at end of file + tardis_profiling_threads diff --git a/docs/index.rst b/docs/index.rst index ce71ae3b974..6e796baa93c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,7 +18,7 @@ TARDIS Core Package Documentation TARDIS is an open-source Monte Carlo radiative-transfer spectral synthesis code for 1D models of supernova ejecta. It is designed for rapid spectral modelling -of supernovae. It is developed and maintained by a +of supernovae. It is developed and maintained by a `multi-disciplinary team `_ including software engineers, computer scientists, statisticians, and astrophysicists. @@ -40,11 +40,11 @@ assistance. Mission Statement ----------------- - *The mission of the TARDIS community is to develop open-source software - instruments to analyze and simulate astronomical transients - (supernovae, kilonovae, etc.) for research and education purposes. - We aim to build up a diverse group of researchers and developers - using an open-community model that emphasizes interdisciplinary + *The mission of the TARDIS community is to develop open-source software + instruments to analyze and simulate astronomical transients + (supernovae, kilonovae, etc.) for research and education purposes. + We aim to build up a diverse group of researchers and developers + using an open-community model that emphasizes interdisciplinary research and science reproducibility.* .. toctree:: @@ -63,7 +63,7 @@ Mission Statement :maxdepth: 3 :caption: Input/Output :hidden: - + io/hdf/index io/configuration/index io/model/index @@ -76,7 +76,7 @@ Mission Statement :maxdepth: 2 :caption: Physics Walkthrough :hidden: - + physics/intro/index physics/setup/index physics/montecarlo/index @@ -99,7 +99,7 @@ Mission Statement .. toctree:: :caption: Other Resources :hidden: - + resources/credits resources/research_done_using_TARDIS/research_papers resources/code_comparison/index diff --git a/docs/installation.rst b/docs/installation.rst index b3fc1a886dc..56881492756 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,13 +6,13 @@ Installation .. warning:: - - - TARDIS is only supported on macOS and GNU/Linux. Windows users can run TARDIS - from our official Docker image (*coming soon*), `WSL `_ + + - TARDIS is only supported on macOS and GNU/Linux. Windows users can run TARDIS + from our official Docker image (*coming soon*), `WSL `_ or a Virtual Machine. - - TARDIS packages and dependencies are distributed only through the `conda `_ - package management system, therefore installation requires `Anaconda `_ + - TARDIS packages and dependencies are distributed only through the `conda `_ + package management system, therefore installation requires `Anaconda `_ or `Miniconda `_ to be installed on your system. @@ -24,7 +24,7 @@ Conda lockfiles are platform-specific dependency files that produce repeatable e These files are generated on every new release. We strongly recommend installing TARDIS using this method by following the steps described below. -1. Download the latest lockfile for your operating system from our +1. Download the latest lockfile for your operating system from our `releases section `_, or run the following command while replacing ``{platform}`` with ``linux`` or ``osx`` as appropriate. @@ -56,17 +56,17 @@ this method by following the steps described below. .. note:: The complete developer guidelines can be found :ref:`here `. - + b. Non-developers can install from specific releases using pip- :: $ pip install git+https://github.com/tardis-sn/tardis.git@{tag} - For example- + For example- :: - + $ pip install git+https://github.com/tardis-sn/tardis.git@release-latest or trying the most recent, unreleased changes from upstream. @@ -83,7 +83,7 @@ this method by following the steps described below. From now on, just activate the ``tardis`` environment before working with the TARDIS package. -You have successfully installed TARDIS! 🎉 Please refer to `Quickstart for TARDIS `_ +You have successfully installed TARDIS! 🎉 Please refer to `Quickstart for TARDIS `_ to start running simulations. @@ -127,4 +127,3 @@ Use the following ``conda`` command to remove your current ``tardis`` environmen $ conda remove --name tardis --all Now, you can create a new environment by following the steps given `here `_. - diff --git a/docs/io/configuration/components/atomic/atomic_data_description.rst b/docs/io/configuration/components/atomic/atomic_data_description.rst index 5e77056a7f7..8ef7ef9cea1 100644 --- a/docs/io/configuration/components/atomic/atomic_data_description.rst +++ b/docs/io/configuration/components/atomic/atomic_data_description.rst @@ -52,7 +52,7 @@ Ionization Data +------------------------+------------------------------+----------+ -.. note:: In TARDIS, Ion 0 is neutral. +.. note:: In TARDIS, Ion 0 is neutral. Levels Data diff --git a/docs/io/configuration/components/debug.rst b/docs/io/configuration/components/debug.rst index f3208a600e0..f572f56ead9 100644 --- a/docs/io/configuration/components/debug.rst +++ b/docs/io/configuration/components/debug.rst @@ -6,4 +6,4 @@ Coming soon! .. jsonschema:: schemas/debug.yml -. \ No newline at end of file +. diff --git a/docs/io/configuration/components/index.rst b/docs/io/configuration/components/index.rst index 2757b50646c..2936beeda0b 100644 --- a/docs/io/configuration/components/index.rst +++ b/docs/io/configuration/components/index.rst @@ -39,4 +39,4 @@ in the base schema, and important information about the configuration is linked models/index montecarlo spectrum - debug \ No newline at end of file + debug diff --git a/docs/io/configuration/components/models/Custom_TARDIS_Model_Tutorial.ipynb b/docs/io/configuration/components/models/Custom_TARDIS_Model_Tutorial.ipynb index 38f081d41f2..0c6709dcbe1 100644 --- a/docs/io/configuration/components/models/Custom_TARDIS_Model_Tutorial.ipynb +++ b/docs/io/configuration/components/models/Custom_TARDIS_Model_Tutorial.ipynb @@ -793,4 +793,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} diff --git a/docs/io/configuration/components/models/abundancecust/abundancecust.rst b/docs/io/configuration/components/models/abundancecust/abundancecust.rst index b6f15a4754e..3c2ac537494 100644 --- a/docs/io/configuration/components/models/abundancecust/abundancecust.rst +++ b/docs/io/configuration/components/models/abundancecust/abundancecust.rst @@ -27,7 +27,7 @@ the TARDIS calculations --- so if your model is, for example, based on an explos simulation, you may need to calculate the state of any radioactive decay chains at the correct epoch. -The example file shown here has three simple layers: +The example file shown here has three simple layers: - an innermost region (indices 0 to 2) that is composed of Si (Z=14), S (Z=16), Ar (Z=18), Ca (Z=20), Fe (Z=26), Co (Z=27) and Ni (Z=28) @@ -69,7 +69,7 @@ work on a mesh with ten cells should be formatted like this: .. literalinclude:: tardis_model_abund.csv .. note:: - + The file should always contain the cell index as a running index in the first column. @@ -80,7 +80,7 @@ work on a mesh with ten cells should be formatted like this: In this file: -- Header row contains element and isotopes symbol +- Header row contains element and isotopes symbol - the remaining entries in each row give the set of elemental and isotopic abundances. - the first column contains a running index @@ -88,7 +88,7 @@ The abundances are specified as mass fractions (i.e. the sum of columns in each row should be 1.0). The mass fractions specified will be adopted directly in the TARDIS calculations. -The example file shown here has three simple layers: +The example file shown here has three simple layers: - an innermost region that is composed of Si and two Nickel Isotopes Ni56 and Ni58 @@ -97,14 +97,14 @@ The example file shown here has three simple layers: - an outer region that is composed of C and O .. note:: - + Suppose you specify Elemental and Isotopic abundances for the same element. For ex- - :code:`Ni` and :code:`Ni56`. + :code:`Ni` and :code:`Ni56`. Here, Ni will refer to the stable Nickel (i.e. Z=26, A=58). .. note:: - + As with the custom density file, the first row will be ignored. It is supposed to give the composition below the photosphere. Thus, the first row (after the header) can be filled with dummy values. @@ -123,16 +123,16 @@ in this example), you can use it in TARDIS by putting the following lines in the model section of the YAML file: .. literalinclude:: tardis_configv1_isotope_abundance_cust_example.yml - :language: yaml + :language: yaml Convert ASCII abundance file format to CSV format ================================================= -If you want to convert an ASCII abundance file (say "abund.dat") to CSV format, you can use +If you want to convert an ASCII abundance file (say "abund.dat") to CSV format, you can use :code:`convert_abundances_format` function for it. Here is an example to demonstrate this: .. code:: python from tardis.util import convert_abundances_format df = convert_abundances_format('abund.dat') - df.to_csv('converted_abund.csv', index=False, sep=' ') + df.to_csv('converted_abund.csv', index=False, sep=' ') diff --git a/docs/io/configuration/components/models/abundancecust/tardis_configv1_abundance_cust_example.yml b/docs/io/configuration/components/models/abundancecust/tardis_configv1_abundance_cust_example.yml index 48e58b831b4..28121618f91 100644 --- a/docs/io/configuration/components/models/abundancecust/tardis_configv1_abundance_cust_example.yml +++ b/docs/io/configuration/components/models/abundancecust/tardis_configv1_abundance_cust_example.yml @@ -1,5 +1,5 @@ model: - + abundances: type: file filename: abund.dat diff --git a/docs/io/configuration/components/models/data/abund.dat b/docs/io/configuration/components/models/data/abund.dat index 36145e93d2d..dead6c17642 100755 --- a/docs/io/configuration/components/models/data/abund.dat +++ b/docs/io/configuration/components/models/data/abund.dat @@ -1,12 +1,12 @@ H He - -0.000000 1.000000 -0.100000 0.900000 -0.200000 0.800000 -0.300000 0.700000 -0.400000 0.600000 -0.500000 0.500000 -0.600000 0.400000 -0.700000 0.300000 -0.800000 0.200000 -0.900000 0.100000 + +0.000000 1.000000 +0.100000 0.900000 +0.200000 0.800000 +0.300000 0.700000 +0.400000 0.600000 +0.500000 0.500000 +0.600000 0.400000 +0.700000 0.300000 +0.800000 0.200000 +0.900000 0.100000 diff --git a/docs/io/configuration/components/models/densitycust/densitycust.rst b/docs/io/configuration/components/models/densitycust/densitycust.rst index d655aa5782e..ef6435632c3 100644 --- a/docs/io/configuration/components/models/densitycust/densitycust.rst +++ b/docs/io/configuration/components/models/densitycust/densitycust.rst @@ -20,7 +20,7 @@ In this file: - (the second line in our example is a comment) -- the remaining lines (ten in our example) give an indexed table of points that specify mass density (g / cm^3) as a function of velocity (km / s). +- the remaining lines (ten in our example) give an indexed table of points that specify mass density (g / cm^3) as a function of velocity (km / s). TARDIS will use this table of density versus velocity to specify the density distribution in the ejecta. For the calculation, TARDIS will use the reference @@ -72,4 +72,3 @@ the model section of the YAML file: The specifications for the velocities of the inner and outer boundary values can be neglected (in which case TARDIS will default to using the full velocity range specified in the density.txt file). Values for the boundary velocities that lie outside the range covered by density.txt will not be accepted. - diff --git a/docs/io/configuration/components/models/example_data.inc b/docs/io/configuration/components/models/example_data.inc index 7bfaa37404e..684392d47e1 100644 --- a/docs/io/configuration/components/models/example_data.inc +++ b/docs/io/configuration/components/models/example_data.inc @@ -1,2 +1,2 @@ .. _example_yml: https://github.com/tardis-sn/tardis-setups/blob/master/2014/2014_kerzendorf_sim/appendix_A1/tardis_example.yml -.. _example_atomic_database: https://github.com/tardis-sn/tardis-refdata/raw/master/atom_data/kurucz_cd23_chianti_H_He.h5 \ No newline at end of file +.. _example_atomic_database: https://github.com/tardis-sn/tardis-refdata/raw/master/atom_data/kurucz_cd23_chianti_H_He.h5 diff --git a/docs/io/configuration/components/models/index.rst b/docs/io/configuration/components/models/index.rst index ff7bc621f35..6b856083d26 100644 --- a/docs/io/configuration/components/models/index.rst +++ b/docs/io/configuration/components/models/index.rst @@ -45,34 +45,34 @@ model configuration. .. jsonschema:: ../schemas/model_definitions.yml#/definitions/structure/file :lift_description: - + For example: - + .. literalinclude:: densitycust/tardis_configv1_density_cust_example.yml :language: yaml - + In this example, our configuration references a file named ``density.dat``. For more information on what this file would entail, see: - + .. toctree:: :maxdepth: 1 - + densitycust/densitycust - + .. jsonschema:: ../schemas/model_definitions.yml#/definitions/abundances/file :lift_description: - + For example: - + .. literalinclude:: abundancecust/tardis_configv1_abundance_cust_example.yml :language: yaml - + In this example, our configuration references a file named ``abund.dat``. For more information on what this file would entail, see: - + .. toctree:: :maxdepth: 1 - + abundancecust/abundancecust Custom Model Tutorial @@ -88,11 +88,11 @@ Custom Model Tutorial Model Converters ---------------- - + There are a variety of formats for models from other codes (both hydro and radiative transfer) that can be converted to TARDIS input files. Here we aim to provide converters for the most commonly used file formats. - + .. toctree:: :maxdepth: 2 @@ -145,7 +145,7 @@ For example: model: structure: type: specific - + density: type: branch85_w7 @@ -161,7 +161,7 @@ For example: model: structure: type: specific - + density: type: exponential rho_0: 1e-10 g/cm^3 @@ -179,7 +179,7 @@ For example: model: structure: type: specific - + density: type: power_law rho_0: 1e-10 g/cm^3 @@ -202,7 +202,7 @@ For example: density: type: uniform value: 1e-10 g/cm^3 - + For more information, see `Uniform Density <../../../../physics/setup/model.ipynb#uniform-density>`_. diff --git a/docs/io/configuration/components/montecarlo.rst b/docs/io/configuration/components/montecarlo.rst index 0f57b2a50ed..29aa928e093 100644 --- a/docs/io/configuration/components/montecarlo.rst +++ b/docs/io/configuration/components/montecarlo.rst @@ -17,7 +17,7 @@ of the Monte Carlo loop (which calculates the final spectrum!) when the radiatio use the Virtual Packet formalism. Increasing this number drastically increases computational costs (and memory requirements if they are logged). The ``iterations`` parameter describes the maximum number of Monte Carlo loops executed in a simulation before it ends. Convergence criteria can be used to make the simulation stop sooner when the convergence threshold has been reached (see :doc:`../../../physics/update_and_conv/update_and_conv`). - + .. _conv-config: Convergence Strategy @@ -46,4 +46,4 @@ Parallel Execution with Numba The ``montecarlo`` section of the Configuration file accepts the parameter ``nthreads`` which sets the number of threads to be used for parallelisation. Setting the value of the parameter between 1 and the environment variable ``NUMBA_NUM_THREADS`` (which is, by default, the number of CPU cores on your system) will automatically invoke Numba -to parallelise the code. (See :ref:`config-file` section). \ No newline at end of file +to parallelise the code. (See :ref:`config-file` section). diff --git a/docs/io/configuration/components/plasma.rst b/docs/io/configuration/components/plasma.rst index 7ff017c9776..19b396ab57f 100644 --- a/docs/io/configuration/components/plasma.rst +++ b/docs/io/configuration/components/plasma.rst @@ -14,21 +14,21 @@ boundary. ``initial_t_rad`` is the initial radiation temperature (will be update There are currently two ``plasma_type`` options available: ``nebular`` and ``lte``, which tell TARDIS how to run the ionization equilibrium and level population calculations (see :ref:`plasma` for more information). The radiative rates describe how to calculate the :math:`J_\textrm{blue}` needed for the :ref:`nlte` calculations and -:ref:`macroatom` calculations. There are three options for ``radiative_rates_type``: - +:ref:`macroatom` calculations. There are three options for ``radiative_rates_type``: + 1) ``blackbody``, in which :math:`J_\textrm{blue} = \textrm{Blackbody}(T_\textrm{rad})` - + 2) ``dilute-blackbody`` in which :math:`J_\textrm{blue} = W \times \textrm{Blackbody}(T_\textrm{rad})` - + 3) ``detailed`` in which the :math:`J_\textrm{blue}` are calculated using an estimator (this is described in :doc:`../../../physics/montecarlo/estimators`). - + TARDIS currently supports three different kinds of line interaction: ``scatter`` --- a resonance scattering implementation, ``macroatom`` --- the most complex form of line interaction described in :ref:`macroatom` and ``downbranch`` a simplified version of ``macroatom`` in which only downward transitions are allowed (see :ref:`lineinteraction`). - + Finally, ``w_epsilon`` describes the dilution factor to use to calculate :math:`J_\textrm{blue}` that are 0, which causes problems with the code (so :math:`J_\textrm{blue}` are set to a very small number). @@ -44,11 +44,11 @@ Continuum Interaction - H I - H II - He I - - He II + - He II enable_adiabatic_cooling: True -This will add continuum interactions for all specified species. Setting :math:`T_\textrm{rad} = T_\textrm{electron}` through -``link_t_rad_t_electron: 1.0`` is recommended to enforce LTE (unless the simulation uses NLTE treatment). +This will add continuum interactions for all specified species. Setting :math:`T_\textrm{rad} = T_\textrm{electron}` through +``link_t_rad_t_electron: 1.0`` is recommended to enforce LTE (unless the simulation uses NLTE treatment). ``enable_adiabatic_cooling`` enables adiabatic cooling. NLTE @@ -73,7 +73,7 @@ NLTE Ionization plasma: nlte_ionization_species: [H I, H II, He I, He II] nlte_solver: root - + This option allows the user to specify which species should be included in the NLTE ionization treatment. Note that the species must be present in the continuum interaction species as well. Here, ``nlte_solver`` can be set to ``root`` or ``lu``. ``root`` is the default and uses a root solver to calculate the diff --git a/docs/io/configuration/components/spectrum.rst b/docs/io/configuration/components/spectrum.rst index 6f20b3b8519..e36bc11bbc7 100644 --- a/docs/io/configuration/components/spectrum.rst +++ b/docs/io/configuration/components/spectrum.rst @@ -8,18 +8,18 @@ Finally, the spectrum configuration tells TARDIS information needed for spectrum .. jsonschema:: schemas/spectrum.yml -``start`` and ``end`` are given as values with units. -``num`` specifies the number of bins used to build the spectrum and must be given as an integer. +``start`` and ``end`` are given as values with units. +``num`` specifies the number of bins used to build the spectrum and must be given as an integer. TARDIS produces the spectrum via three different methods. For more information on these methods, visit the pages below: - + * real: :doc:`Basic Spectrum Generation <../../../physics/spectrum/basic>` * virtual: :ref:`Virtual Packet Scheme ` * integrated: :ref:`Formal Integral Method ` The three methods can be specified when plotting the spectrum (see the :doc:`quickstart guide <../../../quickstart>` for an example of this). -The following example shows how to edit variables for the different methods. +The following example shows how to edit variables for the different methods. .. code-block:: yaml @@ -36,14 +36,12 @@ The following example shows how to edit variables for the different methods. survival_probability: 0.1 enable_biasing: True virtual_packet_logging: True - + One can also change these parameters as they wish by reading in the configuration file and editing them before running the simulation (see :doc:`Reading a Configuration <../tutorial_read_configuration>`). .. warning:: - As of now, the `method` argument serves no purpose other than adding + As of now, the `method` argument serves no purpose other than adding the integrated spectrum to the HDF output when "integrated" is used as the method - (see :doc:`How to Store Simulations to HDF <../../output/how_to_to_hdf>`). - - + (see :doc:`How to Store Simulations to HDF <../../output/how_to_to_hdf>`). diff --git a/docs/io/configuration/components/supernova.rst b/docs/io/configuration/components/supernova.rst index f01583c5c92..b4731336faf 100644 --- a/docs/io/configuration/components/supernova.rst +++ b/docs/io/configuration/components/supernova.rst @@ -10,14 +10,12 @@ The supernova component of the configuration file contains some key information As luminosity (in units of energy/s) is computed by integrating over the spectral luminosity (in units of energy/s/wavelength), TARDIS sums over all discrete energy packets to compute luminosity when ran, attempting to converge the output spectrum to match `luminosity_requested` (see :doc:`../../../physics/update_and_conv/update_and_conv`). `luminosity_requested` can be given in standard units, such as erg/s or J/s, or in logarithmic units such as log_lsun. The range over which TARDIS sums these energy packets is set by default from 0 to infinity via `luminosity_wavelength_start` and `luminosity_wavelength_end`, respectively, so as to generate a spectrum whose total luminosity across the entire spectrum is `luminosity_requested`. However, if in the event only the luminosity within a certain range of wavelengths is known, then `luminosity_wavelength_start` and `luminosity_wavelength_end` can be changed as necessary to reflect this, allowing TARDIS to attempt to create a spectrum whose luminosity within the set range will converge to the value defined in `luminosity_requested`. -As an example, here is a sample code which will generate a specturm where only the luminosity of the visible light portion of the spectrum is given. Here, the output spectrum will have a luminosity of approximately :math:`10^{9.44}L_{sun}` within the visible range. +As an example, here is a sample code which will generate a specturm where only the luminosity of the visible light portion of the spectrum is given. Here, the output spectrum will have a luminosity of approximately :math:`10^{9.44}L_{sun}` within the visible range. .. code-block:: yaml - + supernova: luminosity_requested: 9.44 log_lsun time_explosion: 13 day luminosity_wavelength_start: 400 nm luminosity_wavelength_end: 700 nm - - diff --git a/docs/io/configuration/config_validator.rst b/docs/io/configuration/config_validator.rst index 6bb20d521a6..d3b07ae2f76 100644 --- a/docs/io/configuration/config_validator.rst +++ b/docs/io/configuration/config_validator.rst @@ -54,7 +54,7 @@ If the type declaration for this container is finished, you can specify all cont - default: 'This is a container item' - mandatory: False - help: This is a container item from the container one. - + - one_two: - sub_one_two_one: - property_type: string @@ -66,7 +66,7 @@ If the type declaration for this container is finished, you can specify all cont - default: 'This is a container item' - mandatory: False - help: This is a container item from the container one. - + - two_one: - quantity_range: - property_type: quantity_range @@ -76,7 +76,7 @@ If the type declaration for this container is finished, you can specify all cont How to use ^^^^^^^^^^ - + To use the default parser create a new config object form the class ConfigurationValidator either from a dictionaries or from YAML files: :: @@ -90,4 +90,3 @@ or - My_config = ConfigurationValidator.from_yaml (default configuration file, user configuration file). To access the configuration for TARDIS, use the method ``get_config``. - diff --git a/docs/io/configuration/example.rst b/docs/io/configuration/example.rst index e00aeb90a98..67d575353eb 100644 --- a/docs/io/configuration/example.rst +++ b/docs/io/configuration/example.rst @@ -13,7 +13,7 @@ It calculates a spectrum for a Type Ia supernova model 13 days after explosion, requesting a total output luminosity of .. math:: - + L = 10^{9.44}\, \mathrm{L}_{\odot} A simple power-law density profile (seventh order polynomial fit to the Nomoto diff --git a/docs/io/configuration/index.rst b/docs/io/configuration/index.rst index b2330f44ebd..99dd76608d4 100644 --- a/docs/io/configuration/index.rst +++ b/docs/io/configuration/index.rst @@ -9,7 +9,7 @@ The necessary parameters for a TARDIS simulation are provided via a `YAML ` or as +If ``virtual_packet_logging`` is set to ``True`` in either the :ref:`spectrum configuration ` or as an :ref:`argument to the run_tardis function `, then TARDIS will log information about the simulation's :ref:`virtual packets `. @@ -16,7 +16,7 @@ After running the simulation, the following information can be retrieved: .. list-table:: :header-rows: 1 - + * - Attribute of Simulation - Type - Description @@ -48,15 +48,15 @@ After running the simulation, the following information can be retrieved: * - ``transport.virt_packet_last_line_interaction_in_id`` - Numpy array - | If the last interaction was a line interaction, the - | line_interaction_in_id for that interaction + | line_interaction_in_id for that interaction | (see :doc:`how_to_physical_quantities`) * - ``transport.virt_packet_last_line_interaction_out_id`` - Numpy array - | If the last interaction was a line interaction, the - | line_interaction_out_id for that interaction + | line_interaction_out_id for that interaction | (see :doc:`how_to_physical_quantities`) * - ``transport.virt_packet_last_line_interaction_shell_id`` - Numpy array - | If the last interaction was a line interaction, the - | line_interaction_shell_id for that interaction - | (see :doc:`how_to_physical_quantities`) \ No newline at end of file + | line_interaction_shell_id for that interaction + | (see :doc:`how_to_physical_quantities`) diff --git a/docs/io/visualization/index.rst b/docs/io/visualization/index.rst index c98a32caae0..46c67d5f6a8 100644 --- a/docs/io/visualization/index.rst +++ b/docs/io/visualization/index.rst @@ -30,4 +30,4 @@ Jupyter Notebooks, making data exploration much easier. using_widgets Generating Custom Abundance Widget - Generating Data Exploration Widgets \ No newline at end of file + Generating Data Exploration Widgets diff --git a/docs/io/visualization/using_widgets.rst b/docs/io/visualization/using_widgets.rst index c8e03016fcd..41731fe40a3 100644 --- a/docs/io/visualization/using_widgets.rst +++ b/docs/io/visualization/using_widgets.rst @@ -4,7 +4,7 @@ Using TARDIS Widgets This page describes what each TARDIS Widget has to offer and how you can make the best use of it. If you're looking for the code to generate widgets, head -over to `Generating Custom Abundance Widget `_ section or +over to `Generating Custom Abundance Widget `_ section or `Generating Data Exploration Widgets `_ section to see the notebook in action. @@ -12,7 +12,7 @@ Currently, TARDIS supports the following widgets: Custom Abundance Widget ####################### -This widget (or GUI) allows you to develop custom model compositions +This widget (or GUI) allows you to develop custom model compositions graphically and output the model to a new file. .. image:: ../images/custom_abundance_widget.png @@ -20,13 +20,13 @@ graphically and output the model to a new file. The GUI consists of three parts: -1. **Visualization plot** - An interactive step graph that shows abundances -and densities as a function of velocity. +1. **Visualization plot** - An interactive step graph that shows abundances +and densities as a function of velocity. -2. **Data editor** - An interface to edit abundances, densities and velocity +2. **Data editor** - An interface to edit abundances, densities and velocity shells. -3. **File output** - An output module to save the model compositions as a CSVY +3. **File output** - An output module to save the model compositions as a CSVY file. Interacting with the GUI @@ -36,11 +36,11 @@ You can interact with this GUI in the following ways: Edit Abundances --------------- -There are two radio buttons which allow you to edit either single shell or -mutiple shells. The new input will be applied to selected shell(s) immediately -and the plot is updated at the same time. If you want to edit multiple shells -at a time, remember to choose the second radio button and set the range of -shell number using int slider. The selected shell(s) is highlighted in the +There are two radio buttons which allow you to edit either single shell or +mutiple shells. The new input will be applied to selected shell(s) immediately +and the plot is updated at the same time. If you want to edit multiple shells +at a time, remember to choose the second radio button and set the range of +shell number using int slider. The selected shell(s) is highlighted in the plot. .. image:: ../images/cus_abund_edit_abundance.gif @@ -48,10 +48,10 @@ plot. Normalize Abundances -------------------- -Click `Normalize` button to normalize the abundances on selected shell(s) to -1. If you wish to keep the abundance of a certain element unchanged during the -normalization, you can select the checkbox near that element to lock it. -The normalization will be applied to other elements and the sum of the +Click `Normalize` button to normalize the abundances on selected shell(s) to +1. If you wish to keep the abundance of a certain element unchanged during the +normalization, you can select the checkbox near that element to lock it. +The normalization will be applied to other elements and the sum of the abundances still remains at 1. .. image:: ../images/cus_abund_norm.gif @@ -59,8 +59,8 @@ abundances still remains at 1. Edit Densities -------------- -In `Edit Density` tab, you also can edit either single shell or the whole -density profile. To calculate a new profile, you need to choose the density +In `Edit Density` tab, you also can edit either single shell or the whole +density profile. To calculate a new profile, you need to choose the density type and input required parameters. .. image:: ../images/cus_abund_edit_density.gif @@ -68,8 +68,8 @@ type and input required parameters. Add New Element --------------- -At the bottom of the editor, the symbol input box allows you to add new element -or isotope to the model. It automatically recognizes whether the symbol exists +At the bottom of the editor, the symbol input box allows you to add new element +or isotope to the model. It automatically recognizes whether the symbol exists or whether the element is already in the model. .. image:: ../images/cus_abund_add_element.gif @@ -77,9 +77,9 @@ or whether the element is already in the model. Add New Shell ------------- -Another important functionality is to add new shell to the model. You need to -specify the velocity range of the new shell and abundances at that new shell -will be set to 0. Note that the existing shell(s) will be resized smartly if +Another important functionality is to add new shell to the model. You need to +specify the velocity range of the new shell and abundances at that new shell +will be set to 0. Note that the existing shell(s) will be resized smartly if the new shell overlaps with it. .. image:: ../images/cus_abund_add_shell.gif @@ -106,7 +106,7 @@ given in ascending order, from the innermost shell to the outermost. in the selected shell. 3. **Ion Abundances** - Fractional mass abundance of each ion (species) of the -selected element present in the selected shell. +selected element present in the selected shell. 4. **Level Abundances** - Fractional mass abundance of each level of the selected ion and element in the selected shell. @@ -158,7 +158,7 @@ particular wavelength range in the long spectrum. .. image:: ../images/line_info_spectrum_rangeslider.gif :alt: Demo of using rangeslider -Either you can **slide** the zoomed range by clicking and dragging it or you +Either you can **slide** the zoomed range by clicking and dragging it or you can **resize** it by dragging the handles (vertical bars) at its edges. Using other options in Modebar diff --git a/docs/physics/montecarlo/basicprinciples.rst b/docs/physics/montecarlo/basicprinciples.rst index 1b24408e1e0..555e4a813fe 100644 --- a/docs/physics/montecarlo/basicprinciples.rst +++ b/docs/physics/montecarlo/basicprinciples.rst @@ -116,13 +116,13 @@ The probability of a photon interacting after covering an optical depth f(\tau) &= 1 - \exp(-\tau). -With the inverse transformation method, the optical depth to the next interaction location may then be sampled by +With the inverse transformation method, the optical depth to the next interaction location may then be sampled by .. math:: \tau = - \mathrm{ln}(1 - z) - - + + which is equivalent to .. math:: diff --git a/docs/physics/montecarlo/index.rst b/docs/physics/montecarlo/index.rst index f23def90068..1e68656aed3 100644 --- a/docs/physics/montecarlo/index.rst +++ b/docs/physics/montecarlo/index.rst @@ -24,4 +24,4 @@ can also be found in various papers by L. Lucy and in the main TARDIS publicatio initialization propagation lineinteraction - estimators \ No newline at end of file + estimators diff --git a/docs/physics/montecarlo/propagation.rst b/docs/physics/montecarlo/propagation.rst index 15050b1c6d6..025ca28c8ea 100644 --- a/docs/physics/montecarlo/propagation.rst +++ b/docs/physics/montecarlo/propagation.rst @@ -48,7 +48,7 @@ Note that the propagation direction has also changed and now takes the value .. math:: \mu_f = \frac{l + r_i \mu_i}{r_f}. - + Supernova Expansion =================== @@ -66,8 +66,8 @@ shown in the animation. TARDIS simulates radiative transfer between an inner boundary (the photosphere) with a radius :math:`r_\mathrm{boundary\_inner}`, and an outer boundary (the outer edge of the supernova ejecta) with a radius :math:`r_\mathrm{boundary\_outer}`. Additionally, TARDIS divides the space between the inner and outer computational -boundaries into cells -- radial shells for which the plasma state is (spatially) constant. In the animation, 6 cells -are shown, being divided by the light blue lines. The boundaries of the computational domain and of these cells are +boundaries into cells -- radial shells for which the plasma state is (spatially) constant. In the animation, 6 cells +are shown, being divided by the light blue lines. The boundaries of the computational domain and of these cells are computed during the simulation setup (refer back to :doc:`../setup/model`). As TARDIS is a time-independent code, meaning that it calculates the spectra at an instant in time (namely at the time :math:`t_\mathrm{explosion}`), the radii of the boundaries (both of the computational domain and of the cells) do not change throughout the simulation. @@ -84,11 +84,11 @@ Reference Frames Because ejecta in the supernova is moving, TARDIS must take reference frames into account. -In TARDIS, two reference frames are of particular importance: the lab frame and the co-moving frame. In the lab +In TARDIS, two reference frames are of particular importance: the lab frame and the co-moving frame. In the lab frame, the center of the supernova is at rest; for example, the animation above is shown in the lab frame. This is the frame for which the spectra are calculated. -The co-moving frame at some point in the supernova, however, has the plasma at that point be at rest. This is the +The co-moving frame at some point in the supernova, however, has the plasma at that point be at rest. This is the frame of reference "according to the plasma." If a photon is propagating in the ejecta with a frequency :math:`\nu_\mathrm{lab}` in the lab frame and a propagation @@ -97,14 +97,14 @@ the supernova, the photon's frequency is shifted to .. math:: \nu_\mathrm{co-moving} = \nu_\mathrm{lab}\frac{1-\beta\mu}{\sqrt{1-\beta^2}} - + where :math:`\beta = \frac{v}{c} = \frac{r}{ct_\mathrm{explosion}}` (note again that :math:`v` is the velocity of the plasma at a radius :math:`r` from the center of the supernova). The term :math:`\frac{1-\beta\mu}{\sqrt{1-\beta^2}}` is known as the doppler factor. In the nonrelativistic limit (as :math:`v << c`), we get .. math:: \nu_\mathrm{co-moving} = \nu_\mathrm{lab}(1-\beta\mu). - + Note that if the photon is propagating away from the center of the supernova (:math:`\mu>0`) it is red-shifted (:math:`\nu_\mathrm{co-moving}<\nu_\mathrm{lab}`), and if the photon is propagating towards the center of the supernova (:math:`\mu<0`) it is blue-shifted (:math:`\nu_\mathrm{co-moving}>\nu_\mathrm{lab}`). @@ -144,7 +144,7 @@ The calculations for the distance to the inner cell boundary: .. image:: ../../graphics/d_inner.png :width: 500 - + Special care is taken at the edges of the computational domain. If a packet crosses back into the photosphere, it is discarded. Its propagation is stopped and it is no longer considered. Instead, processing the @@ -196,7 +196,7 @@ Photons and thus Monte Carlo packets can only interact with a line transition if their frequency in the co-moving frame corresponds to the energy difference between the atomic levels linked by the transition, i.e. if it comes into resonance. As discussed above, as a photon/packet propagates through the homologously expanding ejecta, its -co-moving frame frequency is continuously red- or blue-shifted (depending on the packet's propagation direction). +co-moving frame frequency is continuously red- or blue-shifted (depending on the packet's propagation direction). Thus, during its propagation through the supernova ejecta, a photon/packet may come into resonance with many line transitions. This and the fact that line transitions have a finite @@ -233,12 +233,12 @@ optical depth :math:`\tau_\mathrm{Sobolev}` (see :ref:`tau_sobolev`). This corre :math:`1-e^{-\tau_\mathrm{Sobolev}}` that the packet interacts with the atomic line. Distance to Next Event ----------------------- +---------------------- With these assumptions, the accumulation of optical depth along a packet's trajectory currently proceeds according -to the following scheme (which was originally introduced by :cite:`Mazzali1993`): +to the following scheme (which was originally introduced by :cite:`Mazzali1993`): given the current lab-frame frequency of the packet, the distance to the next -Sobolev point (i.e. to the next line resonance) is calculated as discussed above. +Sobolev point (i.e. to the next line resonance) is calculated as discussed above. Until this location, the packet continuously accumulates optical depth due to the possibility of electron-scattering. At the Sobolev point, the accumulated optical depth is instantaneously incremented by the Sobolev optical depth. Afterwards, the @@ -279,7 +279,7 @@ direction is sampled according to (see :ref:`Random Sampling `) .. math:: \mu_f = 2 z - 1. - + using a new random :math:`z` (between 0 and 1). For Thomson scattering, the energy of the packet in the co-moving frame is conserved, and thus the new energy and @@ -289,7 +289,7 @@ frequency of the packet in the lab frame (due to the doppler effect) is: \varepsilon_f & = \varepsilon_i \frac{1 - \beta \mu_i}{1 - \beta \mu_f} \\ \nu_f & = \nu_i \frac{1 - \beta \mu_i}{1 - \beta \mu_f} - + Here, the subscripts highlight the packet properties before (:math:`i` for initial) and after (:math:`f` for final) the scattering. Note that :math:`\mu_i` is the propagation direction prior to the interaction **but at the interaction location.** @@ -364,5 +364,5 @@ The following flow chart summarizes this process again: allpacketsprocessed[label="All packets\nprocessed?"] nextpacket[label="Select next packet\nfrom pool"] shortestdistance[label="Distance to cell\nedge shortest?"] - + } diff --git a/docs/physics/pyplot/lte_ionization_balance.py b/docs/physics/pyplot/lte_ionization_balance.py index 786547379cc..4c9aa722795 100644 --- a/docs/physics/pyplot/lte_ionization_balance.py +++ b/docs/physics/pyplot/lte_ionization_balance.py @@ -1,11 +1,12 @@ import os -from matplotlib import pyplot as plt + +import numpy as np +import pandas as pd from matplotlib import colors +from matplotlib import pyplot as plt import tardis.util.base from tardis.io.atom_data import AtomData -import numpy as np -import pandas as pd # Making 2 Figures for ionization balance and level populations diff --git a/docs/physics/pyplot/nebular_ionization_balance.py b/docs/physics/pyplot/nebular_ionization_balance.py index 7aa1b7b3850..f5feee0e307 100644 --- a/docs/physics/pyplot/nebular_ionization_balance.py +++ b/docs/physics/pyplot/nebular_ionization_balance.py @@ -1,13 +1,12 @@ import os +import numpy as np +import pandas as pd from matplotlib import colors +from matplotlib import pyplot as plt import tardis.util.base from tardis.io.atom_data import base -from matplotlib import pyplot as plt - -import numpy as np -import pandas as pd # Making 2 Figures for ionization balance and level populations diff --git a/docs/physics/pyplot/plot_mu_in_out_packet.py b/docs/physics/pyplot/plot_mu_in_out_packet.py index c71896d0341..940a2f9c7ef 100644 --- a/docs/physics/pyplot/plot_mu_in_out_packet.py +++ b/docs/physics/pyplot/plot_mu_in_out_packet.py @@ -1,5 +1,6 @@ -from pylab import * from astropy import units as u +from pylab import * + from tardis import constants as const x, y = x, y = mgrid[1:1000, 1:1000] diff --git a/docs/physics/setup/index.rst b/docs/physics/setup/index.rst index 38e716717a6..7163b92cf17 100644 --- a/docs/physics/setup/index.rst +++ b/docs/physics/setup/index.rst @@ -14,4 +14,4 @@ class. .. toctree:: setup_example model - plasma/index \ No newline at end of file + plasma/index diff --git a/docs/physics/setup/plasma/helium_nlte.rst b/docs/physics/setup/plasma/helium_nlte.rst index b328c4b9b4a..23b655c83d6 100644 --- a/docs/physics/setup/plasma/helium_nlte.rst +++ b/docs/physics/setup/plasma/helium_nlte.rst @@ -3,7 +3,7 @@ Helium NLTE The `helium_treatment` setting in the TARDIS config. file will accept one of three options: * `none`: The default setting. Populate helium in the same way as the other elements. - * `recomb-nlte`: Treats helium in NLTE using the analytical approximation outlined in :cite:`Boyle2017`. + * `recomb-nlte`: Treats helium in NLTE using the analytical approximation outlined in :cite:`Boyle2017`. * `numerical-nlte`: To be implemented. Will allow the use of a separate module (not distributed with TARDIS) to perform helium NLTE calculations numerically. Recombination He NLTE diff --git a/docs/physics/setup/plasma/index.rst b/docs/physics/setup/plasma/index.rst index 359c7585a98..78db6a1375a 100644 --- a/docs/physics/setup/plasma/index.rst +++ b/docs/physics/setup/plasma/index.rst @@ -5,7 +5,7 @@ Plasma ****** -The role of the plasma module is to determine the ionisation and excitation states of the elements of the +The role of the plasma module is to determine the ionisation and excitation states of the elements of the supernova ejecta, given the basic structure, including the elemental abundances, densities and radiation temperature. After the calculation of the plasma state, the :math:`\tau_{\textrm{sobolev}}` values can be calculated. @@ -81,7 +81,7 @@ TARDIS also allows for NLTE treatments of specified species, as well as special nlte helium_nlte - + .. _tau_sobolev: @@ -98,7 +98,7 @@ After the above calculations, TARDIS calculates the Sobolev optical depth :math: \tau_\textrm{Sobolev} = C_\textrm{Sobolev}\, \lambda\, f_{\textrm{lower}\rightarrow\textrm{upper}}\, t_\textrm{explosion}\, N_\textrm{lower} (1 - \frac{g_\textrm{lower}}{g_\textrm{upper}}\frac{N_\textrm{upper}}{N_\textrm{lower}}) - + Macro Atom Line Interaction Treatment ------------------------------------- @@ -107,5 +107,5 @@ The following page describes the macro atom treatment of line interactions: .. toctree:: :maxdepth: 2 - + macroatom diff --git a/docs/physics/setup/plasma/lte_plasma.rst b/docs/physics/setup/plasma/lte_plasma.rst index ce06d924651..607dfa70f39 100644 --- a/docs/physics/setup/plasma/lte_plasma.rst +++ b/docs/physics/setup/plasma/lte_plasma.rst @@ -47,4 +47,3 @@ Example Calculations .. .. plot:: physics/pyplot/lte_ionization_balance.py :include-source: - diff --git a/docs/physics/setup/plasma/nebular_plasma.rst b/docs/physics/setup/plasma/nebular_plasma.rst index 94f014a26c8..cf3bab1cc5a 100644 --- a/docs/physics/setup/plasma/nebular_plasma.rst +++ b/docs/physics/setup/plasma/nebular_plasma.rst @@ -88,4 +88,3 @@ Example Calculations .. .. plot:: physics/pyplot/nebular_ionization_balance.py :include-source: - diff --git a/docs/physics/setup/plasma/nlte.rst b/docs/physics/setup/plasma/nlte.rst index 33cb8bcac05..a59fc02ed2f 100644 --- a/docs/physics/setup/plasma/nlte.rst +++ b/docs/physics/setup/plasma/nlte.rst @@ -184,8 +184,3 @@ Next, we will group the stimulated emission and stimulated absorption terms, as - n_2 \bigg{(}A_{21} + C_{23} n_e + n_2 B_{23} \bar{J}_{23} \underbrace{\bigg{(}1 - \frac{n_3}{n_2}\frac{B_{32}}{B_{23}}\bigg{)}}_\text{stimulated emission term}\bigg{)} + n_3 (A_{32} + C_{32} n_e) - - - - - diff --git a/docs/physics/spectrum/index.rst b/docs/physics/spectrum/index.rst index 3de45aaa376..81cbd2ae2d3 100644 --- a/docs/physics/spectrum/index.rst +++ b/docs/physics/spectrum/index.rst @@ -4,7 +4,7 @@ Spectrum Generation ******************* -During the final :ref:`Monte Carlo iteration `, TARDIS calculates the emitted spectrum. We currently +During the final :ref:`Monte Carlo iteration `, TARDIS calculates the emitted spectrum. We currently employ three diiferent methods for doing this: a basic spectrum generation directly from the Monte Carlo packets, a method using so-called "virtual packets," and by the formal intrgral method. These are all detailed in the links below. @@ -17,4 +17,4 @@ below. .. toctree:: basic virtualpackets - formal_integral \ No newline at end of file + formal_integral diff --git a/docs/physics/spectrum/virtualpackets.rst b/docs/physics/spectrum/virtualpackets.rst index e64c025180c..10aad052ea7 100644 --- a/docs/physics/spectrum/virtualpackets.rst +++ b/docs/physics/spectrum/virtualpackets.rst @@ -86,7 +86,7 @@ dependence (represented by the non-uniform sampling rule for real packets, Here, :math:`\varepsilon` is the energy of the real packet that spawned the virtual ones. If virtual packets are generated during a real packet interaction at the location :math:`r`, their propagation direction is sampled uniformly -from the interval :math:`[\mu_{\mathrm{min}}, 1]`. +from the interval :math:`[\mu_{\mathrm{min}}, 1]`. .. math:: diff --git a/docs/resources/code_comparison/index.rst b/docs/resources/code_comparison/index.rst index ec2740d85bd..7041fe0644a 100644 --- a/docs/resources/code_comparison/index.rst +++ b/docs/resources/code_comparison/index.rst @@ -15,4 +15,3 @@ For our code comparison, we will calculate spectra at 5, 10, 15, 20 days post-ex toy_models/reading blondin toymodel plasma_compare/plasma_compare - diff --git a/docs/resources/code_comparison/toy_models/blondin_model_compare_01.yml b/docs/resources/code_comparison/toy_models/blondin_model_compare_01.yml index 88d7f249701..cc7e7c213cf 100644 --- a/docs/resources/code_comparison/toy_models/blondin_model_compare_01.yml +++ b/docs/resources/code_comparison/toy_models/blondin_model_compare_01.yml @@ -31,7 +31,7 @@ montecarlo: damping_constant: 0.5 threshold: 0.05 fraction: 0.8 - + t_inner: damping_constant: 0.0 @@ -41,4 +41,3 @@ spectrum: num: 10000 integrated: interpolate_shells: 80 - \ No newline at end of file diff --git a/docs/resources/code_comparison/toy_models/blondin_model_compare_06.yml b/docs/resources/code_comparison/toy_models/blondin_model_compare_06.yml index 194833e922c..9940c8702bd 100644 --- a/docs/resources/code_comparison/toy_models/blondin_model_compare_06.yml +++ b/docs/resources/code_comparison/toy_models/blondin_model_compare_06.yml @@ -31,7 +31,7 @@ montecarlo: damping_constant: 0.5 threshold: 0.05 fraction: 0.8 - + t_inner: damping_constant: 0.0 @@ -41,4 +41,3 @@ spectrum: num: 10000 integrated: interpolate_shells: 80 - \ No newline at end of file diff --git a/docs/resources/credits.rst b/docs/resources/credits.rst index db36f05d484..3588fac87ea 100644 --- a/docs/resources/credits.rst +++ b/docs/resources/credits.rst @@ -189,4 +189,3 @@ The following BibTeX entries are needed for the references: doi = {10.5281/zenodo.10207663}, url = {https://doi.org/10.5281/zenodo.10207663} } - diff --git a/docs/resources/credits_template.rst b/docs/resources/credits_template.rst index 0a6d97af335..8f1c68333a4 100644 --- a/docs/resources/credits_template.rst +++ b/docs/resources/credits_template.rst @@ -26,7 +26,7 @@ following paragraph to the Acknowledgement section: sponsored project of NumFOCUS. \\textsc{tardis} makes extensive use of Astropy and Pyne. If you use any of the full relativity treatments or use TARDIS for modelling -Type II supernovae, also add `Spectral modeling of type II supernovae. I. Dilution factors `_ +Type II supernovae, also add `Spectral modeling of type II supernovae. I. Dilution factors `_ to the Acknowledgement. .. parsed-literal:: diff --git a/docs/resources/research_done_using_TARDIS/research_papers.rst b/docs/resources/research_done_using_TARDIS/research_papers.rst index cecc55fa9b9..19106a9d3fb 100644 --- a/docs/resources/research_done_using_TARDIS/research_papers.rst +++ b/docs/resources/research_done_using_TARDIS/research_papers.rst @@ -2,146 +2,144 @@ Papers Using TARDIS ################### **Dutta, Anirban, Singh, Avinash, Anupama, G. C., et al.** 2021, MNRAS, *"SN 2017hpa: a carbon-rich Type Ia supernova"* `(ADS Link) `__ - + **Kerzendorf, Wolfgang E., Vogl, Christian, Buchner, Johannes, et al.** 2021, ApJL, *"Dalek: A Deep Learning Emulator for TARDIS"* `(ADS Link) `__ - + **Magee, M. R., Maguire, K., Kotak, R., et al.** 2021, MNRAS, *"Exploring the diversity of double-detonation explosions for Type Ia supernovae: effects of the post-explosion helium shell composition"* `(ADS Link) `__ - + **Fiore, A., Chen, T. -W., Jerkstrand, A., et al.** 2021, MNRAS, *"SN 2017gci: a nearby Type I Superluminous Supernova with a bumpy tail"* `(ADS Link) `__ - + **Williamson, Marc, Kerzendorf, Wolfgang, Modjaz, Maryam** 2021, ApJ, *"Modeling Type Ic Supernovae with TARDIS: Hidden Helium in SN 1994I?"* `(ADS Link) `__ - + **Barna, Barnabás, Szalai, Tamás, Jha, Saurabh W., et al.** 2021, MNRAS, *"SN 2019muj - a well-observed Type Iax supernova that bridges the luminosity gap of the class"* `(ADS Link) `__ - + **Magee, M. R., Maguire, K.** 2020, A&A, *"An investigation of* :sup:`56`\ *Ni shells as the source of early light curve bumps in type Ia supernovae"* `(ADS Link) `__ - + **Chen, Xingzhuo, Hu, Lei, Wang, Lifan** 2020, ApJS, *"Artificial Intelligence-Assisted Inversion (AIAI) of Synthetic Type Ia Supernova Spectra"* `(ADS Link) `__ - + **Gillanders, J. H., Sim, S. A., Smartt, S. J.** 2020, MNRAS, *"AT2018kzr: the merger of an oxygen-neon white dwarf and a neutron star or black hole"* `(ADS Link) `__ - + **Tomasella, Lina, Stritzinger, Maximilian, Benetti, Stefano, et al.** 2020, MNRAS, *"Observations of the low-luminosity Type Iax supernova 2019gsc: a fainter clone of SN 2008ha?"* `(ADS Link) `__ - + **Miller, A. A., Magee, M. R., Polin, A., et al.** 2020, ApJ, *"The Spectacular Ultraviolet Flash from the Peculiar Type Ia Supernova 2019yvq"* `(ADS Link) `__ - + **Bouquin, Daina R., Chivvis, Daniel A., Henneken, Edwin, et al.** 2020, ApJS, *"Credit Lost: Two Decades of Software Citation in Astronomy"* `(ADS Link) `__ - + **Livneh, Ran, Katz, Boaz** 2020, MNRAS, *"An asymmetric explosion mechanism may explain the diversity of Si II linewidths in Type Ia supernovae"* `(ADS Link) `__ - + **Kawabata, Miho, Maeda, Keiichi, Yamanaka, Masayuki, et al.** 2020, ApJ, *"SN 2019ein: New Insights into the Similarities and Diversity among High-velocity Type Ia Supernovae"* `(ADS Link) `__ - + **Srivastav, Shubham, Smartt, Stephen J., Leloudas, Giorgos, et al.** 2020, ApJL, *"The Lowest of the Low: Discovery of SN 2019gsc and the Nature of Faint Iax Supernovae"* `(ADS Link) `__ - + **Magee, M. R., Maguire, K., Kotak, R., et al.** 2020, A&A, *"Determining the* :sup:`56`\ *Ni distribution of type Ia supernovae from observations within days of explosion"* `(ADS Link) `__ - + **Vogl, C., Kerzendorf, W. E., Sim, S. A., et al.** 2020, A&A, *"Spectral modeling of type II supernovae. II. A machine-learning approach to quantitative spectroscopic analysis"* `(ADS Link) `__ - + **McBrien, Owen R., Smartt, Stephen J., Chen, Ting-Wan, et al.** 2019, ApJL, *"SN2018kzr: A Rapidly Declining Transient from the Destruction of a White Dwarf"* `(ADS Link) `__ - + **Watson, Darach, Hansen, Camilla J., Selsing, Jonatan, et al.** 2019, Natur, *"Identification of strontium in the merger of two neutron stars"* `(ADS Link) `__ - + **Jacobson-Galán, Wynn V., Foley, Ryan J., Schwab, Josiah, et al.** 2019, MNRAS, *"Detection of circumstellar helium in Type Iax progenitor systems"* `(ADS Link) `__ - + **Noebauer, Ulrich M., Sim, Stuart A.** 2019, LRCA, *"Monte Carlo radiative transfer"* `(ADS Link) `__ - + **Chatzopoulos, E., Weide, K.** 2019, ApJ, *"Gray Radiation Hydrodynamics with the FLASH Code for Astrophysical Applications"* `(ADS Link) `__ - + **Mulligan, Brian W., Zhang, Kaicheng, Wheeler, J. Craig** 2019, MNRAS, *"Exploring the shell model of high-velocity features of Type Ia supernovae using TARDIS"* `(ADS Link) `__ - + **Magee, M. R., Sim, S. A., Kotak, R., et al.** 2019, A&A, *"Detecting the signatures of helium in type Iax supernovae"* `(ADS Link) `__ - + **Heringer, E., van Kerkwijk, M. H., Sim, S. A., et al.** 2019, ApJ, *"Spectral Sequences of Type Ia Supernovae. II. Carbon as a Diagnostic Tool for Explosion Mechanisms"* `(ADS Link) `__ - + **Izzo, L., de Ugarte Postigo, A., Maeda, K., et al.** 2019, Natur, *"Signatures of a jet cocoon in early spectra of a supernova associated with a γ-ray burst"* `(ADS Link) `__ - + **Vogl, C., Sim, S. A., Noebauer, U. M., et al.** 2019, A&A, *"Spectral modeling of type II supernovae. I. Dilution factors"* `(ADS Link) `__ - + **Ergon, M., Fransson, C., Jerkstrand, A., et al.** 2018, A&A, *"Monte-Carlo methods for NLTE spectral synthesis of supernovae"* `(ADS Link) `__ - + **Barna, Barnabás, Szalai, Tamás, Kerzendorf, Wolfgang E., et al.** 2018, MNRAS, *"Type Iax supernovae as a few-parameter family"* `(ADS Link) `__ - + **Prentice, S. J., Maguire, K., Smartt, S. J., et al.** 2018, ApJL, *"The Cow: Discovery of a Luminous, Hot, and Rapidly Evolving Transient"* `(ADS Link) `__ - + **Beaujean, Frederik, Eggers, Hans C., Kerzendorf, Wolfgang E.** 2018, MNRAS, *"Bayesian modelling of uncertainties of Monte Carlo radiative-transfer simulations"* `(ADS Link) `__ - + **Magee, M. R., Sim, S. A., Kotak, R., et al.** 2018, A&A, *"Modelling the early time behaviour of type Ia supernovae: effects of the* :sup:`56`\ *Ni distribution"* `(ADS Link) `__ - + **Röpke, Friedrich K., Sim, Stuart A.** 2018, SSRv, *"Models for Type Ia Supernovae and Related Astrophysical Transients"* `(ADS Link) `__ - + **Barna, Barnabás, Szalai, Tamás, Kromer, Markus, et al.** 2017, MNRAS, *"Abundance tomography of Type Iax SN 2011ay with tardis"* `(ADS Link) `__ - + **Smartt, S. J., Chen, T. -W., Jerkstrand, A., et al.** 2017, Natur, *"A kilonova as the electromagnetic counterpart to a gravitational-wave source"* `(ADS Link) `__ - + **Heringer, E., van Kerkwijk, M. H., Sim, S. A., et al.** 2017, ApJ, *"Spectral Sequences of Type Ia Supernovae. I. Connecting Normal and Subluminous SNe Ia and the Presence of Unburned Carbon"* `(ADS Link) `__ - + **Magee, M. R., Kotak, R., Sim, S. A., et al.** 2017, A&A, *"Growing evidence that SNe Iax are not a one-parameter family. The case of PS1-12bwh"* `(ADS Link) `__ - + **Boyle, Aoife, Sim, Stuart A., Hachinger, Stephan, et al.** 2017, A&A, *"Helium in double-detonation models of type Ia supernovae"* `(ADS Link) `__ - + **Noebauer, U. M., Taubenberger, S., Blinnikov, S., et al.** 2016, MNRAS, *"Type Ia supernovae within dense carbon- and oxygen-rich envelopes: a model for `Super-Chandrasekhar' explosions?"* `(ADS Link) `__ - + **Inserra, C., Bulla, M., Sim, S. A., et al.** 2016, ApJ, *"Spectropolarimetry of Superluminous Supernovae: Insight into Their Geometry"* `(ADS Link) `__ - + **Szalai, Tamás, Vinkó, József, Nagy, Andrea P., et al.** 2016, MNRAS, *"The continuing story of SN IIb 2013df: new optical and IR observations and analysis"* `(ADS Link) `__ - + **Magee, M. R., Kotak, R., Sim, S. A., et al.** 2016, A&A, *"The type Iax supernova, SN 2015H. A white dwarf deflagration candidate"* `(ADS Link) `__ - + **Dubernet, M. L., Antony, B. K., Ba, Y. A., et al.** 2016, JPhB, *"The virtual atomic and molecular data centre (VAMDC) consortium"* `(ADS Link) `__ - + **Parrent, J. T., Howell, D. A., Fesen, R. A., et al.** 2016, MNRAS, *"Comparative analysis of SN 2012dn optical spectra: days -14 to +114"* `(ADS Link) `__ - + **Young, P. R., Dere, K. P., Landi, E., et al.** 2016, JPhB, *"The CHIANTI atomic database"* `(ADS Link) `__ - + **Noebauer, U. M., Sim, S. A.** 2015, MNRAS, *"Self-consistent modelling of line-driven hot-star winds with Monte Carlo radiation hydrodynamics"* `(ADS Link) `__ - + **Matthews, J. H., Knigge, C., Long, K. S., et al.** 2015, MNRAS, *"The impact of accretion disc winds on the optical spectra of cataclysmic variables"* `(ADS Link) `__ - - **Kerzendorf, Wolfgang E., Sim, Stuart A.** 2014, MNRAS, *"A spectral synthesis code for rapid modelling of supernovae"* `(ADS Link) `__ - + **Kerzendorf, Wolfgang E., Sim, Stuart A.** 2014, MNRAS, *"A spectral synthesis code for rapid modelling of supernovae"* `(ADS Link) `__ diff --git a/docs/resources/zreferences.rst b/docs/resources/zreferences.rst index df7fd39b077..a68cf675fc4 100644 --- a/docs/resources/zreferences.rst +++ b/docs/resources/zreferences.rst @@ -12,19 +12,19 @@ References Glossary ======== -.. glossary:: - +.. glossary:: + Chianti CHIANTI consists of a critically evaluated set of up-to-date atomic data, together with user-friendly programs written in Interactive Data Language (IDL) and Python to calculate the spectra from astrophysical plasmas. - + Meta-Stable Metastability is the condition of a system where the system has stability, but is not as stable as in the system's state of least energy. - + Synapps SYNAPPS is an open-source spectrum fitter embedding a highly parameterized synthetic SN spectrum calculation within a parallel asynchronous optimizer, created to systematically interpret large sets of SN spectroscopy data. - + TOML TOML (Tom's Obvious, Minimal Language) is a minimal configuration file format that is designed to be easy to read due to obvious semantics. It is designed to map unambiguously to a hash table and to be easy to parse into data structures in a wide variety of languages. TOML files have the ending ".toml". - + YAML - YAML (YAML Ain't Markup Language) is a human friendly data serialization standard for all programming languages. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML files have the ending ".yml". \ No newline at end of file + YAML (YAML Ain't Markup Language) is a human friendly data serialization standard for all programming languages. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML files have the ending ".yml". diff --git a/pyproject.toml b/pyproject.toml index 529a9d9300a..daf7895fa04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -172,7 +172,7 @@ tardis = ["data/*"] tardis_grid = ["tests/data/*", "./"] tardis_io = [ "configuration/schemas/*", - "configuration/tests/data/*", + "configuration/tests/data/*", "model/readers/tests/data/*" ] tardis_model_tests = ["data/*"] @@ -216,4 +216,4 @@ sort_commits = "newest" [tool.git-cliff.remote.github] owner = "tardis-sn" -repo = "tardis" \ No newline at end of file +repo = "tardis" diff --git a/setup.py b/setup.py index dd5a522af29..6a181d6cbf0 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ from setuptools import setup - # First provide helpful messages if contributors try and run legacy commands # for tests or docs. diff --git a/tardis/__init__.py b/tardis/__init__.py index 5d2ec94e90b..e7ed92b7bf0 100644 --- a/tardis/__init__.py +++ b/tardis/__init__.py @@ -22,7 +22,7 @@ " after TARDIS." ) else: - from astropy import physical_constants, astronomical_constants + from astropy import astronomical_constants, physical_constants physical_constants.set("codata2014") astronomical_constants.set("iau2012") diff --git a/tardis/_astropy_init.py b/tardis/_astropy_init.py index bd4532450e4..55510a7bfa9 100644 --- a/tardis/_astropy_init.py +++ b/tardis/_astropy_init.py @@ -10,4 +10,5 @@ # Create the test function for self test from astropy.tests.runner import TestRunner + test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) diff --git a/tardis/analysis/opacities.py b/tardis/analysis/opacities.py index e1b383233c1..86972a592c5 100644 --- a/tardis/analysis/opacities.py +++ b/tardis/analysis/opacities.py @@ -1,11 +1,13 @@ """This module provides an opacity calculator class with which the opacities and optical depth information may be extracted from Tardis runs.""" import logging -import numpy as np + import astropy.units as units -from tardis import constants as const +import numpy as np from astropy.modeling.models import Blackbody +from tardis import constants as const + logger = logging.getLogger(__name__) diff --git a/tardis/base.py b/tardis/base.py index aafdb593abb..41f59506b75 100644 --- a/tardis/base.py +++ b/tardis/base.py @@ -4,7 +4,6 @@ import logging - logger = logging.getLogger(__name__) @@ -70,9 +69,9 @@ def run_tardis( ----- Please see the `logging tutorial `_ to know more about `log_level` and `specific` options. """ - from tardis.io.logger.logger import logging_state - from tardis.io.configuration.config_reader import Configuration from tardis.io.atom_data.base import AtomData + from tardis.io.configuration.config_reader import Configuration + from tardis.io.logger.logger import logging_state from tardis.simulation import Simulation if isinstance(config, Configuration): diff --git a/tardis/conftest.py b/tardis/conftest.py index e5af08a5cdf..526f501f3df 100644 --- a/tardis/conftest.py +++ b/tardis/conftest.py @@ -5,12 +5,12 @@ import pytest from astropy.version import version as astropy_version +from tardis import run_tardis from tardis.io.configuration.config_reader import Configuration from tardis.io.util import YAMLLoader, yaml_load_file from tardis.simulation import Simulation from tardis.tests.fixtures.atom_data import * from tardis.tests.fixtures.regression_data import regression_data -from tardis import run_tardis # ensuring that regression_data is not removed by ruff assert regression_data is not None @@ -33,10 +33,8 @@ ASTROPY_HEADER = True else: try: - from pytest_astropy_header.display import ( - PYTEST_HEADER_MODULES, - TESTED_VERSIONS, - ) + from pytest_astropy_header.display import (PYTEST_HEADER_MODULES, + TESTED_VERSIONS) ASTROPY_HEADER = True except ImportError: diff --git a/tardis/data/default_tardis_internal_config.yml b/tardis/data/default_tardis_internal_config.yml index 0bcdbc53b37..bb39b39e793 100644 --- a/tardis/data/default_tardis_internal_config.yml +++ b/tardis/data/default_tardis_internal_config.yml @@ -1 +1 @@ -data_dir: \ No newline at end of file +data_dir: diff --git a/tardis/energy_input/GXPacket.py b/tardis/energy_input/GXPacket.py index dd8792876bc..de24827d1b2 100644 --- a/tardis/energy_input/GXPacket.py +++ b/tardis/energy_input/GXPacket.py @@ -1,15 +1,12 @@ from enum import IntEnum + import numpy as np -from numba import int64, float64 +from numba import float64, int64 from numba.experimental import jitclass from tardis.energy_input.samplers import sample_decay_time, sample_energy -from tardis.energy_input.util import ( - get_index, - get_random_unit_vector, - doppler_factor_3d, - H_CGS_KEV, -) +from tardis.energy_input.util import (H_CGS_KEV, doppler_factor_3d, get_index, + get_random_unit_vector) class GXPacketStatus(IntEnum): diff --git a/tardis/energy_input/energy_source.py b/tardis/energy_input/energy_source.py index 4fa33734944..270847fa524 100644 --- a/tardis/energy_input/energy_source.py +++ b/tardis/energy_input/energy_source.py @@ -2,13 +2,9 @@ import pandas as pd import radioactivedecay as rd -from tardis.util.base import ( - atomic_number2element_symbol, -) -from tardis.energy_input.util import ( - convert_half_life_to_astropy_units, - ELECTRON_MASS_ENERGY_KEV, -) +from tardis.energy_input.util import (ELECTRON_MASS_ENERGY_KEV, + convert_half_life_to_astropy_units) +from tardis.util.base import atomic_number2element_symbol def setup_input_energy(nuclear_data, source): diff --git a/tardis/energy_input/gamma_packet_loop.py b/tardis/energy_input/gamma_packet_loop.py index 385febda679..39905b73d1d 100644 --- a/tardis/energy_input/gamma_packet_loop.py +++ b/tardis/energy_input/gamma_packet_loop.py @@ -2,31 +2,18 @@ from numba import njit from tardis.energy_input.gamma_ray_estimators import deposition_estimator_kasen -from tardis.energy_input.gamma_ray_grid import ( - distance_trace, - move_packet, -) +from tardis.energy_input.gamma_ray_grid import distance_trace, move_packet from tardis.energy_input.gamma_ray_interactions import ( - compton_scatter, - get_compton_fraction_artis, - pair_creation_packet, - scatter_type, -) + compton_scatter, get_compton_fraction_artis, pair_creation_packet, + scatter_type) from tardis.energy_input.GXPacket import GXPacketStatus -from tardis.energy_input.util import ( - C_CGS, - H_CGS_KEV, - doppler_factor_3d, - get_index, -) -from tardis.opacities.opacities import ( - SIGMA_T, - compton_opacity_calculation, - kappa_calculation, - pair_creation_opacity_artis, - pair_creation_opacity_calculation, - photoabsorption_opacity_calculation, -) +from tardis.energy_input.util import (C_CGS, H_CGS_KEV, doppler_factor_3d, + get_index) +from tardis.opacities.opacities import (SIGMA_T, compton_opacity_calculation, + kappa_calculation, + pair_creation_opacity_artis, + pair_creation_opacity_calculation, + photoabsorption_opacity_calculation) from tardis.transport.montecarlo import njit_dict_no_parallel diff --git a/tardis/energy_input/gamma_ray_channel.py b/tardis/energy_input/gamma_ray_channel.py index 6bbb7a9685a..74adbe3870b 100644 --- a/tardis/energy_input/gamma_ray_channel.py +++ b/tardis/energy_input/gamma_ray_channel.py @@ -1,7 +1,8 @@ import logging + +import astropy.units as u import numpy as np import pandas as pd -import astropy.units as u import radioactivedecay as rd from tardis.energy_input.util import KEV2ERG diff --git a/tardis/energy_input/gamma_ray_estimators.py b/tardis/energy_input/gamma_ray_estimators.py index e28ba5029ff..4454c810da7 100644 --- a/tardis/energy_input/gamma_ray_estimators.py +++ b/tardis/energy_input/gamma_ray_estimators.py @@ -1,18 +1,12 @@ import numpy as np from numba import njit -from tardis.energy_input.util import ( - ELECTRON_MASS_ENERGY_KEV, - H_CGS_KEV, - angle_aberration_gamma, - doppler_factor_3d, -) -from tardis.opacities.opacities import ( - SIGMA_T, - compton_opacity_calculation, - kappa_calculation, - photoabsorption_opacity_calculation, -) +from tardis.energy_input.util import (ELECTRON_MASS_ENERGY_KEV, H_CGS_KEV, + angle_aberration_gamma, + doppler_factor_3d) +from tardis.opacities.opacities import (SIGMA_T, compton_opacity_calculation, + kappa_calculation, + photoabsorption_opacity_calculation) from tardis.transport.montecarlo import njit_dict_no_parallel diff --git a/tardis/energy_input/gamma_ray_grid.py b/tardis/energy_input/gamma_ray_grid.py index 1f86be634af..5f1d486d80f 100644 --- a/tardis/energy_input/gamma_ray_grid.py +++ b/tardis/energy_input/gamma_ray_grid.py @@ -1,12 +1,9 @@ import numpy as np from numba import njit +from tardis.energy_input.util import (C_CGS, doppler_factor_3d, + solve_quadratic_equation) from tardis.transport.montecarlo import njit_dict_no_parallel -from tardis.energy_input.util import ( - doppler_factor_3d, - solve_quadratic_equation, - C_CGS, -) @njit(**njit_dict_no_parallel) diff --git a/tardis/energy_input/gamma_ray_interactions.py b/tardis/energy_input/gamma_ray_interactions.py index 649a526af72..b134dcaeb91 100644 --- a/tardis/energy_input/gamma_ray_interactions.py +++ b/tardis/energy_input/gamma_ray_interactions.py @@ -2,20 +2,14 @@ from numba import njit from tardis.energy_input.GXPacket import GXPacketStatus -from tardis.energy_input.util import ( - ELECTRON_MASS_ENERGY_KEV, - H_CGS_KEV, - angle_aberration_gamma, - compton_theta_distribution, - doppler_factor_3d, - euler_rodrigues, - get_perpendicular_vector, - get_random_unit_vector, -) -from tardis.opacities.opacities import ( - compton_opacity_partial, - kappa_calculation, -) +from tardis.energy_input.util import (ELECTRON_MASS_ENERGY_KEV, H_CGS_KEV, + angle_aberration_gamma, + compton_theta_distribution, + doppler_factor_3d, euler_rodrigues, + get_perpendicular_vector, + get_random_unit_vector) +from tardis.opacities.opacities import (compton_opacity_partial, + kappa_calculation) from tardis.transport.montecarlo import njit_dict_no_parallel diff --git a/tardis/energy_input/gamma_ray_packet_source.py b/tardis/energy_input/gamma_ray_packet_source.py index c880bdf3632..48e3ed94437 100644 --- a/tardis/energy_input/gamma_ray_packet_source.py +++ b/tardis/energy_input/gamma_ray_packet_source.py @@ -1,19 +1,11 @@ import numpy as np import pandas as pd -from tardis.energy_input.energy_source import ( - positronium_continuum, -) -from tardis.energy_input.GXPacket import ( - GXPacketCollection, -) +from tardis.energy_input.energy_source import positronium_continuum +from tardis.energy_input.GXPacket import GXPacketCollection from tardis.energy_input.samplers import sample_energy -from tardis.energy_input.util import ( - H_CGS_KEV, - doppler_factor_3d, - get_index, - get_random_unit_vector, -) +from tardis.energy_input.util import (H_CGS_KEV, doppler_factor_3d, get_index, + get_random_unit_vector) from tardis.transport.montecarlo.packet_source import BasePacketSource diff --git a/tardis/energy_input/gamma_ray_transport.py b/tardis/energy_input/gamma_ray_transport.py index bd769191195..ab587bc8f94 100644 --- a/tardis/energy_input/gamma_ray_transport.py +++ b/tardis/energy_input/gamma_ray_transport.py @@ -5,10 +5,8 @@ import pandas as pd import radioactivedecay as rd -from tardis.energy_input.energy_source import ( - get_all_isotopes, - setup_input_energy, -) +from tardis.energy_input.energy_source import (get_all_isotopes, + setup_input_energy) from tardis.opacities.opacities import M_P # Energy: keV, exported as eV for SF solver diff --git a/tardis/energy_input/main_gamma_ray_loop.py b/tardis/energy_input/main_gamma_ray_loop.py index 654656300ad..8a95c54ad51 100644 --- a/tardis/energy_input/main_gamma_ray_loop.py +++ b/tardis/energy_input/main_gamma_ray_loop.py @@ -4,32 +4,18 @@ import numpy as np import pandas as pd -from tardis.energy_input.energy_source import ( - get_nuclear_lines_database, -) +from tardis.energy_input.energy_source import get_nuclear_lines_database from tardis.energy_input.gamma_packet_loop import gamma_packet_loop -from tardis.energy_input.gamma_ray_channel import ( - calculate_total_decays, - create_inventories_dict, - create_isotope_dicts, -) - -from tardis.energy_input.gamma_ray_transport import ( - calculate_total_decays_old, - create_isotope_dicts_old, - create_inventories_dict_old, -) +from tardis.energy_input.gamma_ray_channel import (calculate_total_decays, + create_inventories_dict, + create_isotope_dicts) from tardis.energy_input.gamma_ray_packet_source import RadioactivePacketSource from tardis.energy_input.gamma_ray_transport import ( - calculate_average_energies, - calculate_average_power_per_mass, - calculate_ejecta_velocity_volume, - calculate_energy_per_mass, - decay_chain_energies, - distribute_packets, - get_taus, - iron_group_fraction_per_shell, -) + calculate_average_energies, calculate_average_power_per_mass, + calculate_ejecta_velocity_volume, calculate_energy_per_mass, + calculate_total_decays_old, create_inventories_dict_old, + create_isotope_dicts_old, decay_chain_energies, distribute_packets, + get_taus, iron_group_fraction_per_shell) from tardis.energy_input.GXPacket import GXPacket logger = logging.getLogger(__name__) diff --git a/tardis/energy_input/tests/conftest.py b/tardis/energy_input/tests/conftest.py index b36623ef660..27fbc9836c9 100644 --- a/tardis/energy_input/tests/conftest.py +++ b/tardis/energy_input/tests/conftest.py @@ -1,5 +1,5 @@ -import pytest import numpy as np +import pytest from tardis.energy_input.GXPacket import GXPacket, GXPacketStatus from tardis.energy_input.util import H_CGS_KEV diff --git a/tardis/energy_input/tests/test_energy_source.py b/tardis/energy_input/tests/test_energy_source.py index 106124f1a68..69f61cd70ff 100644 --- a/tardis/energy_input/tests/test_energy_source.py +++ b/tardis/energy_input/tests/test_energy_source.py @@ -2,9 +2,7 @@ import numpy.testing as npt import pytest -from tardis.energy_input.samplers import ( - create_energy_cdf, -) +from tardis.energy_input.samplers import create_energy_cdf @pytest.mark.parametrize( diff --git a/tardis/energy_input/tests/test_gamma_ray_channel.py b/tardis/energy_input/tests/test_gamma_ray_channel.py index 5842ba67783..c7e88fe23b7 100644 --- a/tardis/energy_input/tests/test_gamma_ray_channel.py +++ b/tardis/energy_input/tests/test_gamma_ray_channel.py @@ -1,23 +1,20 @@ -import pytest -import numpy as np from pathlib import Path + +import astropy.constants as const import astropy.units as u +import numpy as np import numpy.testing as npt +import pytest import radioactivedecay as rd -import astropy.constants as const from radioactivedecay import converters -from tardis.model import SimulationState +from tardis.energy_input.energy_source import get_nuclear_lines_database +from tardis.energy_input.gamma_ray_channel import (calculate_total_decays, + create_inventories_dict, + create_isotope_decay_df, + create_isotope_dicts) from tardis.io.configuration import config_reader -from tardis.energy_input.energy_source import ( - get_nuclear_lines_database, -) -from tardis.energy_input.gamma_ray_channel import ( - create_isotope_dicts, - create_inventories_dict, - calculate_total_decays, - create_isotope_decay_df, -) +from tardis.model import SimulationState @pytest.fixture(scope="module") diff --git a/tardis/energy_input/tests/test_gamma_ray_grid.py b/tardis/energy_input/tests/test_gamma_ray_grid.py index 11a6f394ae5..b89fb2a5799 100644 --- a/tardis/energy_input/tests/test_gamma_ray_grid.py +++ b/tardis/energy_input/tests/test_gamma_ray_grid.py @@ -1,12 +1,9 @@ -import pytest -import numpy.testing as npt import numpy as np +import numpy.testing as npt +import pytest -from tardis.energy_input.gamma_ray_grid import ( - calculate_distance_radial, - distance_trace, - move_packet, -) +from tardis.energy_input.gamma_ray_grid import (calculate_distance_radial, + distance_trace, move_packet) @pytest.mark.xfail(reason="To be implemented") diff --git a/tardis/energy_input/tests/test_gamma_ray_interactions.py b/tardis/energy_input/tests/test_gamma_ray_interactions.py index fedc16d9619..a836a0b9d57 100644 --- a/tardis/energy_input/tests/test_gamma_ray_interactions.py +++ b/tardis/energy_input/tests/test_gamma_ray_interactions.py @@ -1,15 +1,12 @@ -import pytest import numpy as np import numpy.testing as npt +import pytest -from tardis.energy_input.gamma_ray_interactions import ( - compton_scatter, - pair_creation_packet, - scatter_type, -) -from tardis.energy_input.util import ELECTRON_MASS_ENERGY_KEV, H_CGS_KEV - +from tardis.energy_input.gamma_ray_interactions import (compton_scatter, + pair_creation_packet, + scatter_type) from tardis.energy_input.GXPacket import GXPacketStatus +from tardis.energy_input.util import ELECTRON_MASS_ENERGY_KEV, H_CGS_KEV @pytest.mark.xfail(reason="To be implemented") diff --git a/tardis/energy_input/tests/test_gamma_ray_transport.py b/tardis/energy_input/tests/test_gamma_ray_transport.py index c7b05308b1f..bdb63e3ae23 100644 --- a/tardis/energy_input/tests/test_gamma_ray_transport.py +++ b/tardis/energy_input/tests/test_gamma_ray_transport.py @@ -7,11 +7,9 @@ import radioactivedecay as rd from radioactivedecay import converters -from tardis.energy_input.gamma_ray_channel import ( - calculate_total_decays, - create_inventories_dict, - create_isotope_dicts, -) +from tardis.energy_input.gamma_ray_channel import (calculate_total_decays, + create_inventories_dict, + create_isotope_dicts) from tardis.io.configuration import config_reader from tardis.model import SimulationState diff --git a/tardis/energy_input/tests/test_util.py b/tardis/energy_input/tests/test_util.py index 052a68efc20..9a18bc959f7 100644 --- a/tardis/energy_input/tests/test_util.py +++ b/tardis/energy_input/tests/test_util.py @@ -2,15 +2,10 @@ import numpy.testing as npt import pytest -from tardis.energy_input.util import ( - R_ELECTRON_SQUARED, - get_perpendicular_vector, - klein_nishina, - spherical_to_cartesian, -) -from tardis.opacities.opacities import ( - kappa_calculation, -) +from tardis.energy_input.util import (R_ELECTRON_SQUARED, + get_perpendicular_vector, klein_nishina, + spherical_to_cartesian) +from tardis.opacities.opacities import kappa_calculation @pytest.mark.parametrize( diff --git a/tardis/grid/__init__.py b/tardis/grid/__init__.py index 1b5b3213ca9..80499809712 100644 --- a/tardis/grid/__init__.py +++ b/tardis/grid/__init__.py @@ -1,6 +1,6 @@ """ -Storing a grid of TARDIS parameters that -facilitates running large numbers of +Storing a grid of TARDIS parameters that +facilitates running large numbers of simulations easily. """ diff --git a/tardis/grid/base.py b/tardis/grid/base.py index d0090ab493e..906d468aa8f 100644 --- a/tardis/grid/base.py +++ b/tardis/grid/base.py @@ -1,10 +1,11 @@ -import pandas as pd -import numpy as np import copy -import tardis -from tardis.io.configuration.config_reader import Configuration +import numpy as np +import pandas as pd + +import tardis from tardis.io.atom_data import AtomData +from tardis.io.configuration.config_reader import Configuration from tardis.model import SimulationState diff --git a/tardis/grid/tests/test_grid.py b/tardis/grid/tests/test_grid.py index 4a793c7e9a4..e6f84281acc 100644 --- a/tardis/grid/tests/test_grid.py +++ b/tardis/grid/tests/test_grid.py @@ -4,11 +4,8 @@ import pandas as pd import tardis - -from pathlib import Path import tardis.grid as grid - DATA_PATH = Path(tardis.__path__[0]) / "grid" / "tests" / "data" diff --git a/tardis/gui/__init__.py b/tardis/gui/__init__.py index a22e23fccfd..cf4d3944433 100644 --- a/tardis/gui/__init__.py +++ b/tardis/gui/__init__.py @@ -1,9 +1,9 @@ """ Creation of the basic framework for the TARDIS GUI. -The data that should be displayed in the GUI is put into -respective data structures (either a tree or a table), such -that they can be used in the widgets. These widgets are +The data that should be displayed in the GUI is put into +respective data structures (either a tree or a table), such +that they can be used in the widgets. These widgets are used to form the building blocks of the basic framework for the GUI. """ diff --git a/tardis/gui/datahandler.py b/tardis/gui/datahandler.py index 57de369e3cd..594e2318dd1 100644 --- a/tardis/gui/datahandler.py +++ b/tardis/gui/datahandler.py @@ -1,15 +1,14 @@ import os -from pkg_resources import parse_version -import numpy as np import matplotlib import matplotlib.pylab as plt - +import numpy as np +from pkg_resources import parse_version if os.environ.get("QT_API", None) == "pyqt": - from PyQt5 import QtGui, QtCore, QtWidgets + from PyQt5 import QtCore, QtGui, QtWidgets elif os.environ.get("QT_API", None) == "pyside": - from PySide2 import QtGui, QtCore, QtWidgets + from PySide2 import QtCore, QtGui, QtWidgets else: raise ImportError( """QT_API was not set! Please exit the IPython console\n @@ -19,8 +18,8 @@ import yaml from tardis import run_tardis -from tardis.gui.widgets import MatplotlibWidget, ModelViewer, ShellInfo -from tardis.gui.widgets import LineInfo, LineInteractionTables +from tardis.gui.widgets import (LineInfo, LineInteractionTables, + MatplotlibWidget, ModelViewer, ShellInfo) if parse_version(matplotlib.__version__) >= parse_version("1.4"): matplotlib.style.use("fivethirtyeight") diff --git a/tardis/gui/interface.py b/tardis/gui/interface.py index cdfd6ae1361..4259dd118be 100644 --- a/tardis/gui/interface.py +++ b/tardis/gui/interface.py @@ -13,16 +13,16 @@ import sys try: - from IPython.lib.guisupport import get_app_qt5, start_event_loop_qt5 - from IPython.lib.guisupport import is_event_loop_running_qt5 + from IPython.lib.guisupport import (get_app_qt5, is_event_loop_running_qt5, + start_event_loop_qt5) importFailed = False except ImportError: importFailed = True -from tardis.gui.widgets import Tardis -from tardis.gui.datahandler import SimpleTableModel from tardis import run_tardis +from tardis.gui.datahandler import SimpleTableModel +from tardis.gui.widgets import Tardis def show(model): diff --git a/tardis/gui/tests/test_gui.py b/tardis/gui/tests/test_gui.py index 2cc05187376..5ea3c5564c0 100644 --- a/tardis/gui/tests/test_gui.py +++ b/tardis/gui/tests/test_gui.py @@ -1,13 +1,16 @@ import os + +import astropy.units as u import pytest + from tardis.io.configuration.config_reader import Configuration from tardis.simulation import Simulation -import astropy.units as u if "QT_API" in os.environ: from PyQt5 import QtWidgets - from tardis.gui.widgets import Tardis + from tardis.gui.datahandler import SimpleTableModel + from tardis.gui.widgets import Tardis @pytest.fixture(scope="module") diff --git a/tardis/gui/widgets.py b/tardis/gui/widgets.py index f79075dfea5..77508daaa75 100644 --- a/tardis/gui/widgets.py +++ b/tardis/gui/widgets.py @@ -3,9 +3,9 @@ import tardis.util.base if os.environ.get("QT_API", None) == "pyqt": - from PyQt5 import QtGui, QtCore, QtWidgets + from PyQt5 import QtCore, QtGui, QtWidgets elif os.environ.get("QT_API", None) == "pyside": - from PySide2 import QtGui, QtCore, QtWidgets + from PySide2 import QtCore, QtGui, QtWidgets else: raise ImportError( """QT_API was not set! Please exit the IPython console\n @@ -14,16 +14,16 @@ ) import matplotlib -from matplotlib.figure import * import matplotlib.gridspec as gridspec -from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas -from matplotlib.backends.backend_qt5 import ( - NavigationToolbar2QT as NavigationToolbar, -) -from matplotlib import colors -from matplotlib.patches import Circle import matplotlib.pylab as plt from astropy import units as u +from matplotlib import colors +from matplotlib.backends.backend_qt5 import \ + NavigationToolbar2QT as NavigationToolbar +from matplotlib.backends.backend_qt5agg import \ + FigureCanvasQTAgg as FigureCanvas +from matplotlib.figure import * +from matplotlib.patches import Circle import tardis from tardis import analysis, util diff --git a/tardis/io/atom_data/__init__.py b/tardis/io/atom_data/__init__.py index 39d2bbdfef1..af7e471a7dd 100644 --- a/tardis/io/atom_data/__init__.py +++ b/tardis/io/atom_data/__init__.py @@ -1,6 +1,6 @@ """ -Getting and handling the atomic data. +Getting and handling the atomic data. """ -from tardis.io.atom_data.base import AtomData from tardis.io.atom_data.atom_web_download import download_atom_data +from tardis.io.atom_data.base import AtomData diff --git a/tardis/io/atom_data/base.py b/tardis/io/atom_data/base.py index 90628b0ec72..e911f0d8b55 100644 --- a/tardis/io/atom_data/base.py +++ b/tardis/io/atom_data/base.py @@ -9,9 +9,8 @@ from tardis import constants as const from tardis.io.atom_data.util import resolve_atom_data_fname -from tardis.plasma.properties.continuum_processes import ( - get_ground_state_multi_index, -) +from tardis.plasma.properties.continuum_processes import \ + get_ground_state_multi_index class AtomDataNotPreparedError(Exception): diff --git a/tardis/io/atom_data/util.py b/tardis/io/atom_data/util.py index ce4b2765bce..bb848ab8544 100644 --- a/tardis/io/atom_data/util.py +++ b/tardis/io/atom_data/util.py @@ -1,12 +1,10 @@ -import os import logging +import os from pathlib import Path +from tardis.io.atom_data.atom_web_download import (download_atom_data, + get_atomic_repo_config) from tardis.io.configuration.config_internal import get_data_dir -from tardis.io.atom_data.atom_web_download import ( - get_atomic_repo_config, - download_atom_data, -) logger = logging.getLogger(__name__) diff --git a/tardis/io/configuration/config_internal.py b/tardis/io/configuration/config_internal.py index 5c622be66ae..6a767f14f6d 100644 --- a/tardis/io/configuration/config_internal.py +++ b/tardis/io/configuration/config_internal.py @@ -1,11 +1,13 @@ -import logging, shutil -import yaml +import logging import os +import shutil from pathlib import Path -from tardis import __path__ as TARDIS_PATH +import yaml from astropy.config import get_config_dir +from tardis import __path__ as TARDIS_PATH + TARDIS_PATH = Path(TARDIS_PATH[0]) DEFAULT_CONFIG_PATH = ( TARDIS_PATH / "data" / "default_tardis_internal_config.yml" diff --git a/tardis/io/configuration/schemas/base.yml b/tardis/io/configuration/schemas/base.yml index 492379aa322..3654dc57ccc 100644 --- a/tardis/io/configuration/schemas/base.yml +++ b/tardis/io/configuration/schemas/base.yml @@ -33,4 +33,3 @@ required: - tardis_config_version - atom_data - spectrum - diff --git a/tardis/io/configuration/schemas/csvy_model.yml b/tardis/io/configuration/schemas/csvy_model.yml index b4d12303d0c..99b6dbd564f 100644 --- a/tardis/io/configuration/schemas/csvy_model.yml +++ b/tardis/io/configuration/schemas/csvy_model.yml @@ -2,7 +2,7 @@ $schema: http://json-schema.org/draft-04/schema# type: object additionalProperties: false properties: - name: + name: type: string description: name of the model being run diff --git a/tardis/io/configuration/schemas/debug.yml b/tardis/io/configuration/schemas/debug.yml index ac7fd441d37..e675625c51e 100644 --- a/tardis/io/configuration/schemas/debug.yml +++ b/tardis/io/configuration/schemas/debug.yml @@ -19,4 +19,3 @@ properties: type: boolean default: false description: Allows for logging on the specified logging levels - diff --git a/tardis/io/configuration/schemas/model_definitions.yml b/tardis/io/configuration/schemas/model_definitions.yml index d8df51735bb..66f384d8f84 100644 --- a/tardis/io/configuration/schemas/model_definitions.yml +++ b/tardis/io/configuration/schemas/model_definitions.yml @@ -161,7 +161,7 @@ definitions: - velocity - density abundances: - + file: $$target: 'model_definitions.yml#/definitions/abundances/file' $$description: One can use a file referenced in the model configuration @@ -207,5 +207,3 @@ definitions: maximum: 1 required: - model_isotope_time_0 - - diff --git a/tardis/io/configuration/schemas/montecarlo.yml b/tardis/io/configuration/schemas/montecarlo.yml index 1baa9f37dac..31a3ff9aee5 100644 --- a/tardis/io/configuration/schemas/montecarlo.yml +++ b/tardis/io/configuration/schemas/montecarlo.yml @@ -6,8 +6,8 @@ properties: type: number multipleOf: 1.0 default: 1 - description: The number of Numba threads for parallelisation. Must be between 1 and the - environment variable NUMBA_NUM_THREADS (by default NUMBA_NUM_THREADS is equal to the + description: The number of Numba threads for parallelisation. Must be between 1 and the + environment variable NUMBA_NUM_THREADS (by default NUMBA_NUM_THREADS is equal to the number of CPU cores on the local system). seed: type: number @@ -73,7 +73,7 @@ properties: default: 10 multiple: 1 description: Configures the initial array length for the RPacketCollection Properties arrays - description: Sets up tracking for Montecarlo + description: Sets up tracking for Montecarlo debug_packets: type: boolean default: false diff --git a/tardis/io/configuration/schemas/spectrum.yml b/tardis/io/configuration/schemas/spectrum.yml index d6afea03106..264ddb9c63b 100644 --- a/tardis/io/configuration/schemas/spectrum.yml +++ b/tardis/io/configuration/schemas/spectrum.yml @@ -6,7 +6,7 @@ properties: description: The lower limit of the spectrum to be generated. Values below this point will not be generated. stop: type: quantity - description: The upper limit of the spectrum to be generated. Values above this point will not be generated. + description: The upper limit of the spectrum to be generated. Values above this point will not be generated. num: type: number description: Number of bins used to build the spectrum @@ -41,7 +41,7 @@ properties: default: "CPU" description: Which method the formal_integral will be computed with. It defaults to the Numba version, but it can be run on NVIDIA Cuda - GPUs. GPU will make it only run on a NVIDIA Cuda GPU, so if one is + GPUs. GPU will make it only run on a NVIDIA Cuda GPU, so if one is not available it will raise an error. Automatic first tries to find an acceptable GPU, and if none is found it will run on the CPU. properties: @@ -50,7 +50,7 @@ properties: - "CPU" - "GPU" - "Automatic" - + virtual: type: object default: {} diff --git a/tardis/io/configuration/tests/data/paper1_tardis_configv1.yml b/tardis/io/configuration/tests/data/paper1_tardis_configv1.yml index 7fb56090114..cb3da72b5d2 100644 --- a/tardis/io/configuration/tests/data/paper1_tardis_configv1.yml +++ b/tardis/io/configuration/tests/data/paper1_tardis_configv1.yml @@ -40,4 +40,4 @@ montecarlo: spectrum: start: 500 angstrom stop: 20000 angstrom - num: 10000 \ No newline at end of file + num: 10000 diff --git a/tardis/io/configuration/tests/data/tardis_configv1_density_exponential_test.yml b/tardis/io/configuration/tests/data/tardis_configv1_density_exponential_test.yml index 16e4dc4b6d3..bd6e3248b84 100644 --- a/tardis/io/configuration/tests/data/tardis_configv1_density_exponential_test.yml +++ b/tardis/io/configuration/tests/data/tardis_configv1_density_exponential_test.yml @@ -18,7 +18,7 @@ model: time_0: 2. day rho_0: 6.e-10 g/cm^3 v_0: 3000. km/s - + abundances: type: uniform diff --git a/tardis/io/configuration/tests/data/tardis_configv1_nlte.yml b/tardis/io/configuration/tests/data/tardis_configv1_nlte.yml index 9e232f3c140..3a874851d2c 100644 --- a/tardis/io/configuration/tests/data/tardis_configv1_nlte.yml +++ b/tardis/io/configuration/tests/data/tardis_configv1_nlte.yml @@ -36,7 +36,7 @@ plasma: link_t_rad_t_electron: 1.0 nlte_ionization_species: [H I, He II, Ti II] nlte_solver: root - + continuum_interaction: species: - H I diff --git a/tardis/io/configuration/tests/data/tardis_configv1_verysimple_logger.yml b/tardis/io/configuration/tests/data/tardis_configv1_verysimple_logger.yml index 1c4110dac0a..d76df86bbc8 100644 --- a/tardis/io/configuration/tests/data/tardis_configv1_verysimple_logger.yml +++ b/tardis/io/configuration/tests/data/tardis_configv1_verysimple_logger.yml @@ -44,4 +44,4 @@ spectrum: num: 10000 debug: - specific_log_level: False \ No newline at end of file + specific_log_level: False diff --git a/tardis/io/configuration/tests/test_config_reader.py b/tardis/io/configuration/tests/test_config_reader.py index f525557ca63..e27d3f57065 100644 --- a/tardis/io/configuration/tests/test_config_reader.py +++ b/tardis/io/configuration/tests/test_config_reader.py @@ -1,13 +1,14 @@ # tests for the config reader module import os -from attr import validate -import pytest + import pandas as pd -from numpy.testing import assert_almost_equal +import pytest +from astropy.units import Quantity +from attr import validate from jsonschema.exceptions import ValidationError +from numpy.testing import assert_almost_equal from tardis.io.configuration import config_reader -from astropy.units import Quantity from tardis.io.configuration.config_reader import Configuration from tardis.plasma.exceptions import PlasmaConfigError from tardis.plasma.standard_plasmas import assemble_plasma diff --git a/tardis/io/configuration/tests/test_configuration_namespace.py b/tardis/io/configuration/tests/test_configuration_namespace.py index c9445c8f1ec..3d32f476e56 100644 --- a/tardis/io/configuration/tests/test_configuration_namespace.py +++ b/tardis/io/configuration/tests/test_configuration_namespace.py @@ -1,10 +1,11 @@ -from tardis.io.configuration.config_reader import ConfigurationNameSpace -import pytest -from astropy import units as u import os +import pytest +from astropy import units as u from numpy.testing import assert_almost_equal +from tardis.io.configuration.config_reader import ConfigurationNameSpace + simple_config_dict = { "a": {"b": {"param1": 1, "param2": [0, 1, 2 * u.km], "param3": 4.0 * u.km}} } diff --git a/tardis/io/logger/__init__.py b/tardis/io/logger/__init__.py index 78bc5622358..d8a1c931684 100644 --- a/tardis/io/logger/__init__.py +++ b/tardis/io/logger/__init__.py @@ -1,3 +1,3 @@ """ -Managing the logging output. +Managing the logging output. """ diff --git a/tardis/io/logger/tests/test_logging.py b/tardis/io/logger/tests/test_logging.py index 7ab6d8e638b..e60d6889f9b 100644 --- a/tardis/io/logger/tests/test_logging.py +++ b/tardis/io/logger/tests/test_logging.py @@ -1,11 +1,11 @@ -import pytest import logging +import pytest + +from tardis import run_tardis from tardis.io.configuration.config_reader import Configuration -from tardis.simulation import Simulation from tardis.io.logger.logger import LOGGING_LEVELS -from tardis import run_tardis -import pytest +from tardis.simulation import Simulation pytestmark = pytest.mark.skip( reason="logging testing slow and disabled for now" diff --git a/tardis/io/model/__init__.py b/tardis/io/model/__init__.py index 9a877f17b98..7f3011d3ee5 100644 --- a/tardis/io/model/__init__.py +++ b/tardis/io/model/__init__.py @@ -1,4 +1,3 @@ -from tardis.io.model.readers.stella import read_stella_model - # from tardis.io.model.stella import read_stella_model from tardis.io.model.readers.cmfgen import read_cmfgen_model +from tardis.io.model.readers.stella import read_stella_model diff --git a/tardis/io/model/parse_composition_configuration.py b/tardis/io/model/parse_composition_configuration.py index 898f136e05f..2b95147418d 100644 --- a/tardis/io/model/parse_composition_configuration.py +++ b/tardis/io/model/parse_composition_configuration.py @@ -1,11 +1,7 @@ from tardis.io.model.parse_density_configuration import ( - parse_density_from_config, - parse_density_from_csvy, -) + parse_density_from_config, parse_density_from_csvy) from tardis.io.model.parse_mass_fraction_configuration import ( - parse_mass_fractions_from_config, - parse_mass_fractions_from_csvy, -) + parse_mass_fractions_from_config, parse_mass_fractions_from_csvy) from tardis.model.matter.composition import Composition diff --git a/tardis/io/model/parse_density_configuration.py b/tardis/io/model/parse_density_configuration.py index 29e054c4e72..3f6384b85c6 100644 --- a/tardis/io/model/parse_density_configuration.py +++ b/tardis/io/model/parse_density_configuration.py @@ -4,13 +4,10 @@ import numpy as np from astropy import units as u -from tardis.io.configuration.config_reader import ( - Configuration, - ConfigurationNameSpace, -) -from tardis.io.model.parse_geometry_configuration import ( - parse_structure_from_config, -) +from tardis.io.configuration.config_reader import (Configuration, + ConfigurationNameSpace) +from tardis.io.model.parse_geometry_configuration import \ + parse_structure_from_config from tardis.util.base import quantity_linspace logger = logging.getLogger(__name__) diff --git a/tardis/io/model/parse_packet_source_configuration.py b/tardis/io/model/parse_packet_source_configuration.py index 2e711001b76..026f4e77542 100644 --- a/tardis/io/model/parse_packet_source_configuration.py +++ b/tardis/io/model/parse_packet_source_configuration.py @@ -1,9 +1,7 @@ from astropy import units as u from tardis.transport.montecarlo.packet_source import ( - BlackBodySimpleSource, - BlackBodySimpleSourceRelativistic, -) + BlackBodySimpleSource, BlackBodySimpleSourceRelativistic) def initialize_packet_source(packet_source, config, geometry): diff --git a/tardis/io/model/parse_radiation_field_configuration.py b/tardis/io/model/parse_radiation_field_configuration.py index d311ad94923..fd90aa90b7c 100644 --- a/tardis/io/model/parse_radiation_field_configuration.py +++ b/tardis/io/model/parse_radiation_field_configuration.py @@ -4,9 +4,8 @@ from astropy import units as u from tardis import constants as const -from tardis.io.model.parse_geometry_configuration import ( - parse_structure_from_config, -) +from tardis.io.model.parse_geometry_configuration import \ + parse_structure_from_config from tardis.plasma.radiation_field import DilutePlanckianRadiationField logger = logging.getLogger(__name__) diff --git a/tardis/io/model/parse_simulation_state.py b/tardis/io/model/parse_simulation_state.py index bca12b73330..7b69bd11a35 100644 --- a/tardis/io/model/parse_simulation_state.py +++ b/tardis/io/model/parse_simulation_state.py @@ -1,6 +1,5 @@ -from tardis.io.model.parse_packet_source_configuration import ( - initialize_packet_source, -) +from tardis.io.model.parse_packet_source_configuration import \ + initialize_packet_source from tardis.model import SimulationState diff --git a/tardis/io/model/readers/arepo.py b/tardis/io/model/readers/arepo.py index a60acd983a8..1dc762a4236 100644 --- a/tardis/io/model/readers/arepo.py +++ b/tardis/io/model/readers/arepo.py @@ -1,8 +1,8 @@ -import os import argparse +import os -import numpy as np import matplotlib.pyplot as plt +import numpy as np from scipy import stats diff --git a/tardis/io/model/readers/artis.py b/tardis/io/model/readers/artis.py index 21a353d0d94..7d493d04ae8 100644 --- a/tardis/io/model/readers/artis.py +++ b/tardis/io/model/readers/artis.py @@ -1,6 +1,6 @@ import numpy as np -from astropy import units as u import pandas as pd +from astropy import units as u def read_artis_density(fname): diff --git a/tardis/io/model/readers/base.py b/tardis/io/model/readers/base.py index ec0ac37dd54..2b2659a9132 100644 --- a/tardis/io/model/readers/base.py +++ b/tardis/io/model/readers/base.py @@ -1,19 +1,12 @@ -from tardis.io.model.readers.cmfgen_deprecated import ( - read_cmfgen_composition, - read_cmfgen_density, -) -from tardis.io.model.readers.generic_readers import ( - ConfigurationError, - read_csv_composition, - read_simple_ascii_mass_fractions, - read_simple_ascii_density, -) - - import numpy as np import pandas as pd from tardis.io.model.readers.artis import read_artis_density +from tardis.io.model.readers.cmfgen_deprecated import (read_cmfgen_composition, + read_cmfgen_density) +from tardis.io.model.readers.generic_readers import ( + ConfigurationError, read_csv_composition, read_simple_ascii_density, + read_simple_ascii_mass_fractions) def read_mass_fractions_file( diff --git a/tardis/io/model/readers/cmfgen.py b/tardis/io/model/readers/cmfgen.py index 77865a3a5d4..df2247204b6 100644 --- a/tardis/io/model/readers/cmfgen.py +++ b/tardis/io/model/readers/cmfgen.py @@ -1,8 +1,9 @@ +import dataclasses import re +from pathlib import Path + import pandas as pd from astropy import units as u -from pathlib import Path -import dataclasses @dataclasses.dataclass diff --git a/tardis/io/model/readers/cmfgen_deprecated.py b/tardis/io/model/readers/cmfgen_deprecated.py index 898f7a5dc2c..7d9e4583e07 100644 --- a/tardis/io/model/readers/cmfgen_deprecated.py +++ b/tardis/io/model/readers/cmfgen_deprecated.py @@ -1,12 +1,10 @@ -from tardis.io.model.readers.util import read_csv_isotope_mass_fractions -from tardis.util.base import parse_quantity - +import warnings import pandas as pd from astropy import units as u - -import warnings +from tardis.io.model.readers.util import read_csv_isotope_mass_fractions +from tardis.util.base import parse_quantity def read_cmfgen_density(fname: str): diff --git a/tardis/io/model/readers/csvy.py b/tardis/io/model/readers/csvy.py index 7e6c1f1c73b..5b0075e96a5 100644 --- a/tardis/io/model/readers/csvy.py +++ b/tardis/io/model/readers/csvy.py @@ -1,9 +1,11 @@ import logging + import numpy as np +import pandas as pd +import yaml from radioactivedecay import Nuclide from radioactivedecay.utils import Z_DICT, elem_to_Z -import yaml -import pandas as pd + from tardis.io.util import YAMLLoader from tardis.util.base import is_valid_nuclide_or_elem diff --git a/tardis/io/model/readers/tests/data/abund.dat b/tardis/io/model/readers/tests/data/abund.dat index d6e385f9211..95b047b0eb7 100644 --- a/tardis/io/model/readers/tests/data/abund.dat +++ b/tardis/io/model/readers/tests/data/abund.dat @@ -7,5 +7,5 @@ 5 0 0 0 0 0 0 0 0.2 0 0 0 0.1 0 0.2 0 0.2 0 0.2 0 0.1 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0.2 0 0 0 0.1 0 0.2 0 0.2 0 0.2 0 0.1 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0.2 0 0 0 0.1 0 0.2 0 0.2 0 0.2 0 0.1 0 0 0 0 0 0 0 0 0 0 -8 0 0 0 0 0 0.5 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +8 0 0 0 0 0 0.5 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0.5 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/tardis/io/model/readers/tests/data/arepo_cone_reference_model.csvy b/tardis/io/model/readers/tests/data/arepo_cone_reference_model.csvy index 839679159ec..94274a6526d 100644 --- a/tardis/io/model/readers/tests/data/arepo_cone_reference_model.csvy +++ b/tardis/io/model/readers/tests/data/arepo_cone_reference_model.csvy @@ -38,4 +38,4 @@ velocity,density,Ni56,Si28 1.82952e+09,0.00188048,1.06163e-10,0.227405 1.87985e+09,0.00137231,4.77628e-11,0.218543 1.93045e+09,0.00100844,2.41338e-11,0.204091 -1.98087e+09,0.000773981,1.42833e-11,0.182151 \ No newline at end of file +1.98087e+09,0.000773981,1.42833e-11,0.182151 diff --git a/tardis/io/model/readers/tests/data/arepo_full_reference_model.csvy b/tardis/io/model/readers/tests/data/arepo_full_reference_model.csvy index 7190f69f071..49636a5d5fe 100644 --- a/tardis/io/model/readers/tests/data/arepo_full_reference_model.csvy +++ b/tardis/io/model/readers/tests/data/arepo_full_reference_model.csvy @@ -38,4 +38,4 @@ velocity,density,Ni56,Si28 1.82971e+09,0.00685711,1.42244e-10,0.228703 1.88009e+09,0.00488457,5.92117e-11,0.220137 1.93084e+09,0.00369041,3.0944e-11,0.206345 -1.98142e+09,0.00271805,1.68858e-11,0.18518 \ No newline at end of file +1.98142e+09,0.00271805,1.68858e-11,0.18518 diff --git a/tardis/io/model/readers/tests/data/cmfgen_model.csv b/tardis/io/model/readers/tests/data/cmfgen_model.csv index 517f5f7ace7..df54965c84c 100644 --- a/tardis/io/model/readers/tests/data/cmfgen_model.csv +++ b/tardis/io/model/readers/tests/data/cmfgen_model.csv @@ -1,4 +1,4 @@ -t0: 0.976 day +t0: 0.976 day Index velocity temperature densities electron_densities C O Mg Si Ni56 Ni58 - km/s K g/cm^3 /cm^3 1 1 1 1 1 1 0 871.66905 76395.577 4.2537191E-09 2.60E+14 0 0 0 0.6 0.4 0 diff --git a/tardis/io/model/readers/tests/data/conf_def.yml b/tardis/io/model/readers/tests/data/conf_def.yml index 4fd6d7d4283..459ed4f1933 100644 --- a/tardis/io/model/readers/tests/data/conf_def.yml +++ b/tardis/io/model/readers/tests/data/conf_def.yml @@ -58,7 +58,7 @@ value_test: default: [1 m,10 cm, 0.1 cm] #[Start,End, sample] mandatory: False help: range for testing - + range: property_type: range default: [0,10] #[Start,End] @@ -69,7 +69,7 @@ value_test: default: [0,10,1] #[Start,End,Nsample] mandatory: False help: 'Like property type range, ?? is should it be the # samples or the spacing ??' - + container_example: property_type: container-property type: @@ -83,7 +83,7 @@ container_example: default: 'This is a container item' mandatory: False help: This is a container item from the container one. - + one_two: sub_one_two_one: property_type: string @@ -95,15 +95,15 @@ container_example: default: 'This is a container item' mandatory: False help: This is a container item from the container one. - + two_one: quantity_range: property_type: quantity_range default: [1 m,10 cm] #[Start,End] mandatory: False help: Like property type range but with quantitys as start and stop. The consistency of the units is checked. - - + + @@ -144,5 +144,4 @@ test: property_type: string default: blabla mandatory: False - help: very helpful - + help: very helpful diff --git a/tardis/io/model/readers/tests/data/conf_tes.yml b/tardis/io/model/readers/tests/data/conf_tes.yml index 52455e5a5c6..86d29666ae5 100644 --- a/tardis/io/model/readers/tests/data/conf_tes.yml +++ b/tardis/io/model/readers/tests/data/conf_tes.yml @@ -14,7 +14,7 @@ value_test: end: 30 km quantity_range_sampled: [2 cm, 10 km, 1 m] list: ['bla','blub'] - + container_example: type: one @@ -29,7 +29,7 @@ supernova: test: structure: type: file - file_property: + file_property: filename: bla file_container: type: bla diff --git a/tardis/io/model/readers/tests/data/tardis_configv1_ascii_density_uniabund.yml b/tardis/io/model/readers/tests/data/tardis_configv1_ascii_density_uniabund.yml index 8748df6240c..45cefeae76e 100644 --- a/tardis/io/model/readers/tests/data/tardis_configv1_ascii_density_uniabund.yml +++ b/tardis/io/model/readers/tests/data/tardis_configv1_ascii_density_uniabund.yml @@ -49,7 +49,7 @@ montecarlo: hold_iterations: 3 t_inner: damping_constant: 1.0 - + spectrum: start : 500 angstrom stop : 20000 angstrom diff --git a/tardis/io/model/readers/tests/test_arepo_parser.py b/tardis/io/model/readers/tests/test_arepo_parser.py index d205d9d90ed..a3f86499854 100644 --- a/tardis/io/model/readers/tests/test_arepo_parser.py +++ b/tardis/io/model/readers/tests/test_arepo_parser.py @@ -1,9 +1,11 @@ +import json +import os from pathlib import Path -from tardis.io.model.readers import arepo -import pytest + import numpy as np -import os -import json +import pytest + +from tardis.io.model.readers import arepo @pytest.fixture() diff --git a/tardis/io/model/readers/tests/test_ascii_readers.py b/tardis/io/model/readers/tests/test_ascii_readers.py index 10fb6bf5bca..949295561fa 100644 --- a/tardis/io/model/readers/tests/test_ascii_readers.py +++ b/tardis/io/model/readers/tests/test_ascii_readers.py @@ -1,21 +1,16 @@ import os -from astropy import units as u -from tardis import io -from tardis.io.model.readers.generic_readers import ConfigurationError +from pathlib import Path +import numpy as np import numpy.testing as npt - import pytest +from astropy import units as u -import numpy as np - -from pathlib import Path +from tardis import io from tardis.io.model.readers.base import read_density_file - from tardis.io.model.readers.generic_readers import ( - read_simple_ascii_mass_fractions, - read_simple_ascii_density, -) + ConfigurationError, read_simple_ascii_density, + read_simple_ascii_mass_fractions) test_data_directory = os.path.dirname(__file__) diff --git a/tardis/io/model/readers/tests/test_cmfgen_reader.py b/tardis/io/model/readers/tests/test_cmfgen_reader.py index 25ba9fefc87..45a9c0efa56 100644 --- a/tardis/io/model/readers/tests/test_cmfgen_reader.py +++ b/tardis/io/model/readers/tests/test_cmfgen_reader.py @@ -1,9 +1,9 @@ -import numpy as np - from pathlib import Path -from pytest import fixture +import numpy as np from astropy import units as u +from pytest import fixture + from tardis.io.model.readers.cmfgen import read_cmfgen_model MODEL_DATA_PATH = Path(__file__).parent / "data" diff --git a/tardis/io/model/readers/tests/test_csvy_reader.py b/tardis/io/model/readers/tests/test_csvy_reader.py index daf283eca55..40170a3ae3b 100644 --- a/tardis/io/model/readers/tests/test_csvy_reader.py +++ b/tardis/io/model/readers/tests/test_csvy_reader.py @@ -1,12 +1,14 @@ +import os from pathlib import Path -import tardis -from tardis.io.model.readers import csvy -from tardis.io.configuration.config_validator import validate_dict -from jsonschema import exceptions as json_schema_exc + +import numpy.testing as npt import pytest -import os from astropy import units as u -import numpy.testing as npt +from jsonschema import exceptions as json_schema_exc + +import tardis +from tardis.io.configuration.config_validator import validate_dict +from tardis.io.model.readers import csvy @pytest.fixture diff --git a/tardis/io/model/readers/tests/test_stella_reader.py b/tardis/io/model/readers/tests/test_stella_reader.py index ace192118c9..055cae778ff 100644 --- a/tardis/io/model/readers/tests/test_stella_reader.py +++ b/tardis/io/model/readers/tests/test_stella_reader.py @@ -1,9 +1,9 @@ -import numpy as np - from pathlib import Path -from pytest import fixture +import numpy as np from astropy import units as u +from pytest import fixture + from tardis.io.model import read_stella_model MODEL_DATA_PATH = Path(__file__).parent / "data" diff --git a/tardis/io/tests/test_HDFWriter.py b/tardis/io/tests/test_HDFWriter.py index bc7be113880..4c82f57efd3 100644 --- a/tardis/io/tests/test_HDFWriter.py +++ b/tardis/io/tests/test_HDFWriter.py @@ -2,12 +2,10 @@ import pandas as pd import pytest from astropy import units as u - from numpy.testing import assert_almost_equal, assert_array_almost_equal from tardis.io.util import HDFWriterMixin - # Test Cases # DataFrame diff --git a/tardis/io/tests/test_atomic.py b/tardis/io/tests/test_atomic.py index 5fdf4c9ba41..4c810b8a7f2 100644 --- a/tardis/io/tests/test_atomic.py +++ b/tardis/io/tests/test_atomic.py @@ -1,7 +1,7 @@ import pytest - -from astropy.tests.helper import assert_quantity_allclose from astropy import units as u +from astropy.tests.helper import assert_quantity_allclose + from tardis import constants as const diff --git a/tardis/io/tests/test_decay.py b/tardis/io/tests/test_decay.py index 4acccabfb57..3645357cef4 100644 --- a/tardis/io/tests/test_decay.py +++ b/tardis/io/tests/test_decay.py @@ -1,8 +1,8 @@ -import pytest import pandas as pd +import pytest +from numpy.testing import assert_almost_equal from tardis.model.matter.decay import IsotopicMassFraction -from numpy.testing import assert_almost_equal @pytest.fixture diff --git a/tardis/io/tests/test_model_reader.py b/tardis/io/tests/test_model_reader.py index d1ed9808a75..b36bc4dcde0 100644 --- a/tardis/io/tests/test_model_reader.py +++ b/tardis/io/tests/test_model_reader.py @@ -5,15 +5,11 @@ from tardis.io.configuration.config_reader import Configuration from tardis.io.model.readers.artis import read_artis_density -from tardis.io.model.readers.cmfgen_deprecated import ( - read_cmfgen_composition, - read_cmfgen_density, -) +from tardis.io.model.readers.cmfgen_deprecated import (read_cmfgen_composition, + read_cmfgen_density) from tardis.io.model.readers.generic_readers import ( - read_csv_composition, - read_simple_ascii_mass_fractions, - read_uniform_mass_fractions, -) + read_csv_composition, read_simple_ascii_mass_fractions, + read_uniform_mass_fractions) @pytest.fixture diff --git a/tardis/model/__init__.py b/tardis/model/__init__.py index 4b7881ad71e..d0358c87876 100644 --- a/tardis/model/__init__.py +++ b/tardis/model/__init__.py @@ -1,8 +1,8 @@ """ -Holding information about the TARDIS model. +Holding information about the TARDIS model. -This includes information about the shell structure, -density, abundance, temperatures and dilution +This includes information about the shell structure, +density, abundance, temperatures and dilution factor of the model used in the simulation. """ diff --git a/tardis/model/base.py b/tardis/model/base.py index d3e1ce6cee4..6a724936ce8 100644 --- a/tardis/model/base.py +++ b/tardis/model/base.py @@ -8,23 +8,15 @@ from tardis.io.configuration.config_reader import Configuration from tardis.io.configuration.config_validator import validate_dict from tardis.io.model.parse_composition_configuration import ( - parse_composition_from_config, - parse_composition_from_csvy, -) + parse_composition_from_config, parse_composition_from_csvy) from tardis.io.model.parse_geometry_configuration import ( - parse_geometry_from_config, - parse_geometry_from_csvy, -) -from tardis.io.model.parse_packet_source_configuration import ( - parse_packet_source_from_config, -) + parse_geometry_from_config, parse_geometry_from_csvy) +from tardis.io.model.parse_packet_source_configuration import \ + parse_packet_source_from_config from tardis.io.model.parse_radiation_field_configuration import ( parse_radiation_field_state_from_config, - parse_radiation_field_state_from_csvy, -) -from tardis.io.model.readers.csvy import ( - load_csvy, -) + parse_radiation_field_state_from_csvy) +from tardis.io.model.readers.csvy import load_csvy from tardis.io.util import HDFWriterMixin from tardis.util.base import is_valid_nuclide_or_elem diff --git a/tardis/model/geometry/radial1d.py b/tardis/model/geometry/radial1d.py index a6bf3382cbc..76a6eed327b 100644 --- a/tardis/model/geometry/radial1d.py +++ b/tardis/model/geometry/radial1d.py @@ -1,8 +1,9 @@ -from numba import float64 -from numba.experimental import jitclass +import warnings + import numpy as np from astropy import units as u -import warnings +from numba import float64 +from numba.experimental import jitclass class HomologousRadial1DGeometry: diff --git a/tardis/model/geometry/tests/test_radial1d.py b/tardis/model/geometry/tests/test_radial1d.py index e6c887180d0..1881067052c 100644 --- a/tardis/model/geometry/tests/test_radial1d.py +++ b/tardis/model/geometry/tests/test_radial1d.py @@ -1,11 +1,10 @@ -from astropy import units as u import numpy as np import numpy.testing as npt +import pytest +from astropy import units as u from tardis.model.geometry.radial1d import HomologousRadial1DGeometry -import pytest - @pytest.fixture(scope="function") def homologous_radial1d_geometry(): diff --git a/tardis/model/tests/data/branch85_csvy.csvy b/tardis/model/tests/data/branch85_csvy.csvy index e1d4ce277fd..386a0e4dfac 100644 --- a/tardis/model/tests/data/branch85_csvy.csvy +++ b/tardis/model/tests/data/branch85_csvy.csvy @@ -2,7 +2,7 @@ name: branch85_csvy model_density_time_0: 1 day model_isotope_time_0: 0 day -description: csvy file with uniform abundances and branch85 density profile (no values declared in the CSV section) +description: csvy file with uniform abundances and branch85 density profile (no values declared in the CSV section) tardis_model_config_version: v1.0 velocity: diff --git a/tardis/model/tests/data/csvy_model_to_test_abundances.csvy b/tardis/model/tests/data/csvy_model_to_test_abundances.csvy index 5b00b0e511e..4f419dfbbca 100644 --- a/tardis/model/tests/data/csvy_model_to_test_abundances.csvy +++ b/tardis/model/tests/data/csvy_model_to_test_abundances.csvy @@ -2,7 +2,7 @@ name: cvy_model_abundance_dataframes model_density_time_0: 1 day model_isotope_time_0: 0 day -description: csvy file to test abundances and decay (test values declared in the CSV section) +description: csvy file to test abundances and decay (test values declared in the CSV section) tardis_model_config_version: v1.0 datatype: fields: @@ -16,7 +16,7 @@ datatype: desc: fractional H abundance - name: He desc: fractional He abundance - - name: Ni56 + - name: Ni56 desc: fractional Ni56 abundance v_inner_boundary: 9000 km/s @@ -25,7 +25,7 @@ v_outer_boundary: 16000 km/s velocity,density,H,He,Ni56 9000, 5e-10, 0.5, 0.5, 0 10500, 2.0e-10, 0.0, 0.98, 0.02 -12000, 9e-11, 0.33, 0.64, 0.03 +12000, 9e-11, 0.33, 0.64, 0.03 13000, 9e-12, 0.3, 0.6, 0.1 14000, 6e-12, 0.5, 0.4, 0.1 15000, 4e-12, 0.4, 0.55, 0.05 diff --git a/tardis/model/tests/data/exponential_csvy.csvy b/tardis/model/tests/data/exponential_csvy.csvy index 166db60f9c2..f8e0e84ad35 100644 --- a/tardis/model/tests/data/exponential_csvy.csvy +++ b/tardis/model/tests/data/exponential_csvy.csvy @@ -2,7 +2,7 @@ name: exponential_csvy model_density_time_0: 1 day model_isotope_time_0: 0 day -description: csvy file with uniform abundances and exponential density profile (no values declared in the CSV section) +description: csvy file with uniform abundances and exponential density profile (no values declared in the CSV section) tardis_model_config_version: v1.0 velocity: diff --git a/tardis/model/tests/data/model_full_csvy.csvy b/tardis/model/tests/data/model_full_csvy.csvy index 4c3608e5f9d..e76e57a6d78 100644 --- a/tardis/model/tests/data/model_full_csvy.csvy +++ b/tardis/model/tests/data/model_full_csvy.csvy @@ -2,7 +2,7 @@ name: model_full_csvy model_density_time_0: 1 day model_isotope_time_0: 0 day -description: csvy file with all quantities stored as CSV +description: csvy file with all quantities stored as CSV tardis_model_config_version: v1.0 datatype: fields: diff --git a/tardis/model/tests/data/powerlaw_csvy.csvy b/tardis/model/tests/data/powerlaw_csvy.csvy index 21b3a5d4689..67fa3806dda 100644 --- a/tardis/model/tests/data/powerlaw_csvy.csvy +++ b/tardis/model/tests/data/powerlaw_csvy.csvy @@ -2,7 +2,7 @@ name: powerlaw_csvy model_density_time_0: 1 day model_isotope_time_0: 0 day -description: csvy file with a power-law density profile and uniform abundances (no values declared in the CSV section) +description: csvy file with a power-law density profile and uniform abundances (no values declared in the CSV section) tardis_model_config_version: v1.0 velocity: diff --git a/tardis/model/tests/data/uniform_csvy.yml b/tardis/model/tests/data/uniform_csvy.yml index faa09f0ae1b..1080e2df899 100644 --- a/tardis/model/tests/data/uniform_csvy.yml +++ b/tardis/model/tests/data/uniform_csvy.yml @@ -1,4 +1,4 @@ -# YAML model config file with uniform density and uniform abundances +# YAML model config file with uniform density and uniform abundances tardis_config_version: v1.0 supernova: diff --git a/tardis/model/tests/test_base.py b/tardis/model/tests/test_base.py index 3aedf574420..c5a6e9cc77b 100644 --- a/tardis/model/tests/test_base.py +++ b/tardis/model/tests/test_base.py @@ -1,7 +1,8 @@ import os from pathlib import Path -import pytest + import pandas as pd +import pytest from astropy import units as u from numpy.testing import assert_almost_equal, assert_array_almost_equal diff --git a/tardis/model/tests/test_csvy_model.py b/tardis/model/tests/test_csvy_model.py index 7463a475628..455a8ede3ad 100644 --- a/tardis/model/tests/test_csvy_model.py +++ b/tardis/model/tests/test_csvy_model.py @@ -1,13 +1,14 @@ from pathlib import Path + import numpy as np -import pandas as pd import numpy.testing as npt - +import pandas as pd +import pytest from astropy import units as u -from tardis.io.configuration.config_reader import Configuration + from tardis.io.atom_data.base import AtomData +from tardis.io.configuration.config_reader import Configuration from tardis.model import SimulationState -import pytest @pytest.fixture( diff --git a/tardis/model/tests/test_density.py b/tardis/model/tests/test_density.py index 907e2ef3e24..a9571dbc88c 100644 --- a/tardis/model/tests/test_density.py +++ b/tardis/model/tests/test_density.py @@ -1,4 +1,5 @@ import os + import pandas as pd import pytest from numpy.testing import assert_almost_equal diff --git a/tardis/opacities/macro_atom/transition_probabilities.py b/tardis/opacities/macro_atom/transition_probabilities.py index 6facd5ee70a..b86030a94ed 100644 --- a/tardis/opacities/macro_atom/transition_probabilities.py +++ b/tardis/opacities/macro_atom/transition_probabilities.py @@ -5,12 +5,9 @@ from scipy import sparse as sp from tardis.plasma.properties.base import ProcessingPlasmaProperty -from tardis.plasma.properties.continuum_processes import ( - get_ground_state_multi_index, -) -from tardis.transport.montecarlo.macro_atom import ( - MacroAtomTransitionType, -) +from tardis.plasma.properties.continuum_processes import \ + get_ground_state_multi_index +from tardis.transport.montecarlo.macro_atom import MacroAtomTransitionType __all__ = [ "MarkovChainTransProbs", diff --git a/tardis/opacities/opacities.py b/tardis/opacities/opacities.py index dd7aeae83d4..d46f64ba64b 100644 --- a/tardis/opacities/opacities.py +++ b/tardis/opacities/opacities.py @@ -3,12 +3,8 @@ from numba import njit from tardis import constants as const -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) -from tardis.transport.montecarlo.configuration.constants import ( - SIGMA_THOMSON, -) +from tardis.transport.montecarlo import njit_dict_no_parallel +from tardis.transport.montecarlo.configuration.constants import SIGMA_THOMSON H = const.h.cgs.value M_E = const.m_e.cgs.value diff --git a/tardis/plasma/__init__.py b/tardis/plasma/__init__.py index ec0d4cd7358..e8d928cfb58 100644 --- a/tardis/plasma/__init__.py +++ b/tardis/plasma/__init__.py @@ -1,5 +1,5 @@ """ -Dealing with plasma properties and calculations related to it. +Dealing with plasma properties and calculations related to it. """ from tardis.plasma.base import BasePlasma diff --git a/tardis/plasma/base.py b/tardis/plasma/base.py index ef785486673..b2ea7910d1e 100644 --- a/tardis/plasma/base.py +++ b/tardis/plasma/base.py @@ -1,14 +1,14 @@ +import fileinput +import logging import os import re -import logging import tempfile -import fileinput import networkx as nx -from tardis.plasma.exceptions import PlasmaMissingModule, NotInitializedModule -from tardis.plasma.properties.base import * from tardis.io.util import PlasmaWriterMixin +from tardis.plasma.exceptions import NotInitializedModule, PlasmaMissingModule +from tardis.plasma.properties.base import * logger = logging.getLogger(__name__) diff --git a/tardis/plasma/properties/atomic.py b/tardis/plasma/properties/atomic.py index 72fd4b6b472..89872cc29db 100644 --- a/tardis/plasma/properties/atomic.py +++ b/tardis/plasma/properties/atomic.py @@ -10,19 +10,11 @@ from tardis import constants as const from tardis.plasma.exceptions import IncompleteAtomicData -from tardis.plasma.properties.base import ( - BaseAtomicDataProperty, - HiddenPlasmaProperty, - ProcessingPlasmaProperty, -) +from tardis.plasma.properties.base import (BaseAtomicDataProperty, + HiddenPlasmaProperty, + ProcessingPlasmaProperty) from tardis.plasma.properties.continuum_processes import ( - A0, - BETA_COLL, - K_B, - M_E, - H, - get_ground_state_multi_index, -) + A0, BETA_COLL, K_B, M_E, H, get_ground_state_multi_index) logger = logging.getLogger(__name__) diff --git a/tardis/plasma/properties/continuum_processes.py b/tardis/plasma/properties/continuum_processes.py index 06121cc4e20..79620b62d24 100644 --- a/tardis/plasma/properties/continuum_processes.py +++ b/tardis/plasma/properties/continuum_processes.py @@ -5,18 +5,13 @@ from numba import njit, prange from tardis import constants as const -from tardis.transport.montecarlo.estimators.util import ( - bound_free_estimator_array2frame, - integrate_array_by_blocks, -) -from tardis.transport.montecarlo import njit_dict from tardis.plasma.exceptions import PlasmaException -from tardis.plasma.properties.base import ( - Input, - ProcessingPlasmaProperty, - TransitionProbabilitiesProperty, -) +from tardis.plasma.properties.base import (Input, ProcessingPlasmaProperty, + TransitionProbabilitiesProperty) from tardis.plasma.properties.j_blues import JBluesDiluteBlackBody +from tardis.transport.montecarlo import njit_dict +from tardis.transport.montecarlo.estimators.util import ( + bound_free_estimator_array2frame, integrate_array_by_blocks) __all__ = [ "SpontRecombRateCoeff", diff --git a/tardis/plasma/properties/helium_nlte.py b/tardis/plasma/properties/helium_nlte.py index cd05ce73327..80240f34ca4 100644 --- a/tardis/plasma/properties/helium_nlte.py +++ b/tardis/plasma/properties/helium_nlte.py @@ -4,9 +4,7 @@ import numpy as np import pandas as pd -from tardis.plasma.properties.base import ( - ProcessingPlasmaProperty, -) +from tardis.plasma.properties.base import ProcessingPlasmaProperty from tardis.plasma.properties.ion_population import PhiSahaNebular __all__ = [ diff --git a/tardis/plasma/properties/j_blues.py b/tardis/plasma/properties/j_blues.py index 1f34f0a276b..a9eebb677df 100644 --- a/tardis/plasma/properties/j_blues.py +++ b/tardis/plasma/properties/j_blues.py @@ -2,10 +2,8 @@ import pandas as pd from tardis import constants as const -from tardis.plasma.properties.base import ( - DataFrameInput, - ProcessingPlasmaProperty, -) +from tardis.plasma.properties.base import (DataFrameInput, + ProcessingPlasmaProperty) from tardis.util.base import intensity_black_body diff --git a/tardis/plasma/properties/level_population.py b/tardis/plasma/properties/level_population.py index 09ec8c3853e..d05a89ece67 100644 --- a/tardis/plasma/properties/level_population.py +++ b/tardis/plasma/properties/level_population.py @@ -1,6 +1,7 @@ import logging -import pandas as pd + import numpy as np +import pandas as pd from tardis.plasma.properties.base import ProcessingPlasmaProperty diff --git a/tardis/plasma/properties/nlte.py b/tardis/plasma/properties/nlte.py index f5a9a424046..9a8e70cc757 100644 --- a/tardis/plasma/properties/nlte.py +++ b/tardis/plasma/properties/nlte.py @@ -4,9 +4,7 @@ import numpy as np import pandas as pd -from tardis.plasma.properties.base import ( - PreviousIterationProperty, -) +from tardis.plasma.properties.base import PreviousIterationProperty from tardis.plasma.properties.ion_population import PhiSahaNebular __all__ = [ diff --git a/tardis/plasma/properties/partition_function.py b/tardis/plasma/properties/partition_function.py index 0fafaeee976..33a6df61019 100644 --- a/tardis/plasma/properties/partition_function.py +++ b/tardis/plasma/properties/partition_function.py @@ -1,11 +1,11 @@ import logging import numpy as np -from numpy.linalg.linalg import LinAlgError import pandas as pd +from numpy.linalg.linalg import LinAlgError -from tardis.plasma.properties.base import ProcessingPlasmaProperty from tardis.plasma.exceptions import PlasmaConfigError +from tardis.plasma.properties.base import ProcessingPlasmaProperty logger = logging.getLogger(__name__) diff --git a/tardis/plasma/properties/plasma_input.py b/tardis/plasma/properties/plasma_input.py index ac77507f978..3ed02065acc 100644 --- a/tardis/plasma/properties/plasma_input.py +++ b/tardis/plasma/properties/plasma_input.py @@ -1,8 +1,5 @@ -from tardis.plasma.properties.base import ( - ArrayInput, - Input, - ProcessingPlasmaProperty, -) +from tardis.plasma.properties.base import (ArrayInput, Input, + ProcessingPlasmaProperty) __all__ = [ "TRadiative", diff --git a/tardis/plasma/properties/property_collections.py b/tardis/plasma/properties/property_collections.py index 80d3753d266..83d6a162769 100644 --- a/tardis/plasma/properties/property_collections.py +++ b/tardis/plasma/properties/property_collections.py @@ -1,7 +1,5 @@ from tardis.opacities.macro_atom.base import ( - NonMarkovChainTransitionProbabilities, - TransitionProbabilities, -) + NonMarkovChainTransitionProbabilities, TransitionProbabilities) from tardis.opacities.tau_sobolev import TauSobolev from tardis.plasma.properties import * diff --git a/tardis/plasma/properties/radiative_properties.py b/tardis/plasma/properties/radiative_properties.py index a1b8d0a5d8e..d5709deec6e 100644 --- a/tardis/plasma/properties/radiative_properties.py +++ b/tardis/plasma/properties/radiative_properties.py @@ -7,10 +7,8 @@ from tardis import constants as const from tardis.opacities.macro_atom.base import TransitionProbabilities -from tardis.plasma.properties.base import ( - ProcessingPlasmaProperty, - TransitionProbabilitiesProperty, -) +from tardis.plasma.properties.base import (ProcessingPlasmaProperty, + TransitionProbabilitiesProperty) logger = logging.getLogger(__name__) diff --git a/tardis/plasma/properties/rate_matrix_index.py b/tardis/plasma/properties/rate_matrix_index.py index ab16121b57f..e7de82a4a8d 100644 --- a/tardis/plasma/properties/rate_matrix_index.py +++ b/tardis/plasma/properties/rate_matrix_index.py @@ -1,4 +1,5 @@ import pandas as pd + from tardis.plasma.properties.base import ProcessingPlasmaProperty __all__ = [ diff --git a/tardis/plasma/radiation_field/__init__.py b/tardis/plasma/radiation_field/__init__.py index 307ea6046c5..295379dd2bf 100644 --- a/tardis/plasma/radiation_field/__init__.py +++ b/tardis/plasma/radiation_field/__init__.py @@ -1,3 +1,2 @@ -from tardis.plasma.radiation_field.planck_rad_field import ( - DilutePlanckianRadiationField, -) +from tardis.plasma.radiation_field.planck_rad_field import \ + DilutePlanckianRadiationField diff --git a/tardis/plasma/standard_plasmas.py b/tardis/plasma/standard_plasmas.py index a048a59c254..6280ee980ba 100644 --- a/tardis/plasma/standard_plasmas.py +++ b/tardis/plasma/standard_plasmas.py @@ -6,46 +6,27 @@ from tardis.plasma import BasePlasma from tardis.plasma.exceptions import PlasmaConfigError -from tardis.plasma.properties import ( - HeliumNumericalNLTE, - IonNumberDensity, - IonNumberDensityHeNLTE, - JBluesBlackBody, - JBluesDetailed, - JBluesDiluteBlackBody, - LevelBoltzmannFactorNLTE, - MarkovChainTransProbsCollector, - RadiationFieldCorrection, - StimulatedEmissionFactor, -) +from tardis.plasma.properties import (HeliumNumericalNLTE, IonNumberDensity, + IonNumberDensityHeNLTE, JBluesBlackBody, + JBluesDetailed, JBluesDiluteBlackBody, + LevelBoltzmannFactorNLTE, + MarkovChainTransProbsCollector, + RadiationFieldCorrection, + StimulatedEmissionFactor) from tardis.plasma.properties.base import TransitionProbabilitiesProperty from tardis.plasma.properties.level_population import LevelNumberDensity from tardis.plasma.properties.nlte_rate_equation_solver import ( - NLTEPopulationSolverLU, - NLTEPopulationSolverRoot, -) + NLTEPopulationSolverLU, NLTEPopulationSolverRoot) from tardis.plasma.properties.property_collections import ( - adiabatic_cooling_properties, - basic_inputs, - basic_properties, - continuum_interaction_inputs, - continuum_interaction_properties, - detailed_j_blues_inputs, - detailed_j_blues_properties, - dilute_lte_excitation_properties, - helium_lte_properties, - helium_nlte_properties, - helium_numerical_nlte_properties, - lte_excitation_properties, - lte_ionization_properties, - macro_atom_properties, - nebular_ionization_properties, - nlte_lu_solver_properties, - nlte_properties, - nlte_root_solver_properties, - non_nlte_properties, - two_photon_properties, -) + adiabatic_cooling_properties, basic_inputs, basic_properties, + continuum_interaction_inputs, continuum_interaction_properties, + detailed_j_blues_inputs, detailed_j_blues_properties, + dilute_lte_excitation_properties, helium_lte_properties, + helium_nlte_properties, helium_numerical_nlte_properties, + lte_excitation_properties, lte_ionization_properties, + macro_atom_properties, nebular_ionization_properties, + nlte_lu_solver_properties, nlte_properties, nlte_root_solver_properties, + non_nlte_properties, two_photon_properties) from tardis.plasma.properties.rate_matrix_index import NLTEIndexHelper from tardis.plasma.radiation_field import DilutePlanckianRadiationField from tardis.util.base import species_string_to_tuple diff --git a/tardis/plasma/tests/__init__.py b/tardis/plasma/tests/__init__.py index 8b137891791..e69de29bb2d 100644 --- a/tardis/plasma/tests/__init__.py +++ b/tardis/plasma/tests/__init__.py @@ -1 +0,0 @@ - diff --git a/tardis/plasma/tests/data/abund.dat b/tardis/plasma/tests/data/abund.dat index 36145e93d2d..dead6c17642 100755 --- a/tardis/plasma/tests/data/abund.dat +++ b/tardis/plasma/tests/data/abund.dat @@ -1,12 +1,12 @@ H He - -0.000000 1.000000 -0.100000 0.900000 -0.200000 0.800000 -0.300000 0.700000 -0.400000 0.600000 -0.500000 0.500000 -0.600000 0.400000 -0.700000 0.300000 -0.800000 0.200000 -0.900000 0.100000 + +0.000000 1.000000 +0.100000 0.900000 +0.200000 0.800000 +0.300000 0.700000 +0.400000 0.600000 +0.500000 0.500000 +0.600000 0.400000 +0.700000 0.300000 +0.800000 0.200000 +0.900000 0.100000 diff --git a/tardis/plasma/tests/test_nlte_excitation.py b/tardis/plasma/tests/test_nlte_excitation.py index fcefce08c73..6a9d3562ac2 100644 --- a/tardis/plasma/tests/test_nlte_excitation.py +++ b/tardis/plasma/tests/test_nlte_excitation.py @@ -6,10 +6,8 @@ from tardis.plasma.properties.nlte_excitation_data import NLTEExcitationData from tardis.plasma.properties.nlte_rate_equation_solver import ( - prepare_r_uls_r_lus, - prepare_bound_bound_rate_matrix, - create_coll_exc_deexc_matrix, -) + create_coll_exc_deexc_matrix, prepare_bound_bound_rate_matrix, + prepare_r_uls_r_lus) def test_prepare_bound_bound_rate_matrix(nlte_atomic_dataset, regression_data): diff --git a/tardis/plasma/tests/test_nlte_solver.py b/tardis/plasma/tests/test_nlte_solver.py index 48045d3cf09..a16e9b791ce 100644 --- a/tardis/plasma/tests/test_nlte_solver.py +++ b/tardis/plasma/tests/test_nlte_solver.py @@ -2,18 +2,12 @@ import numpy.testing as npt import pandas as pd import pytest -import numpy.testing as npt - -from tardis.plasma.properties import ( - NLTEPopulationSolverLU, - NLTEPopulationSolverRoot, -) +from tardis.plasma.properties import (NLTEPopulationSolverLU, + NLTEPopulationSolverRoot) from tardis.plasma.properties.ion_population import IonNumberDensity from tardis.plasma.properties.nlte_rate_equation_solver import ( - calculate_jacobian_matrix, - calculate_rate_matrix, -) + calculate_jacobian_matrix, calculate_rate_matrix) from tardis.plasma.standard_plasmas import assemble_plasma diff --git a/tardis/plasma/tests/test_plasma_continuum.py b/tardis/plasma/tests/test_plasma_continuum.py index f0eaa28e170..c8a200e109f 100644 --- a/tardis/plasma/tests/test_plasma_continuum.py +++ b/tardis/plasma/tests/test_plasma_continuum.py @@ -1,6 +1,6 @@ import numpy as np - import numpy.testing as npt + from tardis.plasma.properties import YgData diff --git a/tardis/radiation_field/base.py b/tardis/radiation_field/base.py index 4fe0658c20c..5b77762c3a4 100644 --- a/tardis/radiation_field/base.py +++ b/tardis/radiation_field/base.py @@ -1,8 +1,8 @@ import numpy as np from astropy import units as u -from tardis.transport.montecarlo.packet_source import BasePacketSource from tardis.opacities.opacity_state import OpacityState +from tardis.transport.montecarlo.packet_source import BasePacketSource class MonteCarloRadiationFieldState: diff --git a/tardis/scripts/cmfgen2tardis.py b/tardis/scripts/cmfgen2tardis.py index 7f01fba3940..a8ecbdd5f12 100644 --- a/tardis/scripts/cmfgen2tardis.py +++ b/tardis/scripts/cmfgen2tardis.py @@ -1,6 +1,7 @@ +import argparse import os import sys -import argparse + import numpy as np import pandas as pd diff --git a/tardis/scripts/tardis b/tardis/scripts/tardis index 9d99a9b3776..c4f183c0b9b 100755 --- a/tardis/scripts/tardis +++ b/tardis/scripts/tardis @@ -1,9 +1,11 @@ #!/usr/bin/env python -import warnings import argparse import logging +import warnings + import numpy as np + from tardis.io import config_reader from tardis.simulation import Simulation diff --git a/tardis/simulation/base.py b/tardis/simulation/base.py index 378a6107ad3..ac5bd2ded87 100644 --- a/tardis/simulation/base.py +++ b/tardis/simulation/base.py @@ -11,9 +11,7 @@ from tardis import constants as const from tardis.io.configuration.config_reader import ConfigurationError from tardis.io.model.parse_atom_data import parse_atom_data -from tardis.io.model.parse_simulation_state import ( - parse_simulation_state, -) +from tardis.io.model.parse_simulation_state import parse_simulation_state from tardis.io.util import HDFWriterMixin from tardis.plasma.radiation_field import DilutePlanckianRadiationField from tardis.plasma.standard_plasmas import assemble_plasma diff --git a/tardis/simulation/tests/test_simulation.py b/tardis/simulation/tests/test_simulation.py index 5e6188bd746..ba68b20b7fc 100644 --- a/tardis/simulation/tests/test_simulation.py +++ b/tardis/simulation/tests/test_simulation.py @@ -1,20 +1,17 @@ +import logging import os - from pathlib import Path -import pytest -import logging - -from tardis.io.configuration.config_reader import Configuration -from tardis.simulation import Simulation -from tardis import run_tardis -import pandas.testing as pdt - +import astropy.units as u import numpy as np import pandas as pd +import pandas.testing as pdt +import pytest -import astropy.units as u import tardis +from tardis import run_tardis +from tardis.io.configuration.config_reader import Configuration +from tardis.simulation import Simulation @pytest.fixture(scope="module") diff --git a/tardis/spectrum/base.py b/tardis/spectrum/base.py index 4ef1a913258..1d8f7f37d35 100644 --- a/tardis/spectrum/base.py +++ b/tardis/spectrum/base.py @@ -6,9 +6,7 @@ from tardis.io.util import HDFWriterMixin from tardis.spectrum.formal_integral import IntegrationError from tardis.spectrum.spectrum import TARDISSpectrum -from tardis.util.base import ( - quantity_linspace, -) +from tardis.util.base import quantity_linspace class SpectrumSolver(HDFWriterMixin): diff --git a/tardis/spectrum/formal_integral.py b/tardis/spectrum/formal_integral.py index 3f938080a73..2048ded96b7 100644 --- a/tardis/spectrum/formal_integral.py +++ b/tardis/spectrum/formal_integral.py @@ -1,31 +1,24 @@ import warnings + import numpy as np import pandas as pd import scipy.sparse as sp import scipy.sparse.linalg as linalg -from scipy.interpolate import interp1d from astropy import units as u -from tardis import constants as const -from numba import njit, char, float64, int64, typeof, byte, prange +from numba import byte, char, float64, int64, njit, prange, typeof from numba.experimental import jitclass +from scipy.interpolate import interp1d - -from tardis.opacities.opacity_state import ( - OpacityState, - opacity_state_initialize, -) -from tardis.transport.montecarlo.configuration.constants import SIGMA_THOMSON -from tardis.transport.montecarlo.configuration import montecarlo_globals +from tardis import constants as const +from tardis.opacities.opacity_state import (OpacityState, + opacity_state_initialize) +from tardis.spectrum.formal_integral_cuda import CudaFormalIntegrator +from tardis.spectrum.spectrum import TARDISSpectrum from tardis.transport.montecarlo import njit_dict, njit_dict_no_parallel +from tardis.transport.montecarlo.configuration import montecarlo_globals +from tardis.transport.montecarlo.configuration.constants import SIGMA_THOMSON from tardis.transport.montecarlo.numba_interface import ( - opacity_state_initialize, - OpacityState, -) -from tardis.spectrum.formal_integral_cuda import ( - CudaFormalIntegrator, -) - -from tardis.spectrum.spectrum import TARDISSpectrum + OpacityState, opacity_state_initialize) C_INV = 3.33564e-11 M_PI = np.arccos(-1) diff --git a/tardis/spectrum/formal_integral_cuda.py b/tardis/spectrum/formal_integral_cuda.py index cf759a95f4c..0159762a970 100644 --- a/tardis/spectrum/formal_integral_cuda.py +++ b/tardis/spectrum/formal_integral_cuda.py @@ -1,8 +1,9 @@ +import math import sys + import numpy as np from astropy import units as u -from numba import float64, int64, cuda -import math +from numba import cuda, float64, int64 from tardis.transport.montecarlo.configuration.constants import SIGMA_THOMSON diff --git a/tardis/spectrum/tests/test_cuda_formal_integral.py b/tardis/spectrum/tests/test_cuda_formal_integral.py index 6f4dc3f7154..c7157065b40 100644 --- a/tardis/spectrum/tests/test_cuda_formal_integral.py +++ b/tardis/spectrum/tests/test_cuda_formal_integral.py @@ -7,14 +7,10 @@ import tardis.spectrum.formal_integral_cuda as formal_integral_cuda from tardis import constants as c from tardis.model.geometry.radial1d import NumbaRadial1DGeometry -from tardis.spectrum.formal_integral import ( - FormalIntegrator, - NumbaFormalIntegrator, -) - +from tardis.spectrum.formal_integral import (FormalIntegrator, + NumbaFormalIntegrator) from tardis.transport.montecarlo.base import MonteCarloTransportSolver - # Test cases must also take into account use of a GPU to run. If there is no GPU then the test cases will fail. GPUs_available = cuda.is_available() diff --git a/tardis/spectrum/tests/test_numba_formal_integral.py b/tardis/spectrum/tests/test_numba_formal_integral.py index f23c2c55a51..158eb821677 100644 --- a/tardis/spectrum/tests/test_numba_formal_integral.py +++ b/tardis/spectrum/tests/test_numba_formal_integral.py @@ -1,13 +1,13 @@ -import pytest -import numpy as np -from tardis import constants as c - from copy import deepcopy + +import numpy as np import numpy.testing as ntest +import pytest -from tardis.util.base import intensity_black_body import tardis.spectrum.formal_integral as formal_integral +from tardis import constants as c from tardis.model.geometry.radial1d import NumbaRadial1DGeometry +from tardis.util.base import intensity_black_body @pytest.mark.parametrize( diff --git a/tardis/spectrum/tests/test_spectrum.py b/tardis/spectrum/tests/test_spectrum.py index e23badeff42..95e93fb3f4c 100644 --- a/tardis/spectrum/tests/test_spectrum.py +++ b/tardis/spectrum/tests/test_spectrum.py @@ -1,14 +1,14 @@ -import pytest +import os + +import astropy.tests.helper as test_helper import numpy as np import pandas as pd -import os +import pytest from astropy import units as u -from tardis import constants as c -import astropy.tests.helper as test_helper from numpy.testing import assert_almost_equal -from tardis.spectrum.spectrum import ( - TARDISSpectrum, -) + +from tardis import constants as c +from tardis.spectrum.spectrum import TARDISSpectrum BIN = 5 diff --git a/tardis/tests/fixtures/atom_data.py b/tardis/tests/fixtures/atom_data.py index d2b4c7b084a..4cdc5ad8bd8 100644 --- a/tardis/tests/fixtures/atom_data.py +++ b/tardis/tests/fixtures/atom_data.py @@ -1,5 +1,6 @@ from copy import deepcopy from pathlib import Path + import pytest from tardis.io.atom_data.base import AtomData diff --git a/tardis/tests/integration_tests/conftest.py b/tardis/tests/integration_tests/conftest.py index 2392fbe8446..de05ee3a7a8 100644 --- a/tardis/tests/integration_tests/conftest.py +++ b/tardis/tests/integration_tests/conftest.py @@ -1,8 +1,9 @@ import glob import os -import yaml + import pandas as pd import pytest +import yaml # NOTE: the __githash__ variable is not available anymore # on `version.py`. Find another way to fix it! diff --git a/tardis/tests/integration_tests/test_integration.py b/tardis/tests/integration_tests/test_integration.py index a380763e12a..a344f030b0b 100644 --- a/tardis/tests/integration_tests/test_integration.py +++ b/tardis/tests/integration_tests/test_integration.py @@ -1,16 +1,16 @@ import os -import yaml -import pytest import matplotlib +import pytest +import yaml matplotlib.use("Agg") import matplotlib.pyplot as plt from numpy.testing import assert_allclose from tardis.io.atom_data.base import AtomData -from tardis.simulation import Simulation from tardis.io.configuration.config_reader import Configuration +from tardis.simulation import Simulation pytestmarker = [pytest.mark.no_cover, pytest.mark.integration] diff --git a/tardis/tests/test_util.py b/tardis/tests/test_util.py index 335f9442d14..0854695b96b 100644 --- a/tardis/tests/test_util.py +++ b/tardis/tests/test_util.py @@ -1,28 +1,19 @@ -import pytest +from io import StringIO + import numpy as np import numpy.testing as npt - +import pytest from astropy import units as u -from io import StringIO -from tardis.util.base import ( - MalformedSpeciesError, - MalformedElementSymbolError, - MalformedQuantityError, - int_to_roman, - roman_to_int, - calculate_luminosity, - create_synpp_yaml, - intensity_black_body, - species_tuple_to_string, - species_string_to_tuple, - parse_quantity, - element_symbol2atomic_number, - atomic_number2element_symbol, - reformat_element_symbol, - quantity_linspace, - convert_abundances_format, -) +from tardis.util.base import (MalformedElementSymbolError, + MalformedQuantityError, MalformedSpeciesError, + atomic_number2element_symbol, + calculate_luminosity, convert_abundances_format, + create_synpp_yaml, element_symbol2atomic_number, + int_to_roman, intensity_black_body, + parse_quantity, quantity_linspace, + reformat_element_symbol, roman_to_int, + species_string_to_tuple, species_tuple_to_string) @pytest.fixture diff --git a/tardis/transport/frame_transformations.py b/tardis/transport/frame_transformations.py index 9813664b98a..32a23ee1931 100644 --- a/tardis/transport/frame_transformations.py +++ b/tardis/transport/frame_transformations.py @@ -2,11 +2,9 @@ from numba import njit -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) - -from tardis.transport.montecarlo.configuration.constants import C_SPEED_OF_LIGHT +from tardis.transport.montecarlo import njit_dict_no_parallel +from tardis.transport.montecarlo.configuration.constants import \ + C_SPEED_OF_LIGHT @njit(**njit_dict_no_parallel) diff --git a/tardis/transport/geometry/calculate_distances.py b/tardis/transport/geometry/calculate_distances.py index 02b1c13cb2b..5745bbe06b5 100644 --- a/tardis/transport/geometry/calculate_distances.py +++ b/tardis/transport/geometry/calculate_distances.py @@ -2,21 +2,11 @@ from numba import njit -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) - +from tardis.transport.montecarlo import njit_dict_no_parallel from tardis.transport.montecarlo.configuration.constants import ( - C_SPEED_OF_LIGHT, - MISS_DISTANCE, - SIGMA_THOMSON, - CLOSE_LINE_THRESHOLD, -) - + C_SPEED_OF_LIGHT, CLOSE_LINE_THRESHOLD, MISS_DISTANCE, SIGMA_THOMSON) +from tardis.transport.montecarlo.r_packet import print_r_packet_properties from tardis.transport.montecarlo.utils import MonteCarloException -from tardis.transport.montecarlo.r_packet import ( - print_r_packet_properties, -) @njit(**njit_dict_no_parallel) diff --git a/tardis/transport/montecarlo/__init__.py b/tardis/transport/montecarlo/__init__.py index 23913353290..299d3d538dd 100644 --- a/tardis/transport/montecarlo/__init__.py +++ b/tardis/transport/montecarlo/__init__.py @@ -1,9 +1,9 @@ """ -Faciliating the MonteCarlo iterations. +Faciliating the MonteCarlo iterations. During a simulation run, a number of MonteCarlo iterations specified in the configuration are run using the numba compiler. -Most of the iterations are used to calculate the steady-state plasma +Most of the iterations are used to calculate the steady-state plasma properties and with the last iteration, the spectrum is determined. """ @@ -21,7 +21,5 @@ "parallel": False, } +from tardis.transport.montecarlo.packet_collections import PacketCollection from tardis.transport.montecarlo.r_packet import RPacket -from tardis.transport.montecarlo.packet_collections import ( - PacketCollection, -) diff --git a/tardis/transport/montecarlo/base.py b/tardis/transport/montecarlo/base.py index 8c7559da7fb..a53d0f6d486 100644 --- a/tardis/transport/montecarlo/base.py +++ b/tardis/transport/montecarlo/base.py @@ -7,30 +7,20 @@ from tardis import constants as const from tardis.io.logger import montecarlo_tracking as mc_tracker from tardis.io.util import HDFWriterMixin -from tardis.transport.montecarlo.montecarlo_main_loop import ( - montecarlo_main_loop, -) from tardis.transport.montecarlo.configuration.base import ( - MonteCarloConfiguration, - configuration_initialize, -) -from tardis.transport.montecarlo.estimators.radfield_mc_estimators import ( - initialize_estimator_statistics, -) -from tardis.transport.montecarlo.montecarlo_transport_state import ( - MonteCarloTransportState, -) -from tardis.transport.montecarlo.numba_interface import ( - opacity_state_initialize, -) -from tardis.transport.montecarlo.packet_trackers import ( - rpacket_trackers_to_dataframe, -) -from tardis.util.base import ( - quantity_linspace, - refresh_packet_pbar, - update_iterations_pbar, -) + MonteCarloConfiguration, configuration_initialize) +from tardis.transport.montecarlo.estimators.radfield_mc_estimators import \ + initialize_estimator_statistics +from tardis.transport.montecarlo.montecarlo_main_loop import \ + montecarlo_main_loop +from tardis.transport.montecarlo.montecarlo_transport_state import \ + MonteCarloTransportState +from tardis.transport.montecarlo.numba_interface import \ + opacity_state_initialize +from tardis.transport.montecarlo.packet_trackers import \ + rpacket_trackers_to_dataframe +from tardis.util.base import (quantity_linspace, refresh_packet_pbar, + update_iterations_pbar) logger = logging.getLogger(__name__) diff --git a/tardis/transport/montecarlo/configuration/base.py b/tardis/transport/montecarlo/configuration/base.py index 3e890f39c57..668452e1aec 100644 --- a/tardis/transport/montecarlo/configuration/base.py +++ b/tardis/transport/montecarlo/configuration/base.py @@ -1,13 +1,11 @@ +import numpy as np from astropy import units as u -from numba import float64, int64, boolean +from numba import boolean, float64, int64 from numba.experimental import jitclass -import numpy as np -from tardis.transport.montecarlo.configuration import montecarlo_globals from tardis.transport.montecarlo import montecarlo_main_loop -from tardis.transport.montecarlo.numba_interface import ( - LineInteractionType, -) +from tardis.transport.montecarlo.configuration import montecarlo_globals +from tardis.transport.montecarlo.numba_interface import LineInteractionType numba_config_spec = [ ("ENABLE_FULL_RELATIVITY", boolean), diff --git a/tardis/transport/montecarlo/estimators/continuum_radfield_properties.py b/tardis/transport/montecarlo/estimators/continuum_radfield_properties.py index da742cc1ee3..5796af2374c 100644 --- a/tardis/transport/montecarlo/estimators/continuum_radfield_properties.py +++ b/tardis/transport/montecarlo/estimators/continuum_radfield_properties.py @@ -6,17 +6,14 @@ import tardis.constants as const from tardis.io.atom_data import AtomData -from tardis.plasma.radiation_field.planck_rad_field import ( - DilutePlanckianRadiationField, -) -from tardis.transport.montecarlo.estimators.radfield_mc_estimators import ( - RadiationFieldMCEstimators, -) +from tardis.plasma.properties.continuum_processes import \ + PhotoIonBoltzmannFactor +from tardis.plasma.radiation_field.planck_rad_field import \ + DilutePlanckianRadiationField +from tardis.transport.montecarlo.estimators.radfield_mc_estimators import \ + RadiationFieldMCEstimators from tardis.transport.montecarlo.estimators.util import ( - bound_free_estimator_array2frame, - integrate_array_by_blocks, -) -from tardis.plasma.properties.continuum_processes import PhotoIonBoltzmannFactor + bound_free_estimator_array2frame, integrate_array_by_blocks) H = const.h.cgs.value diff --git a/tardis/transport/montecarlo/estimators/dilute_blackbody_properties.py b/tardis/transport/montecarlo/estimators/dilute_blackbody_properties.py index c82612584ea..5406d7cb203 100644 --- a/tardis/transport/montecarlo/estimators/dilute_blackbody_properties.py +++ b/tardis/transport/montecarlo/estimators/dilute_blackbody_properties.py @@ -3,9 +3,8 @@ from scipy.special import zeta from tardis import constants as const -from tardis.plasma.radiation_field.planck_rad_field import ( - DilutePlanckianRadiationField, -) +from tardis.plasma.radiation_field.planck_rad_field import \ + DilutePlanckianRadiationField DILUTION_FACTOR_ESTIMATOR_CONSTANT = ( (const.c**2 / (2 * const.h)) diff --git a/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py b/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py index 6be62d7af0c..8692b5f6abc 100644 --- a/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py +++ b/tardis/transport/montecarlo/estimators/radfield_estimator_calcs.py @@ -2,14 +2,10 @@ from numba import njit -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) -from tardis.transport.montecarlo.configuration.constants import KB, H from tardis.transport.frame_transformations import ( - calc_packet_energy, - calc_packet_energy_full_relativity, -) + calc_packet_energy, calc_packet_energy_full_relativity) +from tardis.transport.montecarlo import njit_dict_no_parallel +from tardis.transport.montecarlo.configuration.constants import KB, H @njit(**njit_dict_no_parallel) diff --git a/tardis/transport/montecarlo/estimators/tests/test_continuum_property_solver.py b/tardis/transport/montecarlo/estimators/tests/test_continuum_property_solver.py index b3e322c2aa2..774a87fbd2c 100644 --- a/tardis/transport/montecarlo/estimators/tests/test_continuum_property_solver.py +++ b/tardis/transport/montecarlo/estimators/tests/test_continuum_property_solver.py @@ -4,11 +4,9 @@ import pandas.testing as pdt import pytest -from tardis.transport.montecarlo.estimators.continuum_radfield_properties import ( - DiluteBlackBodyContinuumPropertiesSolver, - MCContinuumPropertiesSolver, -) from tardis.simulation import Simulation +from tardis.transport.montecarlo.estimators.continuum_radfield_properties import ( + DiluteBlackBodyContinuumPropertiesSolver, MCContinuumPropertiesSolver) @pytest.mark.continuum diff --git a/tardis/transport/montecarlo/interaction.py b/tardis/transport/montecarlo/interaction.py index 0801fec4e34..5133a3bc51a 100644 --- a/tardis/transport/montecarlo/interaction.py +++ b/tardis/transport/montecarlo/interaction.py @@ -3,23 +3,15 @@ import tardis.transport.montecarlo.configuration.montecarlo_globals as montecarlo_globals from tardis import constants as const +from tardis.transport.frame_transformations import (angle_aberration_CMF_to_LF, + get_doppler_factor, + get_inverse_doppler_factor) from tardis.transport.montecarlo import njit_dict_no_parallel -from tardis.transport.montecarlo.macro_atom import ( - MacroAtomTransitionType, - macro_atom, -) -from tardis.transport.montecarlo.numba_interface import ( - LineInteractionType, -) -from tardis.transport.montecarlo.r_packet import ( - PacketStatus, -) +from tardis.transport.montecarlo.macro_atom import (MacroAtomTransitionType, + macro_atom) +from tardis.transport.montecarlo.numba_interface import LineInteractionType +from tardis.transport.montecarlo.r_packet import PacketStatus from tardis.transport.montecarlo.utils import get_random_mu -from tardis.transport.frame_transformations import ( - angle_aberration_CMF_to_LF, - get_doppler_factor, - get_inverse_doppler_factor, -) K_B = const.k_B.cgs.value H = const.h.cgs.value diff --git a/tardis/transport/montecarlo/macro_atom.py b/tardis/transport/montecarlo/macro_atom.py index c1864486bd8..c81a13e5a4b 100644 --- a/tardis/transport/montecarlo/macro_atom.py +++ b/tardis/transport/montecarlo/macro_atom.py @@ -1,7 +1,8 @@ -import numpy as np from enum import IntEnum +import numpy as np from numba import njit + from tardis.transport.montecarlo import njit_dict, njit_dict_no_parallel diff --git a/tardis/transport/montecarlo/montecarlo_main_loop.py b/tardis/transport/montecarlo/montecarlo_main_loop.py index 8460b72461b..ceae9e3eccf 100644 --- a/tardis/transport/montecarlo/montecarlo_main_loop.py +++ b/tardis/transport/montecarlo/montecarlo_main_loop.py @@ -3,25 +3,16 @@ from numba.np.ufunc.parallel import get_num_threads, get_thread_id from numba.typed import List +import tardis.transport.montecarlo.montecarlo_main_loop as montecarlo_loop from tardis.transport.montecarlo import njit_dict from tardis.transport.montecarlo.configuration import montecarlo_globals from tardis.transport.montecarlo.packet_collections import ( - VPacketCollection, - consolidate_vpacket_tracker, - initialize_last_interaction_tracker, -) -import tardis.transport.montecarlo.montecarlo_main_loop as montecarlo_loop + VPacketCollection, consolidate_vpacket_tracker, + initialize_last_interaction_tracker) from tardis.transport.montecarlo.packet_trackers import ( - RPacketTracker, - RPacketLastInteractionTracker, -) -from tardis.transport.montecarlo.r_packet import ( - PacketStatus, - RPacket, -) -from tardis.transport.montecarlo.single_packet_loop import ( - single_packet_loop, -) + RPacketLastInteractionTracker, RPacketTracker) +from tardis.transport.montecarlo.r_packet import PacketStatus, RPacket +from tardis.transport.montecarlo.single_packet_loop import single_packet_loop from tardis.util.base import update_packet_pbar ENABLE_RPACKET_TRACKING = False diff --git a/tardis/transport/montecarlo/montecarlo_transport_state.py b/tardis/transport/montecarlo/montecarlo_transport_state.py index 293024a2f5d..e296653765a 100644 --- a/tardis/transport/montecarlo/montecarlo_transport_state.py +++ b/tardis/transport/montecarlo/montecarlo_transport_state.py @@ -4,11 +4,10 @@ from astropy import units as u from tardis.io.util import HDFWriterMixin -from tardis.transport.montecarlo.estimators.dilute_blackbody_properties import ( - MCDiluteBlackBodyRadFieldSolver, -) from tardis.spectrum.formal_integral import IntegrationError from tardis.spectrum.spectrum import TARDISSpectrum +from tardis.transport.montecarlo.estimators.dilute_blackbody_properties import \ + MCDiluteBlackBodyRadFieldSolver class MonteCarloTransportState(HDFWriterMixin): diff --git a/tardis/transport/montecarlo/nonhomologous_grid.py b/tardis/transport/montecarlo/nonhomologous_grid.py index 05b681a91f7..1e7b27bddcf 100644 --- a/tardis/transport/montecarlo/nonhomologous_grid.py +++ b/tardis/transport/montecarlo/nonhomologous_grid.py @@ -1,9 +1,7 @@ import numpy as np from numba import njit -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) +from tardis.transport.montecarlo import njit_dict_no_parallel @njit(**njit_dict_no_parallel) diff --git a/tardis/transport/montecarlo/packet_collections.py b/tardis/transport/montecarlo/packet_collections.py index 2f73e083c0d..37f7e872520 100644 --- a/tardis/transport/montecarlo/packet_collections.py +++ b/tardis/transport/montecarlo/packet_collections.py @@ -2,9 +2,7 @@ from numba import float64, int64, njit from numba.experimental import jitclass -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) +from tardis.transport.montecarlo import njit_dict_no_parallel packet_collection_spec = [ ("initial_radii", float64[:]), diff --git a/tardis/transport/montecarlo/packet_source.py b/tardis/transport/montecarlo/packet_source.py index ae2f73e8df8..0fc0d21a807 100644 --- a/tardis/transport/montecarlo/packet_source.py +++ b/tardis/transport/montecarlo/packet_source.py @@ -1,13 +1,12 @@ import abc -import numpy as np import numexpr as ne +import numpy as np +from astropy import units as u + from tardis import constants as const -from tardis.transport.montecarlo.packet_collections import ( - PacketCollection, -) from tardis.io.util import HDFWriterMixin -from astropy import units as u +from tardis.transport.montecarlo.packet_collections import PacketCollection class BasePacketSource(abc.ABC): diff --git a/tardis/transport/montecarlo/packet_trackers.py b/tardis/transport/montecarlo/packet_trackers.py index f7ff0a50cd5..b5ce23fff58 100644 --- a/tardis/transport/montecarlo/packet_trackers.py +++ b/tardis/transport/montecarlo/packet_trackers.py @@ -1,7 +1,7 @@ -from numba import float64, int64 -from numba.experimental import jitclass import numpy as np import pandas as pd +from numba import float64, int64 +from numba.experimental import jitclass rpacket_tracker_spec = [ ("length", int64), diff --git a/tardis/transport/montecarlo/r_packet.py b/tardis/transport/montecarlo/r_packet.py index 038468afcac..98a91903fb7 100644 --- a/tardis/transport/montecarlo/r_packet.py +++ b/tardis/transport/montecarlo/r_packet.py @@ -2,15 +2,10 @@ import numpy as np import pandas as pd -from numba import int64, float64, njit, objmode +from numba import float64, int64, njit, objmode from numba.experimental import jitclass -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) -from tardis.transport.frame_transformations import ( - get_doppler_factor, -) +from tardis.transport.frame_transformations import get_doppler_factor from tardis.transport.montecarlo import njit_dict_no_parallel diff --git a/tardis/transport/montecarlo/r_packet_transport.py b/tardis/transport/montecarlo/r_packet_transport.py index a7a9aa01cbd..bbe551b34f3 100644 --- a/tardis/transport/montecarlo/r_packet_transport.py +++ b/tardis/transport/montecarlo/r_packet_transport.py @@ -2,22 +2,13 @@ from numba import njit import tardis.transport.montecarlo.configuration.montecarlo_globals as montecarlo_globals -from tardis.transport.frame_transformations import ( - get_doppler_factor, -) +from tardis.transport.frame_transformations import get_doppler_factor from tardis.transport.geometry.calculate_distances import ( - calculate_distance_boundary, - calculate_distance_line, -) + calculate_distance_boundary, calculate_distance_line) from tardis.transport.montecarlo import njit_dict_no_parallel from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import ( - update_base_estimators, - update_line_estimators, -) -from tardis.transport.montecarlo.r_packet import ( - InteractionType, - PacketStatus, -) + update_base_estimators, update_line_estimators) +from tardis.transport.montecarlo.r_packet import InteractionType, PacketStatus @njit(**njit_dict_no_parallel) diff --git a/tardis/transport/montecarlo/single_packet_loop.py b/tardis/transport/montecarlo/single_packet_loop.py index 36763b03725..397e2a41519 100644 --- a/tardis/transport/montecarlo/single_packet_loop.py +++ b/tardis/transport/montecarlo/single_packet_loop.py @@ -1,33 +1,20 @@ from numba import njit from tardis import constants as const -from tardis.opacities.opacities import ( - chi_continuum_calculator, - chi_electron_calculator, -) -from tardis.transport.frame_transformations import ( - get_doppler_factor, - get_inverse_doppler_factor, -) -from tardis.transport.montecarlo.r_packet import RPacket +from tardis.opacities.opacities import (chi_continuum_calculator, + chi_electron_calculator) +from tardis.transport.frame_transformations import (get_doppler_factor, + get_inverse_doppler_factor) from tardis.transport.montecarlo.configuration import montecarlo_globals -from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import ( - update_bound_free_estimators, -) -from tardis.transport.montecarlo.interaction import ( - continuum_event, - line_scatter, - thomson_scatter, -) -from tardis.transport.montecarlo.r_packet import ( - InteractionType, - PacketStatus, -) +from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import \ + update_bound_free_estimators +from tardis.transport.montecarlo.interaction import (continuum_event, + line_scatter, + thomson_scatter) +from tardis.transport.montecarlo.r_packet import (InteractionType, + PacketStatus, RPacket) from tardis.transport.montecarlo.r_packet_transport import ( - move_packet_across_shell_boundary, - move_r_packet, - trace_packet, -) + move_packet_across_shell_boundary, move_r_packet, trace_packet) from tardis.transport.montecarlo.vpacket import trace_vpacket_volley C_SPEED_OF_LIGHT = const.c.to("cm/s").value diff --git a/tardis/transport/montecarlo/tests/__init__.py b/tardis/transport/montecarlo/tests/__init__.py index 8b137891791..e69de29bb2d 100644 --- a/tardis/transport/montecarlo/tests/__init__.py +++ b/tardis/transport/montecarlo/tests/__init__.py @@ -1 +0,0 @@ - diff --git a/tardis/transport/montecarlo/tests/conftest.py b/tardis/transport/montecarlo/tests/conftest.py index 61f80e4aac0..362c6db2232 100644 --- a/tardis/transport/montecarlo/tests/conftest.py +++ b/tardis/transport/montecarlo/tests/conftest.py @@ -7,18 +7,13 @@ from tardis.opacities.opacity_state import opacity_state_initialize from tardis.simulation import Simulation from tardis.transport.montecarlo import RPacket -from tardis.transport.montecarlo.estimators.radfield_mc_estimators import ( - RadiationFieldMCEstimators, -) -from tardis.transport.montecarlo.numba_interface import ( - opacity_state_initialize, -) -from tardis.transport.montecarlo.packet_collections import ( - VPacketCollection, -) -from tardis.transport.montecarlo.weighted_packet_source import ( - BlackBodyWeightedSource, -) +from tardis.transport.montecarlo.estimators.radfield_mc_estimators import \ + RadiationFieldMCEstimators +from tardis.transport.montecarlo.numba_interface import \ + opacity_state_initialize +from tardis.transport.montecarlo.packet_collections import VPacketCollection +from tardis.transport.montecarlo.weighted_packet_source import \ + BlackBodyWeightedSource @pytest.fixture(scope="function") diff --git a/tardis/transport/montecarlo/tests/test_base.py b/tardis/transport/montecarlo/tests/test_base.py index 876aaffb10d..647980550fa 100644 --- a/tardis/transport/montecarlo/tests/test_base.py +++ b/tardis/transport/montecarlo/tests/test_base.py @@ -1,10 +1,11 @@ import os -import pandas as pd +from pathlib import Path + import numpy as np +import pandas as pd import pytest from astropy import units as u from numpy.testing import assert_almost_equal -from pathlib import Path ### # Save and Load diff --git a/tardis/transport/montecarlo/tests/test_interaction.py b/tardis/transport/montecarlo/tests/test_interaction.py index bd6d04422cf..3b66bc5f51d 100644 --- a/tardis/transport/montecarlo/tests/test_interaction.py +++ b/tardis/transport/montecarlo/tests/test_interaction.py @@ -1,10 +1,9 @@ -import pytest -import numpy.testing as npt import numpy as np +import numpy.testing as npt +import pytest + import tardis.transport.montecarlo.interaction as interaction -from tardis.transport.montecarlo.numba_interface import ( - LineInteractionType, -) +from tardis.transport.montecarlo.numba_interface import LineInteractionType def test_thomson_scatter(packet, verysimple_time_explosion): diff --git a/tardis/transport/montecarlo/tests/test_macro_atom.py b/tardis/transport/montecarlo/tests/test_macro_atom.py index 5ef26f16b49..7bb065b12bd 100644 --- a/tardis/transport/montecarlo/tests/test_macro_atom.py +++ b/tardis/transport/montecarlo/tests/test_macro_atom.py @@ -1,6 +1,7 @@ +import numpy as np import pytest + import tardis.transport.montecarlo.macro_atom as macro_atom -import numpy as np @pytest.mark.parametrize( diff --git a/tardis/transport/montecarlo/tests/test_montecarlo.py b/tardis/transport/montecarlo/tests/test_montecarlo.py index eb6d97cd406..030012deaf9 100644 --- a/tardis/transport/montecarlo/tests/test_montecarlo.py +++ b/tardis/transport/montecarlo/tests/test_montecarlo.py @@ -6,28 +6,22 @@ import tardis.spectrum.formal_integral as formal_integral import tardis.transport.montecarlo.r_packet as r_packet -import tardis.transport.montecarlo.utils as utils import tardis.transport.montecarlo.r_packet_transport as r_packet_transport +import tardis.transport.montecarlo.utils as utils from tardis import constants as const -from tardis.transport.montecarlo.estimators.radfield_mc_estimators import ( - RadiationFieldMCEstimators, -) +from tardis.transport.frame_transformations import (angle_aberration_CMF_to_LF, + angle_aberration_LF_to_CMF, + get_doppler_factor) +from tardis.transport.montecarlo.estimators.radfield_mc_estimators import \ + RadiationFieldMCEstimators from tardis.transport.montecarlo.packet_trackers import RPacketTracker -from tardis.transport.frame_transformations import ( - angle_aberration_CMF_to_LF, - angle_aberration_LF_to_CMF, - get_doppler_factor, -) C_SPEED_OF_LIGHT = const.c.to("cm/s").value pytestmark = pytest.mark.skip(reason="Port from C to numba") -from numpy.testing import ( - assert_allclose, - assert_almost_equal, -) +from numpy.testing import assert_allclose, assert_almost_equal from tardis import __path__ as path diff --git a/tardis/transport/montecarlo/tests/test_numba_interface.py b/tardis/transport/montecarlo/tests/test_numba_interface.py index 25d907049f6..1bd16a56fd8 100644 --- a/tardis/transport/montecarlo/tests/test_numba_interface.py +++ b/tardis/transport/montecarlo/tests/test_numba_interface.py @@ -1,7 +1,8 @@ +import numpy as np +import numpy.testing as npt import pytest + import tardis.opacities.opacity_state as numba_interface -import numpy.testing as npt -import numpy as np @pytest.mark.parametrize("input_params", ["scatter", "macroatom", "downbranch"]) diff --git a/tardis/transport/montecarlo/tests/test_opacities.py b/tardis/transport/montecarlo/tests/test_opacities.py index 07096d6e0c6..02f5e20fc06 100644 --- a/tardis/transport/montecarlo/tests/test_opacities.py +++ b/tardis/transport/montecarlo/tests/test_opacities.py @@ -1,12 +1,10 @@ import numpy.testing as npt import pytest -from tardis.opacities.opacities import ( - compton_opacity_calculation, - kappa_calculation, - pair_creation_opacity_calculation, - photoabsorption_opacity_calculation, -) +from tardis.opacities.opacities import (compton_opacity_calculation, + kappa_calculation, + pair_creation_opacity_calculation, + photoabsorption_opacity_calculation) @pytest.mark.parametrize( diff --git a/tardis/transport/montecarlo/tests/test_packet.py b/tardis/transport/montecarlo/tests/test_packet.py index ce8b756123f..ca85add8ba5 100644 --- a/tardis/transport/montecarlo/tests/test_packet.py +++ b/tardis/transport/montecarlo/tests/test_packet.py @@ -1,33 +1,24 @@ import numpy as np import pytest -import tardis.opacities.opacities as opacities -import tardis.transport.frame_transformations as frame_transformations -import tardis.transport.geometry.calculate_distances as calculate_distances -import tardis.transport.montecarlo.estimators.radfield_mc_estimators import tardis.opacities.opacities as opacities import tardis.transport.frame_transformations as frame_transformations import tardis.transport.geometry.calculate_distances as calculate_distances import tardis.transport.montecarlo.configuration.montecarlo_globals as montecarlo_globals +import tardis.transport.montecarlo.estimators.radfield_mc_estimators import tardis.transport.montecarlo.numba_interface as numba_interface import tardis.transport.montecarlo.r_packet as r_packet -import tardis.transport.montecarlo.utils as utils -import tardis.transport.frame_transformations as frame_transformations -import tardis.transport.geometry.calculate_distances as calculate_distances import tardis.transport.montecarlo.r_packet_transport as r_packet_transport +import tardis.transport.montecarlo.utils as utils from tardis import constants as const from tardis.model.geometry.radial1d import NumbaRadial1DGeometry -from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import ( - update_line_estimators, -) +from tardis.transport.montecarlo.estimators.radfield_estimator_calcs import \ + update_line_estimators C_SPEED_OF_LIGHT = const.c.to("cm/s").value SIGMA_THOMSON = const.sigma_T.to("cm^2").value -from numpy.testing import ( - assert_allclose, - assert_almost_equal, -) +from numpy.testing import assert_allclose, assert_almost_equal @pytest.fixture(scope="function") diff --git a/tardis/transport/montecarlo/tests/test_packet_source.py b/tardis/transport/montecarlo/tests/test_packet_source.py index a34dd2c0b71..71573eda6ae 100644 --- a/tardis/transport/montecarlo/tests/test_packet_source.py +++ b/tardis/transport/montecarlo/tests/test_packet_source.py @@ -1,16 +1,14 @@ import os -from astropy import units as u import numpy as np import pandas as pd import pytest +from astropy import units as u from numpy.testing import assert_allclose -from tardis.transport.montecarlo.packet_source import ( - BlackBodySimpleSource, - BlackBodySimpleSourceRelativistic, -) from tardis.tests.fixtures.regression_data import RegressionData +from tardis.transport.montecarlo.packet_source import ( + BlackBodySimpleSource, BlackBodySimpleSourceRelativistic) class TestBlackBodySimpleSource: diff --git a/tardis/transport/montecarlo/tests/test_rpacket_last_interaction_tracker.py b/tardis/transport/montecarlo/tests/test_rpacket_last_interaction_tracker.py index b9f94d4ecd5..94d949312bb 100644 --- a/tardis/transport/montecarlo/tests/test_rpacket_last_interaction_tracker.py +++ b/tardis/transport/montecarlo/tests/test_rpacket_last_interaction_tracker.py @@ -1,11 +1,10 @@ -import pytest import numpy as np import numpy.testing as npt +import pytest +from tardis.transport.montecarlo.packet_trackers import \ + RPacketLastInteractionTracker from tardis.transport.montecarlo.r_packet import InteractionType -from tardis.transport.montecarlo.packet_trackers import ( - RPacketLastInteractionTracker, -) @pytest.fixture(scope="module") diff --git a/tardis/transport/montecarlo/tests/test_rpacket_tracker.py b/tardis/transport/montecarlo/tests/test_rpacket_tracker.py index 9a42da459e5..8677d50bb42 100644 --- a/tardis/transport/montecarlo/tests/test_rpacket_tracker.py +++ b/tardis/transport/montecarlo/tests/test_rpacket_tracker.py @@ -1,12 +1,10 @@ +import numpy as np import numpy.testing as npt import pytest -import numpy as np +from tardis.transport.montecarlo.packet_trackers import \ + rpacket_trackers_to_dataframe from tardis.transport.montecarlo.r_packet import InteractionType -from tardis.transport.montecarlo.packet_trackers import ( - rpacket_trackers_to_dataframe, -) - pytestmark = pytest.mark.rpacket_tracking diff --git a/tardis/transport/montecarlo/tests/test_single_packet_loop.py b/tardis/transport/montecarlo/tests/test_single_packet_loop.py index 065b694c5f4..b6270d3c746 100644 --- a/tardis/transport/montecarlo/tests/test_single_packet_loop.py +++ b/tardis/transport/montecarlo/tests/test_single_packet_loop.py @@ -1,11 +1,8 @@ -import pytest - import numpy.testing as npt +import pytest from tardis.transport.montecarlo import RPacket -from tardis.transport.montecarlo.single_packet_loop import ( - single_packet_loop, -) +from tardis.transport.montecarlo.single_packet_loop import single_packet_loop @pytest.mark.xfail(reason="Need to fix estimator differences across runs") diff --git a/tardis/transport/montecarlo/tests/test_vpacket.py b/tardis/transport/montecarlo/tests/test_vpacket.py index e081abe7670..fc1fac961e9 100644 --- a/tardis/transport/montecarlo/tests/test_vpacket.py +++ b/tardis/transport/montecarlo/tests/test_vpacket.py @@ -1,13 +1,12 @@ import os -import pytest + import numpy as np import pandas as pd +import pytest + import tardis.transport.montecarlo.vpacket as vpacket from tardis import constants as const - -from tardis.transport.frame_transformations import ( - get_doppler_factor, -) +from tardis.transport.frame_transformations import get_doppler_factor C_SPEED_OF_LIGHT = const.c.to("cm/s").value diff --git a/tardis/transport/montecarlo/tests/test_weighted_packet_source.py b/tardis/transport/montecarlo/tests/test_weighted_packet_source.py index 34b8f4599b7..e01cdfa9265 100644 --- a/tardis/transport/montecarlo/tests/test_weighted_packet_source.py +++ b/tardis/transport/montecarlo/tests/test_weighted_packet_source.py @@ -1,15 +1,14 @@ import os -from astropy import units as u import numpy as np import pandas as pd import pytest +from astropy import units as u from numpy.testing import assert_allclose -from tardis.transport.montecarlo.weighted_packet_source import ( - BlackBodyWeightedSource, -) from tardis.tests.fixtures.regression_data import RegressionData +from tardis.transport.montecarlo.weighted_packet_source import \ + BlackBodyWeightedSource class TestBlackBodyWeightedSource: diff --git a/tardis/transport/montecarlo/utils.py b/tardis/transport/montecarlo/utils.py index 1bc4e1a6ccb..431cccea666 100644 --- a/tardis/transport/montecarlo/utils.py +++ b/tardis/transport/montecarlo/utils.py @@ -1,8 +1,7 @@ import numpy as np from numba import njit -from tardis.transport.montecarlo import ( - njit_dict_no_parallel, -) + +from tardis.transport.montecarlo import njit_dict_no_parallel class MonteCarloException(ValueError): diff --git a/tardis/transport/montecarlo/vpacket.py b/tardis/transport/montecarlo/vpacket.py index 657e1c016d0..305e4cc970c 100644 --- a/tardis/transport/montecarlo/vpacket.py +++ b/tardis/transport/montecarlo/vpacket.py @@ -5,29 +5,18 @@ from numba.experimental import jitclass import tardis.transport.montecarlo.configuration.montecarlo_globals as montecarlo_globals -from tardis.opacities.opacities import ( - chi_continuum_calculator, -) -from tardis.transport.frame_transformations import ( - angle_aberration_CMF_to_LF, - angle_aberration_LF_to_CMF, - get_doppler_factor, -) +from tardis.opacities.opacities import chi_continuum_calculator +from tardis.transport.frame_transformations import (angle_aberration_CMF_to_LF, + angle_aberration_LF_to_CMF, + get_doppler_factor) from tardis.transport.geometry.calculate_distances import ( - calculate_distance_boundary, - calculate_distance_line, -) + calculate_distance_boundary, calculate_distance_line) from tardis.transport.montecarlo import njit_dict_no_parallel from tardis.transport.montecarlo.configuration.constants import ( - C_SPEED_OF_LIGHT, - SIGMA_THOMSON, -) -from tardis.transport.montecarlo.r_packet import ( - PacketStatus, -) -from tardis.transport.montecarlo.r_packet_transport import ( - move_packet_across_shell_boundary, -) + C_SPEED_OF_LIGHT, SIGMA_THOMSON) +from tardis.transport.montecarlo.r_packet import PacketStatus +from tardis.transport.montecarlo.r_packet_transport import \ + move_packet_across_shell_boundary vpacket_spec = [ ("r", float64), diff --git a/tardis/transport/montecarlo/weighted_packet_source.py b/tardis/transport/montecarlo/weighted_packet_source.py index dbdbb85efd3..1cba773afd3 100644 --- a/tardis/transport/montecarlo/weighted_packet_source.py +++ b/tardis/transport/montecarlo/weighted_packet_source.py @@ -3,11 +3,9 @@ from astropy import constants as const from astropy import units as u -from tardis.transport.montecarlo.packet_source import ( - BasePacketSource, - HDFWriterMixin, - BlackBodySimpleSource, -) +from tardis.transport.montecarlo.packet_source import (BasePacketSource, + BlackBodySimpleSource, + HDFWriterMixin) from tardis.util.base import intensity_black_body diff --git a/tardis/transport/tests/test_doppler_factor.py b/tardis/transport/tests/test_doppler_factor.py index f057e1686f8..6a724a89ff9 100644 --- a/tardis/transport/tests/test_doppler_factor.py +++ b/tardis/transport/tests/test_doppler_factor.py @@ -1,13 +1,10 @@ -import pytest import numpy as np +import pytest +from numpy.testing import assert_almost_equal import tardis.transport.frame_transformations as frame_transformations import tardis.transport.montecarlo.r_packet as r_packet -from numpy.testing import ( - assert_almost_equal, -) - @pytest.mark.parametrize( ["mu", "r", "inv_t_exp", "expected"], diff --git a/tardis/util/base.py b/tardis/util/base.py index 8e21da9d667..7f1a687b2f4 100644 --- a/tardis/util/base.py +++ b/tardis/util/base.py @@ -1,24 +1,24 @@ +import functools import logging import os import re +import warnings from collections import OrderedDict import numexpr as ne import numpy as np import pandas as pd +import tqdm +import tqdm.notebook import yaml -from tardis import constants from astropy import units as u -from radioactivedecay import Nuclide, DEFAULTDATA -from radioactivedecay.utils import parse_nuclide, Z_DICT +from IPython import display, get_ipython +from radioactivedecay import DEFAULTDATA, Nuclide +from radioactivedecay.utils import Z_DICT, parse_nuclide import tardis +from tardis import constants from tardis.io.util import get_internal_data_path -from IPython import get_ipython, display -import tqdm -import tqdm.notebook -import functools -import warnings k_B_cgs = constants.k_B.cgs.value c_cgs = constants.c.cgs.value diff --git a/tardis/visualization/__init__.py b/tardis/visualization/__init__.py index cadfff0cdc3..1925181bdc9 100644 --- a/tardis/visualization/__init__.py +++ b/tardis/visualization/__init__.py @@ -1,14 +1,11 @@ """Visualization tools and widgets for TARDIS.""" from tardis.visualization.tools.convergence_plot import ConvergencePlots - -from tardis.visualization.widgets.shell_info import ( - shell_info_from_simulation, - shell_info_from_hdf, -) -from tardis.visualization.widgets.line_info import LineInfoWidget -from tardis.visualization.widgets.grotrian import GrotrianWidget -from tardis.visualization.widgets.custom_abundance import CustomAbundanceWidget -from tardis.visualization.tools.sdec_plot import SDECPlotter -from tardis.visualization.tools.rpacket_plot import RPacketPlotter from tardis.visualization.tools.liv_plot import LIVPlotter +from tardis.visualization.tools.rpacket_plot import RPacketPlotter +from tardis.visualization.tools.sdec_plot import SDECPlotter +from tardis.visualization.widgets.custom_abundance import CustomAbundanceWidget +from tardis.visualization.widgets.grotrian import GrotrianWidget +from tardis.visualization.widgets.line_info import LineInfoWidget +from tardis.visualization.widgets.shell_info import ( + shell_info_from_hdf, shell_info_from_simulation) diff --git a/tardis/visualization/plot_util.py b/tardis/visualization/plot_util.py index 54b740411dc..1c30b5d4d02 100644 --- a/tardis/visualization/plot_util.py +++ b/tardis/visualization/plot_util.py @@ -1,6 +1,7 @@ """Utility functions to be used in plotting.""" import re + import numpy as np diff --git a/tardis/visualization/tools/convergence_plot.py b/tardis/visualization/tools/convergence_plot.py index baac3ea0722..0387c0fdc79 100644 --- a/tardis/visualization/tools/convergence_plot.py +++ b/tardis/visualization/tools/convergence_plot.py @@ -1,16 +1,17 @@ """Convergence Plots to see the convergence of the simulation in real time.""" from collections import defaultdict +from contextlib import suppress + +import ipywidgets as widgets +import matplotlib as mpl import matplotlib.cm as cm import matplotlib.colors as clr import numpy as np import plotly.graph_objects as go +from astropy import units as u from IPython.display import display -import matplotlib as mpl -import ipywidgets as widgets -from contextlib import suppress from traitlets import TraitError -from astropy import units as u def transition_colors(length, name="jet"): diff --git a/tardis/visualization/tools/liv_plot.py b/tardis/visualization/tools/liv_plot.py index eef3a4e0cf4..57f19ee93e7 100644 --- a/tardis/visualization/tools/liv_plot.py +++ b/tardis/visualization/tools/liv_plot.py @@ -1,16 +1,14 @@ import logging -import matplotlib.pyplot as plt + +import astropy.units as u import matplotlib.cm as cm -import plotly.graph_objects as go +import matplotlib.pyplot as plt import numpy as np import pandas as pd -import astropy.units as u +import plotly.graph_objects as go -from tardis.util.base import ( - atomic_number2element_symbol, - int_to_roman, -) import tardis.visualization.tools.sdec_plot as sdec +from tardis.util.base import atomic_number2element_symbol, int_to_roman from tardis.visualization import plot_util as pu logger = logging.getLogger(__name__) diff --git a/tardis/visualization/tools/rpacket_plot.py b/tardis/visualization/tools/rpacket_plot.py index 0e276c3cfe8..e22506fd649 100644 --- a/tardis/visualization/tools/rpacket_plot.py +++ b/tardis/visualization/tools/rpacket_plot.py @@ -1,8 +1,9 @@ -import math import logging -import pandas as pd -import numpy as np +import math + import astropy.units as u +import numpy as np +import pandas as pd import plotly.express as px import plotly.graph_objects as go @@ -107,7 +108,7 @@ def from_simulation(cls, sim, no_of_packets=15): return cls(sim, sim.last_no_of_packets) else: raise AttributeError( - """ There is no attribute named rpacket_tracker in the simulation object passed. Try enabling the + """ There is no attribute named rpacket_tracker in the simulation object passed. Try enabling the rpacket tracking in the configuration. To enable rpacket tracking see: https://tardis-sn.github.io/tardis/io/output/rpacket_tracking.html#How-to-Setup-the-Tracking-for-the-RPackets?""" ) diff --git a/tardis/visualization/tools/sdec_plot.py b/tardis/visualization/tools/sdec_plot.py index 9602bc96447..4abbba217a3 100644 --- a/tardis/visualization/tools/sdec_plot.py +++ b/tardis/visualization/tools/sdec_plot.py @@ -16,13 +16,9 @@ import plotly.graph_objects as go from astropy.modeling.models import BlackBody -from tardis.util.base import ( - atomic_number2element_symbol, - element_symbol2atomic_number, - int_to_roman, - roman_to_int, - species_string_to_tuple, -) +from tardis.util.base import (atomic_number2element_symbol, + element_symbol2atomic_number, int_to_roman, + roman_to_int, species_string_to_tuple) from tardis.visualization import plot_util as pu logger = logging.getLogger(__name__) diff --git a/tardis/visualization/tools/tests/test_convergence_plot.py b/tardis/visualization/tools/tests/test_convergence_plot.py index bb69e23e68b..8dcb689e64f 100644 --- a/tardis/visualization/tools/tests/test_convergence_plot.py +++ b/tardis/visualization/tools/tests/test_convergence_plot.py @@ -1,18 +1,17 @@ """Tests for Convergence Plots.""" +from collections import defaultdict from copy import deepcopy -import pytest -from tardis.tests.test_util import monkeysession -from tardis import run_tardis -from tardis.visualization.tools.convergence_plot import ( - ConvergencePlots, - transition_colors, -) -from collections import defaultdict import plotly.graph_objects as go +import pytest from astropy import units as u +from tardis import run_tardis +from tardis.tests.test_util import monkeysession +from tardis.visualization.tools.convergence_plot import (ConvergencePlots, + transition_colors) + @pytest.fixture(scope="module", params=[0, 1, 2]) def convergence_plots(request): diff --git a/tardis/visualization/tools/tests/test_rpacket_plot.py b/tardis/visualization/tools/tests/test_rpacket_plot.py index 7b7a48367bf..b17d60f602d 100755 --- a/tardis/visualization/tools/tests/test_rpacket_plot.py +++ b/tardis/visualization/tools/tests/test_rpacket_plot.py @@ -1,10 +1,12 @@ """Tests for RPacketPlotter Plots""" import math + import astropy.units as u -import pytest import numpy as np import numpy.testing as npt +import pytest + from tardis.visualization import RPacketPlotter diff --git a/tardis/visualization/widgets/custom_abundance.py b/tardis/visualization/widgets/custom_abundance.py index 490aaa8c7ac..2a73b1715a9 100644 --- a/tardis/visualization/widgets/custom_abundance.py +++ b/tardis/visualization/widgets/custom_abundance.py @@ -1,35 +1,27 @@ """Class to create and display Custom Abundance Widget.""" import os -import yaml +from pathlib import Path + +import ipywidgets as ipw import numpy as np import pandas as pd -import ipywidgets as ipw import plotly.graph_objects as go +import yaml from astropy import units as u from radioactivedecay import Nuclide from radioactivedecay.utils import Z_DICT, elem_to_Z -from pathlib import Path import tardis -from tardis.io.model.readers.generic_readers import read_uniform_mass_fractions -from tardis.util.base import ( - quantity_linspace, - is_valid_nuclide_or_elem, - is_notebook, -) -from tardis.io.configuration.config_reader import Configuration -from tardis.model import SimulationState -from tardis.io.model.parse_density_configuration import ( - calculate_power_law_density, - calculate_exponential_density, -) from tardis.io.atom_data.base import AtomData +from tardis.io.configuration.config_reader import Configuration from tardis.io.configuration.config_validator import validate_dict -from tardis.io.model.readers.csvy import load_csvy -from tardis.io.model.readers.csvy import ( - parse_csv_mass_fractions, -) -from tardis.util.base import atomic_number2element_symbol, quantity_linspace +from tardis.io.model.parse_density_configuration import ( + calculate_exponential_density, calculate_power_law_density) +from tardis.io.model.readers.csvy import load_csvy, parse_csv_mass_fractions +from tardis.io.model.readers.generic_readers import read_uniform_mass_fractions +from tardis.model import SimulationState +from tardis.util.base import (atomic_number2element_symbol, is_notebook, + is_valid_nuclide_or_elem, quantity_linspace) from tardis.visualization.tools.convergence_plot import transition_colors from tardis.visualization.widgets.util import debounce diff --git a/tardis/visualization/widgets/grotrian.py b/tardis/visualization/widgets/grotrian.py index 6c3558f769c..594c8d7dd37 100644 --- a/tardis/visualization/widgets/grotrian.py +++ b/tardis/visualization/widgets/grotrian.py @@ -3,17 +3,18 @@ This widget displays a Grotrian Diagram of the last line interactions of the simulation packets """ -from tardis.analysis import LastLineInteraction -from tardis.util.base import species_tuple_to_string, species_string_to_tuple -from tardis.util.base import int_to_roman -import plotly.graph_objects as go -from plotly.subplots import make_subplots -import numpy as np -import pandas as pd +import ipywidgets as ipw import matplotlib import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +import plotly.graph_objects as go from astropy import units as u -import ipywidgets as ipw +from plotly.subplots import make_subplots + +from tardis.analysis import LastLineInteraction +from tardis.util.base import (int_to_roman, species_string_to_tuple, + species_tuple_to_string) ANGSTROM_SYMBOL = "\u212B" diff --git a/tardis/visualization/widgets/line_info.py b/tardis/visualization/widgets/line_info.py index 7c125264fd2..f73b2d05ed9 100644 --- a/tardis/visualization/widgets/line_info.py +++ b/tardis/visualization/widgets/line_info.py @@ -2,25 +2,20 @@ import re -from astropy import units as u +import ipywidgets as ipw import numpy as np import pandas as pd import qgrid +from astropy import units as u from plotly import graph_objects as go from plotly.callbacks import BoxSelector -import ipywidgets as ipw from tardis.analysis import LastLineInteraction -from tardis.util.base import ( - species_tuple_to_string, - species_string_to_tuple, - is_notebook, -) -from tardis.visualization.widgets.util import ( - create_table_widget, - TableSummaryLabel, -) +from tardis.util.base import (is_notebook, species_string_to_tuple, + species_tuple_to_string) from tardis.visualization import plot_util as pu +from tardis.visualization.widgets.util import (TableSummaryLabel, + create_table_widget) class LineInfoWidget: diff --git a/tardis/visualization/widgets/shell_info.py b/tardis/visualization/widgets/shell_info.py index 811386be4ae..7d135100f00 100644 --- a/tardis/visualization/widgets/shell_info.py +++ b/tardis/visualization/widgets/shell_info.py @@ -1,17 +1,13 @@ +import ipywidgets as ipw +import numpy as np +import pandas as pd + from tardis.base import run_tardis from tardis.io.atom_data.atom_web_download import download_atom_data -from tardis.util.base import ( - atomic_number2element_symbol, - species_tuple_to_string, - is_notebook, -) - +from tardis.util.base import (atomic_number2element_symbol, is_notebook, + species_tuple_to_string) from tardis.visualization.widgets.util import create_table_widget -import pandas as pd -import numpy as np -import ipywidgets as ipw - class BaseShellInfo: """The simulation information that is used by shell info widget""" diff --git a/tardis/visualization/widgets/tests/test_custom_abundance.py b/tardis/visualization/widgets/tests/test_custom_abundance.py index d05586c8d4e..b632737de77 100644 --- a/tardis/visualization/widgets/tests/test_custom_abundance.py +++ b/tardis/visualization/widgets/tests/test_custom_abundance.py @@ -1,16 +1,14 @@ """Tests for custom abundance widget.""" from pathlib import Path -import pytest -import tardis + import numpy as np import numpy.testing as npt +import pytest +import tardis from tardis.tests.test_util import monkeysession from tardis.visualization.widgets.custom_abundance import ( - CustomAbundanceWidgetData, - CustomYAML, - CustomAbundanceWidget, -) + CustomAbundanceWidget, CustomAbundanceWidgetData, CustomYAML) @pytest.fixture(scope="module") diff --git a/tardis/visualization/widgets/tests/test_line_info.py b/tardis/visualization/widgets/tests/test_line_info.py index 87686c3af29..6cde6a42417 100644 --- a/tardis/visualization/widgets/tests/test_line_info.py +++ b/tardis/visualization/widgets/tests/test_line_info.py @@ -1,10 +1,11 @@ -import pytest -import pandas as pd import numpy as np -from plotly.callbacks import Points, BoxSelector -from tardis.visualization.widgets.line_info import LineInfoWidget -from tardis.util.base import species_string_to_tuple +import pandas as pd +import pytest +from plotly.callbacks import BoxSelector, Points + from tardis.tests.test_util import monkeysession +from tardis.util.base import species_string_to_tuple +from tardis.visualization.widgets.line_info import LineInfoWidget @pytest.fixture(scope="class") diff --git a/tardis/visualization/widgets/tests/test_shell_info.py b/tardis/visualization/widgets/tests/test_shell_info.py index 7a99374dbc5..efd27bba130 100644 --- a/tardis/visualization/widgets/tests/test_shell_info.py +++ b/tardis/visualization/widgets/tests/test_shell_info.py @@ -1,14 +1,12 @@ -import pytest import numpy as np import pandas.testing as pdt +import pytest from tardis.tests.test_util import monkeysession -from tardis.visualization.widgets.shell_info import ( - BaseShellInfo, - SimulationShellInfo, - HDFShellInfo, - ShellInfoWidget, -) +from tardis.visualization.widgets.shell_info import (BaseShellInfo, + HDFShellInfo, + ShellInfoWidget, + SimulationShellInfo) @pytest.fixture(scope="class") diff --git a/tardis/visualization/widgets/util.py b/tardis/visualization/widgets/util.py index c354ebbf38d..a7a8e75cd03 100644 --- a/tardis/visualization/widgets/util.py +++ b/tardis/visualization/widgets/util.py @@ -1,9 +1,10 @@ """Utility classes and functions for widgets.""" +import asyncio import logging -import qgrid + import ipywidgets as ipw -import asyncio +import qgrid logger = logging.getLogger(__name__) diff --git a/tardis_env3.yml b/tardis_env3.yml index 8882a45d094..733c2debb48 100644 --- a/tardis_env3.yml +++ b/tardis_env3.yml @@ -74,4 +74,3 @@ dependencies: # Other - git-lfs -