Point Source Response with Earth Occultation

This notebook requires downloading the following files from wasabi:

  1. DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth.ori (from DC3)

  2. SMEXv12.Continuum.HEALPixO3_10bins_log_flat.binnedimaging.imagingresponse.nonsparse_nside8.area.good_chunks_unzip.h5 (from DC2)

Additionally, you need test_earth_occ.ori, which is included in the same directory as this notebook.

[1]:
# Imports
from cosipy.spacecraftfile import SpacecraftFile
from cosipy.response import FullDetectorResponse
from cosipy.util import fetch_wasabi_file
import astropy.units as u
from astropy.coordinates import SkyCoord
import numpy as np
16:35:19 WARNING   The naima package is not available. Models that depend on it will not be         functions.py:48
                  available                                                                                        
         WARNING   The GSL library or the pygsl wrapper cannot be loaded. Models that depend on it  functions.py:69
                  will not be available.                                                                           
16:35:20 WARNING   The ebltable package is not available. Models that depend on it will not be     absorption.py:33
                  available                                                                                        
16:35:21 INFO      Starting 3ML!                                                                     __init__.py:39
         WARNING   WARNINGs here are NOT errors                                                      __init__.py:40
         WARNING   but are inform you about optional packages that can be installed                  __init__.py:41
         WARNING    to disable these messages, turn off start_warning in your config file            __init__.py:44
         WARNING   no display variable set. using backend for graphics without display (agg)         __init__.py:50
16:35:22 WARNING   ROOT minimizer not available                                                minimization.py:1345
         WARNING   Multinest minimizer not available                                           minimization.py:1357
         WARNING   PyGMO is not available                                                      minimization.py:1369
16:35:23 WARNING   The cthreeML package is not installed. You will not be able to use plugins which  __init__.py:94
                  require the C/C++ interface (currently HAWC)                                                     
         WARNING   Could not import plugin FermiLATLike.py. Do you have the relative instrument     __init__.py:144
                  software installed and configured?                                                               
16:35:24 WARNING   Could not import plugin HAWCLike.py. Do you have the relative instrument         __init__.py:144
                  software installed and configured?                                                               
16:35:26 WARNING   No fermitools installed                                              lat_transient_builder.py:44
16:35:26 WARNING   Env. variable OMP_NUM_THREADS is not set. Please set it to 1 for optimal         __init__.py:387
                  performances in 3ML                                                                              
         WARNING   Env. variable MKL_NUM_THREADS is not set. Please set it to 1 for optimal         __init__.py:387
                  performances in 3ML                                                                              
         WARNING   Env. variable NUMEXPR_NUM_THREADS is not set. Please set it to 1 for optimal     __init__.py:387
                  performances in 3ML                                                                              

Load orientation file:

[4]:
ori_file = "your/path/DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth.ori"
ori = SpacecraftFile.parse_from_file(ori_file)

Define coordinate of source (Crab):

[5]:
coord = SkyCoord(l=184.56*u.deg,b=-5.78*u.deg,frame="galactic")

Calculate scatt map for given coordinate:

[7]:
scatt_map = ori.get_scatt_map(coord, nside = 16, coordsys = 'galactic')

Calculate psr:

[8]:
response_path = "your/path/"
response_file = response_path + "SMEXv12.Continuum.HEALPixO3_10bins_log_flat.binnedimaging.imagingresponse.nonsparse_nside8.area.good_chunks_unzip.h5"
with FullDetectorResponse.open(response_file) as response:
    psr = response.get_point_source_response(coord = coord, scatt_map = scatt_map)
print("Works!")
Works!

Now let’s do a simple test:

Load test orientation file: the z-axis of the instrument points to the Galactic center for 30 seconds. For the first 15 seconds, the instrument is in front of Earth, and then for the last 15.1 seconds the instrument is behind Earth. This should be reflected in the scatt map.

[9]:
ori_file = "your/path/test_earth_occ.ori"
ori = SpacecraftFile.parse_from_file(ori_file)
[10]:
coord = SkyCoord(l=0*u.deg,b=0*u.deg,frame="galactic")
[11]:
scatt_map = ori.get_scatt_map(coord, nside = 16, coordsys = 'galactic')
[12]:
np.sum(scatt_map.contents.todense())
[12]:
15.099999904632568