Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Convergence Plots #1636

Merged
merged 40 commits into from
Jul 23, 2021
Merged

Conversation

atharva-2001
Copy link
Member

@atharva-2001 atharva-2001 commented Jun 8, 2021

This PR adds convergence plots to TARDIS.

Description

Convergence plots will allow the user to see the convergence of the simulation in plots and study the state of the simulation at different iterations. Convergence plots are plotted by default as the simulation runs. One can configure the plots by providing arguments in the run_tardis function. This includes overriding the default plotly layout of the graphs and options to change color scale and show or not show the plots.

Motivation and context

How has this been tested?

  • Testing pipeline.
  • Other.

Examples

Link to the convergence plots in the documentation.
Link to the notebook.
Link to the API
cplots-new2

Convergence Plots along with progress bars
Peek 2021-07-09 18-15
See also: #1629

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

adding convergence plot notebook and python file
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@MarkMageeAstro
Copy link
Contributor

This looks like a great start. I have a few stylistic comments:

Plasma updates

  1. Can you swap the plot round so that temperature is on the left? There are no labels for temperature or velocity, is this the latex rendering issue?
  2. I think the first example you have with iterations and then just the numbers looks the best. It's hard to tell exactly what's going on in the last one because the lines aren't connected and that also makes it difficult to see the colours on the right hand side
  3. It would be best to change the display formatting and add units. The full temperature should be printed out, not just rounded to the nearest 1000. For example, use 10,000 K and not 10k K. Similarly, the x-axis should be in km/s but at the minute is in cm/s
  4. Personally, I think a different colour scheme would be good, like rainbow or jet. If we stick with this one then I would at least swap it round so that the lighter yellow is the last iteration.

Temperature plots

  1. We need units here too. Luminosity should be in erg / s
  2. A bar chart isn't really the best way to present this data, so I would remove it. The line plot is much better. It should also have a legend to say what each colour is and to say what the horizontal line is. I would use some more contrasting colours as well
  3. I think the labels are the wrong way round. In the line plot, the final emitted luminosity is listed as 4e42, but the simulation output says this is the luminosity absorbed.
  4. Might also be nice to show a residual difference between the emitted and requested luminosities for each iteration. This can just be the difference between the two given as a percentage of the luminosity requested or something like that. Could be a subpanel to the main plot, just below

@atharva-2001 atharva-2001 requested a review from marxwillia June 9, 2021 09:39
@atharva-2001 atharva-2001 marked this pull request as ready for review June 15, 2021 14:33
fixing swapped y-axis labels in plasma plot
@codecov
Copy link

codecov bot commented Jun 16, 2021

Codecov Report

Merging #1636 (2b08432) into master (2010e81) will increase coverage by 0.56%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1636      +/-   ##
==========================================
+ Coverage   61.88%   62.45%   +0.56%     
==========================================
  Files          63       64       +1     
  Lines        5851     5985     +134     
