Simple instructions on using MCNPydE

Data reduction tool for MCNP output

by Megat Harun Al Rashid bin Megat Ahmad and Rafhayudi bin Jamro


MCNPydE is a Python library for extracting data from MCNP output file. It requires Python, Matplotlib and Numpy. It is a data reduction tool for MCNP output for ease of results analysis and viewing.

To start using the program, first import the library:


In [1]:
from MCNPydE import *

To view the MCNP output file, it is best to assign it to a variable by passing a file name to the dataExtract class (e.g. var1):


In [2]:
var1 = dataExtract('NUR13o.txt')

by default it will pass the strings 'There are 20 grid points along the s-axis' as identifier. It is also possible to use a different strings identifier but the strings identifier must be unique as a starting line to extract the block of data:


In [3]:
var1 = dataExtract('NUR13o.txt','There are     20 grid points along the s-axis')

The total line number of the file can then be viewed:


In [4]:
var1.lineNumber()


76713

The content of the file can also be viewed even though it is advisable not to view the whole MCNP output file as it is usually very large. The rawContent() function allows viewing the first 100 lines (i.e. the header) of the ouput file and by passing arguments allow user to view specific range of the file:


In [5]:
var1.rawContent()


0 1mcnpx    version 27a   ld=Fri Oct 31 08:00:00 MST 2008                12/10/14 16:23:42
0  ***************************************************************************************   probid =   12/10/14 16:23:42
0  i=NUR13.txt o=NUR13o                                                                                                    
0 
0  *************************************************************
0  *                                                           *
0  *                   MCNPX                                   *
0  *                                                           *
0  * Copyright 2007. Los Alamos National Security, LLC.        *
0  * All rights reserved.                                      *
0  *                                                           *
0  * This material was produced under U.S. Government contract *
0  * DE-AC52-06NA25396 for Los Alamos National Laboratory,     *
0  * which is operated by Los Alamos National Security, LLC    *
0  * for the U.S. Department of Energy. The Government is      *
0  * granted for itself and others acting on its behalf a      *
0  * paid-up, nonexclusive, irrevocable worldwide license in   *
0  * this material to reproduce, prepare derivative works, and *
0  * works, and perform publicly and display publicly.         *
0  * Beginning five (5) years after June 1, 2006, subject to   *
0  * additional five-year worldwide renewals, the Government   *
0  * is granted for itself and others acting on its behalf     *
0  * a paid-up, nonexclusive, irrevocable worldwide license    *
0  * in this material to reproduce, prepare derivative works,  *
0  * distribute copies to the public, perform publicly and     *
0  * display publicly, and to permit others to do so.          *
0  *                                                           *
0  * NEITHER THE UNITED STATES NOR THE UNITED STATES           *
0  * DEPARTMENT OF ENERGY, NOR LOS ALAMOS NATIONAL SECURITY,   *
0  * LLC, NOR ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY,      *
0  * EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR     *
0  * RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR         *
0  * USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR     *
0  * PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT   *
0  * INFRINGE PRIVATELY OWNED RIGHTS.                          *
0  *                                                           *
0  *************************************************************
0     1-       NUR II CONE DESIGN FULL BEAM D=3.48cm 5cmBi/5cmPb                               
0     2-       c CELL CARD                                                                     
0     3-       c SMALL CYLINDER                                                                
0     4-         530  0 -500 520 -510 (-501 -510 520 ) #600 #601 #610 #620                     
0     5-              #630 #640 #611 #621 imp:n=1  imp:p=1                                     
0     6-         501  3 -2.7 -500 501 -510 520  imp:n=1  imp:p=1                               
0     7-         541  0    -503 510 -521 (-504 510 -521 )(504 :-505 :-510 :511 )               
0     8-                   (504 :-505 :-511 :512 )(504 :-505 :-512 :513 )                      
0     9-                   imp:n=1  imp:p=1                                                    
0    10-         506  3    -2.7 -503 504 510 -521 imp:n=1  imp:p=1                             
0    11-         507  3    -2.7 -504 505 510 -511 imp:n=1  imp:p=1                             
0    12-         508  5   -11.4 -504 505 511 -512 imp:n=1  imp:p=1                             
0    13-         509  8   -1.12 -504 505 512 -513 imp:n=1  imp:p=1                             
0    14-       c                                                                               
0    15-       c OUTSIDE COLLIMATOR                                                            
0    16-         510  4   -3.52 520 -521 522 -523 524 -525 (500 520 -510 :503 510 -521 )       
0    17-                  imp:n=1  imp:p=1                                                     
0    18-       c NR EXPOSURE ROOM  SHEILDING                                                   
0    19-         511  4 -3.52 521 -530 522 -523 524 -525 (-521 :532 :-533 :534 :-535 :536)     
0    20-              imp:n=1  imp:p=1                                                         
0    21-       c INSIDE EXPOSURE ROOM                                                          
0    22-         513  0 521 -532 533 -534 535 -536 (-540 :541 :-542 :543:-544 :545 )           
0    23-              imp:n=1  imp:p=1                                                         
0    24-       c CCD SHEILDING OUTSIDE                                                         
0    25-         514  3 -2.7 540 -541 542 -543 544 -545 (-546 :547 :-548 :549 :-550 :551)      
0    26-              imp:n=1  imp:p=1                                                         
0    27-       c CCD SHEILDING INSIDE                                                          
0    28-         515  0         546 -547 548 -549 550 -551 (-552 :553 :-554 :555:-556 :557 )   
0    29-              imp:n=1  imp:p=1                                                         
0    30-       c CCD CAMERA                                                                    
0    31-         516 3 -2.7 552 -553 554 -555 556 -557 imp:n=1  imp:p=1                        
0    32-       c Collimator                                                                    
0    33-        600 0 -611 -501 520  #610 #611      imp:n=1  imp:p=1                           
0    34-        601 0 -612 -501 -510 #610 #611      imp:n=1  imp:p=1                           
0    35-        610 6 -9.8 -620 508  -569           imp:n=1  imp:p=1                           
0    36-        611 10 -3.9 -620 569 -562           imp:n=1  imp:p=1                           
0    37-        620 6 -9.8 -501 620  508 -569 #610  imp:n=1  imp:p=1                           
0    38-        621 10 -3.9 -501 620 569 -562 #610  imp:n=1  imp:p=1                           
0    39-        630 9 -0.957 611 520 -508 -501      imp:n=1  imp:p=1                           
0    40-        640 5 -11.4 612 562 -501            imp:n=1  imp:p=1                           
0    41-       c UNIVERSE                                                                      
0    42-        9999 0 -520 :530 :-522 :523 :-524 :525 imp:n=0  imp:p=0                        
0    43-                                                                                       
0    44-       c SURFACE CARD                                                                  
0    45-         500        cx 7.6                                                             
0    46-         501        cx 6.6                                                             
0    47-         502        cx 5.6                                                             
0    48-       c                                                                               
0    49-         503        cx 10                                                              
0    50-         504        cx 9                                                               
0    51-         505        cx 6.6                                                             
0    52-         506        cx 2                                                               
0    53-       c                                                                               
0    54-         509        px -40                                                             
0    55-         511        px 1                                                               
0    56-       c ccccccccccccccccccccccccccccc                                                 
0    57-       c NEW PLANE FOR SMALL CYLINDER 03/11/2014 HZB                                   
0    58-       c ccccccccccccccccccccccccccccc                                                 
0    59-         560        px -95                                                             
0    60-         561        px -90                                                             
0    61-         508        px -80                                                             
0    62-         562        px -70                                                             
0    63-         569        px -75                                                             

