Exemple #1
0
def create_yml(image, title):
    """ This function generates a yml file with information.
    Args:
        image:
        title:
    """
    cube = parse_file_label(image.proj.cub)
    label = cube['IsisCube']
    print label
    orbit = label['Archive']['OrbitNumber']
    scale = label['Mapping']['PixelResolution']
    time  = label['Instrument']['StartTime'].replace('T',' ')

    isis.campt(from_=image, to=image.campt)
    label = parse_file_label(image.campt)

    points = label['GroundPoint']
    clon  = points['PositiveEast360Longitude']
    clat  = points['PlanetocentricLatitude']

    data = {
        ':release':    'YYYY-MM-DD 10:00:00.00 +00:00',
        ':title':      title,
        ':timestamp':  '%s +00:00' % time,
        ':orbit':      orbit,
        ':clat':       '%.3f°' % clat,
        ':clon':       '%.3f°' % clon,
        ':resolution': '%.2f m/pixel' % scale['value'],
        ':mode':       'Native',
        ':ptif':       str(image.tif),
        ':thumb':      str(image.png)
    }

    with open(image.yml, 'w') as yaml_file:
        yaml.dump(data, yaml_file, default_flow_style=False)
Exemple #2
0
def fi_yaml(image, **options):
    cube = parse_file_label(image)
    label = cube['IsisCube']
    orbit = label['Archive']['OrbitNumber']
    scale = label['Mapping']['PixelResolution']
    time  = label['Instrument']['StartTime'].replace('T',' ')

    with TempImage(image, 'campt') as campt:
        isis.campt(from_=image, to=campt)
        label = parse_file_label(campt)

    points = label['GroundPoint']
    clon  = points['PositiveEast360Longitude']
    clat  = points['PlanetocentricLatitude']

    data = {
        ':release':    'YYYY-MM-DD 10:00:00.00 +00:00',
        ':title':      title,
        ':timestamp':  '%s +00:00' % time,
        ':orbit':      orbit,
        ':clat':       '%.3f°' % clat,
        ':clon':       '%.3f°' % clon,
        ':resolution': '%.2f m/pixel' % scale['value'],
        ':mode':       'Native',
        ':ptif':       str(image.tif),
        ':thumb':      str(image.png)
    }

    with open(rename(image, '.yml', '.proj.cub'), 'w') as fp:
        yaml.dump(data, fp, default_flow_style=False)
Exemple #3
0
def get_proj_pixel_scale(img_name):
    """
    Args: image filename
    Returns: the pixel_scale
    """
    label = parse_file_label(img_name)
    mapping = label['IsisCube']['Mapping']
    pixel_scale = mapping['PixelResolution']
    
    return pixel_scale['value']
Exemple #4
0
def get_exposure_time(image):
    """
    Exposure time is in units of milliseconds. Images in calibrated DN and need 
    to be divided by exposure time. Exposure time is the same for UV and VIS 
    observations.
    """
    # Get label info
    label = parse_file_label(image)
    instrument = label['IsisCube']['Instrument']
    
    return instrument['ExposureDuration']
Exemple #5
0
def get_sample_line(filename, center_latitude, center_longitude):
    # call mappt to get the sample/line for the clat/clon from the projected image

    isis.mappt(from_=filename, to='sample_line.pvl', append='FALSE', type='ground',
                latitude=center_latitude, longitude=center_longitude)
    label = parse_file_label('sample_line.pvl')
    center_sample = label['Results']['Sample']
    center_line = label['Results']['Line']
    print center_sample
    print center_line

    # call getkey to get the sample/line
    #center_sample = os.popen('getkey from=sample_line.pvl grpname=Results keyword=sample').read()
    #center_line = os.popen('getkey from=sample_line.pvl grpname=Results keyword=line').read()

    return int(iround(center_sample)), int(iround(center_line)) #TODO: round, don't truncate
Exemple #6
0
def get_image_info(image):
    """
    GATHER INFORMATION ABOUT SINGLE OBSERVATION
    BASED ON VIS mosaic only
    """
    # Get label info
    label = parse_file_label(image)
    instrument = label['IsisCube']['Instrument']

    # Get campt info
    output = isis.campt.check_output(from_=image)
    gp = parse_label(GROUP_RE.search(output).group(1))['GroundPoint']

    return pd.Series({
        'start_time':              instrument['StartTime'],
        'exp_time':                instrument['ExposureDuration'],
        'fpa_temp':                instrument['MiddleTemperatureFpa'],
        'subsolar_azimuth':        gp['SubSolarAzimuth'],
        'subsolar_ground_azimuth': gp['SubSolarGroundAzimuth'],
        'solar_distance':          gp['SolarDistance']
    })