{ "cells": [ { "cell_type": "markdown", "id": "2a6bafbd", "metadata": {}, "source": [ "# Point Source Response with Earth Occultation\n", "\n", "This notebook requires downloading the following files from wasabi:\n", "\n", "1) DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth.fits (from DC3)\n", "\n", "2) SMEXv12.Continuum.HEALPixO3_10bins_log_flat.binnedimaging.imagingresponse.h5 (from develop)\n", "\n", "Additionally, you need test_earth_occ.fits, which is included in the same directory as this notebook. " ] }, { "cell_type": "code", "execution_count": null, "id": "e1f7d927", "id": "518224fe", "metadata": {}, "outputs": [], "source": [ "# Imports\n", "from cosipy.spacecraftfile import SpacecraftHistory\n", "from cosipy.response import FullDetectorResponse\n", "from cosipy.util import fetch_wasabi_file\n", "import astropy.units as u\n", "from astropy.coordinates import SkyCoord\n", "import numpy as np" ] }, { "cell_type": "markdown", "id": "bdb078d7", "metadata": {}, "source": [ "Load orientation file:" ] }, { "cell_type": "code", "execution_count": null, "id": "d9c226e9", "id": "259bd69a", "metadata": {}, "outputs": [], "source": [ "ori_file = \"your/path/DC3_final_530km_3_month_with_slew_15sbins_GalacticEarth.fits\"\n", "ori = SpacecraftHistory.open(ori_file)" ] }, { "cell_type": "markdown", "id": "2c4dca26", "metadata": {}, "source": [ "Define coordinate of source (Crab):" ] }, { "cell_type": "code", "execution_count": null, "id": "28060b33", "id": "fd7da129", "metadata": {}, "outputs": [], "source": [ "coord = SkyCoord(l=184.56*u.deg,b=-5.78*u.deg,frame=\"galactic\")" ] }, { "cell_type": "markdown", "id": "bea9f63b", "metadata": {}, "source": [ "Calculate scatt map for given coordinate:" ] }, { "cell_type": "code", "execution_count": null, "id": "a18bb203", "id": "c13c4fb4", "metadata": {}, "outputs": [], "source": [ "scatt_map = ori.get_scatt_map(coord, nside = 16)" ] }, { "cell_type": "markdown", "id": "a59d0ac1", "metadata": {}, "source": [ "Calculate psr:" ] }, { "cell_type": "code", "execution_count": null, "id": "058b3798", "id": "14c8ad41", "metadata": {}, "outputs": [], "source": [ "response_path = \"your/path/\"\n", "response_file = response_path + \"SMEXv12.Continuum.HEALPixO3_10bins_log_flat.binnedimaging.imagingresponse.h5\"\n", "with FullDetectorResponse.open(response_file) as response:\n", " psr = response.get_point_source_response(coord = coord, scatt_map = scatt_map)\n", "print(\"Works!\") " ] }, { "cell_type": "markdown", "id": "726158b0", "metadata": {}, "source": [ "### Now let's do a simple test:\n", "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." ] }, { "cell_type": "code", "execution_count": null, "id": "37333bb2", "id": "7e0d7492", "metadata": {}, "outputs": [], "source": [ "ori_file = \"your/path/test_earth_occ.fits\"\n", "ori = SpacecraftHistory.open(ori_file)" ] }, { "cell_type": "code", "execution_count": null, "id": "393f3a7f", "id": "e33cd0db", "metadata": {}, "outputs": [], "source": [ "coord = SkyCoord(l=0*u.deg,b=0*u.deg,frame=\"galactic\")" ] }, { "cell_type": "code", "execution_count": null, "id": "616caa7e", "id": "2f862091", "metadata": {}, "outputs": [], "source": [ "scatt_map = ori.get_scatt_map(coord, nside = 16)" ] }, { "cell_type": "code", "execution_count": null, "id": "b57ded15", "id": "ea1116c4", "metadata": {}, "outputs": [], "source": [ "np.sum(scatt_map.weights)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }