/Cocoon-paper

Codes to reproduce the plots in the cocoon paper.

Primary LanguagePython

############################
# B. Hona, July 28, 2020  #
############################

This are the steps to follow to reproduce the results from the "HAWC Cocoon" paper:

1) 3ML and HAL installation:
# 3ML is a multi-wavelength/multi-messenger analysis framework that provides a
# unified interface to software from many different instruments. It is 
# available as open-source code under: https://github.com/threeML/threeML . 
# HAL (HAWC Accelerated Likelihood - python-only framework for HAWC data analysis. It is available as open source code under: https://github.com/threeML/hawc_hal.
# Both frameworks can be installed via conda:

# Install miniconda
curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh  > Miniconda3-latest.sh

# This will install conda in ~/miniconda . If you want to put it somewhere else change accordingly these 3 lines
bash Miniconda3-latest.sh -p ${MINICONDA_PATH}/ -b
export PATH=${MINICONDA_PATH}/bin:$PATH


# Install all the needed framework via
install_from_conda.sh

# Activate environment
From a clean shell, use `source ~/init_conda_hawc.sh` to activate the hawc_analysis enviroment 
----------------------------------------------------------------------------------
1) Reproduce the fit results for the HAWC Cocoon:
# After activating the hawc_analysis environment, run the 3ML script in the '3ML_fit' directory. Data file (maptree.hd5) is healpx maps (NSIDE = 1024) of signal and expected background counts in bins of fHit and reconstructed energy with 1343 days of lifetime. response.hd5 is the HAWC detector response file. 
python 3ml_fit.py 

----------------------------------------------------------------------------------
2) Reproduce the Significance maps:
#Significance maps are in the FITS format in the maps directory. To display the FITS files, a list of viewers is available at https://fits.gsfc.nasa.gov/fits_viewer.html
----------------------------------------------------------------------------------
3) Reproduce the hadronic and leptonic distribution:
#Before running the python scripts in the hadronic directory, load the data file(maptree.hd5), the detector response file (response.hd5) and the region of interest file (roi.fits) in the python scripts.
# For the fit results of steady case scenario
python hadronic/steady.py
# For the fit results of burst case scenario
python hadronic/burst.py 
# Plotting expected gamma-ray distribution from the hadronic fit results
# The parameters for the leptonic scenario are described in the file
leptonic/electron_description.py
#An example plotting script to plot the expected gamma-ray spectra from the hadronic models along with the Cocoon flux points
python plot_spectra.py

----------------------------------------------------------------------------------
4) Reproduce the cosmic-ray profile plot, inside cr_profile directory:
#Produce a model of the four rings centered at the OB2 association and save the yml file in the results directory
mkdir results
python ring.py
#Using the model file obtained from ring.py, fit the rings and other sources using 3ML. Load data file (maptree.hd5), detector response file (response.hd5) and region of interest file (roi.fits) in ring_model_fit.py script and then run
python ring_model_fit.py
# Obtain the integrated flux for each ring from the fits file saved from 3ml fit
python flux.py
#Calculate cosmic-ray profile using eq 5 and plot 
python plot_cr_profile.py

----------------------------------------------------------------------------------
5) Energy range and lower limit to the Cocoon cutoff:
#Upper limit to the minimum energy range for the Cocoon
python energy-range_lowerbound.py
#Lower limit to the maximum energy range for the Cocoon
python energy-range_upperbound.py
#lower limit to the Cocoon cutoff energy
python lower_limit_cocoon_cutoff.py

----------------------------------------------------------------------------------
6) Reproduce the systematic uncertainties for the Cocoon spectrum:
# Systematic uncertainties due to detector effects
# To load the different detector systematics results:
python reload_results-from-fits.py

# Systematic uncertainties due to various effects:
# These scripts require data file (maptree.hd5), detectot response file (response.hd5) and region of interest file (roi.fits) provided in this repository.
python gde_unresolved_background.py #to calculate systematics uncertainties due to Galactic diffuse emission and unresolved sources

python uniform_background.py # to calculate systematics uncertainties due to larger than ROI uniform background

python larger_roi.py #to calculate systematics uncertainties from the larger ROI

#################################################
If you have question you can reach us by email:
bhona AT mtu DOT edu
hfleisch AT mtu DOT edu 
kefang AT standford DOT edu
rdb3 AT standford DOT edu 
sabrinacasanova AT gmail DOT com 
petra mtu DOT edu 
#################################################