{ "cells": [ { "cell_type": "markdown", "id": "d7ca544e", "metadata": {}, "source": [ "# Onderzoek de data van je eigen station" ] }, { "cell_type": "code", "execution_count": null, "id": "eaf47469", "metadata": {}, "outputs": [], "source": [ "STATION = 15 # gvdveen" ] }, { "cell_type": "code", "execution_count": null, "id": "7471bbab", "metadata": {}, "outputs": [], "source": [ "import sapphire\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import datetime as dt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "id": "eea8f3f0", "metadata": {}, "outputs": [], "source": [ "data = sapphire.quick_download(STATION)" ] }, { "cell_type": "markdown", "id": "f04951bc", "metadata": {}, "source": [ "Na enige tijd verschijnt hierboven een regel zoals:\n", "\"`100%|############################################################|Time: 0:00:06`\"\n", "\n", "Soms is de download zo snel dat deze regel niet wordt afgedrukt.\n", "\n", "De variabele \"`data`\" bevat nu een set meetgegevens. Deze set is af te drukken." ] }, { "cell_type": "code", "execution_count": null, "id": "8820aeea", "metadata": {}, "outputs": [], "source": [ "# Download data van een andere dag\n", "# start = dt.datetime(2019, 3, 20)\n", "# end = dt.datetime(2019, 3, 21)\n", "# sapphire.download_data(data, '/s%d' % STATION, start, end)" ] }, { "cell_type": "code", "execution_count": null, "id": "3456486b", "metadata": {}, "outputs": [], "source": [ "print(data)" ] }, { "cell_type": "markdown", "id": "4bbdc53a", "metadata": {}, "source": [ "Het \"`data`\" bestand heeft een hierarchise opbouw. In \"`data`\" zit een\n", "RootGroup, deze is te benaderen met \"`data.root`\". Hierin zit weer een groep\n", "\"`s102`\", deze is te benaderen met \"`data.root.s102`\". Hierin zit een tabel\n", "\"`events`\".\n", "\n", "## Werken met een events tabel\n", "Voor het gemak maken we een variable\n", "`events` die naar de eventstabel van het station wijst:\n", "\n", "De tabel heeft een\n", "bepaalde plaats het HDF5 data bestand: `/s????/events` waarbij `????` staat voor\n", "het station nummer. Deze plaats heet een `node`:" ] }, { "cell_type": "code", "execution_count": null, "id": "650daaab", "metadata": {}, "outputs": [], "source": [ "node_naam = '/s%d/events' % STATION\n", "node_naam" ] }, { "cell_type": "code", "execution_count": null, "id": "a9a91f65", "metadata": {}, "outputs": [], "source": [ "event_tabel = data.get_node(node_naam)\n", "event_tabel" ] }, { "cell_type": "markdown", "id": "b88986b4", "metadata": {}, "source": [ "Dit is een tabel tienduizenden regels. Elke regel is een event.\n", "\n", "De informatie van het eerste event is op te halen met:" ] }, { "cell_type": "code", "execution_count": null, "id": "fd5482d0", "metadata": {}, "outputs": [], "source": [ "event_tabel[0]" ] }, { "cell_type": "markdown", "id": "9ba79da4", "metadata": {}, "source": [ "Het **tweede** event: (Let op, python telt vanaf 0 en niet vanaf 1)" ] }, { "cell_type": "code", "execution_count": null, "id": "cfca2519", "metadata": {}, "outputs": [], "source": [ "event_tabel[1]" ] }, { "cell_type": "markdown", "id": "faaa9f01", "metadata": {}, "source": [ "De informatie in een event bestaat uit een lijst getallen. Deze getallen hebben\n", "de volgende betekenis:\n", "\n", "1. event_id: Het unieke nummer van het event in deze dataset.\n", "1. timestamp: De tijd in hele seconden (GPS) waarop de trigger van het event plaatsvond.\n", "1. nanoseconds: De tijd in nanoseconden waarop de trigger van het event plaatsvond.\n", "1. ext_timestamp: Dit getal is vrij groot, namelijk de twee vorige achter elkaar.\n", "1. pulseheights: Een array met pulshoogten, \"`-1`\" betekent dat er geen detector was.\n", "1. integrals: Een array met pulsoppervlakten, \"`-1`\" betekent ook hier dat er geen detector was.\n", "1. n1: Het aantal MIPS's (Minimal Ionising Particles) dat in detector 1 is gereconstrueerd.\n", "1. n2\n", "1. n3\n", "1. n4\n", "1. t1: De gereconstrueerde detectietijden vanaf het begin van het opgeslagen signaal voor detector 1.\n", "1. t2\n", "1. t3\n", "1. t4\n", "1. t_trigger: Het moment van de GPS-tijdstempel vanaf het begin van het opgeslagen signaal.\n", "\n", "In het\n", "werkblad [https://docs.hisparc.nl/infopakket/pdf/traces.pdf](https://docs.hisparc.nl/infopakket/pdf/traces.pdf)\n", "wordt de natuurkundige betekenis van deze\n", "getallen beschreven. De afbeeldingen in dit werkblad zijn afkomstig uit het\n", "interactieve werkblad [https://data.hisparc.nl/media/jsparc/jsparc.html](https://data.hisparc.nl/media/jsparc/jsparc.html).\n", "Let op, computers tellen vanaf \"`0`\" en niet vanaf \"`1`\"." ] }, { "cell_type": "markdown", "id": "fce5975a", "metadata": {}, "source": [ "### Werken met kolomnamen\n", "\n", "Een kolom zoals 'event_id', 'timestamp' of 't1' kan opgevraagd worden door de\n", "index van de kolom (0, 1, 2, ...) of door de kolomnaam. Door gebruik te maken\n", "van de kolomnaam wordt de code veel beter leesbaar:" ] }, { "cell_type": "code", "execution_count": null, "id": "cecf00f8", "metadata": {}, "outputs": [], "source": [ "first_event = event_tabel[0]\n", "first_event['timestamp']" ] }, { "cell_type": "markdown", "id": "4dac6fec", "metadata": {}, "source": [ "Het aantal gereconstrueerde deeltjes in detector 1 (het zevende getal) bij het\n", "eerste event is dus te vinden met:" ] }, { "cell_type": "code", "execution_count": null, "id": "28823c1e", "metadata": {}, "outputs": [], "source": [ "event_tabel[0][6] # 7de kolom van 1ste rij" ] }, { "cell_type": "markdown", "id": "34149150", "metadata": {}, "source": [ "en:" ] }, { "cell_type": "code", "execution_count": null, "id": "af01df06", "metadata": {}, "outputs": [], "source": [ "first_event = event_tabel[0]\n", "first_event['n1']" ] }, { "cell_type": "markdown", "id": "1c714b81", "metadata": {}, "source": [ "De tweede code is weliswaar langer, maar veel beter leesbaar." ] }, { "cell_type": "code", "execution_count": null, "id": "95d4c9bf", "metadata": {}, "outputs": [], "source": [ "print(first_event['n1'])\n", "print(event_tabel[0][6])" ] }, { "cell_type": "markdown", "id": "4ac32e92", "metadata": {}, "source": [ "Een array met pulshoogten in ADC-waarden is in dit geval te vinden met:" ] }, { "cell_type": "code", "execution_count": null, "id": "a2f795a6", "metadata": {}, "outputs": [], "source": [ "first_event['pulseheights']" ] }, { "cell_type": "markdown", "id": "e6c7c55b", "metadata": {}, "source": [ "Merk op dat de pulshoogtes van detector 3 en 4 de waarde '-1' hebben. De waarde\n", "'-1' betekent dat de pulsehoogte niet bepaald kon worden; Station 102 heeft\n", "slechts twee detectoren.\n", "\n", "De eerste pulshoogte is te vinden met:" ] }, { "cell_type": "code", "execution_count": null, "id": "ff3e6f2a", "metadata": {}, "outputs": [], "source": [ "print(\"pulshoogte detector 1: %d ADC (eerste event)\" % first_event['pulseheights'][0])" ] }, { "cell_type": "markdown", "id": "41d4c82b", "metadata": {}, "source": [ "## Timestamps\n", "Vaak is het eenvoudiger om een hele *kolom* bijvoorbeeld `timestamp` in een keer te bekijken.\n", "\n", "Eerst lezen we de hele tabel in het geheugen. Het object `events` is de gehele tabel:" ] }, { "cell_type": "code", "execution_count": null, "id": "182a624d", "metadata": {}, "outputs": [], "source": [ "events = event_tabel.read()" ] }, { "cell_type": "markdown", "id": "dba40326", "metadata": {}, "source": [ "De variabele `ts` wijst naar de kolom `timestamp` en we bekijken de eerste 30 regels (events):" ] }, { "cell_type": "code", "execution_count": null, "id": "028fa08f", "metadata": {}, "outputs": [], "source": [ "ts = events['timestamp']\n", "ts[:30]" ] }, { "cell_type": "code", "execution_count": null, "id": "4b1782fe", "metadata": {}, "outputs": [], "source": [ "ns = events['nanoseconds']\n", "ns[:30]" ] }, { "cell_type": "code", "execution_count": null, "id": "657bdea1", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,4))\n", "plt.hist(ns, histtype='step')\n", "plt.ylabel('aantal')\n", "plt.xlabel('nanoseconds deel van de timestamp')\n", "plt.title('ESD Events van een enkele dag van station %d' % STATION)" ] }, { "cell_type": "code", "execution_count": null, "id": "720f922e", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,4))\n", "plt.hist(ts, bins=24, histtype='step')\n", "plt.ylabel('aantal')\n", "plt.xlabel('timestamp [s]')\n", "plt.title('ESD Events van een enkele dag van station %d' % STATION)" ] }, { "cell_type": "code", "execution_count": null, "id": "af8b8d3d", "metadata": {}, "outputs": [], "source": [ "eerste_ts = ts[0]\n", "eerste_ts" ] }, { "cell_type": "code", "execution_count": null, "id": "7c69c30d", "metadata": {}, "outputs": [], "source": [ "# linker en rechter grenzen van bins van 1 uur (3600 s) breed vanaf de eerste timestamp (1 dag)\n", "bins = [eerste_ts + 3600 * h for h in range(25)]" ] }, { "cell_type": "code", "execution_count": null, "id": "7bf4aa2c", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,4))\n", "plt.hist(ts, bins=bins, histtype='step')\n", "plt.ylabel('aantal')\n", "plt.xlabel('tijd vanaf middernacht [h]')\n", "plt.xticks(bins, range(25))\n", "plt.title('ESD Events van een enkele dag van station %d' % STATION)" ] }, { "cell_type": "markdown", "id": "48f72a93", "metadata": {}, "source": [ "# MIPs" ] }, { "cell_type": "code", "execution_count": null, "id": "18c66381", "metadata": {}, "outputs": [], "source": [ "n1 = event_tabel.col('n1')\n", "plt.figure(figsize=(10,4))\n", "plt.hist(n1, bins=np.arange(0.3, 5., .1), histtype='step')\n", "plt.title('Station %d: Number of particles in detector 1' % STATION)\n", "plt.xlabel('number of particles (MIP)')\n", "plt.ylabel('counts')" ] }, { "cell_type": "markdown", "id": "205cf0f7", "metadata": {}, "source": [ "## Pulshoogte\n", "\n", "Maak een histogram van de pulshoogtes van detector 1 en 2 van het\n", "station.\n", "\n", "Een voorbeeld is hier te zien: https://data.hisparc.nl/show/stations/15" ] }, { "cell_type": "code", "execution_count": null, "id": "50cf5deb", "metadata": {}, "outputs": [], "source": [ "ph = event_tabel.col('pulseheights')\n", "ph1 = ph[:, 0]\n", "ph2 = ph[:, 1]" ] }, { "cell_type": "markdown", "id": "5e8b68a3", "metadata": {}, "source": [ "'pulseheights' is een *matrix*:\n", "- `[:, 0]` is de gehele eerste rij, dwz de pulshoogtes per event van detector 0\n", "- `[:, 1]` is de gehele tweede rij, dwz de pulshoogtes per event van detector 1" ] }, { "cell_type": "code", "execution_count": null, "id": "4370308f", "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,4))\n", "plt.hist(ph1, bins=np.arange(0, 2000., 20.), histtype='step', log=True)\n", "plt.hist(ph2, bins=np.arange(0, 2000., 20.), histtype='step', log=True)\n", "plt.title('Station %d: Pulseheights' % STATION)\n", "plt.xlabel('Pulseheight (ADC)')\n", "plt.ylabel('counts')\n", "plt.legend(['detector 1', 'detector 2' ])\n", "plt.ylim(10, 1e4)" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all" } }, "nbformat": 4, "nbformat_minor": 5 }