diff --git a/README.rst b/README.rst index abf75c4a42547d1c5f99470f923c63987bf232b3..0df3147b884764663f8b886e57514eb399e34a63 100644 --- a/README.rst +++ b/README.rst @@ -390,7 +390,7 @@ to read data in hits tree with km3io: >>> r.hits <OfflineHits: 10 parsed elements> -this shows that in our offline file, there are 10 hits trees (because we have 10 events and each event has a hits tree!). +this shows that in our offline file, there are 10 events, with each event is associated a hits trees. to have access to all data in a specific branche from the hits tree, you can use the tab completion: diff --git a/notebooks/OfflineReader_tutorial.ipynb b/notebooks/OfflineReader_tutorial.ipynb index cd1f495d4c3d81315ae1833df8ff6908ff9aa982..93c3cfc1a995a97b361e06835a73b7fd808351fb 100644 --- a/notebooks/OfflineReader_tutorial.ipynb +++ b/notebooks/OfflineReader_tutorial.ipynb @@ -4,22 +4,13 @@ "cell_type": "code", "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['/home/zineb/km3net/km3net/km3io/notebooks', '/home/zineb/miniconda3/envs/km3pipe/lib/python37.zip', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/lib-dynload', '', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/site-packages', '/home/zineb/km3net/km3net/km3io', '/home/zineb/miniconda3/envs/km3pipe/lib/python3.7/site-packages/IPython/extensions', '/home/zineb/.ipython', '/home/zineb/km3net/km3net/km3io', '/home/zineb/km3net/km3net/km3io', '/home/zineb/km3net/km3net/km3io']\n" - ] - } - ], + "outputs": [], "source": [ "# Add file to current python path\n", "from pathlib import Path\n", "import sys\n", "sys.path.append(str(Path.cwd().parent))\n", "Path.cwd()\n", - "print(sys.path)\n", "\n", "# test samples directory - aanet test file\n", "files_path = Path.cwd().parent / 'tests/samples' \n", @@ -27,35 +18,41 @@ ] }, { - "cell_type": "code", - "execution_count": 4, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "import km3io as ki" + "# Read offline files (aanet)" ] }, { "cell_type": "code", - "execution_count": 90, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "<km3io.aanet.OfflineReader at 0x7f249af32750>" + "<km3io.aanet.OfflineReader at 0x7f756b8edd90>" ] }, - "execution_count": 90, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "import km3io as ki\n", "r = ki.OfflineReader(aanet_file)\n", "r" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To explore all the available branches in our offline file:" + ] + }, { "cell_type": "code", "execution_count": 8, @@ -186,9 +183,16 @@ "r.keys" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# read events data" + ] + }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -197,7 +201,7 @@ "<OfflineEvents: 10 parsed events>" ] }, - "execution_count": 15, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -206,6 +210,13 @@ "r.events" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "number of events:" + ] + }, { "cell_type": "code", "execution_count": 12, @@ -288,16 +299,16 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "<ChunkedArray [176 125 318 ... 84 255 105] at 0x7f249eebaa10>" + "<ChunkedArray [176 125 318 ... 84 255 105] at 0x7f756b805ad0>" ] }, - "execution_count": 24, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -306,6 +317,13 @@ "r.events.hits" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "lazyarrays can be used with any Numpy universal function. For example:" + ] + }, { "cell_type": "code", "execution_count": 33, @@ -327,9 +345,16 @@ "np.log(r.events.hits)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "let's look at event 0:" + ] + }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -360,7 +385,7 @@ "\tt_fNanoSec : 200000000" ] }, - "execution_count": 41, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -391,7 +416,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -400,7 +425,7 @@ "176" ] }, - "execution_count": 48, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -409,6 +434,13 @@ "r.events[0].hits" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# read hits data:" + ] + }, { "cell_type": "code", "execution_count": 56, @@ -560,7 +592,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -569,7 +601,7 @@ "806451572" ] }, - "execution_count": 76, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -578,6 +610,13 @@ "r[0].hits[0].dom_id" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# read tracks data:" + ] + }, { "cell_type": "code", "execution_count": 77, @@ -731,7 +770,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -740,7 +779,7 @@ "294.6407542676734" ] }, - "execution_count": 85, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -749,6 +788,15 @@ "r[0].tracks[0].lik" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# read mc hits:" + ] + }, { "cell_type": "code", "execution_count": 86, @@ -786,7 +834,7 @@ } ], "source": [ - "r.mc_tracks." + "r.mc_tracks" ] }, { @@ -794,9 +842,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "r.mc_hits." - ] + "source": [] }, { "cell_type": "code",