To see the whole file (which is not advisable):


In [ ]:
var1.rawContent(1,-1)

To view an instance of the block of data:


In [6]:
var1.dataBlockContent()


Use the index position to select mapping energy when plotting

Line Number--->Energy Index--->Line Content


944 		     starting at -9.00000E+00 and ending at  9.00000E+00

945 		 

946 		

947 		 s-axis        -9.00000E+00 to -8.10000E+00                                                                            

948 		 t-axis       -9.00000E+00 to -8.10000E+00                                                                             

949 		      energy

950 	1 	    0.0000E+00   0.00000E+00 0.0000

951 	2 	    1.0000E-09   0.00000E+00 0.0000

952 	3 	    5.0000E-09   0.00000E+00 0.0000

953 	4 	    1.0000E-08   0.00000E+00 0.0000

954 	5 	    1.5000E-08   0.00000E+00 0.0000

955 	6 	    2.0000E-08   0.00000E+00 0.0000

956 	7 	    2.5000E-08   0.00000E+00 0.0000

957 	8 	    3.0000E-08   0.00000E+00 0.0000

958 	9 	    5.0000E-08   0.00000E+00 0.0000

959 	10 	    1.0000E-07   0.00000E+00 0.0000

960 	11 	    1.0000E-06   0.00000E+00 0.0000

961 	12 	    1.0000E-05   0.00000E+00 0.0000

962 	13 	    1.0000E-02   0.00000E+00 0.0000

963 	14 	    1.0000E+00   0.00000E+00 0.0000

964 	15 	    1.0000E+01   0.00000E+00 0.0000

965 	16 	      total      0.00000E+00 0.0000

966 	17 	 

967 	18 	 Shadow radiography image detector:

968 	19 	     Image grid centered at x,y,z =-9.90000E+01 0.00000E+00 0.00000E+00

969 	20 	

Here it can be seen that by default it automatically display up to 25 lines of the first block data starting from the identifying strings. The first column shows the line numbers of the output file whereas second column shows the index number of the energy data which later can be used for plotting. The third column shows the contant of block of data.

To view other block of data, then it must be known beforehand all the lines in the file that contains the identifying strings. This can be done by using the listLinenumber() function.


In [7]:
var1.listLinenumber()


The line number list that contain the passed 
strings is:

