Skip to content

ingestimages.py

Command

Bases: BaseCommand

This script runs the first part of the pipeline only. It ingests a set of images into the database along with their measurements.

Source code in vast_pipeline/management/commands/ingestimages.py
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
class Command(BaseCommand):
    """
    This script runs the first part of the pipeline only. It ingests a set of
    images into the database along with their measurements.
    """
    help = (
        'Ingest/add a set of images to the database'
    )

    def add_arguments(self, parser: ArgumentParser) -> None:
        """
        Enables arguments for the command.

        Args:
            parser (ArgumentParser): The parser object of the command.

        Returns:
            None
        """
        parser.add_argument(
            'image_ingest_config',
            nargs=1,
            type=str,
            help=('Image ingestion configuration filename/path.')
        )

    def handle(self, *args, **options) -> None:
        """
        Handle function of the command.

        Args:
            *args: Variable length argument list.
            **options: Variable length options.

        Returns:
            None
        """
        # configure logging
        if options['verbosity'] > 1:
            # set root logger to use the DEBUG level
            root_logger = logging.getLogger('')
            root_logger.setLevel(logging.DEBUG)
            # set the traceback on
            options['traceback'] = True

        # Create image ingestion configuration object from input file
        image_config = ImageIngestConfig.from_file(
            options['image_ingest_config'][0], validate=False
        )

        # Validate the config
        try:
            image_config.validate()
        except PipelineConfigError as e:
            raise CommandError(e)

        if image_config.image_opts()['condon_errors']:
            logger.warning(
                "You have selected condon_errors=True. "
                "Using the Condon uncertainties will overwrite those provide "
                "by the input catalogue and should not be used if you have "
                "applied any corrections to the input catalogues, or if you "
                "trust their uncertainties."
                )
            logger.warning(
                "The Condon uncertainties only account for the statistical "
                "component of the uncertainty - any systematic uncertainty"
                "should be taken into account using the ra_uncertainty and "
                "dec_uncertainty parameters in the config file."
                )
        # Create a dummy Pipeline instance using the given image ingestion configuration options
        d = _DummyPipeline(image_config)

        # Read, measure and upload the images listed in the image ingestion config
        make_upload_images(d.img_paths,image_config.image_opts())

add_arguments(parser)

Enables arguments for the command.

Parameters:

Name Type Description Default
parser ArgumentParser

The parser object of the command.

required

Returns:

Type Description
None

None

Source code in vast_pipeline/management/commands/ingestimages.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def add_arguments(self, parser: ArgumentParser) -> None:
    """
    Enables arguments for the command.

    Args:
        parser (ArgumentParser): The parser object of the command.

    Returns:
        None
    """
    parser.add_argument(
        'image_ingest_config',
        nargs=1,
        type=str,
        help=('Image ingestion configuration filename/path.')
    )

handle(*args, **options)

Handle function of the command.

Parameters:

Name Type Description Default
*args

Variable length argument list.

()
**options

Variable length options.

{}

Returns:

Type Description
None

None

Source code in vast_pipeline/management/commands/ingestimages.py
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def handle(self, *args, **options) -> None:
    """
    Handle function of the command.

    Args:
        *args: Variable length argument list.
        **options: Variable length options.

    Returns:
        None
    """
    # configure logging
    if options['verbosity'] > 1:
        # set root logger to use the DEBUG level
        root_logger = logging.getLogger('')
        root_logger.setLevel(logging.DEBUG)
        # set the traceback on
        options['traceback'] = True

    # Create image ingestion configuration object from input file
    image_config = ImageIngestConfig.from_file(
        options['image_ingest_config'][0], validate=False
    )

    # Validate the config
    try:
        image_config.validate()
    except PipelineConfigError as e:
        raise CommandError(e)

    if image_config.image_opts()['condon_errors']:
        logger.warning(
            "You have selected condon_errors=True. "
            "Using the Condon uncertainties will overwrite those provide "
            "by the input catalogue and should not be used if you have "
            "applied any corrections to the input catalogues, or if you "
            "trust their uncertainties."
            )
        logger.warning(
            "The Condon uncertainties only account for the statistical "
            "component of the uncertainty - any systematic uncertainty"
            "should be taken into account using the ra_uncertainty and "
            "dec_uncertainty parameters in the config file."
            )
    # Create a dummy Pipeline instance using the given image ingestion configuration options
    d = _DummyPipeline(image_config)

    # Read, measure and upload the images listed in the image ingestion config
    make_upload_images(d.img_paths,image_config.image_opts())