{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# GBM, LAT LLE and Swift Catalogs\n", "\n", "\n", "Using **3ML's** catalog and data downloading tools, it is easy to build an analysis for either a single or multiple GRBs from start to finish. \n", "\n", "Here, we demostrate how we can search the catalogs for trigger information and then use this to perform analysis. Currently, Swift analysis is performed with the Generic **OGIPLike** or **XRTLike** plugin only and no data dowloaders are provided. In the future, a more capable Swift plugin can be included. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Configuration read from /Users/jburgess/.threeML/threeML_config.yml\n", "Available plugins:\n", "\n", "SwiftXRTLike for Swift XRT\n", "FermiGBMTTELike for Fermi GBM TTE (all detectors)\n", "OGIPLike for All OGIP-compliant instruments\n", "FermiLATLLELike for Fermi LAT LLE\n", "XYLike for n.a.\n" ] } ], "source": [ "%matplotlib inline\n", "%matplotlib notebook\n", "\n", "from astropy.time import Time\n", "\n", "from threeML import *\n", "\n", "get_available_plugins()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## GBM catalog\n", "\n", "The **3ML** GBM catalog allows you to search via cones on the sky, trigger names, T90s, date ranges and model parameters." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gbm_catalog = FermiGBMBurstCatalog()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Searching cones on the sky\n", "\n", "We can perform a cone search for a given Ra and Dec to see what GRBs are in this region of the sky." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Trying http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermigbrst&\n", "Downloading http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermigbrst&SR=10.0&DEC=0.0&RA=0.0&VERB=3 [Done]\n" ] }, { "data": { "text/html": [ "<Table masked=True length=17>\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timet90
degdegmjds
objectfloat64float64float64float64
GRB080810549356.8000.32054688.5487567107.457
GRB0907033290.7709.68055015.32919538.960
GRB100612726352.000-1.83055359.72645988.576
GRB1009241650.6727.00455463.16537409.024
GRB110729142353.3904.97055771.1424297408.582
GRB1109214446.090-5.83055825.4436135149.507
GRB1111134104.320-7.52055878.409858315.360
GRB1206243094.7737.16756102.30862660.640
GRB121122870355.4506.34056253.8700119125.439
GRB1306285316.290-5.07056471.530580121.504
GRB1401063452.340-8.75056663.344946333.024
GRB140406120357.5505.63056753.1196037109.312
GRB140918379356.180-0.54056918.3791791165.632
GRB150724782351.9203.67057227.781686537.889
GRB150911315355.280-2.90057276.314518141.728
GRB160215773356.7901.73057433.7732684141.314
GRB1605035670.540-1.93057511.567037159.392
" ], "text/plain": [ "\n", " name ra dec trigger_time t90 \n", " deg deg mjd s \n", " object float64 float64 float64 float64 \n", "------------ ------- ------- ------------- --------\n", "GRB080810549 356.800 0.320 54688.5487567 107.457\n", "GRB090703329 0.770 9.680 55015.3291953 8.960\n", "GRB100612726 352.000 -1.830 55359.7264598 8.576\n", "GRB100924165 0.672 7.004 55463.1653740 9.024\n", "GRB110729142 353.390 4.970 55771.1424297 408.582\n", "GRB110921444 6.090 -5.830 55825.4436135 149.507\n", "GRB111113410 4.320 -7.520 55878.4098583 15.360\n", "GRB120624309 4.773 7.167 56102.3086266 0.640\n", "GRB121122870 355.450 6.340 56253.8700119 125.439\n", "GRB130628531 6.290 -5.070 56471.5305801 21.504\n", "GRB140106345 2.340 -8.750 56663.3449463 33.024\n", "GRB140406120 357.550 5.630 56753.1196037 109.312\n", "GRB140918379 356.180 -0.540 56918.3791791 165.632\n", "GRB150724782 351.920 3.670 57227.7816865 37.889\n", "GRB150911315 355.280 -2.900 57276.3145181 41.728\n", "GRB160215773 356.790 1.730 57433.7732684 141.314\n", "GRB160503567 0.540 -1.930 57511.5670371 59.392" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.cone_search(ra=0,dec=0,radius=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or perhaps we want to know the GRBs around the Crab nebula:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Trying http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermigbrst&\n", "Downloading http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermigbrst&SR=5.0&DEC=22.0144947866&RA=83.6330906247&VERB=3 [Done]\n" ] }, { "data": { "text/plain": [ "(83.63309062468973, 22.014494786634714,
\n", " name ra dec trigger_time t90 \n", " deg deg mjd s \n", " object float64 float64 float64 float64 \n", " ------------ ------- ------- ------------- --------\n", " GRB090612619 81.030 17.710 54994.6186400 42.433\n", " GRB090907808 81.060 20.500 55081.8081884 0.832\n", " GRB100130777 78.570 20.830 55226.7767993 86.018\n", " GRB100915243 85.394 25.095 55454.2428196 7.936)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.search_around_source('Crab',radius=5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Searching on T90 and time\n", "\n", "Perhaps we want to analyze all short GRBs or GRBs in a specific date range.\n", "\n", "First let's search on T90:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=353>\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timet90
objectfloat64float64float64float64
GRB08071408641.9008.50054661.08625065.376
GRB080715950214.7009.90054662.95046497.872
GRB08080658494.60057.80054684.58415752.304
GRB080808451107.400-33.80054686.45142674.352
GRB080816989289.500-6.80054694.98882744.608
GRB08081772080.200-17.10054695.72022594.416
GRB080821332238.60032.60054699.33155655.888
GRB080824909122.400-2.80054702.90896687.424
GRB080828189221.300-12.30054706.18901933.008
GRB080829790221.9003.20054707.79000497.68
...............
GRB160929529340.23022.79057660.52880054.864
GRB16100104579.150-55.36057662.04533242.24
GRB161012637160.430-74.28057673.63697756.4
GRB161128216262.430-46.05057720.21649656.912
GRB161207224294.810-9.93057729.22416328.192
GRB161210524283.12063.05057732.52354582.304
GRB16121265224.94068.23057734.65207612.816
GRB161217128216.63051.98057739.12761333.584
GRB16122749879.50039.15057749.49812752.56
GRB170101374157.49028.90057754.37400362.304
" ], "text/plain": [ "\n", " name ra dec trigger_time t90 \n", " object float64 float64 float64 float64\n", "------------ ------- ------- ------------- -------\n", "GRB080714086 41.900 8.500 54661.0862506 5.376\n", "GRB080715950 214.700 9.900 54662.9504649 7.872\n", "GRB080806584 94.600 57.800 54684.5841575 2.304\n", "GRB080808451 107.400 -33.800 54686.4514267 4.352\n", "GRB080816989 289.500 -6.800 54694.9888274 4.608\n", "GRB080817720 80.200 -17.100 54695.7202259 4.416\n", "GRB080821332 238.600 32.600 54699.3315565 5.888\n", "GRB080824909 122.400 -2.800 54702.9089668 7.424\n", "GRB080828189 221.300 -12.300 54706.1890193 3.008\n", "GRB080829790 221.900 3.200 54707.7900049 7.68\n", " ... ... ... ... ...\n", "GRB160929529 340.230 22.790 57660.5288005 4.864\n", "GRB161001045 79.150 -55.360 57662.0453324 2.24\n", "GRB161012637 160.430 -74.280 57673.6369775 6.4\n", "GRB161128216 262.430 -46.050 57720.2164965 6.912\n", "GRB161207224 294.810 -9.930 57729.2241632 8.192\n", "GRB161210524 283.120 63.050 57732.5235458 2.304\n", "GRB161212652 24.940 68.230 57734.6520761 2.816\n", "GRB161217128 216.630 51.980 57739.1276133 3.584\n", "GRB161227498 79.500 39.150 57749.4981275 2.56\n", "GRB170101374 157.490 28.900 57754.3740036 2.304" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.query(\"2\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timet90
objectfloat64float64float64float64
GRB100101028307.320-27.00055197.02765432.816
GRB10010198870.66018.69055197.98767571.984
GRB1001070746.310-21.24055203.07397990.576
GRB100111176247.04815.55155207.175575219.52
GRB100112418240.140-75.10055208.417564323.04
GRB100116897305.02014.45055212.8965306102.53
GRB10011787911.260-1.59455213.87939430.256
GRB1001181009.260-37.37055214.09969569.216
GRB10012261679.200-2.71055218.616404122.529
GRB100126460338.370-18.74055222.46047610.624
...............
GRB101223834250.55048.22055553.833542856.065
GRB101224227285.92645.71555554.22724381.728
GRB101224578289.140-55.25055554.578451744.737
GRB101224614290.16034.46055554.613575625.601
GRB101224998325.170-38.66055554.998321118.688
GRB10122537760.68032.77055555.377008181.218
GRB101227195186.790-83.55055557.194776895.488
GRB101227406240.500-24.50055557.406326153.347
GRB101227536150.870-49.44055557.535951328.864
GRB101231067191.71017.64055561.067252423.613
" ], "text/plain": [ "\n", " name ra dec trigger_time t90 \n", " object float64 float64 float64 float64\n", "------------ ------- ------- ------------- -------\n", "GRB100101028 307.320 -27.000 55197.0276543 2.816\n", "GRB100101988 70.660 18.690 55197.9876757 1.984\n", "GRB100107074 6.310 -21.240 55203.0739799 0.576\n", "GRB100111176 247.048 15.551 55207.1755752 19.52\n", "GRB100112418 240.140 -75.100 55208.4175643 23.04\n", "GRB100116897 305.020 14.450 55212.8965306 102.53\n", "GRB100117879 11.260 -1.594 55213.8793943 0.256\n", "GRB100118100 9.260 -37.370 55214.0996956 9.216\n", "GRB100122616 79.200 -2.710 55218.6164041 22.529\n", "GRB100126460 338.370 -18.740 55222.460476 10.624\n", " ... ... ... ... ...\n", "GRB101223834 250.550 48.220 55553.8335428 56.065\n", "GRB101224227 285.926 45.715 55554.2272438 1.728\n", "GRB101224578 289.140 -55.250 55554.5784517 44.737\n", "GRB101224614 290.160 34.460 55554.6135756 25.601\n", "GRB101224998 325.170 -38.660 55554.9983211 18.688\n", "GRB101225377 60.680 32.770 55555.3770081 81.218\n", "GRB101227195 186.790 -83.550 55557.1947768 95.488\n", "GRB101227406 240.500 -24.500 55557.406326 153.347\n", "GRB101227536 150.870 -49.440 55557.5359513 28.864\n", "GRB101231067 191.710 17.640 55561.0672524 23.613" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mjd = Time(['2010-01-01T00:00:00','2011-01-01T00:00:00']).mjd\n", "gbm_catalog.query(' %f \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timet90
objectfloat64float64float64float64
GRB090424592189.50016.80054945.59176714.144
GRB090618353293.99078.35855000.3530863112.386
GRB090902462264.93927.32555076.461901819.328
GRB10101417526.940-51.07055483.1749146449.415
GRB110301214229.35029.40055621.21438745.693
GRB110529034118.33067.91055710.03382950.512
GRB11082510244.89615.40755798.101978462.465
GRB111222619179.19369.03655917.61938680.32
GRB1206243094.7737.16756102.30862660.64
GRB13050497891.6303.83456416.978443573.217
...............
GRB140329295145.698-32.22956745.294888121.504
GRB150118409240.240-35.75057040.40853940.193
GRB15021300195.290-4.85057066.00125814.096
GRB150330828329.26049.97057111.8280239153.859
GRB150627183117.490-51.56057200.18291364.577
GRB16042249941.260-58.22057500.499314912.288
GRB160509374310.10076.00057517.3741461369.67
GRB160625945308.3006.90057564.9446328454.665
GRB16072076742.65075.68057589.766631978.849
GRB160821857171.24842.34357621.857292143.009
" ], "text/plain": [ "\n", " name ra dec trigger_time t90 \n", " object float64 float64 float64 float64\n", "------------ ------- ------- ------------- -------\n", "GRB090424592 189.500 16.800 54945.591767 14.144\n", "GRB090618353 293.990 78.358 55000.3530863 112.386\n", "GRB090902462 264.939 27.325 55076.4619018 19.328\n", "GRB101014175 26.940 -51.070 55483.1749146 449.415\n", "GRB110301214 229.350 29.400 55621.2143874 5.693\n", "GRB110529034 118.330 67.910 55710.0338295 0.512\n", "GRB110825102 44.896 15.407 55798.1019784 62.465\n", "GRB111222619 179.193 69.036 55917.6193868 0.32\n", "GRB120624309 4.773 7.167 56102.3086266 0.64\n", "GRB130504978 91.630 3.834 56416.9784435 73.217\n", " ... ... ... ... ...\n", "GRB140329295 145.698 -32.229 56745.2948881 21.504\n", "GRB150118409 240.240 -35.750 57040.408539 40.193\n", "GRB150213001 95.290 -4.850 57066.0012581 4.096\n", "GRB150330828 329.260 49.970 57111.8280239 153.859\n", "GRB150627183 117.490 -51.560 57200.182913 64.577\n", "GRB160422499 41.260 -58.220 57500.4993149 12.288\n", "GRB160509374 310.100 76.000 57517.3741461 369.67\n", "GRB160625945 308.300 6.900 57564.9446328 454.665\n", "GRB160720767 42.650 75.680 57589.7666319 78.849\n", "GRB160821857 171.248 42.343 57621.8572921 43.009" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.query(\"pflx_band_alpha < -2./3. & pflx_band_ergflux > 1E-5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Searching for triggers\n", "\n", "We can also search for specific triggers" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "<Table length=2>\n", "
\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timet90
objectfloat64float64float64float64
GRB080916009119.800-56.60054725.008861362.977
GRB10020402450.780-47.89055231.0235364136.195
" ], "text/plain": [ "\n", " name ra dec trigger_time t90 \n", " object float64 float64 float64 float64\n", "------------ ------- ------- ------------- -------\n", "GRB080916009 119.800 -56.600 54725.0088613 62.977\n", "GRB100204024 50.780 -47.890 55231.0235364 136.195" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.query_sources(\"GRB080916009\",'GRB100204024')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Let's look at what a search can give us:\n", "\n", "The matching criteria can be used to extract information about the analysis as well as for setting up your own analysis.\n", "\n", "For example, we can look at the duration information from each GRB in our last search:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
t90t50
name
GRB08091600962.97732.000
GRB100204024136.19521.504
\n", "" ], "text/plain": [ " t90 t50\n", "name \n", "GRB080916009 62.977 32.000\n", "GRB100204024 136.195 21.504" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gbm_catalog.result[['t90','t50']]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To automate or repeat an analysis, it is good to know the values of source/background selections that were used in the catalog. These are extracted into a dictionary." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [], "source": [ "det_info = gbm_catalog.get_detector_information()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's examine what we have for GRB080916C.\n", "\n", "We'll find the background selections and source (both peak and fluence) stored in a format readable by 3ML.\n", "\n", "Additonally, we have the detectors used for catalog spectral analysis." ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'background': {'full': '-40.100000--6.250000,105.210000-146.350000',\n", " 'post': '105.210000-146.350000',\n", " 'pre': '-40.100000--6.250000'},\n", " 'best fit model': {'fluence': 'sbpl', 'peak': 'comp'},\n", " 'detectors': array(['n3', 'n4', 'b0'], \n", " dtype='|S2'),\n", " 'source': {'fluence': '1.280000-64.257000', 'peak': '2.048000-3.072000'},\n", " 'trigger': 'bn080916009'}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "det_info['GRB080916009']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Downloading data\n", "\n", "We can now get the data now and have a look ourselves. Using the information from the search, we can get the TTE and RSP files needed via the GBM data downloader." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gbm_data = download_GBM_trigger_data(trigger_name=det_info['GRB080916009']['trigger'],\n", " detectors=det_info['GRB080916009']['detectors'],\n", " destination_directory='gbm/bn080916009',\n", " compress_tte=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now have our data locally downloaded from the HEASARC servers. This gets the most current version of the files and prefers RSP2 to RSP. You can of course use other methods to obtain earlier versions or differnt DRM types.\n", "\n", "We can see where they are stored:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the data already exist in that location, the downloader will skip them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making an analysis\n", "\n", "Now we have everything we need to make an analysis. We just need to create our plugins and set our models.\n", "\n", "### Getting a model from the selection\n", "\n", "3ML's GBM catalog will build a model for you from the HEASARC values. We simply choose the model and interval we want, i.e., Band, Comt, PL, SBPL and either peak or fluence interval.\n", "\n", "\n", "Here we will use the best fit model (SBPL) for the fluence interval." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [], "source": [ "interval = 'fluence'\n", "\n", "models = gbm_catalog.get_model(model=det_info['GRB080916009']['best fit model'][interval],interval=interval)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "Model summary:

\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
N
Point sources1
Extended sources0
Particle sources0
\n", "


Free parameters (5):

\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
valuemin_valuemax_valueunit
GRB080916009.spectrum.main.SmoothlyBrokenPowerLaw.K0.01223970None1 / (cm2 keV s)
GRB080916009.spectrum.main.SmoothlyBrokenPowerLaw.alpha-1.13938-1.52
GRB080916009.spectrum.main.SmoothlyBrokenPowerLaw.break_energy301.64710NonekeV
GRB080916009.spectrum.main.SmoothlyBrokenPowerLaw.break_scale0.3010
GRB080916009.spectrum.main.SmoothlyBrokenPowerLaw.beta-2.08541-5-1.6
\n", "


Fixed parameters (3):
(abridged. Use complete=True to see all fixed parameters)


Linked parameters (0):

(none)
" ], "text/plain": [ "Model summary:\n", "==============\n", "\n", " N\n", "Point sources 1\n", "Extended sources 0\n", "Particle sources 0\n", "\n", "Free parameters (5):\n", "--------------------\n", "\n", " value min_value max_value unit\n", "GRB080916009...K 0.0122397 0 None 1 / (cm2 keV s)\n", "GRB080916009...alpha -1.13938 -1.5 2 \n", "GRB080916009...break_energy 301.647 10 None keV\n", "GRB080916009...break_scale 0.3 0 10 \n", "GRB080916009...beta -2.08541 -5 -1.6 \n", "\n", "Fixed parameters (3):\n", "(abridged. Use complete=True to see all fixed parameters)\n", "\n", "\n", "Linked parameters (0):\n", "----------------------\n", "\n", "(none)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "models['GRB080916009']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3ML Analysis\n", "\n", "#### Plugin setup\n", "\n", "Let's build some plugins" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "WARNING UserWarning: No TLMIN keyword found. This DRM does not follow OGIP standards. Assuming TLMIN=1\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING UserWarning: The time interval -40.100000--6.250000 started before the first arrival time (-25.943198), so we are changing the intervals to -25.943198--6.250000\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Auto-determined polynomial order: 0\n", "\n", "\n", "Unbinned 0-order polynomial fit with the Nelder-Mead method\n", "\n", "\n", "Auto-probed noise models:\n", "- observation: poisson\n", "- background: gaussian\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING UserWarning: The time interval -40.100000--6.250000 started before the first arrival time (-25.943522), so we are changing the intervals to -25.943522--6.250000\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Auto-determined polynomial order: 0\n", "\n", "\n", "Unbinned 0-order polynomial fit with the Nelder-Mead method\n", "\n", "\n", "Auto-probed noise models:\n", "- observation: poisson\n", "- background: gaussian\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Minimum MC energy is larger than minimum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Minimum MC energy is larger than minimum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Minimum MC energy is larger than minimum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Maximum MC energy is smaller than maximum EBOUNDS energy\n", "\n", "\n", "WARNING RuntimeWarning: Minimum MC energy is larger than minimum EBOUNDS energy\n", "\n", "\n", "WARNING UserWarning: The time interval -40.100000--6.250000 started before the first arrival time (-25.943228), so we are changing the intervals to -25.943228--6.250000\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Auto-determined polynomial order: 1\n", "\n", "\n", "Unbinned 1-order polynomial fit with the Nelder-Mead method\n", "\n", "\n", "Auto-probed noise models:\n", "- observation: poisson\n", "- background: gaussian\n", "Range 8-900 translates to channels 4-124\n", "Now using 121 channels out of 128\n", "Range 8-900 translates to channels 3-123\n", "Now using 121 channels out of 128\n", "Range 250-42000 translates to channels 1-125\n", "Now using 125 channels out of 128\n" ] } ], "source": [ "det = 'n3'\n", "\n", "nai3 = FermiGBMTTELike(name=det,\n", " source_intervals=det_info['GRB080916009']['source']['fluence'],\n", " background_selections=det_info['GRB080916009']['background']['full'],\n", " tte_file=gbm_data[det]['tte'],\n", " rsp_file=gbm_data[det]['rsp'])\n", "\n", "det = 'n4'\n", "\n", "nai4 = FermiGBMTTELike(name=det,\n", " source_intervals=det_info['GRB080916009']['source']['fluence'],\n", " background_selections=det_info['GRB080916009']['background']['full'],\n", " tte_file=gbm_data[det]['tte'],\n", " rsp_file=gbm_data[det]['rsp'])\n", "\n", "det = 'b0'\n", "\n", "bgo0 = FermiGBMTTELike(name=det,\n", " source_intervals=det_info['GRB080916009']['source']['fluence'],\n", " background_selections=det_info['GRB080916009']['background']['full'],\n", " tte_file=gbm_data[det]['tte'],\n", " rsp_file=gbm_data[det]['rsp'])\n", "\n", "\n", "nai3.set_active_measurements('8-900')\n", "nai4.set_active_measurements('8-900')\n", "bgo0.set_active_measurements('250-42000')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width);\n", " canvas.attr('height', height);\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "_ = display_ogip_model_counts(jl,min_rate=5,step=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## LLE Catalog\n", "\n", "### Searching\n", "Similar to the GBM catalog, we can search LAT LLE triggers with the LLE catalog:\n" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Building cache for fermille.\n", "\n" ] } ], "source": [ "lle_catalog = FermiLLEBurstCatalog()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can perform cone, time, and trigger searches just like as with the GBM catalog. Currently, no T90 searches are available." ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Trying http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermille&\n", "Downloading http://heasarc.gsfc.nasa.gov/cgi-bin/vo/cone/coneGet.pl?table=fermille&SR=30.0&DEC=0.0&RA=0.0&VERB=3 [Done]\n" ] }, { "data": { "text/html": [ "<Table masked=True length=3>\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
nameradectrigger_timetrigger_type
degdegmjd
objectfloat64float64float64object
GRB13123119810.110-2.42056657.1981028GRB
SFLARE140225029337.908-9.26056713.0287958SFLARE
GRB15051013916.1604.79057152.1388164GRB
" ], "text/plain": [ "\n", " name ra dec trigger_time trigger_type\n", " deg deg mjd \n", " object float64 float64 float64 object \n", "--------------- ------- ------- ------------- ------------\n", " GRB131231198 10.110 -2.420 56657.1981028 GRB\n", "SFLARE140225029 337.908 -9.260 56713.0287958 SFLARE\n", " GRB150510139 16.160 4.790 57152.1388164 GRB" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lle_catalog.cone_search(0,0,30)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "<Table length=1>\n", "
\n", "\n", "\n", "\n", "
nameradectrigger_timetrigger_type
objectfloat64float64float64str3
GRB080916009119.800-56.60054725.0088613GRB
" ], "text/plain": [ "\n", " name ra dec trigger_time trigger_type\n", " object float64 float64 float64 str3 \n", "------------ ------- ------- ------------- ------------\n", "GRB080916009 119.800 -56.600 54725.0088613 GRB" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lle_catalog.query_sources('GRB080916009')" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'bn080916009'" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lle_catalog.result.loc['GRB080916009']['trigger_name']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Downloading LLE data\n", "\n", "With the 3ML LLE plugin, we no longer need PHA files. Therefore, the 3ML LLE downloader will get the LLE event file and associated LLE RSP (if it exists) as well as the FT2 file." ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run \"jupyter nbextension enable --py --sys-prefix widgetsnbextension\"\n" ] } ], "source": [ "lle_data_info = download_LLE_trigger_data(lle_catalog.result.loc['GRB080916009']['trigger_name'],destination_directory='lat')" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
cspec: !!python/unicode '/Users/jburgess/coding/3ML/examples/lat/gll_cspec_bn080916009_v10.pha'\n",
       "ft2: !!python/unicode '/Users/jburgess/coding/3ML/examples/lat/gll_pt_bn080916009_v10.fit'\n",
       "!!python/unicode 'lle': !!python/unicode '/Users/jburgess/coding/3ML/examples/lat/gll_lle_bn080916009_v10.fit'\n",
       "rsp: !!python/unicode '/Users/jburgess/coding/3ML/examples/lat/gll_cspec_bn080916009_v10.rsp'\n",
       "
" ], "text/plain": [ "{'cspec': u'/Users/jburgess/coding/3ML/examples/lat/gll_cspec_bn080916009_v10.pha',\n", " 'ft2': u'/Users/jburgess/coding/3ML/examples/lat/gll_pt_bn080916009_v10.fit',\n", " u'lle': u'/Users/jburgess/coding/3ML/examples/lat/gll_lle_bn080916009_v10.fit',\n", " 'rsp': u'/Users/jburgess/coding/3ML/examples/lat/gll_cspec_bn080916009_v10.rsp'}" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lle_data_info" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Analysis with GBM and LLE data\n", "\n", "Analyze the LLE data you have just downloaded along with GBM data" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Auto-determined polynomial order: 1\n", "\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run \"jupyter nbextension enable --py --sys-prefix widgetsnbextension\"\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Binned 1-order polynomial fit with the Powell method\n", "\n", "\n", "Auto-probed noise models:\n", "- observation: poisson\n", "- background: gaussian\n" ] } ], "source": [ "lle = FermiLATLLELike('LLE',\n", " lle_file=lle_data_info['lle'],\n", " rsp_file=lle_data_info['rsp'],\n", " ft2_file=lle_data_info['ft2'],\n", " background_selections=det_info['GRB080916009']['background']['full'],\n", " source_intervals=det_info['GRB080916009']['source']['fluence']\n", " )" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width);\n", " canvas.attr('height', height);\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Best fit valueUnit
GRB080916009...K0.01438 +/- 0.000201 / (cm2 keV s)
GRB080916009...alpha-1.098 +/- 0.017
GRB080916009...beta-2.140 +/- 0.018
GRB080916009...break_energy218 +/- 16keV
GRB080916009...break_scale0.21 +/- 0.06
\n", "
" ], "text/plain": [ " Best fit value Unit\n", "GRB080916009...K 0.01438 +/- 0.00020 1 / (cm2 keV s)\n", "GRB080916009...alpha -1.098 +/- 0.017 \n", "GRB080916009...beta -2.140 +/- 0.018 \n", "GRB080916009...break_energy 218 +/- 16 keV\n", "GRB080916009...break_scale 0.21 +/- 0.06 " ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "NOTE: errors on parameters are approximate. Use get_errors().\n", "\n", "\n", "Correlation matrix:\n", "\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "
1.000.65-0.67-0.130.30
0.651.00-0.310.35-0.04
-0.67-0.311.000.64-0.78
-0.130.350.641.00-0.67
0.30-0.04-0.78-0.671.00
" ], "text/plain": [ " 1.00 0.65 -0.67 -0.13 0.30\n", " 0.65 1.00 -0.31 0.35 -0.04\n", "-0.67 -0.31 1.00 0.64 -0.78\n", "-0.13 0.35 0.64 1.00 -0.67\n", " 0.30 -0.04 -0.78 -0.67 1.00" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Values of -log(likelihood) at the minimum:\n", "\n" ] }, { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
-log(likelihood)
total3261.338531
n31064.142117
n41047.061227
b01117.372724
LLE32.762462
\n", "
" ], "text/plain": [ " -log(likelihood)\n", "total 3261.338531\n", "n3 1064.142117\n", "n4 1047.061227\n", "b0 1117.372724\n", "LLE 32.762462" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "data_list = DataList(nai3,nai4,bgo0,lle)\n", "\n", "jl = JointLikelihood(models['GRB080916009'], data_list=data_list)\n", "\n", "# Now we can fit\n", "\n", "res = jl.fit()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " this.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width);\n", " canvas.attr('height', height);\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('