[944, 975, 1006, 1037, 1068, 1099, 1130, 1161, 1192, 1223, 1254, 1285, 1316, 1347, 1378, 1409, 1440, 1471, 1502, 1533, 1564, 1595, 1626, 1657, 1688, 1719, 1750, 1781, 1812, 1843, 1874, 1905, 1936, 1967, 1998, 2029, 2060, 2091, 2122, 2153, 2184, 2215, 2246, 2277, 2308, 2339, 2370, 2401, 2432, 2463, 2494, 2525, 2556, 2587, 2618, 2649, 2680, 2711, 2742, 2773, 2804, 2835, 2866, 2897, 2928, 2959, 2990, 3021, 3052, 3083, 3114, 3145, 3176, 3207, 3238, 3269, 3300, 3331, 3362, 3393, 3424, 3455, 3486, 3517, 3548, 3579, 3610, 3641, 3672, 3703, 3734, 3765, 3796, 3827, 3858, 3889, 3920, 3951, 3982, 4013, 4044, 4075, 4106, 4137, 4168, 4199, 4230, 4261, 4292, 4323, 4354, 4385, 4416, 4447, 4478, 4509, 4540, 4571, 4602, 4633, 4664, 4695, 4726, 4757, 4788, 4819, 4850, 4881, 4912, 4943, 4974, 5005, 5036, 5067, 5098, 5129, 5160, 5191, 5222, 5253, 5284, 5315, 5346, 5377, 5408, 5439, 5470, 5501, 5532, 5563, 5594, 5625, 5656, 5687, 5718, 5749, 5780, 5811, 5842, 5873, 5904, 5935, 5966, 5997, 6028, 6059, 6090, 6121, 6152, 6183, 6214, 6245, 6276, 6307, 6338, 6369, 6400, 6431, 6462, 6493, 6524, 6555, 6586, 6617, 6648, 6679, 6710, 6741, 6772, 6803, 6834, 6865, 6896, 6927, 6958, 6989, 7020, 7051, 7082, 7113, 7144, 7175, 7206, 7237, 7268, 7299, 7330, 7361, 7392, 7423, 7454, 7485, 7516, 7547, 7578, 7609, 7640, 7671, 7702, 7733, 7764, 7795, 7826, 7857, 7888, 7919, 7950, 7981, 8012, 8043, 8074, 8105, 8136, 8167, 8198, 8229, 8260, 8291, 8322, 8353, 8384, 8415, 8446, 8477, 8508, 8539, 8570, 8601, 8632, 8663, 8694, 8725, 8756, 8787, 8818, 8849, 8880, 8911, 8942, 8973, 9004, 9035, 9066, 9097, 9128, 9159, 9190, 9221, 9252, 9283, 9314, 9345, 9376, 9407, 9438, 9469, 9500, 9531, 9562, 9593, 9624, 9655, 9686, 9717, 9748, 9779, 9810, 9841, 9872, 9903, 9934, 9965, 9996, 10027, 10058, 10089, 10120, 10151, 10182, 10213, 10244, 10275, 10306, 10337, 10368, 10399, 10430, 10461, 10492, 10523, 10554, 10585, 10616, 10647, 10678, 10709, 10740, 10771, 10802, 10833, 10864, 10895, 10926, 10957, 10988, 11019, 11050, 11081, 11112, 11143, 11174, 11205, 11236, 11267, 11298, 11329, 11360, 11391, 11422, 11453, 11484, 11515, 11546, 11577, 11608, 11639, 11670, 11701, 11732, 11763, 11794, 11825, 11856, 11887, 11918, 11949, 11980, 12011, 12042, 12073, 12104, 12135, 12166, 12197, 12228, 12259, 12290, 12321, 12352, 12383, 12414, 12445, 12476, 12507, 12538, 12569, 12600, 12631, 12662, 12693, 12724, 12755, 12786, 12817, 12848, 12879, 12910, 12941, 12972, 13003, 13034, 13065, 13096, 13127, 13158, 13189, 13220, 13251, 13282, 13313, 13344, 13376, 13408, 13440, 13472, 13504, 13536, 13568, 13600, 13632, 13664, 13696, 13728, 13760, 13792, 13824, 13856, 13888, 13920, 13952, 13984, 14016, 14048, 14080, 14112, 14144, 14176, 14208, 14240, 14272, 14304, 14336, 14368, 14400, 14432, 14464, 14496, 14528, 14560, 14592, 14624, 14656, 14688, 14720, 14752, 14784, 14816, 14848, 14880, 14912, 14944, 14976, 15008, 15040, 15072, 15104, 15136, 15168, 15200, 15232, 15264, 15296, 15328, 15360, 15392, 15424, 15456, 15488, 15520, 15552, 15584, 15616, 15648, 15680, 15712, 15744, 15776, 15808, 15840, 15872, 15904, 15936, 15968, 16000, 16032, 16064, 16096, 16128, 16160, 16192, 16224, 16256, 16288, 16320, 16352, 16384, 16416, 16448, 16480, 16512, 16544, 16576, 16608, 16640, 16672, 16704, 16736, 16768, 16800, 16832, 16864, 16896, 16928, 16960, 16992, 17024, 17056, 17088, 17120, 17152, 17184, 17216, 17248, 17280, 17312, 17344, 17376, 17408, 17440, 17472, 17504, 17536, 17568, 17600, 17632, 17664, 17696, 17728, 17760, 17792, 17824, 17856, 17888, 17920, 17952, 17984, 18016, 18048, 18080, 18112, 18144, 18176, 18208, 18240, 18272, 18304, 18336, 18368, 18400, 18432, 18464, 18496, 18528, 18560, 18592, 18624, 18656, 18688, 18720, 18752, 18784, 18816, 18848, 18880, 18912, 18944, 18976, 19008, 19040, 19072, 19104, 19136, 19168, 19200, 19232, 19264, 19296, 19328, 19360, 19392, 19424, 19456, 19488, 19520, 19552, 19584, 19616, 19648, 19680, 19712, 19744, 19776, 19808, 19840, 19872, 19904, 19936, 19968, 20000, 20032, 20064, 20096, 20128, 20160, 20192, 20224, 20256, 20288, 20320, 20352, 20384, 20416, 20448, 20480, 20512, 20544, 20576, 20608, 20640, 20672, 20704, 20736, 20768, 20800, 20832, 20864, 20896, 20928, 20960, 20992, 21024, 21056, 21088, 21120, 21152, 21184, 21216, 21248, 21280, 21312, 21344, 21376, 21408, 21440, 21472, 21504, 21536, 21568, 21600, 21632, 21664, 21696, 21728, 21760, 21792, 21824, 21856, 21888, 21920, 21952, 21984, 22016, 22048, 22080, 22112, 22144, 22176, 22208, 22240, 22272, 22304, 22336, 22368, 22400, 22432, 22464, 22496, 22528, 22560, 22592, 22624, 22656, 22688, 22720, 22752, 22784, 22816, 22848, 22880, 22912, 22944, 22976, 23008, 23040, 23072, 23104, 23136, 23168, 23200, 23232, 23264, 23296, 23328, 23360, 23392, 23424, 23456, 23488, 23520, 23552, 23584, 23616, 23648, 23680, 23712, 23744, 23776, 23808, 23840, 23872, 23904, 23936, 23968, 24000, 24032, 24064, 24096, 24128, 24160, 24192, 24224, 24256, 24288, 24320, 24352, 24384, 24416, 24448, 24480, 24512, 24544, 24576, 24608, 24640, 24672, 24704, 24736, 24768, 24800, 24832, 24864, 24896, 24928, 24960, 24992, 25024, 25056, 25088, 25120, 25152, 25184, 25216, 25248, 25280, 25312, 25344, 25376, 25408, 25440, 25472, 25504, 25536, 25568, 25600, 25632, 25664, 25696, 25728, 25760, 25792, 25824, 25856, 25888, 25920, 25952, 25984, 26016, 26048, 26080, 26112, 26186, 26217, 26248, 26279, 26310, 26341, 26372, 26403, 26434, 26465, 26496, 26527, 26558, 26589, 26620, 26651, 26682, 26713, 26744, 26775, 26806, 26837, 26868, 26899, 26930, 26961, 26992, 27023, 27054, 27085, 27116, 27147, 27178, 27209, 27240, 27271, 27302, 27333, 27364, 27395, 27426, 27457, 27488, 27519, 27550, 27581, 27612, 27643, 27674, 27705, 27736, 27767, 27798, 27829, 27860, 27891, 27922, 27953, 27984, 28015, 28046, 28077, 28108, 28139, 28170, 28201, 28232, 28263, 28294, 28325, 28356, 28387, 28418, 28449, 28480, 28511, 28542, 28573, 28604, 28635, 28666, 28697, 28728, 28759, 28790, 28821, 28852, 28883, 28914, 28945, 28976, 29007, 29038, 29069, 29100, 29131, 29162, 29193, 29224, 29255, 29286, 29317, 29348, 29379, 29410, 29441, 29472, 29503, 29534, 29565, 29596, 29627, 29658, 29689, 29720, 29751, 29782, 29813, 29844, 29875, 29906, 29937, 29968, 29999, 30030, 30061, 30092, 30123, 30154, 30185, 30216, 30247, 30278, 30309, 30340, 30371, 30402, 30433, 30464, 30495, 30526, 30557, 30588, 30619, 30650, 30681, 30712, 30743, 30774, 30805, 30836, 30867, 30898, 30929, 30960, 30991, 31022, 31053, 31084, 31115, 31146, 31177, 31208, 31239, 31270, 31301, 31332, 31363, 31394, 31425, 31456, 31487, 31518, 31549, 31580, 31611, 31642, 31673, 31704, 31735, 31766, 31797, 31828, 31859, 31890, 31921, 31952, 31983, 32014, 32045, 32076, 32107, 32138, 32169, 32200, 32231, 32262, 32293, 32324, 32355, 32386, 32417, 32448, 32479, 32510, 32541, 32572, 32603, 32634, 32665, 32696, 32727, 32758, 32789, 32820, 32851, 32882, 32913, 32944, 32975, 33006, 33037, 33068, 33099, 33130, 33161, 33192, 33223, 33254, 33285, 33316, 33347, 33378, 33409, 33440, 33471, 33502, 33533, 33564, 33595, 33626, 33657, 33688, 33719, 33750, 33781, 33812, 33843, 33874, 33905, 33936, 33967, 33998, 34029, 34060, 34091, 34122, 34153, 34184, 34215, 34246, 34277, 34308, 34339, 34370, 34401, 34432, 34463, 34494, 34525, 34556, 34587, 34618, 34649, 34680, 34711, 34742, 34773, 34804, 34835, 34866, 34897, 34928, 34959, 34990, 35021, 35052, 35083, 35114, 35145, 35176, 35207, 35238, 35269, 35300, 35331, 35362, 35393, 35424, 35455, 35486, 35517, 35548, 35579, 35610, 35641, 35672, 35703, 35734, 35765, 35796, 35827, 35858, 35889, 35920, 35951, 35982, 36013, 36044, 36075, 36106, 36137, 36168, 36199, 36230, 36261, 36292, 36323, 36354, 36385, 36416, 36447, 36478, 36509, 36540, 36571, 36602, 36633, 36664, 36695, 36726, 36757, 36788, 36819, 36850, 36881, 36912, 36943, 36974, 37005, 37036, 37067, 37098, 37129, 37160, 37191, 37222, 37253, 37284, 37315, 37346, 37377, 37408, 37439, 37470, 37501, 37532, 37563, 37594, 37625, 37656, 37687, 37718, 37749, 37780, 37811, 37842, 37873, 37904, 37935, 37966, 37997, 38028, 38059, 38090, 38121, 38152, 38183, 38214, 38245, 38276, 38307, 38338, 38369, 38400, 38431, 38462, 38493, 38524, 38555, 38586, 38618, 38650, 38682, 38714, 38746, 38778, 38810, 38842, 38874, 38906, 38938, 38970, 39002, 39034, 39066, 39098, 39130, 39162, 39194, 39226, 39258, 39290, 39322, 39354, 39386, 39418, 39450, 39482, 39514, 39546, 39578, 39610, 39642, 39674, 39706, 39738, 39770, 39802, 39834, 39866, 39898, 39930, 39962, 39994, 40026, 40058, 40090, 40122, 40154, 40186, 40218, 40250, 40282, 40314, 40346, 40378, 40410, 40442, 40474, 40506, 40538, 40570, 40602, 40634, 40666, 40698, 40730, 40762, 40794, 40826, 40858, 40890, 40922, 40954, 40986, 41018, 41050, 41082, 41114, 41146, 41178, 41210, 41242, 41274, 41306, 41338, 41370, 41402, 41434, 41466, 41498, 41530, 41562, 41594, 41626, 41658, 41690, 41722, 41754, 41786, 41818, 41850, 41882, 41914, 41946, 41978, 42010, 42042, 42074, 42106, 42138, 42170, 42202, 42234, 42266, 42298, 42330, 42362, 42394, 42426, 42458, 42490, 42522, 42554, 42586, 42618, 42650, 42682, 42714, 42746, 42778, 42810, 42842, 42874, 42906, 42938, 42970, 43002, 43034, 43066, 43098, 43130, 43162, 43194, 43226, 43258, 43290, 43322, 43354, 43386, 43418, 43450, 43482, 43514, 43546, 43578, 43610, 43642, 43674, 43706, 43738, 43770, 43802, 43834, 43866, 43898, 43930, 43962, 43994, 44026, 44058, 44090, 44122, 44154, 44186, 44218, 44250, 44282, 44314, 44346, 44378, 44410, 44442, 44474, 44506, 44538, 44570, 44602, 44634, 44666, 44698, 44730, 44762, 44794, 44826, 44858, 44890, 44922, 44954, 44986, 45018, 45050, 45082, 45114, 45146, 45178, 45210, 45242, 45274, 45306, 45338, 45370, 45402, 45434, 45466, 45498, 45530, 45562, 45594, 45626, 45658, 45690, 45722, 45754, 45786, 45818, 45850, 45882, 45914, 45946, 45978, 46010, 46042, 46074, 46106, 46138, 46170, 46202, 46234, 46266, 46298, 46330, 46362, 46394, 46426, 46458, 46490, 46522, 46554, 46586, 46618, 46650, 46682, 46714, 46746, 46778, 46810, 46842, 46874, 46906, 46938, 46970, 47002, 47034, 47066, 47098, 47130, 47162, 47194, 47226, 47258, 47290, 47322, 47354, 47386, 47418, 47450, 47482, 47514, 47546, 47578, 47610, 47642, 47674, 47706, 47738, 47770, 47802, 47834, 47866, 47898, 47930, 47962, 47994, 48026, 48058, 48090, 48122, 48154, 48186, 48218, 48250, 48282, 48314, 48346, 48378, 48410, 48442, 48474, 48506, 48538, 48570, 48602, 48634, 48666, 48698, 48730, 48762, 48794, 48826, 48858, 48890, 48922, 48954, 48986, 49018, 49050, 49082, 49114, 49146, 49178, 49210, 49242, 49274, 49306, 49338, 49370, 49402, 49434, 49466, 49498, 49530, 49562, 49594, 49626, 49658, 49690, 49722, 49754, 49786, 49818, 49850, 49882, 49914, 49946, 49978, 50010, 50042, 50074, 50106, 50138, 50170, 50202, 50234, 50266, 50298, 50330, 50362, 50394, 50426, 50458, 50490, 50522, 50554, 50586, 50618, 50650, 50682, 50714, 50746, 50778, 50810, 50842, 50874, 50906, 50938, 50970, 51002, 51034, 51066, 51098, 51130, 51162, 51194, 51226, 51258, 51290, 51322, 51354, 51428, 51459, 51490, 51521, 51552, 51583, 51614, 51645, 51676, 51707, 51738, 51769, 51800, 51831, 51862, 51893, 51924, 51955, 51986, 52017, 52048, 52079, 52110, 52141, 52172, 52203, 52234, 52265, 52296, 52327, 52358, 52389, 52420, 52451, 52482, 52513, 52544, 52575, 52606, 52637, 52668, 52699, 52730, 52761, 52792, 52823, 52854, 52885, 52916, 52947, 52978, 53009, 53040, 53071, 53102, 53133, 53164, 53195, 53226, 53257, 53288, 53319, 53350, 53381, 53412, 53443, 53474, 53505, 53536, 53567, 53598, 53629, 53660, 53691, 53722, 53753, 53784, 53815, 53846, 53877, 53908, 53939, 53970, 54001, 54032, 54063, 54094, 54125, 54156, 54187, 54218, 54249, 54280, 54311, 54342, 54373, 54404, 54435, 54466, 54497, 54528, 54559, 54590, 54621, 54652, 54683, 54714, 54745, 54776, 54807, 54838, 54869, 54900, 54931, 54962, 54993, 55024, 55055, 55086, 55117, 55148, 55179, 55210, 55241, 55272, 55303, 55334, 55365, 55396, 55427, 55458, 55489, 55520, 55551, 55582, 55613, 55644, 55675, 55706, 55737, 55768, 55799, 55830, 55861, 55892, 55923, 55954, 55985, 56016, 56047, 56078, 56109, 56140, 56171, 56202, 56233, 56264, 56295, 56326, 56357, 56388, 56419, 56450, 56481, 56512, 56543, 56574, 56605, 56636, 56667, 56698, 56729, 56760, 56791, 56822, 56853, 56884, 56915, 56946, 56977, 57008, 57039, 57070, 57101, 57132, 57163, 57194, 57225, 57256, 57287, 57318, 57349, 57380, 57411, 57442, 57473, 57504, 57535, 57566, 57597, 57628, 57659, 57690, 57721, 57752, 57783, 57814, 57845, 57876, 57907, 57938, 57969, 58000, 58031, 58062, 58093, 58124, 58155, 58186, 58217, 58248, 58279, 58310, 58341, 58372, 58403, 58434, 58465, 58496, 58527, 58558, 58589, 58620, 58651, 58682, 58713, 58744, 58775, 58806, 58837, 58868, 58899, 58930, 58961, 58992, 59023, 59054, 59085, 59116, 59147, 59178, 59209, 59240, 59271, 59302, 59333, 59364, 59395, 59426, 59457, 59488, 59519, 59550, 59581, 59612, 59643, 59674, 59705, 59736, 59767, 59798, 59829, 59860, 59891, 59922, 59953, 59984, 60015, 60046, 60077, 60108, 60139, 60170, 60201, 60232, 60263, 60294, 60325, 60356, 60387, 60418, 60449, 60480, 60511, 60542, 60573, 60604, 60635, 60666, 60697, 60728, 60759, 60790, 60821, 60852, 60883, 60914, 60945, 60976, 61007, 61038, 61069, 61100, 61131, 61162, 61193, 61224, 61255, 61286, 61317, 61348, 61379, 61410, 61441, 61472, 61503, 61534, 61565, 61596, 61627, 61658, 61689, 61720, 61751, 61782, 61813, 61844, 61875, 61906, 61937, 61968, 61999, 62030, 62061, 62092, 62123, 62154, 62185, 62216, 62247, 62278, 62309, 62340, 62371, 62402, 62433, 62464, 62495, 62526, 62557, 62588, 62619, 62650, 62681, 62712, 62743, 62774, 62805, 62836, 62867, 62898, 62929, 62960, 62991, 63022, 63053, 63084, 63115, 63146, 63177, 63208, 63239, 63270, 63301, 63332, 63363, 63394, 63425, 63456, 63487, 63518, 63549, 63580, 63611, 63642, 63673, 63704, 63735, 63766, 63797, 63828, 63860, 63892, 63924, 63956, 63988, 64020, 64052, 64084, 64116, 64148, 64180, 64212, 64244, 64276, 64308, 64340, 64372, 64404, 64436, 64468, 64500, 64532, 64564, 64596, 64628, 64660, 64692, 64724, 64756, 64788, 64820, 64852, 64884, 64916, 64948, 64980, 65012, 65044, 65076, 65108, 65140, 65172, 65204, 65236, 65268, 65300, 65332, 65364, 65396, 65428, 65460, 65492, 65524, 65556, 65588, 65620, 65652, 65684, 65716, 65748, 65780, 65812, 65844, 65876, 65908, 65940, 65972, 66004, 66036, 66068, 66100, 66132, 66164, 66196, 66228, 66260, 66292, 66324, 66356, 66388, 66420, 66452, 66484, 66516, 66548, 66580, 66612, 66644, 66676, 66708, 66740, 66772, 66804, 66836, 66868, 66900, 66932, 66964, 66996, 67028, 67060, 67092, 67124, 67156, 67188, 67220, 67252, 67284, 67316, 67348, 67380, 67412, 67444, 67476, 67508, 67540, 67572, 67604, 67636, 67668, 67700, 67732, 67764, 67796, 67828, 67860, 67892, 67924, 67956, 67988, 68020, 68052, 68084, 68116, 68148, 68180, 68212, 68244, 68276, 68308, 68340, 68372, 68404, 68436, 68468, 68500, 68532, 68564, 68596, 68628, 68660, 68692, 68724, 68756, 68788, 68820, 68852, 68884, 68916, 68948, 68980, 69012, 69044, 69076, 69108, 69140, 69172, 69204, 69236, 69268, 69300, 69332, 69364, 69396, 69428, 69460, 69492, 69524, 69556, 69588, 69620, 69652, 69684, 69716, 69748, 69780, 69812, 69844, 69876, 69908, 69940, 69972, 70004, 70036, 70068, 70100, 70132, 70164, 70196, 70228, 70260, 70292, 70324, 70356, 70388, 70420, 70452, 70484, 70516, 70548, 70580, 70612, 70644, 70676, 70708, 70740, 70772, 70804, 70836, 70868, 70900, 70932, 70964, 70996, 71028, 71060, 71092, 71124, 71156, 71188, 71220, 71252, 71284, 71316, 71348, 71380, 71412, 71444, 71476, 71508, 71540, 71572, 71604, 71636, 71668, 71700, 71732, 71764, 71796, 71828, 71860, 71892, 71924, 71956, 71988, 72020, 72052, 72084, 72116, 72148, 72180, 72212, 72244, 72276, 72308, 72340, 72372, 72404, 72436, 72468, 72500, 72532, 72564, 72596, 72628, 72660, 72692, 72724, 72756, 72788, 72820, 72852, 72884, 72916, 72948, 72980, 73012, 73044, 73076, 73108, 73140, 73172, 73204, 73236, 73268, 73300, 73332, 73364, 73396, 73428, 73460, 73492, 73524, 73556, 73588, 73620, 73652, 73684, 73716, 73748, 73780, 73812, 73844, 73876, 73908, 73940, 73972, 74004, 74036, 74068, 74100, 74132, 74164, 74196, 74228, 74260, 74292, 74324, 74356, 74388, 74420, 74452, 74484, 74516, 74548, 74580, 74612, 74644, 74676, 74708, 74740, 74772, 74804, 74836, 74868, 74900, 74932, 74964, 74996, 75028, 75060, 75092, 75124, 75156, 75188, 75220, 75252, 75284, 75316, 75348, 75380, 75412, 75444, 75476, 75508, 75540, 75572, 75604, 75636, 75668, 75700, 75732, 75764, 75796, 75828, 75860, 75892, 75924, 75956, 75988, 76020, 76052, 76084, 76116, 76148, 76180, 76212, 76244, 76276, 76308, 76340, 76372, 76404, 76436, 76468, 76500, 76532, 76564, 76596]

