Esempio n. 1
0
def load_ipython_extension(ipython):
    # The `ipython` argument is the currently active `InteractiveShell`
    # instance, which can be used in any way. This allows you to register
    # new magics or aliases, for example.
    lu.config("console", console_lvl = "info", file_name = None)
    #log = lu.get_logger("__notebook__")
    lu.change_level("INFO")
    #ipython.register_magic_function(recipe_magic, magic_kind = "cell", magic_name = "recipe")
    recmag = RecipeMagics(ipython)
    ipython.register_magics(recmag)
Esempio n. 2
0
def load_ipython_extension(ipython):
    # The `ipython` argument is the currently active `InteractiveShell`
    # instance, which can be used in any way. This allows you to register
    # new magics or aliases, for example.
    lu.config("console", console_lvl="info", file_name=None)
    #log = lu.get_logger("__notebook__")
    lu.change_level("INFO")
    #ipython.register_magic_function(recipe_magic, magic_kind = "cell", magic_name = "recipe")
    recmag = RecipeMagics(ipython)
    ipython.register_magics(recmag)
Esempio n. 3
0
parser = parseUtils.buildNewParser(__version__)
args   = parser.parse_args()
try: assert(args.astrotype)
except AssertionError: print "WARN:\tNo astrotype passed."
try: assert(args.files)
except AssertionError: print "WARN:\tNo files specified on command line."

from astrodata.adutils import logutils

# Configure logging, then instantiate the log
if args.recipename == "USER":
    args.loglevel = "fullinfo"

logutils.config(mode=args.logmode,
                console_lvl=args.loglevel,
                file_name=args.logfile)

log = logutils.get_logger(__name__)

try:
    allinputs = parseUtils.command_line(parser,args, log)
    print "POST All parsing ..."
    if args.displayflags:
        parseUtils.show_parser_options(parser,args)
    for inf in allinputs: print "Input fits file:\t",inf
except SystemExit:
    log.error("SYSTEM EXIT: see log for more information")
    raise
# ----------------------------- end parseUtils ------------------------------- #
Esempio n. 4
0
    def __init__(self, ad, mosaic_ad_function, ref_extname='SCI',
                 column_names='default',dq_planes=False):
        """
          
         Parameters
         ----------
 
          :param ad: Input Astrodata object

          :param mosaic_ad_function: 
              Is a user supplied function that will act as an interface
              to the particular ad, e.g., knows which keywords represent
              the coordinate systems to use and whether they are binned
              or not, or which values in the geometry look up table
              require to be binned. 
              For help of this function please see its description
              in the mosaic.py module.

          :type mosaic_ad_function: 
              A required user function returning a MosaicData
              and a MosaicGeometry objects.

          :param ref_extname:
              Is the IMAGE EXTNAME that should be used as the primary
              reference when reading the ad data arrays.
          :type ref_extname: string. Default is 'SCI'.

          :param column_names: 
              Dictionary with bintable extension names that are associates
              with input images. The extension name is the key with value
              a tuple: (X_pixel_columnName, Y_pixel_columnName, 
              RA_degrees_columnName, DEC_degrees_columnName)
              Example:
               column_names = {'OBJCAT': ('Xpix', 'Ypix', 'RA', 'DEC'),
                               'REFCAT': (None, None, 'RaRef', 'DecRef')}

          :param dq_planes: 
              (False). Boolean flag to transform bit_plane by bit_plane
              for rotation, shifting and scaling. At this the algorithmm 
              has a bad performance. Default value is False.

        """

        # Instantiate the log
        logutils.config(mode='debug', console_lvl='stdinfo',file_name='mosaic.log') 
        self.log = logutils.get_logger(__name__)

        self.log.debug("******* Debug.STARTING MosaicAD **********")
        self.log.info( "******* INFO.STARTING MosaicAD ***********")

        # Make sure we have the default extension name in the input AD.
        if ad[ref_extname] == None:
            raise ValueError("Extension name: '"+ref_extname+"' not found.")

        self.ad = ad

        # The input file ougth to have more than one extension to mosaic.
        if ad.count_exts(ref_extname) <= 1:
            raise ValueError("Nothing to mosaic. Input file has 1 extension.")
            
        # Execute the input user function.
        mosaic_data, geometry = mosaic_ad_function(ad,ref_extname)

        self.ref_extname = ref_extname
        self.extnames = None                 # All extensions names in AD 
        self.im_extnames = None              # All IMAGE extensions names in AD 
        self.tab_extnames = None             # All BINTABLE extensions names in AD 
        self.get_extnames()                  # Form extnames, im_extnames, 
                                             # tab_extnames.
        self.dq_planes = dq_planes           # (False) Input parameter
                                             # Transform bit_plane byt bit_plane
        self.mosaic_data_array = {}          # attribute to reference 
                                             # numpy array by extension.
                                             # Set by method set_mosaic_data() 

        # Instantiate the Base class
        Mosaic.__init__(self,mosaic_data,geometry)  

        # Internal attribute to be used when loading data from another
        # extension name.
        #
        self.__current_extname = ref_extname

        # These are the default column names for merging catalogs.
        if column_names == 'default':
            self.column_names = \
                 {'OBJCAT': ('X_IMAGE', 'Y_IMAGE', 'X_WORLD', 'Y_WORLD'),
                  'REFCAT': (None, None, 'RAJ2000', 'DEJ2000') }
        else:
            self.column_names = column_names

        self.jfactor = []               # Jacobian factors applied to the 
                                        # interpolated pixels to conserve flux.

        self.calculate_jfactor()        # Fill out the jfactor list with the
                                        # jacobian of the transformation matrix.
                                        #  See transformation()

        self.associated_tab_extns = []  # List of binary extension names that
                                        # have the same number and values of 
                                        # extvers as the reference extension name.

        self.associated_im_extns = []   # List of image extension names that 
                                        # have the same number and values of 
                                        # extvers as the reference extension name.

        self.non_associated_extns = []  # List of remaining extension names that
                                        # are not in the above 2 lists.

        self.make_associations()    # Look for associations between image extension