示例#1
0
def process_frames(frames, color, name, model, feature): 
    '''
    Processes WAC frames (uv or vis) into regionally constrained images
    LROWACCAL calibrates pixels to DN
    '''
    subname = name+'.'+color
    mapname = feature+'.map'

    for frame in frames:
        isis.spiceinit(from_='+frame+', 
                       spksmithed='true', 
                       shape='user', 
                       model=model
                       )
        isis.lrowaccal(from_='+frame+',
                       to='+frame+'.cal,
                       RADIOMETRIC=FALSE
                       )
        isis.cam2map(from_='+frame+'.cal,
                     to='+frame+'.proj,
                     map=mapname,
                     matchmap=true
                     )

    create_mosaic(subname)
示例#2
0
    def spiceinit(self):
        """Perform either normal spiceinit or one for ringdata.

        Note how Python name-spacing can distinguish between the method
        and the function with the same name. `spiceinit` from the outer
        namespace is the one imported from pysis.
        """
        shape = "ringplane" if self.is_ring_data else None
        spiceinit(from_=self.pm.raw_cub, cksmithed="yes", spksmithed="yes", shape=shape)
        logger.info("spiceinit done.")
示例#3
0
def preprocess_for_davinci(image, outcube, kernel):
    """
    Run spiceinit and campt to determine incidence and local time.  These
    parameters are required by the davinci pipeline in order to
    determine whether or not deplaid should be run.
    """
    isis.thm2isis(from_=image, to=outcube)
    if kernel is not None:
        isis.spiceinit(from_=outcube, ck=kernel)
    else:
        isis.spiceinit(from_=outcube)
示例#4
0
def spice(image, model):
    """
    Args:
        image: image filename
        model: full path to dtm model name
    """
    isis.spiceinit(
        from_      = image,
        spksmithed = True,
        shape      = 'user',
        model      = model
    )
示例#5
0
def process_ctx(ctx, src, dst):
    IMG = src + '/' + ctx + '.IMG'
    CUB = ctx + '.cub'
    CALCUB = ctx + '.cal.cub'
    TIFF = dst + '/' + ctx + '.tif'  # Directory must already exist!

    mroctx2isis(from_=IMG, to=CUB)
    spiceinit(from_=CUB)
    ctxcal(from_=CUB, to=CALCUB)
    isis2std(from_=CALCUB, to=TIFF, format_='TIFF')

    os.remove(CUB)
    os.remove(CALCUB)
示例#6
0
def nocal_hi(source_product):
    """Import HiRISE product into ISIS and spice-init it.

    Parameters
    ----------
    source_product : hirise_tools.SOURCE_PRODUCT_ID
        Class object managing the precise filenames and locations for HiRISE source products
    """
    logger.info("hi2isis and spiceinit for %s", source_product)
    img_name = source_product.local_path
    cub_name = source_product.local_cube
    try:
        hi2isis(from_=str(img_name), to=str(cub_name))
        spiceinit(from_=str(cub_name))
    except ProcessError as e:
        logger.error("Error in nocal_hi. STDOUT: %s", e.stdout)
        logger.error("STDERR: %s", e.stderr)
        return
示例#7
0
def nocal_hi(source_product):
    """Import HiRISE product into ISIS and spice-init it.

    Parameters
    ----------
    source_product : hirise_tools.SOURCE_PRODUCT_ID
        Class object managing the precise filenames and locations for HiRISE source products
    """
    logger.info("hi2isis and spiceinit for %s", source_product)
    img_name = source_product.local_path
    cub_name = source_product.local_cube
    try:
        hi2isis(from_=str(img_name), to=str(cub_name))
        spiceinit(from_=str(cub_name))
    except ProcessError as e:
        logger.error("Error in nocal_hi. STDOUT: %s", e.stdout)
        logger.error("STDERR: %s", e.stderr)
        return
示例#8
0
文件: utils.py 项目: Kelvinrr/bayleef
def init(outfile, additional_kernels={}):
    try:
        logger.info("Running Spiceinit on {}".format(outfile))
        spiceinit(from_=outfile, spksmithed=True, **additional_kernels)
    except ProcessError as e:
        logger.error('file: {}'.format(outfile))
        logger.error("STDOUT: {}".format(e.stdout.decode('utf-8')))
        logger.error("STDERR: {}".format(e.stderr.decode('utf-8')))
        raise Exception('Spice Init Error')

    try:
        logger.info("Running Footprintinit on {}".format(outfile))
        footprintinit(from_=outfile)
    except ProcessError as e:
        logger.error('file: {}'.format(outfile))
        logger.error("STDOUT: {}".format(e.stdout.decode('utf-8')))
        logger.error("STDERR: {}".format(e.stderr.decode('utf-8')))
        raise Exception('Footprint Init Error')