Other block data can be viewed by selecting the starting line (from the above list) and the range of lines (number of lines after the string identifier). For instance by selecting the range starting from line of 8508 to 8538:


In [8]:
var1.dataBlockContent(8508,30)


Use the index position to select mapping energy when plotting

Line Number--->Energy Index--->Line Content


8508 		     starting at -9.00000E+00 and ending at  9.00000E+00

8509 		 

8510 		

8511 		 s-axis         1.80000E+00 to  2.70000E+00                                                                            

8512 		 t-axis       -5.40000E+00 to -4.50000E+00                                                                             

8513 		      energy

8514 	1 	    0.0000E+00   0.00000E+00 0.0000

8515 	2 	    1.0000E-09   1.41266E-08 0.4593

8516 	3 	    5.0000E-09   5.78881E-05 0.6207

8517 	4 	    1.0000E-08   3.38473E-04 0.5224

8518 	5 	    1.5000E-08   1.09083E-04 0.4567

8519 	6 	    2.0000E-08   1.75430E-04 0.3763

8520 	7 	    2.5000E-08   5.32154E-04 0.8067

8521 	8 	    3.0000E-08   2.38874E-04 0.4508

8522 	9 	    5.0000E-08   1.78793E-03 0.3645

8523 	10 	    1.0000E-07   1.13526E-03 0.2257

