Skip to content

Fix: Correct GMM fitting visualization in amrex_data.ipynb#165

Closed
henry2004y wants to merge 2 commits into
mainfrom
fix-gmm-visualization
Closed

Fix: Correct GMM fitting visualization in amrex_data.ipynb#165
henry2004y wants to merge 2 commits into
mainfrom
fix-gmm-visualization

Conversation

@henry2004y

Copy link
Copy Markdown
Owner
  • Switched from get_gmm_temperatures to get_gmm_parameters to use thermal velocities instead of temperatures in the GMM fitting examples.
  • Updated the plotting to use contours of the reconstructed Gaussian distributions instead of ellipses for a more accurate visualization.

- Switched from `get_gmm_temperatures` to `get_gmm_parameters` to use thermal velocities instead of temperatures in the GMM fitting examples.
- Updated the plotting to use contours of the reconstructed Gaussian distributions instead of ellipses for a more accurate visualization.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @henry2004y, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the Gaussian Mixture Model (GMM) fitting visualization within the amrex_data.ipynb notebook. The primary goal is to enhance the accuracy and consistency of the GMM examples by transitioning from temperature-based parameter extraction to thermal velocity-based parameters and improving the visual representation of the fitted distributions through contour plots instead of ellipses.

Highlights

  • GMM Parameter Extraction: Switched from extracting temperatures to extracting general parameters (specifically thermal velocities) using get_gmm_parameters instead of get_gmm_temperatures in the GMM fitting examples.
  • Visualization Improvement: Updated the plotting method for Gaussian Mixture Model (GMM) components from drawing ellipses to using contours of the reconstructed Gaussian distributions, providing a more accurate and visually representative overlay.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Nov 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.39%. Comparing base (1929ea0) to head (a5d3d3f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #165   +/-   ##
=======================================
  Coverage   68.39%   68.39%           
=======================================
  Files          25       25           
  Lines        4202     4202           
=======================================
  Hits         2874     2874           
  Misses       1328     1328           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly switches from get_gmm_temperatures to get_gmm_parameters and updates the GMM fitting visualization to use contours, which is a great improvement for accuracy. However, the implementation of the contour plotting doesn't produce the 1, 2, and 3-sigma contours as described in the notebook. I've provided suggestions to correct the contour level calculations in both plotting sections. The other changes are well-implemented and consistent.

Comment thread docs/amrex_data.ipynb Outdated
Comment on lines +751 to +752
" rv = multivariate_normal(mean, cov)\n",
" ax.contour(X, Y, rv.pdf(pos), levels=3, colors='red', linestyles='--')\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The use of levels=3 in ax.contour does not plot 1, 2, and 3-sigma contours as stated in the markdown description. It will instead draw 4 automatically-chosen contour levels. To accurately plot the sigma contours, you should calculate the PDF values corresponding to 1, 2, and 3 standard deviations.

    rv = multivariate_normal(mean, cov)
    levels = rv.pdf(mean) * np.exp(-0.5 * np.array([1.0, 2.0, 3.0])**2)
    ax.contour(X, Y, rv.pdf(pos), levels=np.sort(levels), colors='red', linestyles='--')

Comment thread docs/amrex_data.ipynb Outdated
Comment on lines +836 to +837
" rv = multivariate_normal(mean, cov)\n",
" ax.contour(X, Y, rv.pdf(pos), levels=3, colors='red', linestyles='--')\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Similar to the isotropic case, using levels=3 here will not produce the desired 1, 2, and 3-sigma contours. It will draw 4 automatically-chosen levels. To correctly visualize the sigma contours, the levels must be calculated based on the probability density function.

    rv = multivariate_normal(mean, cov)
    levels = rv.pdf(mean) * np.exp(-0.5 * np.array([1.0, 2.0, 3.0])**2)
    ax.contour(X, Y, rv.pdf(pos), levels=np.sort(levels), colors='red', linestyles='--')

- Switched from `get_gmm_temperatures` to `get_gmm_parameters` to use thermal velocities instead of temperatures in the GMM fitting examples.
- Updated the plotting to use contours of the reconstructed Gaussian distributions instead of ellipses for a more accurate visualization.
- Correctly calculate and plot 1, 2, and 3-sigma contours.
- Updated the markdown description to reflect the contour plot changes.
@henry2004y henry2004y closed this Nov 17, 2025
@henry2004y henry2004y deleted the fix-gmm-visualization branch November 17, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant