{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Fermi Data - diffuse photons Galactic coordinates\n", "\n", "Get data from https://fermi.gsfc.nasa.gov/ssc/data/access/lat/. Extract information from fits files and store as Numpy arrays using routines in OneLinux/FermiSky.\n", "\n", "Here, use coordinates in \"Fermi convention\", i.e. RA and Galactic longitude are in the range 0$^\\circ$...360$^\\circ$.\n", "\n", "### Set up file names and variables" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Date and time 2019-11-22 15:07:57.375371\n", " \n", "Running in debug mode!\n", " \n", "Coordinate system used Galactic \n", "Source is AllSky\n", "Location is RA 0.00000, Dec 0.00000.\n", "Radius of RoI: 180.00000.\n", " \n", "Minimum and maximum photon energies: 3000, 300000.\n", "Number of energy bins for analysis: 37.\n", "Number of bins in x and y for images: 180, 180.\n", " \n", "Numpy photon file (OutAllArray) D:\\FermiData\\analysis\\FermiSkyArr-Galactic-HE.txt\n", "Numpy test photon file (OutTestArray) D:\\FermiData\\analysis\\FermiSkyArr-Galactic-test.txt\n", "Source array (OutSourceArray) D:\\FermiData\\analysis\\FermiSourceArr-Galactic.txt\n", "Diffuse photon array (OutDiffArray) D:\\FermiData\\analysis\\FermiSkyDiffTwoDegArr-Galactic-HE.txt\n", "Source photon array (OutDSrcArray) D:\\FermiData\\analysis\\FermiSkySrcOneDegArr-Galactic-HE.txt\n", "Catalogue file (Catalogue) D:\\FermiData\\catalogue\\gll_psc_v20.fit\n", " \n", "Date and time 2019-11-22 15:07:57.377367\n", "Time since last check is 0:00:00.001996\n" ] } ], "source": [ "import sys\n", "import datetime\n", "now = datetime.datetime.now()\n", "print(\"Date and time\",str(now))\n", "#\n", "Debug = True\n", "if Debug:\n", " print(\" \")\n", " print(\"Running in debug mode!\")\n", "#\n", "SourceName = \"AllSky\"\n", "RA = 0.0\n", "Dec = 0.0\n", "RadRoI = 180.0\n", "print(\" \")\n", "Coords = \"Galactic\"\n", "print(\"Coordinate system used {:.10s} \".format(Coords))\n", "#\n", "print(\"Source is \",SourceName)\n", "print(\"Location is RA {:.5f}, Dec {:.5f}.\".format(RA,Dec))\n", "print(\"Radius of RoI: {:.5f}.\".format(RadRoI))\n", "#\n", "Emin = 3000\n", "Emax = 300000\n", "print(\" \")\n", "print(\"Minimum and maximum photon energies: {:.0f}, {:.0f}.\".format(Emin,Emax))\n", "#\n", "nEbins = 37\n", "print(\"Number of energy bins for analysis: {:.0f}.\".format(nEbins))\n", "#\n", "nXbins = 180\n", "nYbins = 180\n", "print(\"Number of bins in x and y for images: {:.0f}, {:.0f}.\".format(nXbins,nYbins))\n", "#\n", "#OutAllArray = \"D:/FermiData/analysis/FermiSkyArr-Galactic-HE.txt\"\n", "OutAllArray = \"D:\\\\FermiData\\\\analysis\\\\FermiSkyArr-Galactic-HE.txt\"\n", "print(\" \")\n", "print(\"Numpy photon file (OutAllArray)\",OutAllArray)\n", "#\n", "#OutTestArray = \"D:/FermiData/analysis/FermiSkyArr-Galactic-test.txt\"\n", "OutTestArray = \"D:\\\\FermiData\\\\analysis\\\\FermiSkyArr-Galactic-test.txt\"\n", "print(\"Numpy test photon file (OutTestArray)\",OutTestArray)\n", "#\n", "#OutSourceArray = \"D:/FermiData/analysis/FermiSourceArr-Galactic.txt\"\n", "OutSourceArray = \"D:\\\\FermiData\\\\analysis\\\\FermiSourceArr-Galactic.txt\"\n", "print(\"Source array (OutSourceArray)\",OutSourceArray)\n", "#\n", "#OutDiffArray = \"D:/FermiData/analysis/FermiSkyDiffTwoDegArr-Galactic-HE.txt\"\n", "OutDiffArray = \"D:\\\\FermiData\\\\analysis\\\\FermiSkyDiffTwoDegArr-Galactic-HE.txt\"\n", "print(\"Diffuse photon array (OutDiffArray)\",OutDiffArray)\n", "#\n", "#OutSrcArray = \"D:/FermiData/analysis/FermiSkySrcOneDegArr-Galactic-HE.txt\"\n", "OutSrcArray = \"D:\\\\FermiData\\\\analysis\\\\FermiSkySrcOneDegArr-Galactic-HE.txt\"\n", "print(\"Source photon array (OutDSrcArray)\",OutSrcArray)\n", "# \n", "#Catalogue = \"D:/FermiData/catalogue/gll_psc_v19.fit\"\n", "#Catalogue = \"D:\\FermiData\\catalogue\\gll_psc_v19.fit\"\n", "Catalogue = \"D:\\\\FermiData\\\\catalogue\\\\gll_psc_v20.fit\"\n", "print(\"Catalogue file (Catalogue)\",Catalogue)\n", "#\n", "then = now\n", "now = datetime.datetime.now()\n", "print(\" \")\n", "print(\"Date and time\",str(now))\n", "print(\"Time since last check is\",str(now - then))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check directories for files." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Date and time 2019-11-22 15:15:51.957919\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\analysis\n", "\n", "22/08/19 15:42 83 184 633 FermiSkyArr-Galactic-HE.txt\n", " 1 File(s) 83 184 633 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\analysis\n", "\n", "22/08/19 15:42 7 549 132 FermiSkyArr-Galactic-test.txt\n", " 1 File(s) 7 549 132 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\analysis\n", "\n", "22/08/19 15:42 2 176 084 FermiSourceArr-Galactic.txt\n", " 1 File(s) 2 176 084 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\analysis\n", "\n", "22/08/19 15:45 12 035 985 FermiSkyDiffTwoDegArr-Galactic-HE.txt\n", " 1 File(s) 12 035 985 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\analysis\n", "\n", "22/08/19 15:48 45 002 380 FermiSkySrcOneDegArr-Galactic-HE.txt\n", " 1 File(s) 45 002 380 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " Volume in drive D has no label.\n", " Volume Serial Number is 3266-3766\n", "\n", " Directory of D:\\FermiData\\catalogue\n", "\n", "18/11/19 07:26 8 660 160 gll_psc_v20.fit\n", " 1 File(s) 8 660 160 bytes\n", " 0 Dir(s) 123 464 318 976 bytes free\n", " \n", "Date and time 2019-11-22 15:15:52.081521\n", "Time since last check is 0:00:00.123602\n" ] } ], "source": [ "import sys\n", "import datetime\n", "now = datetime.datetime.now()\n", "print(\"Date and time\",str(now))\n", "#\n", "!dir $OutAllArray\n", "!dir $OutTestArray\n", "!dir $OutSourceArray\n", "!dir $OutDiffArray\n", "!dir $OutSrcArray\n", "!dir $Catalogue\n", "#\n", "then = now\n", "now = datetime.datetime.now()\n", "print(\" \")\n", "print(\"Date and time\",str(now))\n", "print(\"Time since last check is\",str(now - then))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Fermi routines path\n", "\n", "Set up path to FermiRoutines:\n", "\n", "C:/Users/green/OneDrive/OneLinux/FermiSky/FermiRoutines.py" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Date and time 2019-11-22 11:01:52.117624\n", "Directories in path are:\n", " ['C:\\\\Users\\\\green\\\\OneDrive\\\\OneDocuments\\\\Liverpool\\\\Teaching\\\\Phys105-Comp01-2019\\\\Phys105-Lectures2019', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\python37.zip', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\DLLs', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib', 'C:\\\\Users\\\\green\\\\Anaconda3', '', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib\\\\site-packages', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib\\\\site-packages\\\\win32', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\Users\\\\green\\\\Anaconda3\\\\lib\\\\site-packages\\\\IPython\\\\extensions', 'C:\\\\Users\\\\green\\\\.ipython', 'C:\\\\Users\\\\green\\\\OneDrive\\\\OneLinux\\\\FermiSky']\n", " \n", "Date and time 2019-11-22 11:01:52.117624\n", "Time since last check is 0:00:00\n" ] } ], "source": [ "import sys\n", "import datetime\n", "now = datetime.datetime.now()\n", "print(\"Date and time\",str(now))\n", "#\n", "import sys\n", "#\n", "sys.path.append('C:\\\\Users\\\\green\\\\OneDrive\\\\OneLinux\\\\FermiSky')\n", "print(\"Directories in path are:\\n\",sys.path)\n", "#\n", "then = now\n", "now = datetime.datetime.now()\n", "print(\" \")\n", "print(\"Date and time\",str(now))\n", "print(\"Time since last check is\",str(now - then))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import\n", "\n", "Import FermiRoutines so have access to:\n", "\n", "ToFermi(RA) \n", "FromFermi(RA) \n", "angSep(alpA, delA, alpB, delB) \n", "aitoff(lng, lat) \n", "hammer(lng, lat) \n", "xhamLine(lngBot, lngTop, lat) \n", "yhamLine(lng, latBot, latTop) \n", "xaitLine(lngBot, latTop, Dec) \n", "yaitLine(lng, latBot, altTop) \n", "hamscat(alpha, delta, size, col, revx) \n", "hamscatZero(alpha, delta, size, col) \n", "hamhist2D(alpha, delta, nBins, wgts, revx) \n", "hamhist2Dedges(alpha, delta, aedges, dedges, wgts, revx) \n", "hamhist2Dzero(alpha, delta, nBins, wgts) \n", "hamhist2DedgesZero(alpha, delta, aedges, dedges, wgts) \n", "hamscale(raLim, decLim, col, revx) \n", "hamscaleZero(raLim, decLim, col) \n", "hamlim(raL, decL) \n", "makeBins(nBinsAlpha0, nBinsDelta) \n", "indBins(alpha, delta) \n", "binContents(alpha, delta, weight) " ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Date and time 2019-11-22 11:31:19.123423\n", " \n", "Directory of C:\\Users\\green\\OneDrive\\OneLinux\\FermiSky\\\n", " Volume in drive C is OS\n", " Volume Serial Number is D6E0-363C\n", "\n", " Directory of C:\\Users\\green\\OneDrive\\OneLinux\\FermiSky\n", "\n", "22/11/19 11:29