WARNING: Doc need to be updated since many major changes. Coming asap.
This is a Python wrapper for the MUSE/VLT pipeline recipes. This runs using the esorex command lines (in parallel, using by default likwid, although other options are available). This wrapper is meant to reduce MUSE OBs automatically, after dumping the fits files in a given folder.
This package includes an alignment module which may be useful, independently given a set of images to align and assuming a reference image is provided. It can spit out an "OFFSET_LIST" MUSE compatible fits table including the flux scaling factors.
pymusepipe is also made for multi-pointing mosaics and multi-targets surveys as it will process targets automatically when provided a specific dictionary of which target and which pointings to consider.
Here are some basic instructions to get you going with pymusepipe.
pymusepipe uses Python 3. It is not compatible with python 2.7. If you are still using python 2.7 I would recommend you to switch asap as it won't be supported much longer anyway.
pymusepipe needs a number of standard modules/packages including:
The convolution package of pymusepipe (allowing full convolution of a datacube) uses pypher which is thus a requirement for that module to work.
This also includes a heavy-based usage of mpdaf, which is a super useful package developed by the MUSE GTO-CRAL Team, to process and analyse datacubes, and more specifically MUSE cubes, images and spectra.
You can install this package via Pypi via a simple:
pip install pymusepipe
You can obviously also install it by cloning it from github, or downloading the source (from github) and do something like:
python setup.py develop
I advise to use the "develop" option as it actually does not copy the files in your system but just create a link. In that way you can easily update the source software without reinstalling it. The link will directly use the source which has been udpated.
The other option is to use the standard "install" option:
python setup.py install
The pymusepipe wrapper is meant to provide the user with a simple way to run the MUSE pipeline.
Only 3 steps are needed: preparing the data (download), preparing the configuration files (templates are provided) which should take a couple of minutes, and using the code (a few lines at most). The package has many other hidden functionalities which I'll document as soon as I can.
I recommend to use Ipython
as an environment, possibly via
a screen
which would allow you to disconnect from the server that
actually runs the commands. Jupyter notebooks may also be very handy
although I would not necessarily recommend them for this specific purpose as
the running of the pipeline may take hours.
The first thing to do is to prepare the folder structure to welcome your MUSE datasets. This is actually rather simple.
Imagine you have
Then under your data root folder
<my_data_folder>/NGC1000
./P01
./Raw
./P02
./Raw
./P03
./Raw
Each pointing/OB has a "Raw" folder.
The next step is to download your MUSE data from the ESO web site, and put all the raw files (fits/fits.gz) into each individual "Raw" folder, associated with the right pointing.
pymusepipe only needs 2 configurations ASCII files: 1 for the calibration (calib_tables.dic) and one for the root folders (rc.dic). Examples of such files are provided in the "config_templates" folder of the pymusepipe package.
The pipeline is meant to be run automatically from a given python structure. This should thus take the user only a few lines of codes, including one to import pymusepipe, a couple to define the names of the configuration files, one to initialise the musepipe python structure, and one to launch the recipes. Here is an example of how this should look:
# Import the modules
import pymusepipe as pmp
from pymusepipe import musepipe
# define the names of the configuration files
rcfile = "/my_data/MUSE/Config/rc.dic"
calfile = "my_data_MUSE/Config/calib_tables.dic"
# Initialisation of the python - MusePipe Class - structure
mypipe = musepipe.MusePipe(targetname="NGCXXXX", pointing=1, rc_filename=rcfile,
cal_filename=calfile, log_filename="NGCXXXX_version01.log",
fakemode=False, overwrite_astropy_table=True,
filter_list="white,Cousins_R",
filter_for_alignment="Cousins_R")
# Launching the pipeline
mypipe.run_recipes()
Some explanation may be needed to understand what is happening:
Other options can be useful:
Details to come.
Here we provide a bit more details about a few issues regarding the configuration files or set up parameters.
It contains 3 lines, with: musecalib, musecalib_time and root.
It contains a series of given fits files which will be used by the pipeline. Most names are self-explantory. That includes:
Most MUSE pipeline recipes are run while run_all_recipes is launched. This can be changed in the prep_recipes_pipe.py or just scripted. Actually run_all_recipes() is just a function which launches (assuming 'mypipe' is your MusePipe structure, see above):
mypipe.run_bias()
mypipe.run_flat()
mypipe.run_wave()
mypipe.run_lsf()
mypipe.run_twilight(illum=illum)
mypipe.run_scibasic_all(illum=illum)
mypipe.run_standard()
mypipe.run_sky(fraction=fraction)
mypipe.run_prep_align()
mypipe.run_align_bypointing()
mypipe.run_align_bygroup()
mypipe.run_scipost()
mypipe.run_scipost(expotype="SKY", offset_list=False, skymethod='none')
mypipe.run_combine_pointing()
where "illum" is a boolean (default is True), fraction is 0.8.
Feel free to launch these steps one by one (the order is important as in any data reduction process).
The structure of the output is driven by a set of folder names described in init_musepipe.py in a few dictionaries (dic_input_folders, dic_folders, dic_folders_target). You can in principle change the names of the folders themselves, but I would advise against that.
The pipeline will create the folder structure automatically, checking whether the folders exist or not.
2 basic log files are spitted out: one is the Esorex output which will be stored in the "Esorex_log" folder. The other one will be in the "Log" folder with the name provided at start: that one is like a shell script which can be used to rerun things directly via the command line. In the "Log" folder, there will also be, for each log file, a file ".out" and one with ".err" extensions, respectively including all the stdout and stderr messages. This may be useful to trace details in the data reduction and problems.
Each recipe will trigger the creation of a astropy Table. These are stored under "Astro_Tables". You can use these to monitor which files have been processed or used.
Most of the information you may need is actually stored in the python "MusePipe" class structure. More details to come.
This project is licensed under the MIT License - see the LICENSE file for details
I would like to thank people who have initially sent me their code-samples, including Bernd Husemann, Dimitri Gadotti, Lodovico Coccato, Mark den Brok. I would also like to specifically and warmly thank Rebecca McElroy who supported me with the MUSE data reduction at the early stages of the development of this package, and Francesco Santoro who has significantly contributed in the testing, debugging of the code (version 1), and proposed dedicated python lines to be integrated in pymusepipe (e.g., alignment module).