<jupyter_start><jupyter_text>The change in the CMB intensity due to Compton scattering of CMBphotons off of thermal electrons in galaxy clusters, otherwise known as theSunyaev-Zeldovich (S-Z) effect, can to a reasonable approximation be represented by aprojection of the pressure field of a cluster. However, the *full* S-Z signal is a combination of thermal and kineticcontributions, and for large frequencies and high temperaturesrelativistic effects are important. For computing the full S-Z signalincorporating all of these effects, there is a library:SZpack ([Chluba et al 2012](http://adsabs.harvard.edu/abs/2012MNRAS.426..510C)). The `sunyaev_zeldovich` analysis module in yt makes it possibleto make projections of the full S-Z signal given the properties of thethermal gas in the simulation using SZpack. SZpack has several different options for computing the S-Z signal, from fullintegrations to very good approximations.  Since a full or even apartial integration of the signal for each cell in the projectionwould be prohibitively expensive, we use the method outlined in[Chluba et al 2013](http://adsabs.harvard.edu/abs/2013MNRAS.430.3054C) to expand thetotal S-Z signal in terms of moments of the projected optical depth $\tau$, projected electron temperature $T_e$, andvelocities $\beta_{c,\parallel}$ and $\beta_{c,\perp}$ (their equation 18): $$S(\tau, T_{e},\beta_{c,\parallel},\beta_{\rm c,\perp}) \approx S_{\rm iso}^{(0)} + S_{\rm iso}^{(2)}\omega^{(1)} + C_{\rm iso}^{(1)}\sigma^{(1)} + D_{\rm iso}^{(2)}\kappa^{(1)} + E_{\rm iso}^{(2)}\beta_{\rm c,\perp,SZ}^2 +~...$$ yt makes projections of the various moments needed for thecalculation, and then the resulting projected fields are used tocompute the S-Z signal. In our implementation, the expansion is carried out to first-orderterms in $T_e$ and zeroth-order terms in $\beta_{c,\parallel}$ by default, but terms up to second-order in can be optionallyincluded.   Installing SZpack SZpack can be downloaded [here](http://www.cita.utoronto.ca/~jchluba/Science_Jens/SZpack/SZpack.html). Makesure you install a version later than v1.1.1. For computing the S-Zintegrals, SZpack requires the [GNU Scientific Library](http://www.gnu.org/software/gsl/). For compilingthe Python module, you need to have a recent version of [swig](http://www.swig.org>) installed. After running `make` in the top-level SZpack directory, you'll need to run it in the `python` subdirectory, which is thelocation of the `SZpack` module. You may have to include this location in the `PYTHONPATH` environment variable. **NOTE**: Currently, use of the SZpack library to create S-Z projections in yt is limited to Python 2.x.  Creating S-Z Projections Once you have SZpack installed, making S-Z projections from ytdatasets is fairly straightforward:<jupyter_code>%matplotlib inline
import yt
from yt.extensions.astro_analysis.sunyaev_zeldovich.api import SZProjection

ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")

freqs = [90.,180.,240.]
szprj = SZProjection(ds, freqs)<jupyter_output><empty_output><jupyter_text>`freqs` is a list or array of frequencies in GHz at which the signalis to be computed. The `SZProjection` constructor also accepts theoptional keywords, `mue` (mean molecular weight for computing theelectron number density, 1.143 is the default) and `high_order` (setto True to compute terms in the S-Z signal expansion up tosecond-order in $T_{e,SZ}$ and $\beta$).  Once you have created the `SZProjection` object, you can use it tomake on-axis and off-axis projections:<jupyter_code># An on-axis projection along the z-axis with width 10 Mpc, centered on the gas density maximum
szprj.on_axis("z", center="max", width=(10.0, "Mpc"), nx=400)<jupyter_output><empty_output><jupyter_text>To make an off-axis projection, `szprj.off_axis` is called in the same way, except that the first argument is a three-component normal vector. Currently, only one projection can be in memory at once. These methodscreate images of the projected S-Z signal at each requested frequency,which can be accessed dict-like from the projection object (e.g.,`szprj["90_GHz"]`). Projections of other quantities may also beaccessed; to see what fields are available call `szprj.keys()`. The methods also accept standard ytkeywords for projections such as `center`, `width`, and `source`. The image buffer size can be controlled by setting `nx`.    Writing out the S-Z Projections You may want to output the S-Z images to figures suitable forinclusion in a paper, or save them to disk for later use. There are afew methods included for this purpose. For PNG figures with a colorbarand axes, use `write_png`:<jupyter_code>szprj.write_png("SZ_example")<jupyter_output><empty_output><jupyter_text>For simple output of the image data to disk, call `write_hdf5`:<jupyter_code>szprj.write_hdf5("SZ_example.h5")<jupyter_output><empty_output><jupyter_text>Finally, for output to FITS files which can be opened or analyzedusing other programs (such as ds9), call `export_fits`.<jupyter_code>szprj.write_fits("SZ_example.fits", clobber=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09340659340659341, 'fraction_numerical': 0.015306122448979591, 'mean_word_length': 5.492993630573248, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '18181', 'license': 'BSD-3-Clause-Clear', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1441, 'n_words': 622, 'path': 'doc/source/SZ_projections.ipynb', 'repo_name': 'brittonsmith/yt_astro_analysis', 'size': '5096'}