Esempio n. 1
0
    def test_additional_options_callback(self):

        parser = customparser.get_parser(None)
        parser.add_option('-o', action = 'callback', type = 'str',
                          dest = 'parsed_options', default = {},
                          callback = customparser.additional_options_callback)

        arguments = ['-o', '-v',
                     '-o', '--batch',
                     '-o', '-r=2',
                     '-o', '--sigma 3',
                     '-o=-h',
                     '-o=--invert',
                     '-o=-d=cubic',
                     '-o=--no-verify = True']

        (options, args) = parser.parse_args(args = arguments)
        options = options.parsed_options
        self.assertIsNone(options['-v'])
        self.assertIsNone(options['--batch'])
        self.assertEqual (options['-r'], '2')
        self.assertEqual (options['--sigma'], '3')
        self.assertIsNone(options['-h'])
        self.assertIsNone(options['--invert'])
        self.assertEqual (options['-d'], 'cubic')
        self.assertEqual (options['--no-verify'], 'True')
Esempio n. 2
0
    def test_additional_options_callback(self):

        parser = customparser.get_parser(None)
        parser.add_option('-o',
                          action='callback',
                          type='str',
                          dest='parsed_options',
                          default={},
                          callback=customparser.additional_options_callback)

        arguments = [
            '-o', '-v', '-o', '--batch', '-o', '-r=2', '-o', '--sigma 3',
            '-o=-h', '-o=--invert', '-o=-d=cubic', '-o=--no-verify = True'
        ]

        (options, args) = parser.parse_args(args=arguments)
        options = options.parsed_options
        self.assertIsNone(options['-v'])
        self.assertIsNone(options['--batch'])
        self.assertEqual(options['-r'], '2')
        self.assertEqual(options['--sigma'], '3')
        self.assertIsNone(options['-h'])
        self.assertIsNone(options['--invert'])
        self.assertEqual(options['-d'], 'cubic')
        self.assertEqual(options['--no-verify'], 'True')
Esempio n. 3
0
    def test_additional_options_callback(self):

        parser = customparser.get_parser(None)
        parser.add_option(
            "-o",
            action="callback",
            type="str",
            dest="parsed_options",
            default={},
            callback=customparser.additional_options_callback,
        )

        arguments = [
            "-o",
            "-v",
            "-o",
            "--batch",
            "-o",
            "-r=2",
            "-o",
            "--sigma 3",
            "-o=-h",
            "-o=--invert",
            "-o=-d=cubic",
            "-o=--no-verify = True",
        ]

        (options, args) = parser.parse_args(args=arguments)
        options = options.parsed_options
        self.assertIsNone(options["-v"])
        self.assertIsNone(options["--batch"])
        self.assertEqual(options["-r"], "2")
        self.assertEqual(options["--sigma"], "3")
        self.assertIsNone(options["-h"])
        self.assertIsNone(options["--invert"])
        self.assertEqual(options["-d"], "cubic")
        self.assertEqual(options["--no-verify"], "True")
Esempio n. 4
0
    logging.debug("%s: updating header of output image (%s)" % debug_args)
    msg1 = "Astrometry done via LEMON on %s" % methods.utctime()
    msg2 = "[Astrometry] WCS solution found by Astrometry.net"
    msg3 = "[Astrometry] Original image: %s" % img.path

    output_img.add_history(msg1)
    output_img.add_history(msg2)
    output_img.add_history(msg3)
    logging.debug("%s: header of output image (%s) updated" % debug_args)

    queue.put(output_img.path)
    msg = "{0}: astrometry result ({1!r}) put into global queue"
    logging.debug(msg.format(*debug_args))


parser = customparser.get_parser(description)
parser.usage = "%prog [OPTION]... INPUT_IMGS... OUTPUT_DIR"

parser.add_option('--radius', action = 'store', type = 'float',
                  dest = 'radius', default = 1,
                  help = "only search in indexes within this number of "
                  "degrees of the field center, whose coordinates are read "
                  "from the FITS header of each image (see --rak and --deck). "
                  "In case these keywords cannot be read or contain invalid "
                  "values, the image is solved blindly, as if the --blind "
                  "option had been used. [default: %default]")

parser.add_option('--blind', action = 'store_true', dest = 'blind',
                  help = "ignore --radius, --rak and --deck and solve the "
                  "images blindly. A necessity in case the FITS headers of "
                  "your data have no information about the telescope "
Esempio n. 5
0
import optparse
import os
import os.path
import shutil
import sys
import tempfile

# LEMON modules
import customparser
import defaults
import fitsimage
import keywords
import methods
import style

parser = customparser.get_parser(description)
parser.usage = "%prog [OPTION]... INPUT_IMGS... OUTPUT_IMG"

parser.add_option('--overwrite', action = 'store_true', dest = 'overwrite',
                  help = "overwrite output image if it already exists")

parser.add_option('--background-match', action = 'store_true',
                  dest = 'background_match',
                  help = "include a background-matching step, thus removing "
                  "any discrepancies in brightness or background. Note that, "
                  "although an amazing feature of Montage, this makes the "
                  "assembling of the images take remarkably longer.")

parser.add_option('--no-reprojection', action = 'store_false',
                  dest = 'reproject', default = True,
                  help = "do not reproject the mosaic so that North is up.")
Esempio n. 6
0
call_dict = {
    0: lambda x: None,
    1: lambda x: None,
    2: lambda x: None,
    3: lambda x: print(x[0]),
    4: lambda x: term(x),
    5: lambda x: term_termtail(x),
    6: lambda x: ['+', 0],
    7: lambda x: factor_factortail(x),
    8: lambda x: factor_tail(x),
    9: lambda x: ['*', 1],
    10: lambda x: x[1],
    11: lambda x: x[0],
    12: lambda x: int(x[0]),
    13: lambda x: x[0],
    14: lambda x: x[0],
    15: lambda x: x[0],
    16: lambda x: x[0]
}
grammar = ""
with open('./test/calc.px', 'r') as f:
    grammar = f.read()

calc.lexer.tokens = calc.tokens
parse_obj = customparser.get_parser(grammar, call_dict, calc.lexer)

while True:
    calc.lexer.input(input())
    parse_obj.do_parse()