diff --git a/AniMAIRE_examples.ipynb b/AniMAIRE_examples.ipynb new file mode 100644 index 0000000..322d499 --- /dev/null +++ b/AniMAIRE_examples.ipynb @@ -0,0 +1,185 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.13) or chardet (5.1.0) doesn't match a supported version!\n", + " warnings.warn(\"urllib3 ({}) or chardet ({}) doesn't match a supported \"\n", + "/home/chrisswdavis/.local/lib/python3.8/site-packages/spacepy/time.py:2367: UserWarning: Leapseconds may be out of date. Use spacepy.toolbox.update(leapsecs=True)\n", + " warnings.warn('Leapseconds may be out of date.'\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING: currently unknown whether the reported spectral weighting factor should be in terms of energy or rigidityd\n", + "INFO: Pandarallel will run on 6 workers.\n", + "INFO: Pandarallel will use Memory file system to transfer data between the main process and workers.\n", + "INFO: Pandarallel will run on 6 workers.\n", + "INFO: Pandarallel will use Memory file system to transfer data between the main process and workers.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/chrisswdavis/.local/lib/python3.8/site-packages/numba/core/ir_utils.py:2172: NumbaPendingDeprecationWarning: \u001b[1m\n", + "Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'params_to_use' of function 'sum_yield_values'.\n", + "\n", + "For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types\n", + "\u001b[1m\n", + "File \"AniMAIRE/anisotropic_MAIRE_engine/singleParticleEngineInstance.py\", line 121:\u001b[0m\n", + "\u001b[1m@njit\n", + "\u001b[1mdef sum_yield_values(params_to_use, R_value):\n", + "\u001b[0m\u001b[1m^\u001b[0m\u001b[0m\n", + "\u001b[0m\n", + " warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "from AniMAIRE import AniMAIRE\n", + "import datetime as dt\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Creating an Anisotropic Map" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/chrisswdavis/.local/lib/python3.8/site-packages/spacepy/coordinates.py:248: DeprecationWarning: No coordinate backend specified; using SpacePy. This default changed from IRBEM in version 0.4.0\n", + " warnings.warn('No coordinate backend specified; using SpacePy.'\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "running MAGNETOCOSMICS to acquire asymptotic directions...\n", + "Unexpected exception formatting exception. Falling back to standard exception\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Traceback (most recent call last):\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/interactiveshell.py\", line 3398, in run_code\n", + " exec(code_obj, self.user_global_ns, self.user_ns)\n", + " File \"/tmp/ipykernel_17666/3514468009.py\", line 7, in \n", + " test_anisotropic_dose_rates = AniMAIRE.run_from_spectra(\n", + " File \"/home/chrisswdavis/AniMAIRE-public/AniMAIRE/AniMAIRE.py\", line 69, in run_from_spectra\n", + " output_dose_rate_DF = engine_to_run.getAsymptoticDirsAndRun(use_default_9_zeniths_azimuths,**mag_cos_kwargs)\n", + " File \"/home/chrisswdavis/AniMAIRE-public/AniMAIRE/anisotropic_MAIRE_engine/maireSengine.py\", line 51, in getAsymptoticDirsAndRun\n", + " self.acquireDFofAllAsymptoticDirections(use_default_9_zeniths_azimuths,**mag_cos_kwargs)\n", + " File \"/home/chrisswdavis/AniMAIRE-public/AniMAIRE/anisotropic_MAIRE_engine/maireSengine.py\", line 111, in acquireDFofAllAsymptoticDirections\n", + " self.df_of_asymptotic_directions = generate_asymp_dir_DF(raw_asymp_dir_DF,\n", + " File \"/home/chrisswdavis/AniMAIRE-public/AniMAIRE/anisotropic_MAIRE_engine/utils/AsymptoticDirectionDataframe.py\", line 44, in generate_asymp_dir_DF\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/ParticleRigidityCalculationTools.py\", line 25, in functionWithGeneralInputArgs\n", + " result = functionToModify(*newArgs, **kwargs)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/ParticleRigidityCalculationTools.py\", line 82, in convertParticleRigidityToEnergy\n", + " totalParticleEnergy = np.sqrt((pc**2) + (particleRestEnergy**2))\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/pandas/core/generic.py\", line 2101, in __array_ufunc__\n", + " return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/pandas/core/arraylike.py\", line 397, in array_ufunc\n", + " result = getattr(ufunc, method)(*inputs, **kwargs)\n", + "KeyboardInterrupt\n", + "\n", + "During handling of the above exception, another exception occurred:\n", + "\n", + "Traceback (most recent call last):\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/interactiveshell.py\", line 1993, in showtraceback\n", + " stb = self.InteractiveTB.structured_traceback(\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/ultratb.py\", line 1118, in structured_traceback\n", + " return FormattedTB.structured_traceback(\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/ultratb.py\", line 1012, in structured_traceback\n", + " return VerboseTB.structured_traceback(\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/ultratb.py\", line 865, in structured_traceback\n", + " formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/ultratb.py\", line 818, in format_exception_as_a_whole\n", + " frames.append(self.format_record(r))\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/IPython/core/ultratb.py\", line 736, in format_record\n", + " result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", + " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/core.py\", line 698, in lines\n", + " pieces = self.included_pieces\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", + " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/core.py\", line 649, in included_pieces\n", + " pos = scope_pieces.index(self.executing_piece)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", + " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/stack_data/core.py\", line 628, in executing_piece\n", + " return only(\n", + " File \"/home/chrisswdavis/.local/lib/python3.8/site-packages/executing/executing.py\", line 164, in only\n", + " raise NotOneValueFound('Expected one value, found 0')\n", + "executing.executing.NotOneValueFound: Expected one value, found 0\n" + ] + } + ], + "source": [ + "sigma = np.sqrt(0.19)\n", + "pitch_angle_reference_latitude = -17.0\n", + "pitch_angle_reference_longitude = 148.0\n", + "\n", + "test_pitch_angle_dist_function = lambda pitch_angle,rigidity:np.exp(-(pitch_angle**2)/(sigma**2))\n", + "\n", + "test_anisotropic_dose_rates = AniMAIRE.run_from_spectra(\n", + " proton_rigidity_spectrum=lambda x:2.56*(x**-3.41),\n", + " proton_pitch_angle_distribution=test_pitch_angle_dist_function,\n", + " reference_pitch_angle_latitude=pitch_angle_reference_latitude,reference_pitch_angle_longitude=pitch_angle_reference_longitude,\n", + " Kp_index=3,\n", + " date_and_time=dt.datetime(2006, 12, 13, 3, 0),\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}