#!/usr/bin/env python

import argparse
import numpy as np
import edrixs

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Post-process pole files to get XAS or RIXS spectrum.")
    parser.add_argument('-N', type=int, default=100, help='Number of points in the omega mesh')
    parser.add_argument('-ommin', type=float, default=0.0, help='Minimum value of omega')
    parser.add_argument('-ommax', type=float, default=1.0, help='Maximum value of omega')
    parser.add_argument('-off', type=float, default=0.0, help='Shift omega mesh (+off)')
    parser.add_argument('-T', type=float, default=300, help='Temperature (K)')
    parser.add_argument('-G', type=float, default=0.1, help='Broadening factor (eV)')
    parser.add_argument('-f', type=str, default='spectrum.dat',
                        help='File to store the calculated spectrum')
    parser.add_argument(
            'files_of_poles', type=str, nargs='+',
            help='Pole-files generated by xas.x or rixs.x: xas_poles.xxx, rixs_poles.xxx')

    args = parser.parse_args()
    omega_mesh = np.linspace(args.ommin, args.ommax, args.N)
    gamma_mesh = np.ones(args.N) * args.G
    edrixs.plot_spectrum(args.files_of_poles, omega_mesh, gamma_mesh, args.T, args.f,
                         om_shift=args.off)