示例#9
0
def process_image(image, title, caption):
    image = ImageName(splitext(image)[0])
    
    isis.lronac2isis.print_cmd(from_=image.IMG, to=image.cub)
    isis.lronac2isis(from_=image.IMG, to=image.cub)
    isis.spiceinit(from_=image.cub)

    #lronaccal default is IOF calibration
    isis.lronaccal(from_=image.cub, to=image.cal.cub)
    isis.trim(from_=image.cal.cub, to=image.trim.cub, left=45, right=45)

    write_file_list(image.map.lis, [image.trim.cub])
    isis.mosrange(fromlist=image.map.lis, to=image.nac_eqr.map,
                  precision=2, projection='equirectangular')

    isis.cam2map(from_=image.trim.cub, to=image.proj.cub,
                 pixres='map', map=image.nac_eqr.map)

    create_yml(image, title)
    create_caption(image, caption)
示例#10
0
def postprocess_for_davinci(incube, kernel=None, latlon_bounds=[]):
    #Processing the temperature to a level2 image
    if kernel:
        try:
            isis.spiceinit(from_=incube, ck=kernel)
        except ProcessError as e:
            print(e.stderr)
    else:
        try:
            isis.spiceinit(from_=incube)
        except ProcessError as e:
            print(e.stderr)
    workingpath, fname = os.path.split(incube)
    fname = os.path.splitext(fname)[0]
    isiscube = os.path.join(workingpath, '{}_proj.cub'.format(fname))
    try:
        isis.cam2map(from_=incube,
                     to=isiscube,
                     map='$base/templates/maps/simplecylindrical.map')
    except ProcessError as e:
        print(e.stderr)
    isis_cropped_cube = os.path.join(workingpath,
                                     '{}_proj_cropped.cub'.format(fname))
    if latlon_bounds:
        try:
            isis.maptrim(from_=isiscube,
                         to=isis_cropped_cube,
                         minlat=latlon_bounds[0],
                         maxlat=latlon_bounds[1],
                         minlon=latlon_bounds[2],
                         maxlon=latlon_bounds[3],
                         mode='CROP')
            isiscube = isis_cropped_cube
        except ProcessError as e:
            print(e.stderr)
    return isiscube
示例#11
0
def calibrate_ciss(img_name, ringdata=True, map_project=False):
    """
    Calibrate raw Cassini ISS images using ISIS.

    ISIS is using an official released version the calibration routine `cisscal`
    that is being developed under IDL, but has been converted to C++ for ISIS.
    I am using the pipeline as described here:
    https://isis.astrogeology.usgs.gov/IsisWorkshop/index.php/Working_with_Cassini_ISS_Data
    It is customary to indicate the pipeline of ISIS apps that a file went through
    with a chain of extensions, e.g. '.cal.dst.map.cub', indicating calibration, destriping,
    and map projection.

    Parameters
    ----------
    img_name : pathlib.Path, str
        Absolute path to image

    Returns
    -------
    str : absolute path to map-projected ISIS cube.
    """
    # Check if img_name is maybe a PathManager object with a `raw_label` attribute:
    try:
        img_name = str(img_name.raw_label)
    except AttributeError:
        # doesn't seem to be the case, so I assume it's just a path
        img_name = str(img_name)
    (cub_name,
     cal_name,
     dst_name,
     map_name) = file_variations(img_name,
                                 ['.cub',
                                  '.cal.cub',
                                  '.cal.dst.cub',
                                  '.cal.dst.map.cub'])
    ciss2isis(from_=img_name, to=cub_name)
    logging.info("Import to ISIS done.")
    targetname = getkey(from_=cub_name,
                        grp='instrument',
                        keyword='targetname')
    # forcing the target name to Saturn here, because some observations of
    # the rings have moons as a target, but then the standard map projection
    # onto the Saturn ring plane fails.
    # see also
    # https://isis.astrogeology.usgs.gov/IsisSupport/index.php/topic,3922.0.html
    if targetname.lower() != 'saturn':
        editlab(from_=cub_name, options='modkey',
                keyword='TargetName', value='Saturn',
                grpname='Instrument')

    # perform either normal spiceinit or one for ringdata
    if ringdata is True:
        spiceinit(from_=cub_name, cksmithed='yes', spksmithed='yes',
                  shape='ringplane')
    else:
        spiceinit(from_=cub_name, cksmithed='yes', spksmithed='yes')
    logging.info("spiceinit done.")
    cisscal(from_=cub_name, to=cal_name, units='I/F')
    logging.info('cisscal done.')
    dstripe(from_=cal_name, to=dst_name, mode='horizontal')
    logging.info('Destriping done.')
    if map_project:
        ringscam2map(from_=dst_name, to=map_name, defaultrange='Camera',
                     map=ISISDATA / 'base/templates/maps/ringcylindrical.map')
        isis2std(from_=map_name, to=map_name[:-3]+'tif', format='tiff')
        logging.info('Map projecting done. Function finished.')
    else:
        isis2std(from_=dst_name, to=dst_name[:-3]+'tif', format='tiff',
                 minpercent=0, maxpercent=100)
        logging.warning('Map projection was skipped, set map_project to True if wanted.')
    return map_name
示例#12
0
def spiceinit(image, **options):
    isis.spiceinit(from_=image)