Entry-point console scripts

The scubes package includes various entry-point command-line scripts for different tasks. They are: scubes, scubesml, get_lupton_RGB, sex_mask_stars, sex_mask_stars_cube, ml2header and scubes_filters. Scripts with the ml (master list) identificator are optimized to work with information from with a list of objects used as input. The cube suffix will identify scripts which work with a cube produced by scubes or scubesml as input.

All scripts include the --help option for more information.

Right-ascencion and Declination conversion

The input values of RA and DEC will be converted to degrees using the scubes.utilities.io.convert_coord_to_degrees(). All scripts with RA and DEC inputs parse angles in two different units:

  • hourangle: using hms divisors; Ex: 10h37m2.5s

  • degrees: using : or dms divisors; Ex: 10:37:2.5 or 10d37m2.5s

Note that 10h37m2.5s is a totally different angle from 10:37:2.5 (159.26 deg and 10.62 deg respectively).

scubes

 1            if _sex is None:
 2                print_level(f'SExtractor not found')
 3                sys.exit(1)
 4    '''
 5    return args
 6
 7def scubes():
 8    '''
 9    Entry-point function for creating S-PLUS galaxy data cubes (S-CUBES).
10
11    Raises
12    ------
13    SystemExit
14        If SExtractor is not found.
15
16    Returns
17    -------
18    None
19    '''
20    from .core import SCubes
21

scubes is the main script of S-Cubes. It calibrates the zero-points, calculates the fluxes and uncertainties for the 12-band images cropped from S-PLUS observed tiles. The stamps are downloaded from S-PLUS Cloud and the zero-points for the data-release 4 (DR4) are included to the package.

The usage of this script is detailed in How to create a cube.

scubesml

 1    # Retrieve scubes positional arguments
 2    mlcut = args.ml[args.ml['SNAME'] == args.galaxy]
 3    args.tile = mlcut['FIELD'][0]
 4    args.ra = mlcut['RA__deg'][0]
 5    args.dec = mlcut['DEC__deg'][0]
 6    min_size = args.min_size
 7    args.size = max(round(args.size_multiplicator*float(mlcut['SIZE__pix'])/2)*2, min_size)
 8
 9    return args
10
11def scubesml():
12    '''
13    Entry-point function for creating S-PLUS galaxy data cubes (S-CUBES)
14    using the masterlist for the input arguments.
15
16    Raises
17    ------
18    SystemExit
19        If masterlist not found
20
21    Returns
22    -------
23    None
24    '''
25
26    from .core import SCubes
27    from .utilities.utils import ml2header_updheader

scubesml is the same as scubes but gathering the needed input information from a masterlist.

Masterlist is a csv text file in which one could gather information of a list of objects to create cubes. The file must contain at least 5 columns named with the following header and information:

  1. SNAME: A nickname for the object

  2. FIELD: S-PLUS Field (TILE) in which the program will search for the coordinates

  3. RA__deg: Right-ascencion in degrees

  4. DEC__deg: Declination in degrees

  5. SIZE__pix: SIZE of the object in pixels

Masterlist file content example:

SNAME,FIELD,RA__deg,DEC__deg,SIZE__pix
S00001,SPLUS-s24s34,52.08196,-31.06817,53.65902
S00002,SPLUS-s24s35,52.87771,-30.21333,25.898617
(...)

Warning

There are some differences betweeen scubesml and scubes. The former does not have some options available on the latter (e.g. –det_img, –mask_stars, etc). Another difference is that at the end of the execution of the script, scubesml automatically runs the same routines executed by ml2header, including all the masterlist information to the primary header of the cube. Moreover, the size of the object (scubes option –size) is created using the option –size_multiplicator. The size will be:

\[S = S_{mult} \times R_{50}\ \mathrm{[pix]}\]

Entry-point console scubesml call example:

scubesml --w workdir --size_multiplicator 10 -- MY_OBJECT /path/to/my_masterlist.csv

get_lupton_RGB

 1def get_lupton_RGB():
 2    '''
 3    Entry-point function for downloading S-PLUS RGB images.
 4
 5    Returns
 6    -------
 7    None
 8    '''
 9    from .splusdata import connect_splus_cloud
10
11    parser = create_parser(args_dict=GET_LUPTON_RGB_ARGS, program_description=GET_LUPTON_RGB_DESC)
12    args = get_lupton_RGB_argsparse(parser.parse_args(args=sys.argv[1:]))
13    conn = connect_splus_cloud(args.username, args.password)
14    _get_lupton_RGB(conn, args)

This script will generate a Lupton RGB for the coordinates and size required by the user. The imagem will be generated and downloaded from the S-PLUS Cloud server.

get_lupton_RGB -l 1500 -g NGC1365 -- SPLUS-s28s33 53.40004798 -36.14143008

sex_mask_stars

 1        for name in _SExtr_names:
 2            _sex = which(name)
 3            if _sex is None:
 4                print_level(f'{name}: SExtractor exec not found', 2, args.verbose)
 5            else:
 6                print_level(f'{name}: SExtractor found. Forcing --sextractor={_sex}', 1, args.verbose)
 7                args.sextractor = _sex
 8                pass
 9        if _sex is None:
10            print_level(f'SExtractor not found')
11            sys.exit(1)
12
13    for key, value in args.__dict__.items():
14        print_level(f'control obj - key: {key} - value: {value}', 2, args.verbose)
15
16    args.header = fits.getheader(args.cube_path, 0)
17    h = args.header
18    args.ra, args.dec = convert_coord_to_degrees(h['RA'], h['DEC'])
19    args.size = int(h['SIZE'])
20    args.bands = BANDS
21    args.tile = h['TILE']
22    args.galaxy = h['GALAXY']
23
24    return args
25
26def scube_sex_mask_stars():
27    '''
28    Uses S-PLUS detection image and SExtractor to identify stars on the FOV.
29    This entry-point script uses a S-Cube as input to gather the needed 
30    information to the retrieve the correct detection image stamp.
31
32    Raises
33    ------
34    SystemExit
35        If the detection file exists.
36
37    Returns
38    -------
39    None
40    '''
41    from ..mask_stars import maskStars
42    from ..headers import get_author
43    
44    from .splusdata import connect_splus_cloud, detection_image_hdul

sex_mask_stars scripts uses SExtractor in order to create a spatial mask of stars, attempting to remove the areas enclosed by the brightest ones along the FOV. This script implements the –mask_stars option of the scubes.

sex_mask_stars --back_size 256 --class_star 0.4 -l 1500 -g NGC1365 -- SPLUS-s28s33 53.40004798 -36.14143008

sex_mask_stars_cube

 1
 2    Parameters
 3    ----------
 4    cube_filename : str
 5        Path to S-CUBES raw cube.
 6    
 7    ml_table : :class:`astropy.table.table.Table`
 8        Masterlist read using :meth:`astropy.io.ascii.read`
 9        
10    force : bool, optional
11        Force the update the key value is the key is existent at the 
12        S-CUBES header. 
13    '''
14    import numpy as np
15
16    with fits.open(cube_filename, 'update') as hdul:
17        hdu = hdul['PRIMARY']
18
19        # SNAME CONTROL
20        sname = hdu.header.get('GALAXY', None)
21        if sname is None:
22            print_level('header: missing SNAME information')
23            sys.exit(1)
24        if sname not in ml_table['SNAME']:
25            print_level(f'masterlist: {sname}: missing SNAME information')
26            sys.exit(1)
27
28        mlcut = ml_table[ml_table['SNAME'] == sname]
29        for col in ml_table.colnames:
30            v = mlcut[col][0]
31            desc = None
32            if v is np.ma.masked:
33                v = None
34            if '__' in col:
35                col, desc = col.split('__')
36            if not force and (col in hdu.header):
37                continue 
38            if col == 'FIELD' or col == 'SNAME':
39                continue
40            if col == 'SIZE':
41                col = 'SIZE_ML'
42                desc = 'SIZE masterlist'
43            hdu.header.set(col, value=v, comment=desc)
44

