import re


def load_sta(sta_file):
    """
    Load in station information.

    Parameter:
        sta_file: text file in free format "net sta lon lat ele label\n"
        The label is intended for mark special stations purpose 
    Return:
        dictionary in structure sta_dict[net][sta]=[lon,lat,ele,label]
    """
    sta_dict={}
    with open(sta_file,'r') as f:
        for line in f:
            line = line.rstrip()
            net,sta,_lon,_lat,_ele,label=re.split("[ ,;]+",line)
            if net not in sta_dict:
                sta_dict[net]={}
            if sta not in sta_dict[net]:
                sta_dict[net][sta] = [float(_lon),float(_lat),int(float(_ele)),label]
    return sta_dict