These scripts were developed for Gúrpide et al. 2022 and have been regularly updated since then. They allow to extract useful information mainly from MUSE datacubes and images but there's also some functionality to extract fluxes from hst images and chandra PSF profiles. Scripts can be run from the command line. Run python <script> -h to check the input variables and a small description of the script.
marxsim_script.py --> Script to be run from the command line to simulate N PSFs based on a given chandra observation. Ciao and marx need to be properly setup before running the script.
check_extension.py --> Script to be run after marxsim_script.py has been run to analyse the output. Use python marxsim_script.py -h to obtain the available command line arguments
aperture_photometry.py --> Script to retrieve magnitudes, fluxes from a given ds9 region (it automatically reads the necessary keywords from the header to perform the corrections). A finite aperture correction is needed for small PSFs. Background subtraction is also possible (must be added a second line in the ds9 region file).
astro_corr.py --> Script to refine the astrometry of several HST images (more than one is possible, and the solution will be global to all of them) using the gaia catalogue. It uses tweakreg https://drizzlepac.readthedocs.io/en/latest/tweakreg.html.
lineratio.py --> Script to perform the radio between two line flux maps
python lineratio.py -n NUMERATORS [NUMERATORS ...] [-en ENUMERATORS [ENUMERATORS ...]] -d DENOMINATOR [DENOMINATOR ...] [-ed EDENOMINATOR [EDENOMINATOR ...]] [-o [OUTDIR]] [-f [FILE]
Where numeratos and denominators are a space-separed list of fits files. The files with an "e" prefix are the uncertainty maps. -o and -f control the output dir and file naming.
deredden.py --> Script to deredden flux line maps, it needs as input the balmer decrement map (Halpha/Hbeta) and it will automatically localize the flux maps
deredden_momcheva.py --> Script to deredden flux line maps (based on e.g. Momcheva et al. 2013 see the Appendix), it needs as input the hbeta and halpha directories and it will automatically look for the line flux maps and deredden them.
python deredden_momcheva.py -a halpha_path -b hbeta_path -Rv 4.05 -i 2.86). It creates a map of E(B-V) and one with the uncertainty on E(B-V)
Correct cube from Galactic extinction (both Rv and EBV are optional. If not given EBV is taken from the Schlafly & Finkbeiner 2011 EBV map using the cube coordinates.
python deredden_cube.py cube -R Rv --ebv_gal EBV EBV_err
Get the peak position and FWHM of a given ds9 region or entire image
python get_image_peak.py <image> -r ds9regionfile.reg --psf [gaussian, moffat] --ext 1 --circular
Cut images from an input region ds9 file.
python cutfromregion.py <image or cube .fits? -r <ds9 region for the cut> -o <outname> (otherwise autonamed as cut+image)
| Before | After |
|---|---|
![]() |
![]() |
image_stats.py --> Retrieve statistical information (min, max, mean) of a region or entire image by default image_stats.py image.fits -region ds9reigonfile.reg
extract_radial_profiles.py images -n number_rectangles -r max_r (pixels) --offset -w
e.g. python extract_radial_profiles.py images -n 4 -r 70 --offset 10
| Extraction regions | Radial averaged profiles |
|---|---|
![]() |
![]() |
adjust_coordinates.py --> Runs a cross-correlation between an input reference image and the cube and estimates the offset needed to adjust the cube coordinates to the reference image (uses mpdaf estimate_coordinate_offset and adjust_coordinates)
python adjust_coordinates.py cube.fits --hst <ref image, typically HST>
H2diags.py --> Computes metallicity maps based on Pilyugin, L. S., & Grebel, E. K. 2016, MNRAS, 457, 3678. A config file is needed and optionally a BPT file to exclude non-H2 regions (currently defined as having an index >1). Otherwise the whole map is used python H2diags.py --config metal_config.py -bpt lineratios/bpt_diagrams_v2/BPT_2.fits or simply python H2diags.py --config metal_config.py
extract_spectrum.py --> Extracts a spectrum from a ds9 region file.
cleanskyres.py --> Uses ZAP to remove sky features. Make sure to mask your sources before hand! (with the -r option you can pass a ds9 with several regions to be masked, ideally you wan to mask bright and extended sources)
read_mappings.py --> Script to obtain predicted line ratios from the mapping libraries (python read_mappings.py (for instance V_*b0_001_s_lines.txt V*b1_s_lines.txt [MVQP]*b[0e]s_lines.txt [MVQ]*b10_s_lines.txt T*b0_001_s_lines.txt T_b1_s_ T_*b10_s_lines.txt). The script will read the paths to the BPT diagrams from bpt_config.py file
read_mappingsV.py --> Script to obtain predicted line ratios from the mapping V libraries. The script will read the paths to the BPT diagrams from bpt_config.py file
bpt_colored.py -> Classifies each pixel based on the IFU-improved BPT diagrams from Law+2021. Outputs fits and pngs of BPT diagrams, colored for better visualization
python bpt_colored.py --config config_file (see an example in config_files)
If these scripts were useful to you, we would greatly appreciate if you could cite the original paper for which these scripts were developed.
@article{2022A&A...666A.100G,
author = {{G{\'u}rpide}, A. and {Parra}, M. and {Godet}, O. and {Contini}, T. and {Olive}, J. -F.},
title = "{MUSE spectroscopy of the ULX NGC 1313 X-1: A shock-ionised bubble, an X-ray photoionised nebula, and two supernova remnants}",
journal = {\aap},
keywords = {instrumentation: spectrographs, stars: black holes, ISM: jets and outflows, stars: neutron, X-rays: binaries, accretion, accretion disks, Astrophysics - High Energy Astrophysical Phenomena},
year = 2022,
month = oct,
volume = {666},
eid = {A100},
pages = {A100},
doi = {10.1051/0004-6361/202142229},
archivePrefix = {arXiv},
eprint = {2201.09333},
primaryClass = {astro-ph.HE},
adsurl = {https://ui.adsabs.harvard.edu/abs/2022A&A...666A.100G},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}





