make_disnht_custom.py Required software : python3 HEASoft Xspec (https://heasarc.gsfc.nasa.gov/docs/software/lheasoft/) Description : This program computes the absorption spectrum for a user defined distribution of column densities. The input is a file including the arrray of column densitiey values. The script make_example_disnht_input.py can also be used to produce an example of accepted input (see example 1). Other optional inputs are a cross-section .dat file (-c --cross_section) including the 2-d array [energy, cross-section]; cross sections computed for different abundance model for the interstellar medium (solar values) are also provided with this script {cross_aneb.dat, cross_angr.dat, cross_aspl.dat, cross_feld.dat, cross_grsa.dat, cross_lodd.dat, cross_wilm.dat}. See https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/node115.html for the description of the abundance sets. Other boolean flags can be used for input and output description, rebin, plot or save. The output table format is a .dat tab (-s --save) and/or a etable readable by XSPEC (-x --xspec); Rebinning of the spectrum (-r --rebin) is set by default as 500 log-spaced steps (--Nbins) from 0.1 (--BinLow_keV) to 10 (--BinUpp_keV) keV; NOTE: changing any of the rebin parameters automatically invokes the rebin of the output. Some examples of the script usage are provided below. For results derived with this code please cite Locatelli N., Ponti G. & Bianchi S. (2022). For further information please contact nlocat@mpe.mpg.de. #---------------------------------------------------------------------------------------------------------------------------------------- python3 make_disnht_custom.py -h usage: make_disnht_custom.py [-h] [-o OUTPUT] [-c CROSS_SECTION] [-l [LOGARITHMIC]] [-r [REBIN]] [--BinLow_keV BINLOW_KEV] [--BinUpp_keV BINUPP_KEV] [--Nbins NBINS] [-p [PLOT]] [-s [SAVE]] [-x [XSPEC]] [-v] input_NH This program computes the proper absorption spectrum for a user defined distribution of column densities. The input is a file including the arrray of column densitiey values. Other optional inputs are a cross-section .dat file (--cross_section) including the 2-d array [energy, cross-section] and boolean flags for input description and output rebin, plot or save. The output table format is a .dat tab (--save) and/or a etable readable by XSPEC (--xspec); NOTE: Rebinning of the spectrum (--rebin) is set by default as 500 log-spaced steps (--Nbins) from 0.1 (--BinLow_keV) to 10 (--BinUpp_keV) keV. positional arguments: input_NH str; .dat file name of N_H distribution, example : numpy.savetxt( "input_NH_example.dat", numpy.random.lognormal( 2.3 * 21, 0.3, 100 ) ) optional arguments: -h, --help show this help message and exit -o OUTPUT, --output OUTPUT str; output file path for output absorption tpectra; default = "./disnht.{dat,fits}" -c CROSS_SECTION, --cross_section CROSS_SECTION str; file name containing absorption cross section as a function of energy, shape = ( 2, N_Ebins ) ); choose within { cross_aneb.dat cross_angr.dat cross_aspl.dat cross_feld.dat cross_grsa.dat cross_lodd.dat cross_wilm.dat } or set a custom path -l [LOGARITHMIC], --logarithmic [LOGARITHMIC] bool; set flag if column densities in .dat are log_10 values -r [REBIN], --rebin [REBIN] bool; set flag to decrease spectrum resolution in output file --BinLow_keV BINLOW_KEV float; lower energy bound [keV] for output spectrum; default = 0.1; setting a different value overrides --rebin as True --BinUpp_keV BINUPP_KEV float; upper energy bound [keV] for output spectrum; default = 10; setting a different value overrides --rebin as True --Nbins NBINS int; number of output energy bins; default = 500; setting a different value overrides --rebin as True -p [PLOT], --plot [PLOT] bool; set flag to plot the output absorption spectrum -s [SAVE], --save [SAVE] bool; set flag to save spectrum in output file "disnht_.dat" -x [XSPEC], --xspec [XSPEC] bool; set flag to convert the output into XSPEC etable model "disnht_.fits"; overrides --save as True -v, --verbose increase output verbosity #---------------------------------------------------------------------------------------------------------------------------------------- Some examples of its usage are provided below : 1) python3 make_example_disnht_input.py produces the file "example_disnht_input.dat" containing an array of values that can be used as an input example column density distribution to our routine. The 100 values in the array are randomly extracted from a lognormal distribution centered at 21 dex with std = 0.3 dex. 2) python3 make_disnht_custom.py example_disnht_input.dat -x makes the XSPEC readible etable "disnht.fits". The table contains the absorption spectrum built from the input column density distribution 3) python3 make_disnht_custom.py example_disnht_input.dat -s makes the table "disnht.dat". The table contains the absorption spectrum built from the input column density distribution. The XSPEC readible etable is not produed 4) python3 make_disnht_custom.py example_disnht_input.dat -x -r same as 2). In addition the output is rebinned with 500 equally log-spaced bins from 0.1 (default) to 10 keV (default) 5) python3 make_disnht_custom.py example_disnht_input.dat -x --BinUpp_keV 20 --Nbins 1000 same as 4). The rebinning extends from 0.1 (default) to 20 keV, in 1000 equally log-spaced energy bins. Also --BinLow_keV can be specified 6) python3 make_disnht_custom.py example_disnht_input.dat -p python3 make_disnht_custom.py example_disnht_input.dat -p -o dummy only plot the spectrum, without exporting it to any output file, regardless of the output name specification if neither -x nor -s are used 7) python3 make_disnht_custom.py example_disnht_input.dat -c cross_lodd.dat -o dummy_lodd -x same as 2). The output is written in the files dummy_lodd.dat and dummy_lodd.fits. The absorption is computed using the cross section that assumes Lodders et al. (2003) abundances, stored in file "cross_lodd.dat" 8) python3 make_disnht_custom.py -h shows the file description above