def parse_ratings(ushpa_data):
    """
    Parse ushpa data from bapa.services.ushpa.get_pilot_data
    to return a string such as 'P2, H3'.
    """
    rating_dict = {
        'BEGINNER': '1',
        'NOVICE': '2',
        'INTERMEDIATE': '3',
        'ADVANCED': '4',
        'MASTER': '5'
    }

    pg = ushpa_data.get('pg_pilot_rating')
    hg = ushpa_data.get('hg_pilot_rating')
    ratings = ''
    if pg:
        ratings += 'P-%s' % rating_dict[pg]
    if hg:
        ratings += ' H-%s' % rating_dict[hg]
    if ratings:
        return ratings.strip()
    return