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

Convergence plot correction: Use step plots #2528

Merged

Conversation

sarthak-dv
Copy link
Contributor

@sarthak-dv sarthak-dv commented Mar 4, 2024

📝 Description

Type: 🪲 bugfix

In the convergence plot widget, both T and W are plotted against shell velocity. These plots should present their data as a step function, instead of a scatter line, since the T and W values are constant throughout each individual shell.

convergence

closes Issue#2519

@jamesgillanders @MarkMageeAstro Please review. Also can you please apply the build_docs label since the plots in the docs will change?

📌 Resources

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method: Ran convergence plot to see the plot line shape change
  • My changes can't be tested (explain why)

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

@tardis-bot
Copy link
Contributor

tardis-bot commented Mar 4, 2024

*beep* *bop*

Hi, human.

The docs workflow has succeeded ✔️

Click here to see your results.

@sarthak-dv
Copy link
Contributor Author

@jamesgillanders @MarkMageeAstro Can you please review this fix when you have time?
Also can you please apply the build_docs label since the plots in the docs will change?

Thanks in advance!

@atharva-2001
Copy link
Member

hi, can you please put up a screenshot showing the changes you made in the pr description?

@sarthak-dv
Copy link
Contributor Author

@atharva-2001 Done. Also, can you please put the build_docs label on this PR?

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.51%. Comparing base (1718002) to head (e91101e).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2528      +/-   ##
==========================================
- Coverage   68.18%   67.51%   -0.67%     
==========================================
  Files         168      170       +2     
  Lines       14219    14229      +10     
==========================================
- Hits         9695     9607      -88     
- Misses       4524     4622      +98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarkMageeAstro
Copy link
Contributor

Maybe someone else knows, but is 'hv' or 'vh' correct?

Each shell is defined by an inner and outer velocity, so does the temperature, etc. correspond to the inner or outer boundary? I guess that'll determine which one to use or maybe I'm misunderstanding something

@andrewfullard
Copy link
Contributor

Maybe someone else knows, but is 'hv' or 'vh' correct?

Each shell is defined by an inner and outer velocity, so does the temperature, etc. correspond to the inner or outer boundary? I guess that'll determine which one to use or maybe I'm misunderstanding something

This is actually a rather interesting question about how TARDIS works. Temperature and density are actually defined at the centre of the cell.

@jamesgillanders
Copy link
Member

Temperature etc. are constant throughout each shell. The point to consider and to address is how that looks on a step plot that is generated by using e.g., v_inner values. In that case the step profile should not be "mid"

@sarthak-dv
Copy link
Contributor Author

sarthak-dv commented Mar 7, 2024

@jamesgillanders @andrewfullard @MarkMageeAstro

I believe "hv" is correct given that we're considering inner velocities. (Reference for different modes here. "hv" changes value at the current x-coordinate (inner_boundary_i) and stays put until the next x-value (inner_boundary_{i+1} = outer_boundary_i)

If I chose outer velocities, then "vh" would have been correct.

"hvh" would be correct if I chose mid velocities for the shells. (Though this case might be problematic if the shells have varying widths)

@MarkMageeAstro
Copy link
Contributor

Maybe I'm over thinking it or confusing myself (both are very real possibilities). The code has changed quite a bit since I last looked at it, I think.

It looked to me like we're not actually using the inner velocities, I thought it was the outer velocities. Based on what Andrew said about the temperature being defined in the middle, if you print out the velocities and temperatures you might get something like:

Velocity Temperature
...
19000 10000
20000 9000

I would assume that means that for velocities 19000 < v <= 20000, the temperature should be 9000. That's not what's shown here though because there is a step down at the last cell. Again, I could be misunderstanding something though

@sarthak-dv
Copy link
Contributor Author

@MarkMageeAstro

The plot itself steps down at the correct locations, as seen in the attached image:

convergence_step_example

The last step down is at the inner boundary of the last shell. However, it isn't extended in a horizontal line because the plot doesn't know where to "end" the line segment i.e. outer boundary of last shell).
To fix this, I'll have to additionally pass the outer boundary of the last shell with the same t_rad i.e. (x=v_outer[-1], y=t_rad[-1])

Let me know your thoughts here.

@MarkMageeAstro
Copy link
Contributor

Okay, I see where the confusion has come now. In your first plot, I assumed the step down was at the highest velocity (i.e. v_outer of the last shell), but it's clear from your latest version that's not the case. It's also more obvious which velocities correspond to the temperatures when you print out the complete boundaries for each cell:

Screenshot 2024-03-12 at 12 30 19

Yes, I think it would be good to make sure the line starts at the inner boundary and extends to the outer boundary of the full model.

@sarthak-dv
Copy link
Contributor Author

sarthak-dv commented Mar 13, 2024

@MarkMageeAstro I have updated my branch with the changes. Now the plot looks like this:

convergence_plot_corrected

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@sarthak-dv sarthak-dv changed the base branch from master to main March 13, 2024 00:36
@sarthak-dv sarthak-dv changed the base branch from main to master March 13, 2024 00:37
@sarthak-dv
Copy link
Contributor Author

Can you also please rerun the checks, since the PR was behaving weirdly in between

@sarthak-dv sarthak-dv force-pushed the convergence-plot-correction branch from e186e3b to bf695a5 Compare March 13, 2024 01:50
@jamesgillanders
Copy link
Member

Looks great -- this is exactly what was needed! Happy to merge!

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.

Approved!

@sarthak-dv
Copy link
Contributor Author

Thanks James!

@MarkMageeAstro This required another approval before merge. Please let me know if this is good to go.

@andrewfullard
Copy link
Contributor

It looks like the convergence plot tests are failing, and black needs to be run on the code.

…t step correctly

- Rebase master
- Run black formatter on convergence_plot.py
@sarthak-dv sarthak-dv force-pushed the convergence-plot-correction branch from bf695a5 to cfca84c Compare April 7, 2024 01:39
@sarthak-dv
Copy link
Contributor Author

@andrewfullard I've fixed the convergence plot tests and ran Black formatter on the file.

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.

All good with me!

@sarthak-dv
Copy link
Contributor Author

@MarkMageeAstro Can you please review this? @jamesgillanders has already approved and it needs two approvals to merge

@andrewfullard andrewfullard merged commit 215ad61 into tardis-sn:master Apr 24, 2024
10 of 12 checks passed
KasukabeDefenceForce pushed a commit to KasukabeDefenceForce/tardis that referenced this pull request Apr 25, 2024
* Change convergence plots to step plots

* - Add dummy x-point while plotting convergence plots, to draw the last step correctly
- Rebase master
- Run black formatter on convergence_plot.py

* Fix convergence plot tests

* Run black formatter
@sarthak-dv sarthak-dv deleted the convergence-plot-correction branch August 22, 2024 21:12
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.

Convergence plot correction
6 participants