==========================================
+ Hits         3621     3738     +117     
- Misses       2230     2247      +17     
Impacted Files Coverage Δ
tardis/tardis/base.py 57.14% <0.00%> (-0.55%) ⬇️
tardis/tardis/visualization/widgets/shell_info.py 95.95% <0.00%> (-0.05%) ⬇️
...dis/tardis/visualization/tools/convergence_plot.py 88.67% <0.00%> (ø)
tardis/tardis/simulation/base.py 83.17% <0.00%> (+0.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2010e81...2b08432. Read the comment docs.

@tardis-sn tardis-sn deleted a comment from tardis-bot Jun 17, 2021
@atharva-2001 atharva-2001 mentioned this pull request Jul 15, 2021
10 tasks
Copy link
Member

@jamesgillanders jamesgillanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great @atharva-2001! All requested changes seem to have been addressed, and the code itself works really well. Good job!

@atharva-2001 atharva-2001 force-pushed the convergence_plots branch 4 times, most recently from 746e2f9 to 69c9a8c Compare July 16, 2021 15:07
@atharva-2001 atharva-2001 force-pushed the convergence_plots branch 4 times, most recently from 126fa86 to dab2341 Compare July 21, 2021 15:50
Copy link
Member

@jaladh-singhal jaladh-singhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant work! Thank you for addressing all of my nitpicky comments 😄

@jaladh-singhal
Copy link
Member

@atharva-2001 this needs rebasing now that #1723 is merged

@marxwillia marxwillia merged commit f27fe3d into tardis-sn:master Jul 23, 2021
DhruvSondhi pushed a commit to DhruvSondhi/tardis that referenced this pull request Aug 1, 2021
* initial commit

adding convergence plot notebook and python file

* updating class structure

* adding functions to create empty plots

* adding functions to update convergence plots

* fixing imports for convergence plots

* changes to get update convergence plots from tardis/simulation/base.py

* adding updated notebook

* allowing user to customize plot layout from run_tardis

* adding options to not show plots and change colorscale

* adding docstrings

* adding updated notebook

* fix typo

fixing swapped y-axis labels in plasma plot

* exporting convergence plots

* layout changes

fixing colors, removing marker points, fixing labels

* adding check to see if data is collected

necessary when running simulation with just one iteration

* moving convergence plots notebook

* adding tests for convergence class and transition_colors function

* fix typos and adding comments

* reformatted using black

* adding function to override default plot configuration

* showing how plots can be updated in the notebook

* fixing plot heights and tick labels

* code refactor

raising TypeErrors, fix typos

* adding docstrings

* fixing axes and legend, converting units using astropy

* fixing hover data and making axes titles romanized/upright in certain places

* use same colorscale for both plasma and luminosity plots

* add docstrings and code comments

* add option to change colorscale, format using black, add updated notebook

* remove unnecessary customizations, edit docstrings

* add documentation in the notebook

* test length of fig.data tuple after build

* add tests for update and override function

* edit docstrings and code comments

* renaming luminosity_plot to t_inner_luminosities_plot

* minor changes in documentation and docstrings

* [build docs]
DhruvSondhi pushed a commit to DhruvSondhi/tardis that referenced this pull request Aug 9, 2021
* initial commit

adding convergence plot notebook and python file

* updating class structure

* adding functions to create empty plots

* adding functions to update convergence plots

* fixing imports for convergence plots

* changes to get update convergence plots from tardis/simulation/base.py

* adding updated notebook

* allowing user to customize plot layout from run_tardis

* adding options to not show plots and change colorscale

* adding docstrings

* adding updated notebook

* fix typo

fixing swapped y-axis labels in plasma plot

* exporting convergence plots

* layout changes

fixing colors, removing marker points, fixing labels

* adding check to see if data is collected

necessary when running simulation with just one iteration

* moving convergence plots notebook

* adding tests for convergence class and transition_colors function

* fix typos and adding comments

* reformatted using black

* adding function to override default plot configuration

* showing how plots can be updated in the notebook

* fixing plot heights and tick labels

* code refactor

raising TypeErrors, fix typos

* adding docstrings

* fixing axes and legend, converting units using astropy

* fixing hover data and making axes titles romanized/upright in certain places

* use same colorscale for both plasma and luminosity plots

* add docstrings and code comments

* add option to change colorscale, format using black, add updated notebook

* remove unnecessary customizations, edit docstrings

* add documentation in the notebook

* test length of fig.data tuple after build

* add tests for update and override function

* edit docstrings and code comments

* renaming luminosity_plot to t_inner_luminosities_plot

* minor changes in documentation and docstrings

* [build docs]
DhruvSondhi pushed a commit to DhruvSondhi/tardis that referenced this pull request Aug 9, 2021
* initial commit

adding convergence plot notebook and python file

* updating class structure

* adding functions to create empty plots

* adding functions to update convergence plots

* fixing imports for convergence plots

* changes to get update convergence plots from tardis/simulation/base.py

* adding updated notebook

* allowing user to customize plot layout from run_tardis

* adding options to not show plots and change colorscale

* adding docstrings

* adding updated notebook

* fix typo

fixing swapped y-axis labels in plasma plot

* exporting convergence plots

* layout changes

fixing colors, removing marker points, fixing labels

* adding check to see if data is collected

necessary when running simulation with just one iteration

* moving convergence plots notebook

* adding tests for convergence class and transition_colors function

* fix typos and adding comments

* reformatted using black

* adding function to override default plot configuration

* showing how plots can be updated in the notebook

* fixing plot heights and tick labels

* code refactor

raising TypeErrors, fix typos

* adding docstrings

* fixing axes and legend, converting units using astropy

* fixing hover data and making axes titles romanized/upright in certain places

* use same colorscale for both plasma and luminosity plots

* add docstrings and code comments

* add option to change colorscale, format using black, add updated notebook

* remove unnecessary customizations, edit docstrings

* add documentation in the notebook

* test length of fig.data tuple after build

* add tests for update and override function

* edit docstrings and code comments

* renaming luminosity_plot to t_inner_luminosities_plot

* minor changes in documentation and docstrings

* [build docs]
atharva-2001 added a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
* initial commit

adding convergence plot notebook and python file

* updating class structure

* adding functions to create empty plots

* adding functions to update convergence plots

* fixing imports for convergence plots

* changes to get update convergence plots from tardis/simulation/base.py

* adding updated notebook

* allowing user to customize plot layout from run_tardis

* adding options to not show plots and change colorscale

* adding docstrings

* adding updated notebook

* fix typo

fixing swapped y-axis labels in plasma plot

* exporting convergence plots

* layout changes

fixing colors, removing marker points, fixing labels

* adding check to see if data is collected

necessary when running simulation with just one iteration

* moving convergence plots notebook

* adding tests for convergence class and transition_colors function

* fix typos and adding comments

* reformatted using black

* adding function to override default plot configuration

* showing how plots can be updated in the notebook

* fixing plot heights and tick labels

* code refactor

raising TypeErrors, fix typos

* adding docstrings

* fixing axes and legend, converting units using astropy

* fixing hover data and making axes titles romanized/upright in certain places

* use same colorscale for both plasma and luminosity plots

* add docstrings and code comments

* add option to change colorscale, format using black, add updated notebook

* remove unnecessary customizations, edit docstrings

* add documentation in the notebook

* test length of fig.data tuple after build

* add tests for update and override function

* edit docstrings and code comments

* renaming luminosity_plot to t_inner_luminosities_plot

* minor changes in documentation and docstrings

* [build docs]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants