Getting Started
Here’s a quick start guide to help you begin using WWINPy:
1. Import the Library
import wwinpy
2. Read a WWINP File and access its data
Read the WWINP file.
ww = wwinpy.from_file('path/to/wwinp_file')
Access the data in the header, the mesh data or the weight windows values directly.
print(ww) ================= WWData Object Information ================= Mesh Type : Cartesian Number of Voxels : 392 Geometry Details: ------------------------------------------------------------------- Axis | From | To | No. Bins ------------------------------------------------------------------- I | -25.0 | 112.5 | 8 J | -40.0 | 40.0 | 7 K | -40.0 | 40.0 | 7 ------------------------------------------------------------------- The weight window contains 1 particle type(s). ----------------------- Particle Type 0 --------------------------- Metric : Value ------------------------------------------------------------------- Energy Bins : [1e-08, 3e-08, 5e-08, 1e-07, 2.25e-07, 3.25e-07, 4.1399e-07, 8e-07, 1e-06, 1.1253e-06, 1.3e-06, 1.8554e-06, 3.059e-06, 1.0677e-05, 2.9023e-05, 0.0001013, 0.00058295, 0.0030354, 0.015034, 0.11109, 0.40762, 0.90718, 1.4227, 1.8268, 3.0119, 6.3763, 20.0] Min Value : 1.95E+04 Max Value : 6.72E+12 No. Bins > 0 (%) : 100.0 Average Ratio : 3.53E+00 Max Ratio : 7.11E+01 -------------------------------------------------------------------ww.header.number_of_energy_bins # Same as ww.header.ne [27]ww.mesh.energy_mesh[0] # For particle_type 0 array([1.0000e-08, 3.0000e-08, 5.0000e-08, 1.0000e-07, 2.2500e-07, 3.2500e-07, 4.1399e-07, 8.0000e-07, 1.0000e-06, 1.1253e-06, 1.3000e-06, 1.8554e-06, 3.0590e-06, 1.0677e-05, 2.9023e-05, 1.0130e-04, 5.8295e-04, 3.0354e-03, 1.5034e-02, 1.1109e-01, 4.0762e-01, 9.0718e-01, 1.4227e+00, 1.8268e+00, 3.0119e+00, 6.3763e+00, 2.0000e+01])ww.mesh.fine_geometry_mesh {'x': array([-25. , 1.5 , 28. , 54.5 , 81. , 107.5 , 109.16699982, 110.83300018, 112.5 ]), 'y': array([-40. , -21.25 , -2.5 , -0.83333302, 0.83333302, 2.5 , 21.25 , 40. ]), 'z': array([-40. , -21.25 , -2.5 , -0.83333302, 0.83333302, 2.5 , 21.25 , 40. ])}ww.values.ww_values[0] # For particle_type 0 array([[[3.74716e+11, 4.62784e+10, 2.04099e+10, ..., 1.61974e+09, 1.59127e+09, 1.57594e+09], [2.97558e+11, 4.26816e+10, 1.99507e+10, ..., 1.59839e+09, 1.57100e+09, 1.55731e+09], [2.51297e+11, 4.04473e+10, 1.97289e+10, ..., 1.58933e+09, 1.56242e+09, 1.54924e+09], ..., [3.08912e+09, 1.24770e+09, 6.99321e+08, ..., 4.39785e+07, 4.37943e+07, 4.39171e+07], [2.25040e+09, 9.90649e+08, 5.80925e+08, ..., 3.90302e+07, 3.89225e+07, 3.90854e+07], [1.49079e+09, 7.66075e+08, 4.95798e+08, ..., 4.03358e+07, 4.05160e+07, 4.09321e+07]]])
3. Query Weight Windows
Query weight windows by specifying parameters such as particle type, time, energy, and position coordinates. You can define each parameter as a single value or a range. Exact matches are not required—WWINPy will automatically find the closest match for you.
ww.query_ww( particle_type=0, energy=(1, 20), x=(-20, 20), y=0, z=0 ).to_dataframe()Example output:
particle_type time_start time_end energy_start energy_end x_start x_end y_start y_end z_start z_end ww_value 0 0 0.0 inf 0.90718 1.4227 -25.0 1.5 -0.833 0.833 -0.833 0.833 3.257030e+10 1 0 0.0 inf 0.90718 1.4227 1.5 28.0 -0.833 0.833 -0.833 0.833 2.141830e+09 2 0 0.0 inf 1.4227 1.8268 -25.0 1.5 -0.833 0.833 -0.833 0.833 1.918890e+10 3 0 0.0 inf 1.4227 1.8268 1.5 28.0 -0.833 0.833 -0.833 0.833 1.468830e+09 4 0 0.0 inf 1.8268 3.0119 -25.0 1.5 -0.833 0.833 -0.833 0.833 1.378580e+10 5 0 0.0 inf 1.8268 3.0119 1.5 28.0 -0.833 0.833 -0.833 0.833 1.190380e+09 6 0 0.0 inf 3.0119 6.3763 -25.0 1.5 -0.833 0.833 -0.833 0.833 9.248920e+09 7 0 0.0 inf 3.0119 6.3763 1.5 28.0 -0.833 0.833 -0.833 0.833 9.358320e+08 8 0 0.0 inf 6.3763 20.0 -25.0 1.5 -0.833 0.833 -0.833 0.833 5.637660e+09 9 0 0.0 inf 6.3763 20.0 1.5 28.0 -0.833 0.833 -0.833 0.833 7.149460e+08
4. Optimize Weight Windows for simulation efficiency
Modify weight windows to improve simulation efficiency. The recommended workflow is to multiply, soften and apply ratio threshold to the weight windows. This can reduce the variance reduction but increase a lot the simulation efficiency.
ww.multiply(1.2) ww.soften(0.6) ww.apply_ratio_threshold(10)
5. Write modified Weight Windows
Write back the modified weight windows to a new file with WWINP format.
ww.write_file('path/to/output_file')