2424_FIT_A = 1 # Absorption
2525_FIT_F = 2 # Fission
2626
27- ATOMIC_SYMBOL = {0 : 'n' , 1 : 'H' , 2 : 'He' , 3 : 'Li' , 4 : 'Be' , 5 : 'B' , 6 : 'C' ,
28- 7 : 'N' , 8 : 'O' , 9 : 'F' , 10 : 'Ne' , 11 : 'Na' , 12 : 'Mg' , 13 : 'Al' ,
29- 14 : 'Si' , 15 : 'P' , 16 : 'S' , 17 : 'Cl' , 18 : 'Ar' , 19 : 'K' ,
30- 20 : 'Ca' , 21 : 'Sc' , 22 : 'Ti' , 23 : 'V' , 24 : 'Cr' , 25 : 'Mn' ,
31- 26 : 'Fe' , 27 : 'Co' , 28 : 'Ni' , 29 : 'Cu' , 30 : 'Zn' , 31 : 'Ga' ,
32- 32 : 'Ge' , 33 : 'As' , 34 : 'Se' , 35 : 'Br' , 36 : 'Kr' , 37 : 'Rb' ,
33- 38 : 'Sr' , 39 : 'Y' , 40 : 'Zr' , 41 : 'Nb' , 42 : 'Mo' , 43 : 'Tc' ,
34- 44 : 'Ru' , 45 : 'Rh' , 46 : 'Pd' , 47 : 'Ag' , 48 : 'Cd' , 49 : 'In' ,
35- 50 : 'Sn' , 51 : 'Sb' , 52 : 'Te' , 53 : 'I' , 54 : 'Xe' , 55 : 'Cs' ,
36- 56 : 'Ba' , 57 : 'La' , 58 : 'Ce' , 59 : 'Pr' , 60 : 'Nd' , 61 : 'Pm' ,
37- 62 : 'Sm' , 63 : 'Eu' , 64 : 'Gd' , 65 : 'Tb' , 66 : 'Dy' , 67 : 'Ho' ,
38- 68 : 'Er' , 69 : 'Tm' , 70 : 'Yb' , 71 : 'Lu' , 72 : 'Hf' , 73 : 'Ta' ,
39- 74 : 'W' , 75 : 'Re' , 76 : 'Os' , 77 : 'Ir' , 78 : 'Pt' , 79 : 'Au' ,
40- 80 : 'Hg' , 81 : 'Tl' , 82 : 'Pb' , 83 : 'Bi' , 84 : 'Po' , 85 : 'At' ,
41- 86 : 'Rn' , 87 : 'Fr' , 88 : 'Ra' , 89 : 'Ac' , 90 : 'Th' , 91 : 'Pa' ,
42- 92 : 'U' , 93 : 'Np' , 94 : 'Pu' , 95 : 'Am' , 96 : 'Cm' , 97 : 'Bk' ,
43- 98 : 'Cf' , 99 : 'Es' , 100 : 'Fm' , 101 : 'Md' , 102 : 'No' ,
44- 103 : 'Lr' , 104 : 'Rf' , 105 : 'Db' , 106 : 'Sg' , 107 : 'Bh' ,
45- 108 : 'Hs' , 109 : 'Mt' , 110 : 'Ds' , 111 : 'Rg' , 112 : 'Cn' ,
46- 113 : 'Nh' , 114 : 'Fl' , 115 : 'Mc' , 116 : 'Lv' , 117 : 'Ts' ,
47- 118 : 'Og' }
48- ATOMIC_NUMBER = {value : key for key , value in ATOMIC_SYMBOL .items ()}
49-
5027def check_type (name , value , expected_type ):
5128 r"""Ensure that an object is of an expected type.
5229
@@ -263,7 +240,8 @@ class WindowedMultipole(object):
263240 a/E + b/sqrt(E) + c + d sqrt(E) + ...
264241
265242 """
266- def __init__ (self ):
243+ def __init__ (self , name ):
244+ self .name = name
267245 self .spacing = None
268246 self .sqrtAWR = None
269247 self .E_min = None
@@ -273,6 +251,10 @@ def __init__(self):
273251 self .broaden_poly = None
274252 self .curvefit = None
275253
254+ @property
255+ def name (self ):
256+ return self ._name
257+
276258 @property
277259 def fit_order (self ):
278260 return self .curvefit .shape [1 ] - 1
@@ -313,6 +295,11 @@ def broaden_poly(self):
313295 def curvefit (self ):
314296 return self ._curvefit
315297
298+ @name .setter
299+ def name (self , name ):
300+ check_type ('name' , name , str )
301+ self ._name = name
302+
316303 @spacing .setter
317304 def spacing (self , spacing ):
318305 if spacing is not None :
@@ -422,9 +409,10 @@ def from_hdf5(cls, group_or_filename):
422409 raise ValueError ('The given WMP data uses version '
423410 + version + ' whereas your installation of the OpenMC '
424411 'Python API expects version ' + WMP_VERSION )
425- group = h5file [ 'nuclide' ]
412+ group = list ( h5file . values ())[ 0 ]
426413
427- out = cls ()
414+ name = group .name [1 :]
415+ out = cls (name )
428416
429417 # Read scalars.
430418
@@ -570,26 +558,29 @@ def __call__(self, E, T):
570558 fun = np .vectorize (lambda x : self ._evaluate (x , T ))
571559 return fun (E )
572560
573- def export_to_hdf5 (self , path , libver = 'earliest' ):
561+ def export_to_hdf5 (self , path , mode = 'a' , libver = 'earliest' ):
574562 """Export windowed multipole data to an HDF5 file.
575563
576564 Parameters
577565 ----------
578566 path : str
579567 Path to write HDF5 file to
568+ mode : {'r', r+', 'w', 'x', 'a'}
569+ Mode that is used to open the HDF5 file. This is the second argument
570+ to the :class:`h5py.File` constructor.
580571 libver : {'earliest', 'latest'}
581572 Compatibility mode for the HDF5 file. 'latest' will produce files
582573 that are less backwards compatible but have performance benefits.
583574
584575 """
585576
586577 # Open file and write version.
587- with h5py .File (path , 'w' , libver = libver ) as f :
578+ with h5py .File (path , mode , libver = libver ) as f :
579+ f .attrs ['filetype' ] = np .string_ ('data_wmp' )
588580 f .create_dataset ('version' , (1 , ), dtype = 'S10' )
589581 f ['version' ][:] = WMP_VERSION .encode ('ASCII' )
590582
591- # Make a nuclide group.
592- g = f .create_group ('nuclide' )
583+ g = f .create_group (self .name )
593584
594585 # Write scalars.
595586 g .create_dataset ('spacing' , data = np .array (self .spacing ))
0 commit comments