-
Notifications
You must be signed in to change notification settings - Fork 46
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
custom colors overhaul #786
Open
nialljmiller
wants to merge
15
commits into
main
Choose a base branch
from
features/nialljmiller/customcolors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
53d329c
custom colors overhaul
nialljmiller af05b53
Custom colors overhaul: test suite case (#782)
nialljmiller 4e211fc
ran fortitude and cleaned parts of inlist
nialljmiller 4f3ab46
Auto-format Python files using Black
nialljmiller 8e7ea2a
Temporary removal of python custom colours
nialljmiller c7e912f
README fix
nialljmiller f368063
[ci skip] file cleaning - removed extra run_star_extra and other junk…
nialljmiller 2a067ce
[ci skip] .gitignore cleaning compared to top level .gitignore
nialljmiller 5c94961
[ci skip] fixing faulty push, README should also now be more sensible.
nialljmiller 9332e7d
linear interpolation changed to binary search as data is already ordered
nialljmiller 0e8f936
[ci skip] colors migration - part 1
nialljmiller c91ad4c
[ci skip] colors migration - part 2
nialljmiller 468b648
[ci skip] adding colors controls
mjoyceGR de4c984
[ci skip] colors migration - part defaults
nialljmiller e58e939
adding colors defaults linking in makefile, todos for docs, changelogs
pmocz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Ignore the data directory | ||
data/ | ||
|
||
# Ignore compiled files (e.g., executables, object files, binaries) | ||
*.o | ||
*.out | ||
*.so | ||
*.a | ||
*.dll | ||
*.exe | ||
*.pyc | ||
*.pyo | ||
*.swp | ||
*.jpg | ||
*.png | ||
*.log | ||
*.tmp | ||
*.txz | ||
*.zip | ||
*.yml | ||
*.mod | ||
|
||
# Ignore other files you don't want to track | ||
fort.20 | ||
LOGS/ | ||
star | ||
photos/ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,110 @@ | ||
.. _custom_colors: | ||
MESA Colors Project | ||
==================== | ||
|
||
************* | ||
custom_colors | ||
************* | ||
**MESA Colors** is an extension for the Modules for Experiments in Stellar Astrophysics (MESA) toolkit, designed to enable synthetic photometry calculations and provide additional stellar evolution diagnostics. By incorporating bolometric corrections and synthetic magnitudes, it allows for detailed analysis of stellar properties under various filter systems and atmospheric models. | ||
|
||
This test suite example shows how to use user-defined color filter and extinction files. | ||
Features | ||
-------- | ||
|
||
This test case has 1 part. Click to see a larger view of a plot. | ||
- **Synthetic Magnitudes**: Compute magnitudes using arbitrary filter profiles. | ||
- **Custom History Columns**: Append photometric diagnostics to the MESA history output. | ||
- **SED Interpolation**: Interpolate between stellar models to generate spectral energy distributions (SEDs). | ||
- **Flexible Filter System Integration**: Easily incorporate custom filter profiles for synthetic photometry. | ||
|
||
* Part 1 (``inlist_1.0``) builds a 1.0 Msun, Z=0.02 metallicity, pre-main sequence model and evolves until core hydrogen depletion (mass fraction h1 < 0.1). This example loads the default |LCB98| color filter ''lcb98cor.dat'', a custom color filter ``data/blackbody_bc_v.txt`` which in this case is blackbody V band filter, and a custom extinction color correction file ``data/fake_av_v.txt``. Example color-color, color-magnitude, magnitude-color and magnitude-magnitude plots: | ||
Installation | ||
------------ | ||
|
||
.. image:: ../../../star/test_suite/custom_colors/docs/Color_magnitude1_000241.svg | ||
:width: 100% | ||
1. Clone or download the MESA Colors module to your MESA project directory. | ||
2. Ensure your `mesasdk` path is properly set. | ||
3. Clean and compile the module: | ||
|
||
.. image:: ../../../star/test_suite/custom_colors/docs/Color_magnitude2_000241.svg | ||
:width: 100% | ||
.. code-block:: bash | ||
./clean; ./mk | ||
|
||
.. image:: ../../../star/test_suite/custom_colors/docs/Color_magnitude3_000241.svg | ||
:width: 100% | ||
4. The script will download a 35MB file containing JWST and Gaia filter transmission curves, Kurucz 2003 stellar atmosphere models, and precomputed blackbody curves. These files will be stored in the `data/` directory. | ||
|
||
Directory Structure | ||
------------------- | ||
|
||
pgstar commands used for the first 7 plots: | ||
.. code-block:: text | ||
|
||
.. code-block:: console | ||
mesa_colors/ | ||
├── src/ | ||
│ ├── run_star_extras.f90 # Main Fortran module | ||
│ ├── utilities.f90 # Helper functions for interpolation and file handling | ||
├── data/ | ||
│ ├── stellar_models/ # Stellar models (Kurucz, PHOENIX, etc.) | ||
│ ├── filters/ # Filter profiles (e.g., GAIA, HST, JWST, etc.) | ||
│ ├── extracted_marker # Marker file to confirm data extraction | ||
├── inlist # Example inlist | ||
|
||
&pgstar | ||
Inlist Options | ||
-------------- | ||
|
||
file_white_on_black_flag = .true. ! white_on_black flags -- true means white foreground color on black background | ||
file_device = 'png' ! png | ||
- **x_character_ctrl(1)** : filepath/to/stellar_atmosphere_models/ -- Stellar atmosphere model - http://svo2.cab.inta-csic.es/theory/newov2/ | ||
- **x_character_ctrl(2)** : filepath/to/filters/ -- Photometric filter system - http://svo2.cab.inta-csic.es/theory/fps/ | ||
- **x_character_ctrl(3)** : filepath/to/vega.sed -- Vega SED for Vega photometric system | ||
- **x_character_ctrl(4)** : true/false -- Save CSV files of each constructed SED | ||
|
||
!file_device = 'vcps' ! postscript | ||
Configuring a Stellar Atmosphere Model | ||
-------------------------------------- | ||
|
||
pgstar_interval = 1 | ||
The stellar atmosphere models are grids of precomputed stellar SEDs. These SEDs are computed as a function of multiple stellar features, many of which are generated by MESA. | ||
We use those features to find the N closest SEDs which match our parameters. | ||
Each folder within the stellar atmosphere models contains two main features: | ||
- A grid of stellar models | ||
- A lookup table holding the metadata of those models (e.g., the Teff and Logg used to generate the SED) | ||
|
||
If you wish to add more stellar atmosphere models, a good place to start would be SVO: http://svo2.cab.inta-csic.es/theory/newov2/. | ||
|
||
!# Color Magnitude Panels | ||
! Plots either color-color, color-magnitude, magnitude-color or magnitude-magnitude | ||
Your lookup table only requires some formatting rules: | ||
- The file name is the first column. | ||
- At least one of `Teff`, `Logg`, `Z` must be present. | ||
|
||
!### Color_magnitude1 | ||
Here is an example of the first few lines of the lookup table for the Kurucz2003 stellar atmospheres: | ||
|
||
Color_magnitude1_win_flag = .true. | ||
.. code-block:: text | ||
|
||
Color_magnitude1_win_width = 15 | ||
Color_magnitude1_win_aspect_ratio = 0.75 ! aspect_ratio = height/width | ||
#file_name, alpha, lh, logg, meta, teff, vtur | ||
Kurucz2003all_fid16202.txt,0,1.25,3.5,-0.5,10500,2 | ||
Kurucz2003all_fid16203.txt,0,1.25,4,-0.5,10500,2 | ||
Kurucz2003all_fid16204.txt,0,1.25,4.5,-0.5,10500,2 | ||
Kurucz2003all_fid16205.txt,0,1.25,5,-0.5,10500,2 | ||
Kurucz2003all_fid16206.txt,0,1.25,2,-0.5,10750,2 | ||
Kurucz2003all_fid16207.txt,0,1.25,2.5,-0.5,10750,2 | ||
Kurucz2003all_fid16208.txt,0,1.25,3,-0.5,10750,2 | ||
Kurucz2003all_fid16209.txt,0,1.25,3.5,-0.5,10750,2 | ||
|
||
Color_magnitude1_xleft = 0.15 | ||
Color_magnitude1_xright = 0.85 | ||
Color_magnitude1_ybot = 0.15 | ||
Color_magnitude1_ytop = 0.85 | ||
Color_magnitude1_txt_scale = 1.0 | ||
Color_magnitude1_title = 'Color_magnitude1' | ||
Configuring a photometric filter system | ||
-------------------------------------- | ||
|
||
! setup default | ||
Color_magnitude1_num_panels = 2 | ||
The phtometric filters are configered similarly to the stellar atmosphere models. Indeed, they are sourced from the same website -- http://svo2.cab.inta-csic.es/theory/fps/ | ||
|
||
! Plots xaxis1-xaxis2 leave xaxis2 blank if you only want to plot xaxis1. | ||
Color_magnitude1_xaxis1_name = 'model_number' | ||
Color_magnitude1_xaxis2_name = '' | ||
The filteres are ready by the code with the assumption that they are stored as: | ||
|
||
```data/filters/{TELESCOPE}/{INTRUMENT}/FILTER1.csv, FILTER2.csv...``` | ||
|
||
! Plots yaxis1-yaxis2 leave yaxis2 blank if you only want to plot yaxis1. | ||
Color_magnitude1_yaxis1_name(1) = 'bc_B' | ||
Color_magnitude1_yaxis2_name(1) = 'bc_U' | ||
Color_magnitude1_yaxis_reversed(1) = .false. | ||
|
||
! Plots `other_yaxis1-other_yaxis2` leave `other_yaxis2` blank if you only want to plot `other_yaxis1`. | ||
Color_magnitude1_other_yaxis1_name(1) = 'abs_mag_V' | ||
Color_magnitude1_other_yaxis2_name(1) = '' | ||
Color_magnitude1_other_yaxis_reversed(1) = .true. | ||
|
||
Outputs | ||
------- | ||
|
||
Color_magnitude1_yaxis1_name(2) = 'bc_B' | ||
Color_magnitude1_other_yaxis1_name(2) = 'bc_U' | ||
- **History Columns**: Bolometric magnitudes and fluxes will be appended to the MESA history output. | ||
- **SED.csv**: If ``x_character_ctrl(4) = 'false'``, this will save CSV files of each constructed SED. | ||
|
||
! Enables calling a subroutine to add extra information to a plot | ||
! see `$MESA_DIR/star/other/pgstar_decorator.f90` | ||
Color_magnitude1_use_decorator = .true. | ||
Dependencies | ||
------------ | ||
|
||
! file output | ||
Color_magnitude1_file_flag = .true. | ||
Color_magnitude1_file_dir = 'png' | ||
Color_magnitude1_file_prefix = 'Color_magnitude1_' | ||
Color_magnitude1_file_interval = 5 ! output when `mod(model_number,Color_magnitude1_file_interval)==0` | ||
Color_magnitude1_file_width = -1 ! (inches) negative means use same value as for window | ||
Color_magnitude1_file_aspect_ratio = -1 ! negative means use same value as for window | ||
- **MESA** (Version 24.06.1 or higher recommended) | ||
- **Fortran Compiler** (e.g., `gfortran`, `ifort`) | ||
- **Python Helpers**: | ||
- Python 3 | ||
- `numpy` | ||
- `matplotlib` | ||
- `mesa_reader` | ||
|
||
Acknowledgments | ||
--------------- | ||
|
||
!### Color_magnitude2 | ||
|
||
Color_magnitude2_win_flag = .true. | ||
|
||
Color_magnitude2_win_width = 15 | ||
Color_magnitude2_win_aspect_ratio = 0.75 ! aspect_ratio = height/width | ||
|
||
Color_magnitude2_xleft = 0.15 | ||
Color_magnitude2_xright = 0.85 | ||
Color_magnitude2_ybot = 0.15 | ||
Color_magnitude2_ytop = 0.85 | ||
Color_magnitude2_txt_scale = 1.0 | ||
Color_magnitude2_title = 'Color_magnitude2' | ||
|
||
! Plots xaxis1-xaxis2 leave xaxis2 blank if you only want to plot xaxis1. | ||
Color_magnitude2_xaxis1_name = 'abs_mag_B' | ||
Color_magnitude2_xaxis2_name = 'abs_mag_U' | ||
|
||
! Plots yaxis1-yaxis2 leave yaxis2 blank if you only want to plot yaxis1. | ||
Color_magnitude2_yaxis1_name(1) = 'abs_mag_R' | ||
Color_magnitude2_yaxis2_name(1) = 'abs_mag_J' | ||
|
||
! setup default | ||
Color_magnitude2_num_panels = 1 | ||
! file output | ||
Color_magnitude2_file_flag = .true. | ||
Color_magnitude2_file_dir = 'png' | ||
Color_magnitude2_file_prefix = 'Color_magnitude2_' | ||
Color_magnitude2_file_interval = 5 ! output when `mod(model_number,Color_magnitude2_file_interval)==0` | ||
Color_magnitude2_file_width = -1 ! (inches) negative means use same value as for window | ||
Color_magnitude2_file_aspect_ratio = -1 ! negative means use same value as for window | ||
|
||
|
||
!### Color_magnitude3 | ||
|
||
Color_magnitude3_win_flag = .true. | ||
|
||
Color_magnitude3_win_width = 15 | ||
Color_magnitude3_win_aspect_ratio = 0.75 ! aspect_ratio = height/width | ||
|
||
Color_magnitude3_xleft = 0.15 | ||
Color_magnitude3_xright = 0.85 | ||
Color_magnitude3_ybot = 0.15 | ||
Color_magnitude3_ytop = 0.85 | ||
Color_magnitude3_txt_scale = 1.0 | ||
Color_magnitude3_title = 'Color_magnitude3' | ||
|
||
! Plots xaxis1-xaxis2 leave xaxis2 blank if you only want to plot xaxis1. | ||
Color_magnitude3_xaxis1_name = 'model_number' | ||
Color_magnitude3_xaxis2_name = '' | ||
|
||
! Plots yaxis1-yaxis2 leave yaxis2 blank if you only want to plot yaxis1. | ||
Color_magnitude3_yaxis1_name(1) = 'bc_v_bb' | ||
|
||
Color_magnitude3_other_yaxis1_name(1) = 'av_v' | ||
|
||
! setup default | ||
Color_magnitude3_num_panels = 1 | ||
! file output | ||
Color_magnitude3_file_flag = .true. | ||
Color_magnitude3_file_dir = 'png' | ||
Color_magnitude3_file_prefix = 'Color_magnitude3_' | ||
Color_magnitude3_file_interval = 5 ! output when `mod(model_number,Color_magnitude3_file_interval)==0` | ||
Color_magnitude3_file_width = -1 ! (inches) negative means use same value as for window | ||
Color_magnitude3_file_aspect_ratio = -1 ! negative means use same value as for window | ||
|
||
|
||
/ ! end of pgstar namelist | ||
|
||
.. |LCB98| replace:: `Lejeune, Cuisinier, & Buser (1998) <https://ui.adsabs.harvard.edu/abs/1998A%26AS..130...65L/abstract>`__ | ||
|
||
Last-Updated: 05Jun2021 (MESA 5be9e57) by fxt | ||
This project was inspired by the need for more detailed synthetic photometry in stellar evolution simulations. It incorporates insights from MESA's development community and builds upon the work of Rob Farmer and the MESA Team. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file should be rationalised against the top-level
.gitignore
, and the fact that we shouldn't encounter some of these files (e.g..dll
).The only other two test cases that have
.gitignore
files areccsn_IIp
andtzo
, and those are mostly for a few very specific model files.