8524 	11 	    1.0000E-06   6.12968E-04 0.2384

8525 	12 	    1.0000E-05   1.34599E-04 0.1674

8526 	13 	    1.0000E-02   3.34907E-04 0.2768

8527 	14 	    1.0000E+00   1.28669E-03 0.1756

8528 	15 	    1.0000E+01   5.32264E-04 0.0822

8529 	16 	      total      7.27654E-03 0.1727

8530 	17 	 

8531 	18 	 Shadow radiography image detector:

8532 	19 	     Image grid centered at x,y,z =-9.90000E+01 0.00000E+00 0.00000E+00

8533 	20 	

8534 	21 	

8535 	22 	          There are     20 grid points along the t-axis

8536 	23 	     starting at -9.00000E+00 and ending at  9.00000E+00

8537 	24 	 

8538 	25 	          There are     20 grid points along the s-axis

Viewing the data block above allows the user to select the range of data and by default the allBlockData() will select the range from line 8511 to line 8532.

If satisfied, the user can then run the allBlockData() function to extract all the data blocks into a list.


In [9]:
var1.allBlockData()


The number of blocks are 2400
There would be 3 groups of data

Here the allBlockData() function informs that there are 2400 blocks of data in three spatial groups (usually starting upstream to downstream of the MCNP simulation). This with the index of 15 different energies as viewed with dataBlockContent().

