\documentclass{article}

\usepackage{cite}
\usepackage{hyperref}
\usepackage{aas_macros}
\usepackage{graphicx}
\usepackage{hyperref}

\graphicspath{ {./images/} }

\title{FLAMINGO Lightcone Output Corrections}
\date{2022-12-08}
\author{John Helly}

\begin{document}
\maketitle

\section{FLAMINGO Lightcone Output Corrections}

This document describes the post processing applied to the lightcone
particle outputs and HEALPix maps generated by the FLAMINGO
simulations. This post processing serves two purposes:
\begin{itemize}
\item{To correct various bugs found in the simulation code after the
    simulations were run.}
\item{To put the output into a more convenient form by, for example,
    splitting it over fewer files and adding indexing to allow
    extraction of useful subsets of the data.}
\end{itemize}
The python code and batch scripts used to do this are stored in a git
repository at \url{https://github.com/jchelly/LightconeIO}. The
README.md file in the git repository explains how to run the scripts.

Slurm batch scripts for processing the FLAMINGO outputs on Cosma are
in the \verb|scripts/FLAMINGO| subdirectory in the git repository.

\subsection{Post processing of the particle output}

The script \verb|lightcone_io_index_particles.py| is used to combine the
lightcone particle outputs into a smaller number of files and sort the
particles by redshift and position on the sky so that sub-regions of
the lightcone can be extracted without reading all of the particles.

The output from this script is required for making lightcone halo
catalogues.

No corrections are made to the particle data by this script.

\subsection{Post processing of the HEALPix maps}

The HEALPix maps are processed in three steps: the maps are combined
into one file per redshift bin, various corrections are made, and then
down sampled versions of the maps are created.

\subsubsection{Combining the maps into single files}

The script \verb|lightcone_io_combine_maps.py| is used to combine the maps
for each shell into a single file. This script also sets the unit
information for the following HEALPix maps to an assumed correct
value, disregarding the units in the input files:

\begin{itemize}
\item{XrayErositaLowIntrinsicPhotons}
\item{XrayErositaHighIntrinsicPhotons}
\item{XrayROSATIntrinsicPhotons}
\item{XrayErositaLowIntrinsicEnergies}
\item{XrayErositaHighIntrinsicEnergies}
\item{XrayROSATIntrinsicEnergies}
\end{itemize}

It should be safe to run this script on output from a version of SWIFT
where this bug has been fixed as long as the actual units of the X-ray
maps have not changed. If the script changes the units of a map it
generates a warning on stdout.

The file \verb|lightcone_io/units.py| defines what the units of these maps
should be and any additional corrections can be added there.

\subsubsection{Applying corrections to the maps}

The script \verb|lightcone_io_correct_maps.py| applies corrections to the map
pixel data. The corrections are:
\begin{itemize}
\item{The DopplerB maps must be multiplied by $(1+z)$ at the shell
    midpoint}
\item{The DM (dispersion measure) maps must be multiplied by $1/(1+z)$
    at the shell midpoint}
\item{Three times the mean neutrino mass per pixel must be subtracted
    from the NeutrinoMass and TotalMass maps}
\end{itemize}

This script adds attributes to the maps which describe what
corrections have been made. If the input map already contains these
attributes then the corrections will not be made again.

Note that the script has no way to determine if these corrections have
already been made in SWIFT. If new runs are carried out with the
corresponding bugs fixed then this script should not be run.

\subsubsection{Downsampling the maps}

The script \verb|lightcone_io_downsample_maps.py| can be used to make
low resolution maps. In order to do this it is necessary to know for
each map if pixels should be combined by taking the sum or the average
- the function \verb|get_power()| in
\verb|lightcone_io_downsample_maps.py| will need to be modified if new
map types are added.

This script does not do any corrections so it should be applied to
high resolution maps which have already been corrected.

%\bibliography{references}{}
%\bibliographystyle{plain}

\end{document}
