# Import custom h5 source file

**URL:** <https://openmc.discourse.group/t/import-custom-h5-source-file/3736>\
**Category:** User Support\
**Created:** [December 13, 2023, 9:28am UTC](https://openmc.discourse.group/t/import-custom-h5-source-file/3736 "2023-12-13T09:28:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![squishybrain](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@squishybrain](https://openmc.discourse.group/u/squishybrain)\
**Post date:** [December 13, 2023, 9:28am UTC](https://openmc.discourse.group/t/import-custom-h5-source-file/3736/1 "2023-12-13T09:28:56Z")

</div>

Hi all,

I am looking to convert external source data I have to an .h5 file and later load in later as a point source. My model is unable to run, hoping someone is able sense check my process and see where I am going wrong.

The source data I am looking to use are those provided by this fispact database, all are in the form for a .txt file. [Reference input spectra - FISPACT-II Wiki](https://fispact.ukaea.uk/wiki/Reference_input_spectra).

![image](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/7/7e5e7d34d6d2b63e1784353c27e60147e8e6ca57.png)

Parsing the text, ive obtained the energy and flux values. No other properties are provided by the data.  
The next step I believe is to generate a list of source particles and use openmc.write\_source\_file to export as an .h5 file.

![Screenshot 2023-12-13 092352](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/b/b12fc119207e90d372ca64bd7ba6031e6a2ad28c.png)

By importing this .h5 file. The format of the source is shown with:

source\_file = h5py.File(‘file location’)  
particles = source\_file[‘source\_bank’][()]  
print(particles)

 ![Screenshot 2023-12-13 092441](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/c/c2a2755ddc26a63edbf9794ef5bfbc1c6651df30.png)

To assign this source to a model I have then used

settings.source = openmc.FileSource(‘location of source.h5’)

However when running I get this error. Is this due to the formatting of the h5 or am I importing it incorrectly?

 ![Screenshot 2023-12-13 092734](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/0/07aa36dd7845f20831b3a700e45acfa62d6f3e48.png)

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [December 13, 2023, 12:55pm UTC](https://openmc.discourse.group/t/import-custom-h5-source-file/3736/2 "2023-12-13T12:55:56Z")

</div>

Just looking at your data, It’s possible that your source energies exceed the maximum energy available from the cross section library. Namely, many libraries cut off at 20 MeV whereas in your data, it looks like you have particles up to at least 30 MeV.

One thing you should try is to go to a terminal and run `openmc` to see what output it gives (this is effectively what `model.run(...)` is doing under the hood).