If the output is specified to list only 2 different energies than it is more practical to specify the range of data to be extracted, e.g.:

var1.allBlockData(lowLim = 3, upLim = 5)

The lowLim variable default value is 3 (which is the listing start of energy index) whereas upLim default value is 23. The position of 1 is for the s-axis and 2 is for the t-axis as viewed previously (s-axis and t-axis number points can be specified using the axisPt variable, by default the value is 20).

Plotting of the results is only possible after executing the allBlockData() function. Plot can be made into 2D or 3D image, showing the intensity of particles with specific energy in the cross section of the model. In this instance there are 3 cross section groups as indicated after executing allBlockData().

For instance, if the user wants to plot a 2D representation of the intensity at the second spatial or cross section group for particles with energy of 0.025 eV, the user can pass the index value of 2 (for the spatial group) and 7 (by refering to the index of the energy data when viewing the data block) to the Plot2D function:


In [10]:
%pylab inline

var1.plot2D(2,7)


Populating the interactive namespace from numpy and matplotlib
Energy : 2.5000E-08 MeV

It is possible to filter, save and specififed the color map of the plot (as shown in the same seqeunce below):


In [11]:
var1.plot2D(2,7, intPol = 'catrom', figName = 'plot2D.tiff', colorMap=cm.hsv)