The same as sex_mask_stars but gathering the required information to run from a cube generated by scubes or scubesml.

sex_mask_stars_cube -p 0.3 -B 256 MYGALAXY_cube.fits

ml2header

 1    ofile = f'{splots.scube.galaxy}_sky_spec_iso{il}med{im}.png'
 2    splots.sky_spec_plot(sky, output_filename=ofile)
 3
 4    #######################################
 5    ################# RGBs ################
 6    #######################################
 7    rgblist = [
 8        [9, 7, 5],
 9        [8, 7, 5],
10        [8, 9, 0],
11        [11, 5, 0],
12        [9, [3, 4, 5], [0, 1, 2]],
13        [8, 9, 5],
14        [8, 5, [0, 1, 2, 3, 4]]
15    ] 
16    titlelist = [
17        '(i, r, g)',
18        '(J0660, r, g)',
19        '(J0660, i, u)',
20        '(z, g, u)',
21        '(i, J0410+J0430+g, u+J0378+J0395)',
22        '(J0660, i, g)',

This script will add all masterlist information to the primary header of a S-CUBES original cube.

ml2header /path/to/MYGALAXY_cube.fits /path/to/my_masterlist.csv

scubes_filters

 1{SPLUS_MOTD_SEP} + 
 2
 3   {__author__}
 4'''
 5
 6SCUBES_FILTERS_ARGS = {
 7    # optional arguments
 8    'decimals': ['d', dict(default=99, type=int, help='Format the numbers at the table.')],
 9}
10
11def scubes_filters():
12    '''
13    Print the S-PLUS filters information.
14
15    Raises
16    ------
17    SystemExit
18        If masterlist not found
19
20    Returns
21    -------
22    None
23    '''

This script prints the S-PLUS filters information table formatted with the required number of decimals.

scubes_filters --decimals 2