def parse_jpl_cgi(data):
    '''
    Parses the relevant information from the cgi output.
    '''
    check_type(data, str)
    output = {}
    soe_switch = False
    data = data.split('\n')
    for line in data:
        if line == '$$EOE':
            break
        if soe_switch:
            line = line.split(',')
            line = [item.strip() for item in line if item != ',']
            output['date'] = line[0]
            output['jpl_ra'] = line[3].replace(' ',':')
            output['jpl_dec'] = line[4].replace(' ',':')
            output['jpl_ra_apparent'] = line[5].replace(' ',':')
            output['jpl_dec_apparent'] = line[6].replace(' ',':')
            output['jpl_ra_delta'] = line[7]
            output['jpl_dec_delta'] = line[8]
            output['jpl_APmag'] = line[11]
            output['jpl_ang_diam'] = line[13]
            for key in ['jpl_APmag', 'jpl_ang_diam']:
                if output[key] == 'n.a.':
                    output[key] = '-999'
            return output
        if line == '$$SOE':
            soe_switch = True
Beispiel #2
0
def check_values(data):
    '''
    Checks the returned values.
    '''
    check_type(data, dict)
    assert data['date'] == '1997-Jul-03 09:17'
    assert data['jpl_dec'] == '-19:55:57.3'
    assert data['jpl_dec_apparent'] == '-19:56:11.1'
    assert data['jpl_dec_delta'] == '-0.80270'
    assert data['jpl_ra'] == '20:04:29.56'
    assert data['jpl_ra_apparent'] == '20:04:21.95'
    assert data['jpl_ra_delta'] == '-3.74238'
def get_master_filename(basename):
    '''
    Builds the master_filename.
    '''
    check_type(basename, str)
    if basename.split('_')[1] == 'cr':
        drizzle_type = basename.split('_')[3]
    else:
        drizzle_type = basename.split('_')[2]
    assert drizzle_type in ['wide', 'center'], \
        'Unexpected image type ' + drizzle_type + ' for ' + filename
    master_filename = basename.split('linear')[0] + 'linear.png'
    return master_filename
def get_region(filename):
    '''
    Figures out the subimage region from the filename.
    '''
    check_type(filename, str)
    basename = os.path.basename(filename)
    if basename.split('_')[1] == 'cr':
        drizzle_type = basename.split('_')[3]
    else:
        drizzle_type = basename.split('_')[2]
    assert drizzle_type in ['wide', 'center'], \
        'Unexpected image type ' + drizzle_type + ' for ' + filename
    if drizzle_type == 'wide':
        filename = os.path.splitext(filename)[0]
        region = filename.split('/')[-1].split('_')[-1]
    elif drizzle_type == 'center':
        region = '1'
    for digit in region:
        assert digit in string.digits, 'Region ' + region + ' is not a number.'
    return region