Energy : 2.5000E-08 MeV

and for instance the 3D plot for the intensity at the third spatial group for particles with energy of 1 MeV:


In [12]:
var1.plot3D(3,14)


Energy : 1.0000E+00 MeV

and by assigning the rainbow color map and save the plot file:


In [13]:
var1.plot3D(3,14, figName = 'plot3D.tiff', colorMap=cm.rainbow)


Energy : 1.0000E+00 MeV

To process a different MCNP output file, the user can assign a new variable and process the data (this allows ease of comparison between different MCNP output files):


In [14]:
var2 = dataExtract('TAN44o.txt')

The total line number for 'TAN44o.txt' file:


In [15]:
var2.lineNumber()


216808

Checking the format of the data block:


In [16]:
var2.dataBlockContent()


Use the index position to select mapping energy when plotting

Line Number--->Energy Index--->Line Content


2781 		     starting at -9.00000E+00 and ending at  9.00000E+00

2782 		 

2783 		

2784 		 s-axis        -9.00000E+00 to -8.10000E+00                                                                            

2785 		 t-axis       -9.00000E+00 to -8.10000E+00                                                                             

2786 		      energy

2787 	1 	    0.0000E+00   0.00000E+00 0.0000

2788 	2 	    2.5000E-08   0.00000E+00 0.0000

