How to create a spectral file function?ΒΆ

The following example illustrates how you can create a spectral file function composed of four nodes and how you can save this file function into the file my_file_function.txt.

C++

1GModelSpectralFunc spectrum;
2spectrum.append(GEnergy(1.0, "MeV"), 9.0e-5);
3spectrum.append(GEnergy(2.0, "MeV"), 7.0e-5);
4spectrum.append(GEnergy(4.0, "MeV"), 5.0e-5);
5spectrum.append(GEnergy(8.0, "MeV"), 3.0e-5);
6spectrum.save("my_file_function.txt", true);

Python

1spectrum = gammalib.GModelSpectralFunc()
2spectrum.append(gammalib.GEnergy(1.0, 'MeV'), 9.0e-5)
3spectrum.append(gammalib.GEnergy(2.0, 'MeV'), 7.0e-5)
4spectrum.append(gammalib.GEnergy(4.0, 'MeV'), 5.0e-5)
5spectrum.append(gammalib.GEnergy(8.0, 'MeV'), 3.0e-5)
6spectrum.save('my_file_function.txt', True)