Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
893a326
Update version number for breaking changes to API.
Jul 7, 2026
571fd05
Dependency update: Python, setuptools, and snewpy.
Jul 7, 2026
4655900
Make interaction test 3-flavor compatible.
Jul 7, 2026
eb93552
Simplify detector initialization from eCSV files.
Jul 8, 2026
9987743
Remove redundant source module.
Jul 8, 2026
13681e4
Switch dependency back to snewpy/main branch.
Jul 8, 2026
f73d33b
Fixes for broken tests.
Jul 8, 2026
e8301d8
Remove source module.
Jul 8, 2026
70ae801
Clean up configuration notebook.
Jul 9, 2026
6ada225
Update class property name.
Jul 9, 2026
dafa9e8
Update to 3-flavor calculation in snewpy.
Jul 9, 2026
54ca89b
Cosmetic cleanup.
Jul 9, 2026
8ad3ce8
Add default detector scope.
Jul 9, 2026
ec2a5b0
Update new interface.
Jul 9, 2026
e92adf3
Update to new snewpy interface.
Jul 9, 2026
7be2411
Do not extrapolate outside model time.
Jul 10, 2026
c974ad6
Update notebook to new model.
Jul 10, 2026
d747b5a
Remove obsolete notebook.
Jul 10, 2026
0bfaa58
Update to new detector.Detector interface.
Jul 10, 2026
17ad1bf
Default to no flavor transformations.
Jul 10, 2026
6d81a24
Upgrade nb to new Simulation class.
Jul 10, 2026
ae92f18
Fix change in member name.
Jul 10, 2026
f4ce957
Update to new detector+simulation API.
Jul 10, 2026
abbeb48
Remove obsolete flavor transformation notebooks.
Jul 10, 2026
2a03284
Remove obsolete ROOT output demonstrator.
Jul 10, 2026
66703cb
Cosmetic cleanup.
Jul 10, 2026
db2c040
Cosmetic cleanup.
Jul 10, 2026
3ab4feb
Update to new Simulation interface.
Jul 10, 2026
8531ad0
Update simulation values.
Jul 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 60 additions & 73 deletions docs/source/nb/AnalyticModel_DetectorResponse.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,27 @@
"import numpy as np\n",
"\n",
"from snewpy import model_path\n",
"from snewpy.neutrino import Flavor\n",
"from snewpy.neutrino import Flavor, MixingParameters\n",
"from snewpy.flavor_transformation import AdiabaticMSW\n",
"from snewpy.models.ccsn import Analytic3Species\n",
"\n",
"from asteria.simulation import Simulation\n",
"from asteria import set_rcparams\n",
"\n",
"set_rcparams()"
"from asteria import set_rcparams"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2790c4a0",
"id": "a3318161-8249-40a5-b7bd-6fbeb818813c",
"metadata": {},
"outputs": [],
"source": [
"filename = \"AnalyticFluenceExample.dat\"\n",
"model_folder = f\"{model_path}/AnalyticFluence/\"\n",
"\n",
"if not os.path.exists(model_folder):\n",
" os.makedirs(model_folder)\n",
"file_path = os.path.join(model_folder, filename)"
"mpl.rc('font', size=14)"
]
},
{
"cell_type": "markdown",
"id": "1ae4d76e",
"id": "6aab9b4d-81cb-4de2-82a1-fb003eca97f9",
"metadata": {},
"source": [
"## Creating a SN model file modeled after the Livermore model\n",
Expand All @@ -63,50 +57,57 @@
{
"cell_type": "code",
"execution_count": null,
"id": "52c8193e",
"id": "2790c4a0",
"metadata": {},
"outputs": [],
"source": [
"# These numbers _almost_ reproduce the Livermore model included in the SNOwGLoBES repository.\n",
"# They are obtained by calculating the total L, <E> and <E^2> from the livermore.dat\n",
"# fluence file (which is modelled after a 10kpc supernova).\n",
"total_energy = (5.478e+52, 5.485e+52, 4 * 5.55e+52)\n",
"mean_energy = (11.5081, 15.4678, 21.0690)\n",
"rms_or_pinch = \"rms\"\n",
"rms_energy = (12.8788, 17.8360, 24.3913)\n",
"\n",
"# Make an astropy table with two times, 0s and 1s, with constant neutrino properties\n",
"table = Table()\n",
"table['TIME'] = np.linspace(0,1,2)\n",
"table['L_NU_E'] = np.linspace(1,1,2)*total_energy[0]\n",
"table['L_NU_E_BAR'] = np.linspace(1,1,2)*total_energy[1]\n",
"table['L_NU_X'] = np.linspace(1,1,2)*total_energy[2]/4. #Note, L_NU_X is set to 1/4 of the total NU_X energy\n",
" \n",
"table['E_NU_E'] = np.linspace(1,1,2)*mean_energy[0]\n",
"table['E_NU_E_BAR'] = np.linspace(1,1,2)*mean_energy[1]\n",
"table['E_NU_X'] = np.linspace(1,1,2)*mean_energy[2]\n",
"filename = 'AnalyticFluenceExample.dat '\n",
"model_folder = f\"{model_path}/AnalyticFluence/\"\n",
"file_path = os.path.join(model_folder, filename)\n",
"\n",
"if rms_or_pinch == \"rms\":\n",
" table['RMS_NU_E'] = np.linspace(1,1,2)*rms_energy[0]\n",
" table['RMS_NU_E_BAR'] = np.linspace(1,1,2)*rms_energy[1]\n",
" table['RMS_NU_X'] = np.linspace(1,1,2)*rms_energy[2]\n",
" table['ALPHA_NU_E'] = (2.0 * table['E_NU_E'] ** 2 - table['RMS_NU_E'] ** 2) / (\n",
" table['RMS_NU_E'] ** 2 - table['E_NU_E'] ** 2)\n",
" table['ALPHA_NU_E_BAR'] = (2.0 * table['E_NU_E_BAR'] ** 2 - table['RMS_NU_E_BAR'] ** 2) / (\n",
" table['RMS_NU_E_BAR'] ** 2 - table['E_NU_E_BAR'] ** 2)\n",
" table['ALPHA_NU_X'] = (2.0 * table['E_NU_X'] ** 2 - table['RMS_NU_X'] ** 2) / (\n",
" table['RMS_NU_X'] ** 2 - table['E_NU_X'] ** 2)\n",
"elif rms_or_pinch == \"pinch\":\n",
" table['ALPHA_NU_E'] = np.linspace(1,1,2)*pinch_values[0]\n",
" table['ALPHA_NU_E_BAR'] = np.linspace(1,1,2)*pinch_values[1]\n",
" table['ALPHA_NU_X'] = np.linspace(1,1,2)*pinch_values[2]\n",
" table['RMS_NU_E'] = np.sqrt((2.0 + table['ALPHA_NU_E'])/(1.0 + table['ALPHA_NU_E'])*table['E_NU_E']**2)\n",
" table['RMS_NU_E_BAR'] = np.sqrt((2.0 + table['ALPHA_NU_E_BAR'])/(1.0 + table['ALPHA_NU_E_BAR'])*table['E_NU_E_BAR']**2)\n",
" table['RMS_NU_X'] = np.sqrt((2.0 + table['ALPHA_NU_X'])/(1.0 + table['ALPHA_NU_X'])*table['E_NU_X']**2 )\n",
"else:\n",
" print(\"incorrect second moment method: rms or pinch\")\n",
"if not os.path.exists(file_path):\n",
" os.makedirs(model_folder, exist_ok=True)\n",
"\n",
"table.write(file_path,format='ascii',overwrite=True)"
" # These numbers _almost_ reproduce the Livermore model included in the SNOwGLoBES repository.\n",
" # They are obtained by calculating the total L, <E> and <E^2> from the livermore.dat\n",
" # fluence file (which is modelled after a 10kpc supernova).\n",
" total_energy = (5.478e+52, 5.485e+52, 4 * 5.55e+52)\n",
" mean_energy = (11.5081, 15.4678, 21.0690)\n",
" rms_or_pinch = \"rms\"\n",
" rms_energy = (12.8788, 17.8360, 24.3913)\n",
" \n",
" # Make an astropy table with two times, 0s and 1s, with constant neutrino properties\n",
" table = Table()\n",
" table['TIME'] = np.linspace(0,1,2)\n",
" table['L_NU_E'] = np.linspace(1,1,2)*total_energy[0]\n",
" table['L_NU_E_BAR'] = np.linspace(1,1,2)*total_energy[1]\n",
" table['L_NU_X'] = np.linspace(1,1,2)*total_energy[2]/4. #Note, L_NU_X is set to 1/4 of the total NU_X energy\n",
" \n",
" table['E_NU_E'] = np.linspace(1,1,2)*mean_energy[0]\n",
" table['E_NU_E_BAR'] = np.linspace(1,1,2)*mean_energy[1]\n",
" table['E_NU_X'] = np.linspace(1,1,2)*mean_energy[2]\n",
" \n",
" if rms_or_pinch == \"rms\":\n",
" table['RMS_NU_E'] = np.linspace(1,1,2)*rms_energy[0]\n",
" table['RMS_NU_E_BAR'] = np.linspace(1,1,2)*rms_energy[1]\n",
" table['RMS_NU_X'] = np.linspace(1,1,2)*rms_energy[2]\n",
" table['ALPHA_NU_E'] = (2.0 * table['E_NU_E'] ** 2 - table['RMS_NU_E'] ** 2) / (\n",
" table['RMS_NU_E'] ** 2 - table['E_NU_E'] ** 2)\n",
" table['ALPHA_NU_E_BAR'] = (2.0 * table['E_NU_E_BAR'] ** 2 - table['RMS_NU_E_BAR'] ** 2) / (\n",
" table['RMS_NU_E_BAR'] ** 2 - table['E_NU_E_BAR'] ** 2)\n",
" table['ALPHA_NU_X'] = (2.0 * table['E_NU_X'] ** 2 - table['RMS_NU_X'] ** 2) / (\n",
" table['RMS_NU_X'] ** 2 - table['E_NU_X'] ** 2)\n",
" elif rms_or_pinch == \"pinch\":\n",
" table['ALPHA_NU_E'] = np.linspace(1,1,2)*pinch_values[0]\n",
" table['ALPHA_NU_E_BAR'] = np.linspace(1,1,2)*pinch_values[1]\n",
" table['ALPHA_NU_X'] = np.linspace(1,1,2)*pinch_values[2]\n",
" table['RMS_NU_E'] = np.sqrt((2.0 + table['ALPHA_NU_E'])/(1.0 + table['ALPHA_NU_E'])*table['E_NU_E']**2)\n",
" table['RMS_NU_E_BAR'] = np.sqrt((2.0 + table['ALPHA_NU_E_BAR'])/(1.0 + table['ALPHA_NU_E_BAR'])*table['E_NU_E_BAR']**2)\n",
" table['RMS_NU_X'] = np.sqrt((2.0 + table['ALPHA_NU_X'])/(1.0 + table['ALPHA_NU_X'])*table['E_NU_X']**2 )\n",
" else:\n",
" print(\"incorrect second moment method: rms or pinch\")\n",
" \n",
" table.write(file_path, format='ascii', overwrite=True)"
]
},
{
Expand All @@ -125,19 +126,14 @@
"outputs": [],
"source": [
"# SNEWPY model dictionary, the format must match the below example for analytic models\n",
"model = {\n",
" 'name': 'Analytic3Species',\n",
" 'param': {\n",
" 'filename': file_path\n",
" }\n",
"}\n",
"model = Analytic3Species(filename=file_path)\n",
"\n",
"sim = Simulation(model=model,\n",
" distance=10 * u.kpc, \n",
" Emin=0*u.MeV, Emax=100*u.MeV, dE=1*u.MeV,\n",
" tmin=-1*u.s, tmax=10*u.s, dt=1*u.ms,\n",
" mixing_scheme='AdiabaticMSW',\n",
" hierarchy='normal')\n",
" distance=10*u.kpc, \n",
" E=np.arange(0, 101, 1)*u.MeV,\n",
" t=np.arange(-1, 10.001, 0.001)*u.s,\n",
" flavor_xform=AdiabaticMSW(mixing_params=MixingParameters(mass_order='NORMAL')))\n",
"\n",
"sim.run()"
]
},
Expand All @@ -164,20 +160,11 @@
"t, hits = sim.detector_signal(dt)\n",
"bg = sim.detector.i3_bg(dt, size=hits.size) + sim.detector.dc_bg(dt, size=hits.size)\n",
"\n",
"\n",
"ax.step(t, hits+bg, where='post', lw=2, )\n",
"ax.step(t, (hits+bg), where='post', lw=2, )\n",
"ax.set(xlim=(-1, 5));\n",
"ax.set_xlabel(r'$t-t_\\mathrm{bounce}$ [s]', ha='right', x=1.0)\n",
"ax.set_ylabel(fr'total signal [{dt} bins, $\\times 10^{{{int(np.log10(scale))}}}$]', ha='right', y=1.0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "106f8205",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -196,7 +183,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
"version": "3.12.13"
}
},
"nbformat": 4,
Expand Down
Loading
Loading