Skip to content

Commit

Permalink
Adapt download in notebook so that nbsphinx is happy
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jan 18, 2024
1 parent 05dca52 commit 65510a3
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions docs/notebooks/fact_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"source": [
"import numpy as np\n",
"import astropy.units as u\n",
"import matplotlib.pyplot as plt"
"import matplotlib.pyplot as plt\n",
"import subprocess as sp"
]
},
{
Expand Down Expand Up @@ -48,7 +49,11 @@
"metadata": {},
"outputs": [],
"source": [
"! curl -z gamma_test_dl3.hdf5 -fLO https://factdata.app.tu-dortmund.de/dl3/FACT-Tools/v1.1.2/gamma_test_dl3.hdf5"
"path = \"gamma_test_dl3.hdf5\"\n",
"url = f\"https://factdata.app.tu-dortmund.de/dl3/FACT-Tools/v1.1.2/{path}\"\n",
"ret = sp.run([\"curl\", \"-z\", path, \"-fsSLO\", url], stdout=sp.PIPE, stderr=sp.PIPE, encoding='utf-8')\n",
"if ret.returncode != 0:\n",
" raise IOError(ret.stderr)"
]
},
{
Expand Down Expand Up @@ -111,11 +116,10 @@
"source": [
"### DL2 Event List\n",
"\n",
"\n",
"`pyirf` does not prescribe or use a specific DL2 *file* format.\n",
"You need to read the data into an `astropy.table.QTable` following our conventions, detailed in the docs here: \n",
"\n",
"https://cta-observatory.github.io/pyirf/introduction.html#dl2-event-lists\n",
"<https://cta-observatory.github.io/pyirf/introduction.html#dl2-event-lists>\n",
"\n",
"The FACT-Tools / aict-tools analysis chain uses a column-oriented hdf5 file written using h5py. \n",
"Unfortunately, units have to be known and are not in the metadata."
Expand Down Expand Up @@ -279,9 +283,7 @@
"cell_type": "code",
"execution_count": null,
"id": "norman-personal",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# utility function to converet pyirf Quantities to the gammapy classes\n",
Expand Down Expand Up @@ -414,9 +416,7 @@
"cell_type": "code",
"execution_count": null,
"id": "heard-plate",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from gammapy.irf import EnergyDispersion2D\n",
Expand Down Expand Up @@ -480,14 +480,6 @@
"\n",
"fits.HDUList(hdus).writeto('fact_irf.fits.gz', overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d608e4c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -506,7 +498,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 65510a3

Please sign in to comment.