Ejemplo n.º 1
0
def test_file_variations():
    result = file_variations('image.IMG', ['.cub', '.cal.cub'])
    assert len(result) == 2
    assert result[0] == 'image.cub'
    assert result[1] == 'image.cal.cub'

    result = file_variations('foo/image', ['.TIFF'])
    assert len(result) == 1
    assert result[0] == 'foo/image.TIFF'
Ejemplo n.º 2
0
def main():
    images = iglob('*.IMG')
    
    isis.maptemplate(map='D_mdis_wac_eqr.map', projection='equirectangular',
        clon=0.0, clat=0.0, resopt='mpp', resolution=1000, rngopt='user', 
        minlat=-40.0, maxlat=40.0, minlon=0.0, maxlon=360.0)

    for img_name in images:
        (cub_name, cal_name, pho_name, trim_name, proj_name) = file_variations(img_name,
                        ['.cub', '.cal.cub', '.pho.cub', '.trim.cub', '.proj.cub'])
        #basic_img_proc(img_name)
        isis.photomet(from_=cal_name, to=pho_name, PHTNAME='HAPKEHEN', 
            Wh=0.215984749, Hh=0.075, B0=2.3, Theta=15.78892162,
            HG1=0.206649235, HG2=0.811417942, zerob0standard='false',
            NORMNAME='Albedo', Incref=30.0, Thresh=10E30, Incmat=0.0, Albedo=1.0)
        isis.trim(from_=pho_name, to=trim_name, left=10)
        isis.cam2map(from_=trim_name, to=proj_name, pixres='map', 
                     map='D_mdis_wac_eqr.map', defaultrange='map')

    # sort by resolution: output is .proj.cub
    images = iglob('*.trim.cub')
    sorted_images = sort_images(images, get_pixel_scale, reverse=True)
    
    ext_len = -len('.trim.cub')
    sorted_images = [img_name[:ext_len] + '.proj.cub'
                        for img_name in sorted_images]

    write_file_list('mosaic.list', sorted_images)
    isis.automos(fromlist='mosaic.list', mosaic=mosaic_name)
Ejemplo n.º 3
0
def calibrate_many(images):
    images = [[img_name, ] + file_variations(img_name, ['.cub', '.cal.cub',
                                                        '.map.cal.cub'])
              for img_name in images]

    with IsisPool() as isis_pool:
        for img_name, cub_name, cal_name, map_name in images:
            isis_pool.ciss2isis(from_=img_name, to=cub_name)

    return images
Ejemplo n.º 4
0
def calibrate_many(images):
    images = [
        [img_name] + file_variations(img_name, [".cub", ".cal.cub", ".map.cal.cub"])
        for img_name in images
    ]

    with IsisPool() as isis_pool:
        for img_name, cub_name, cal_name, map_name in images:
            isis_pool.ciss2isis(from_=img_name, to=cub_name)

    return images
Ejemplo n.º 5
0
def calib_to_isis(pm_or_path):
    try:
        img_name = str(pm_or_path.calib_label)
    except AttributeError:
        img_name = str(pm_or_path)
    (cub_name,) = file_variations(img_name, ['.cub'])
    try:
        ciss2isis(from_=img_name, to=cub_name)
    except ProcessError as e:
        print("STDOUT:", e.stdout)
        print("STDERR:", e.stderr)
        return
    return cub_name
Ejemplo n.º 6
0
def create_mapfile(img_name):
    """ Create a mapfile in isis from a LROC NAC

    Args: img_name

    """
    (cub_name, trim_name) = file_variations(img_name,
            ['.cub', '.trim.cub'])
    isis.lronac2isis(from_=img_name, to=cub_name)
    isis.spiceinit(from_=cub_name)
    isis.trim(from_=cal_name, to=trim_name, left=45, right=45)

    write_file_list('map.lis', trim_name)
    isis.mosrange(fromlist='map.lis', to=img_name+'.map', precision=2,
        projection='equirectangular')
Ejemplo n.º 7
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
Ejemplo n.º 8
0
def remapping(img_name):
    (cal_name, map_name) = file_variations(img_name,
                                           ['.cal.cub', '.map.cal.cub'])
    print("Mapping", cal_name, "to", map_name)
    mapfname = pjoin(io.HOME, 'data', 'ciss', 'opus', 'ringcylindrical.map')
    ringscam2map(from_=cal_name, to=map_name, map=mapfname, pixres='map')
Ejemplo n.º 9
0
def basic_img_proc(img_name):
    (cub_name, cal_name) = file_variations(img_name, ['.cub', '.cal.cub'])
    isis.mdis2isis(from_=img_name, to=cub_name, target='MERCURY')
    isis.spiceinit(from_=cub_name)
    isis.mdiscal(from_=cub_name, to=cal_name)