def gen_stats(datain):
    """**Calculate lightning statitics and return a dictionary**

    Using a raw data in certain time interval calculate mean, std, min, max value for detection
    error or number of stations.

    :paramter datain: vector with detection error or number of stations

    :Example:

    >>> gen_stats(lighning_data['#sta'])
    """
    tmp_dic={}
    tmp_dic['count'] = len(datain)
    # if there is no lightning strikes set nan values for all stats parameters
    if(tmp_dic['count'] == 0):
        tmp_dic['mean'] = np.nan
        tmp_dic['std'] = np.nan
        tmp_dic['min'] = np.nan
        tmp_dic['max'] = np.nan
    else:
        tmp_dic['mean'] = np.mean(datain)
        tmp_dic['std'] = np.std(datain)
        tmp_dic['min'] = min(datain)
        tmp_dic['max'] = max(datain)
    return tmp_dic