{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# IceCube🧊: visualize 🎆| azimuth🔭zenith","metadata":{}},{"cell_type":"code","source":"import plotly.offline as pyo\n# Set notebook mode to work in offline\npyo.init_notebook_mode()","metadata":{"execution":{"iopub.status.busy":"2023-01-26T18:18:41.349532Z","iopub.execute_input":"2023-01-26T18:18:41.350068Z","iopub.status.idle":"2023-01-26T18:18:41.446830Z","shell.execute_reply.started":"2023-01-26T18:18:41.350025Z","shell.execute_reply":"2023-01-26T18:18:41.444920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The x, y, and z coordinates are in units of meters, with the origin at the center of the IceCube detector. The coordinate system is right-handed, and the z-axis points upwards when standing at the South Pole. You can convert from these coordinates to azimuth and zenith with the following formulas (here the vector (x,y,z) is normalized):","metadata":{}},{"cell_type":"code","source":"import math\n\ndef coord(azimuth, zenith):\n    x = math.cos(azimuth) * math.sin(zenith)\n    y = math.sin(azimuth) * math.sin(zenith)\n    z = math.cos(zenith)\n    return dict(x=x, y=y, z=z, azimuth=azimuth, zenith=zenith)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-26T18:18:41.450703Z","iopub.execute_input":"2023-01-26T18:18:41.451106Z","iopub.status.idle":"2023-01-26T18:18:41.458506Z","shell.execute_reply.started":"2023-01-26T18:18:41.451072Z","shell.execute_reply":"2023-01-26T18:18:41.456882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The [azimuth/zenith] angle in radians of the neutrino. A value between 0 and 2*pi for the azimuth and 0 and pi for zenith.","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\n\ndata = []\nfor azimuth in np.linspace(0, 2 * math.pi, num=100):\n    for zenith in np.linspace(0, math.pi, num=100):\n        data.append(coord(azimuth, zenith))\ndf = pd.DataFrame(data)\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-26T18:18:41.460539Z","iopub.execute_input":"2023-01-26T18:18:41.460947Z","iopub.status.idle":"2023-01-26T18:18:41.534001Z","shell.execute_reply.started":"2023-01-26T18:18:41.460910Z","shell.execute_reply":"2023-01-26T18:18:41.532668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\n\nfor c in [\"azimuth\", \"zenith\"]:\n    fig = px.scatter_3d(df, x='x', y='y', z='z', opacity=0.6, color=c)\n    fig.update_traces(marker_size=2)\n    fig.update_layout(height=600, width=600)\n    fig.show()","metadata":{"execution":{"iopub.status.busy":"2023-01-26T18:18:41.535452Z","iopub.execute_input":"2023-01-26T18:18:41.535861Z","iopub.status.idle":"2023-01-26T18:18:41.836103Z","shell.execute_reply.started":"2023-01-26T18:18:41.535815Z","shell.execute_reply":"2023-01-26T18:18:41.834573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The solar azimuth and solar zenith express the position of the sun. The solar azimuth is the angle of the direction of the sun measured clockwise north from the horizon. The solar zenith is the angle measured from the local zenith and the line of sight of the sun.\n\n![illustration](https://www.researchgate.net/publication/354755033/figure/fig2/AS:1070891857362948@1632331923300/Schematic-depicting-the-solar-zenith-angle-solar-altitude-angle-and-solar-azimuth-angle_W640.jpg)","metadata":{}}]}