2789 	3 	      total      0.00000E+00 0.0000

2790 	4 	 

2791 	5 	 Shadow radiography image detector:

2792 	6 	     Image grid centered at x,y,z =-9.90000E+01 0.00000E+00 0.00000E+00

2793 	7 	

2794 	8 	

2795 	9 	          There are     20 grid points along the t-axis

2796 	10 	     starting at -9.00000E+00 and ending at  9.00000E+00

2797 	11 	 

2798 	12 	          There are     20 grid points along the s-axis

2799 	13 	     starting at -9.00000E+00 and ending at  9.00000E+00

2800 	14 	 

2801 	15 	

2802 	16 	 s-axis        -9.00000E+00 to -8.10000E+00                                                                            

2803 	17 	 t-axis       -8.10000E+00 to -7.20000E+00                                                                             

2804 	18 	      energy

2805 	19 	    0.0000E+00   0.00000E+00 0.0000

2806 	20 	    2.5000E-08   0.00000E+00 0.0000

In this output file only two index of energies recorded. Extracting all the data blocks into a list:


In [17]:
var2.allBlockData()


The number of blocks are 2400
There would be 3 groups of data

Lastly, viewing the particles intensity in 2D and 3D:


In [18]:
var2.plot2D(3,2, figName = 'plot2D.tiff', colorMap=cm.gist_rainbow)


Energy : 2.5000E-08 MeV

In [19]:
var2.plot3D(1,2, figName = 'plot2D.tiff', colorMap=cm.gist_rainbow)


Energy : 2.5000E-08 MeV

I hope the MCNPydE library and this simple instructions will be useful to MCNP users. Thank you.