Example: Predict UV
import sunbather
sunbather.firstrun(quiet=True)
Directory already exists! Checking if download is still needed...
Already downloaded, skipping ahead.
make: ../gitversion.sh: No such file or directory
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_chianti.o atmdat_chianti.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_chianti.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_chianti.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_dielrec_fe.o atmdat_dielrec_fe.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_dielrec_fe.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_dielrec_fe.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_gaunt.o atmdat_gaunt.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_gaunt.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_gaunt.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_lamda.o atmdat_lamda.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_lamda.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_lamda.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_lines_setup.o atmdat_lines_setup.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_lines_setup.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_lines_setup.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_outer_shell.o atmdat_outer_shell.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_outer_shell.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_outer_shell.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atmdat_readin.o atmdat_readin.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atmdat_readin.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atmdat_readin.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atom_hyperfine.o atom_hyperfine.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atom_hyperfine.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atom_hyperfine.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atom_level2.o atom_level2.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atom_level2.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atom_level2.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atom_leveln.o atom_leveln.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atom_leveln.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atom_leveln.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o atoms.o atoms.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" atoms.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h atoms.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o broke.o broke.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" broke.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h broke.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o ca.o ca.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" ca.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h ca.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o called.o called.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" called.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h called.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o cddefines.o cddefines.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" cddefines.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h cddefines.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o cddrive.o cddrive.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" cddrive.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h cddrive.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o cdgetlinelist.o cdgetlinelist.cpp
./make_depend.pl "/usr/bin/g++ -std=c++11 -MM -MG -DMM -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" cdgetlinelist.cpp" cddefines.h cddefines.h.gch /home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h cdgetlinelist.d
/usr/bin/g++ -std=c++11 -O3 -ftrapping-math -fno-math-errno -fasynchronous-unwind-tables -Wno-deprecated-declarations -ftree-vectorize -march=native -Wall -W -g -no-pie -fno-pie -DSYS_CONFIG=\"/home/docs/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/cloudy/c23.01/source/cloudyconfig.h\" -DREVISION=\"\" -c -o cdinit.o cdinit.cpp
make: *** wait: No child processes. Stop.
make: *** Waiting for unfinished jobs....
make: *** wait: No child processes. Stop.
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Cell In[1], line 2
1 import sunbather
----> 2 sunbather.firstrun(quiet=True)
File ~/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/__init__.py:99, in firstrun(quiet, workingdir, cloudy_version)
95 def firstrun(quiet=False, workingdir=None, cloudy_version="23.01"):
96 """
97 Runs 'check_cloudy()' and 'make_workingdir()'.
98 """
---> 99 check_cloudy(quiet=quiet, cloudy_version=cloudy_version)
100 make_workingdir(quiet=quiet, workingdir=workingdir)
102 print("Sunbather is ready to go!")
File ~/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/__init__.py:57, in check_cloudy(quiet, cloudy_version)
55 installer.download()
56 installer.extract()
---> 57 installer.compile()
58 installer.test()
59 installer.copy_data()
File ~/checkouts/readthedocs.org/user_builds/sunbather/envs/latest/lib/python3.12/site-packages/sunbather/install_cloudy.py:74, in GetCloudy.compile(self)
68 os.chdir(f"{self.cloudypath}/c{self.version}/source/")
69 with subprocess.Popen(
70 [
71 "make",
72 ]
73 ) as p:
---> 74 p.wait()
File ~/.asdf/installs/python/3.12.7/lib/python3.12/subprocess.py:1264, in Popen.wait(self, timeout)
1262 endtime = _time() + timeout
1263 try:
-> 1264 return self._wait(timeout=timeout)
1265 except KeyboardInterrupt:
1266 # https://bugs.python.org/issue25942
1267 # The first keyboard interrupt waits briefly for the child to
1268 # exit under the common assumption that it also received the ^C
1269 # generated SIGINT and will exit rapidly.
1270 if timeout is not None:
File ~/.asdf/installs/python/3.12.7/lib/python3.12/subprocess.py:2053, in Popen._wait(self, timeout)
2051 if self.returncode is not None:
2052 break # Another thread waited.
-> 2053 (pid, sts) = self._try_wait(0)
2054 # Check the pid and loop as waitpid has been known to
2055 # return 0 even without WNOHANG in odd situations.
2056 # http://bugs.python.org/issue14396.
2057 if pid == self.pid:
File ~/.asdf/installs/python/3.12.7/lib/python3.12/subprocess.py:2011, in Popen._try_wait(self, wait_flags)
2009 """All callers to this function MUST hold self._waitpid_lock."""
2010 try:
-> 2011 (pid, sts) = os.waitpid(self.pid, wait_flags)
2012 except ChildProcessError:
2013 # This happens if SIGCLD is set to be ignored or waiting
2014 # for child processes has otherwise been disabled for our
2015 # process. This child is dead, we can't get the status.
2016 pid = self.pid
KeyboardInterrupt:
License
The code in this notebook is free to be used, edited and redistributed by anyone free of charge. Please cite Linssen et al. (in prep) when making use of sunbather and/or the code in this notebook.
Example goal
In this example notebook, we predict the NUV spectrum of WASP-52 b to see if the signatures of escaping metal species are strong enough to be potentially observable with HST/STIS. In the fit_helium.ipynb example notebook, we constrained the mass-loss rate and thermospheric temperature of the planet based on metastable helium observations (the examples can be done in any order). Here, we use those constrained values and make NUV predictions. Since we do not know the (upper) atmospheric metallicity of WASP-52 b, we will explore three different models; one assuming solar metallicity, one assuming 10x solar metallicity, and one assuming 10x solar metallicity but a 100x solar magnesium abundance.
Example layout
The analysis consists of three main steps:
Step 1. Generate Parker wind models at different atmospheric metallicities.
Step 2. Run the Parker wind models through Cloudy to obtain nonisothermal temperature structures and the chemical state of the atmosphere.
Step 3. Make synthetic NUV transit spectra of the different models.
Some of the steps we need to take to go through this analysis have to be taken outside of sunbather (e.g. storing the planet parameters in the planets.txt file, making the stellar SED available to Cloudy). Some steps are part of the “core functionality” of the sunbather package, which means they can be executed with a single command-line call to a Python script (e.g. generating the Parker wind profiles, running them through the Cloudy algorithm). And some of the steps are performed inside a user-made Python file/Jupyter notebook (e.g. calculating the transmission spectra). In this notebook, we will provide all neccessary code.
Preparation
For this exercise, we assume you have all codes set-up. That is; you have downloaded sunbather and installed its dependencies (the Python packages, including p-winds). You have installed Cloudy and have the path to it stored as your $CLOUDY_PATH environmental variable. You have created your “project” folder, and have the path to it stored as your $SUNBATHER_PROJECT_PATH environmental variable. You have copied the planets.txt file to the project path. These steps are described in more detail in the “installation” section of the sunbather wiki.
Before sunbather can create Parker wind profiles, we need to make sure the parameters of the system are available to the code. The parameters are stored in the $SUNBATHER_PROJECT_PATH/planets.txt file, and the parameters of the WASP-52 b system have already been added. If you want to model additional planets, you can simply add lines in the planets.txt file with their parameters, there is no need to replace previous planet parameters. The last column of the planets.txt file specifies the name of the stellar SED that we want to use. The SED with exactly this name must be available to Cloudy, so it must be placed in its source folder, specifically: $CLOUDY_PATH/data/SED/. In the /sunbather/stellar_SEDs/ folder, we have provided the SED that we are going to use for WASP-52 b. This is the MUSCLES spectrum (France et al. 2016; Youngblood et al. 2016; Loyd et al. 2016) of eps Eri, which is a similar spectral type to WASP-52. The code is very specific about the format of the spectrum, so we refer to the wiki on how to prep your stellar SED for sunbather.
# The only step you need to take here, is to ensure the eps_Eri_binned.spec file
# is in Cloudy's SED folder:
import os.path
cloudypath = sunbather.tools.get_cloudy_path()
os.path.exists(f"{cloudypath}/data/SED/eps_Eri_binned.spec")
Step 1: Create Parker wind profiles with p-winds/Cloudy
This step can be done by calling sunbather.construct_parker.run with the proper keyword arguments. Calling help(sunbather.construct_parker.run) will give an overview of the available arguments. In this module, the atmospheric composition/metallicity only affects the structure through the mean molecular weight $\mu$. At solar metallicity, the metal content is low enough to not significantly affect $\mu$, so we will make the Parker wind profile with p-winds standalone, assuming a pure H/He composition of 90/10. At 10x solar metallicity, $\mu$ may be significantly affected by the metal content, so we will make the Parker wind profile with a hybrid p-winds/Cloudy calculation. In Step 2 of this example, we will use this profile also for the run with an enhanced magnesium abundance, since $\mu$ (and hence the structure we calculate here in step 1) will not change much when increasing the abundance of just one metal species.
To make the profile with a 90% hydrogen, 10% helium composition, we pass fraction_hydrogen=0.9. We will only make a profile for the constrained temperature of 9200 K and mass-loss rate of $\dot{M}=10^{11.3}$ g/s, so we pass temp=9200 and mdot=11.3. Since we explore different compositions, construct_parker always expects you to give a folder name pdir where we want to store our Parker profiles. We reccommend using a descriptive name, so in this case we will go with fH_0.9 and the path where our profiles will be saved is then $SUNBATHER_PROJECT_PATH/parker_profiles/WASP52b/fH_0.9/.
# The full command to create our first Parker wind model thus becomes - go ahead and run it:
import sunbather.construct_parker
sunbather.construct_parker.run(
plname="WASP52b", pdir="fH_0.9", temp=9200, mdot=11.3, fraction_hydrogen=0.9, # overwrite=True,
)
For this set of parameters, this command should take on the order of 1 second (but it depends on your machine).
To make the 10x solar metallicity profile, instead of the fraction_hydrogen argument, we use z=10. We don’t want this profile to overwrite the file we just saved for H/He only, so we provide a different pdir.
# The full command to create our second Parker wind model thus becomes - go ahead and run it:
sunbather.construct_parker.run(
plname="WASP52b", pdir="z_10", temp=9200, mdot=11.3, z=10, # overwrite=True,
)
For this set of parameters, this command should take on the order of 3 minutes (but it depends on your machine). In the $SUNBATHER_PROJECT_PATH/parker_profiles/WASP52b/ folder, there should now be 2 subfolders, each containing a .txt file with the isothermal Parker wind structure, feel free to inspect them!
Step 2: Run the Parker wind profiles through Cloudy
This step can be done by calling sunbather.convergeT_parker.run with the proper arguments The $T_0$ and $\dot{M}$ commands are the same as in Step 1 of this example. We need to specify a folder name where we want to save our Cloudy simulations. For the solar composition we will use dir="z_1". We also need to specify the folder where we want to read the Parker wind profiles from, so pdir="fH_0.9". The last thing we need to think about, is for which atomic/ionic species we want to save Cloudy’s output. Since many different metal species absorb in the UV, we will save everything that’s available, which is the default behavior of the save_sp argument (so we do not need to specify it here), but does result in a rather large file size of ~5 MB.
# The command to run our solar composition Parker wind model through *Cloudy* thus becomes
# - go ahead and run it:
import sunbather.convergeT_parker
sunbather.convergeT_parker.run(
plname="WASP52b", workingdir="z_1", pdir="fH_0.9", temp=9200, mdot=11.3, overwrite=True,
)
For the 10x solar metallicity model, we need to make sure we specify pdir="z_10" to read the Parker wind profile from the correct folder. We will save the Cloudy runs in workingdir="z_10", and we also need to tell Cloudy to actually use a 10x solar metallicity with z=10.
# **The command to run our 10x solar metallicity Parker wind model through *Cloudy* thus becomes - go ahead and run it**: <br><br>
sunbather.convergeT_parker.run(
plname="WASP52b", workingdir="z_10", pdir="z_10", temp=9200, mdot=11.3, z=10, overwrite=True,
)
Finally for the model with 10x solar metallicity, but 100x solar magnesium abundance, we choose a different output folder workingdir="z_10_Mg10", but we can use the same pdir as before (see explanation under Step 1 of this example). Since we already have an overall scaling factor of 10 for all the metals, we have to pass zelem={"Mg":10} to scale magnesium by another factor of 10 to get a 100x solar abundance.
# **The command to run our 10x solar metallicity with enhanced magnesium Parker wind model through *Cloudy* thus becomes - go ahead and run it**: <br><br>
sunbather.convergeT_parker.run(
plname="WASP52b", workingdir="z_10_Mg10", pdir="z_10", temp=9200, mdot=11.3,
z=10, zelem={"Mg": 10}, save_sp="all", overwrite=True,
)
For these parameters, all commands together should take on the order of 35 minutes (but it depends on your machine). In the $SUNBATHER_PROJECT_PATH/sims/1D/WASP52b/fH_0.9/ and /…/z_10/ and /…/z_10_Mg10/ folders, there should now be a sub-folder (or more if you also did the fit_helium.ipynb example notebook), with the output of the Cloudy simulation, feel free to inspect the files! The converged.png file shows the converged temperature structure, and the other converged.* files are the Cloudy output files.
Step 3: Make NUV transit spectra
To make transit spectra, we can make use of the FinFout() function in the RT.py module.
The FinFout() function takes a Sim object, which is a class defined in tools.py. For more information on how to use this class, we refer to the wiki. The FinFout() function takes three required arguments: the Sim object, a wavelength array in angstrom and vacuum, and a list of atomic/ionic species which to include in the calculations. There are a few optional arguments (see wiki), for example to specify a limb-darkening law or transit phase, but we will not use those here.
import matplotlib.pyplot as plt
import numpy as np
from sunbather import tools
from sunbather import RT
# Get the project path, and keep this constant during the example
projectpath = tools.get_sunbather_project_path()
Let’s start by making the spectrum at solar composition. As a heads-up, there will be a few warnings from sunbather. This is expected.
wavs = RT.constantR_wavs(
2000, 3000, 100000
) # set up wavelength grid at spectral resolution of 100,000
W52b_solar = tools.Sim(
f"{projectpath}/sims/1D/WASP52b/z_1/parker_9200_11.300/converged"
) # load simulation
# we can quickly get a list of all species as follows:
all_species = tools.get_specieslist(
max_ion=2
) # this includes all species up to doubly ionized - higher is not neccessary here
transit_spectrum_solar, _, _ = RT.FinFout(W52b_solar, wavs, all_species) # do RT
fig, ax = plt.subplots(1, figsize=(12, 7))
ax.plot(wavs, transit_spectrum_solar)
ax.set_xlabel("Wavelength [Å]")
ax.set_ylabel(r"$F_{in} / F_{out}$")
ax.set_title(r"WASP-52 b with T=9200 and $\dot{M}=10^{11.3}$, solar composition")
plt.show()
Now let’s do 10x solar metallicity.
W52b_z_10 = tools.Sim(
projectpath + "/sims/1D/WASP52b/z_10/parker_9200_11.300/converged"
) # load simulation
transit_spectrum_z_10, _, _ = RT.FinFout(W52b_z_10, wavs, all_species) # do RT
fig, ax = plt.subplots(1, figsize=(12, 7))
ax.plot(wavs, transit_spectrum_z_10)
ax.set_xlabel("Wavelength [Å]")
ax.set_ylabel(r"$F_{in} / F_{out}$")
ax.set_title(r"WASP-52 b with T=9200 and $\dot{M}=10^{11.3}$, 10x solar metallicity")
plt.show()
And finally a zoom-in on the magnesium doublet for all three models together: solar composition, 10x solar composition, and the model with a 100x solar magnesium abundance.
A technical detail that is important here: To save computational time, RT.FinFout() function calculates each individual spectral line in a narrow wavelength window (i.e. only a subset of wavs) around the rest-frame wavelength of that line. In the absolute majority of cases, this window is large enough to encompass the whole spectral line, but not in special cases where the line is very strong, such as commonly for the Ly-$\alpha$ line, or here for the Mg II doublet in the 100x solar abundance model. You could visually see this in the resulting spectrum as a discrete “jump” from the line wing to the continuum. In such a case, we have to manually increase the computation window by a certain factor with the width_fac argument. We will set it to 20 here to catch the full Lorentzian wing of the line (try without it to check the difference!).
wavs2 = np.linspace(2795, 2805, num=500) # set up a wav-grid around the Mg II doublet
W52b_z_10_Mg10 = tools.Sim(
projectpath + "/sims/1D/WASP52b/z_10_Mg10/parker_9200_11.300/converged"
) # load simulation
transit_spectrum_z_10_Mg10, _, _ = RT.FinFout(
W52b_z_10_Mg10, wavs2, "Mg+", width_fac=20.0
) # do RT
fig, ax = plt.subplots(1)
ax.plot(wavs, transit_spectrum_solar, label="Solar")
ax.plot(wavs, transit_spectrum_z_10, label="Z=10")
ax.plot(wavs2, transit_spectrum_z_10_Mg10, label="Z=10, Mg=100")
ax.set_xlim(wavs2[0], wavs2[-1])
ax.legend(loc="best")
ax.set_title(r"WASP-52 b Mg II doublet at different metallicities")
ax.set_xlabel("Wavelength [Å]")
ax.set_ylabel(r"$F_{in} / F_{out}$")
plt.show()
To predict the actual observability of these lines in WASP-52 b, we would first need to convolve the spectrum down to the HST/STIS resolution and then do a S/N calculation based on the system magnitude, exposure time, etc. This is outside the scope of this example problem.
References
France, K., Loyd, R. O. P., Youngblood, A., et al. 2016, ApJ, 820, 89
Loyd, R. O. P., France, K., Youngblood, A., et al. 2016, ApJ, 824, 102
Youngblood, A., France, K., Loyd, R. O. P., et al. 2016, ApJ, 824, 101