Example #1
0
def rmse(root, index):
    times = [
        datetime.utcfromtimestamp(int(t)) for t in nc.getvar(root, 'time')[:]
    ]
    days = [t.date() for t in times]
    days.sort()
    days_index = [d.day for d in set(days)]
    days_amount = len(days_index)
    nc.getdim(root, 'diarying', days_amount)
    nc.sync(root)
    measurements = nc.getvar(root, 'measurements')
    estimated = nc.getvar(root, 'globalradiation')
    error_diff = nc.getvar(root, 'errordiff', 'f4', (
        'time',
        'yc_cut',
        'xc_cut',
    ), 4)
    error = nc.getvar(root, 'error', 'f4', (
        'time',
        'yc_cut',
        'xc_cut',
    ), 4)
    diary_error = nc.getvar(root, 'diaryerror', 'f4', (
        'diarying',
        'yc_cut',
        'xc_cut',
    ), 4)
    error_diff[:] = np.zeros(estimated.shape)
    error[:] = np.zeros(estimated.shape)
    diary_error[:] = np.zeros(
        (days_amount, estimated.shape[1], estimated.shape[2]))
    nc.sync(root)
    #the_max = measurements[:].max()
    error_diff[:,
               index, :] = measurements[:, index, :] - estimated[:, index, :]
    error[:, index, :] = np.abs(error_diff[:, index, :])
    nc.sync(root)
    max_value_in_day = np.zeros([days_amount]) + 1
    for i in range(len(days)):
        d_i = days_index.index(days[i].day)
        max_value_in_day[d_i] = measurements[
            i, index, 0] if max_value_in_day[d_i] < measurements[
                i, index, 0] else max_value_in_day[d_i]
        diary_error[d_i, index, :] += np.array([error_diff[i, index, 0]**2, 1])
    count = diary_error[:, index, 1]
    count[count == 0] = 1
    diary_error[:, index, 0] = np.sqrt(diary_error[:, index, 0] / count)
    diary_error[:, index,
                1] = diary_error[:, index, 0] / max_value_in_day * 100
    show("\rDiary RMS error: %.2f" % (diary_error[:, index, 1]).mean())
    for i in range(len(days)):
        d_i = days_index.index(days[i].day)
        error[i, index, 1] = error[i, index, 1] / max_value_in_day[d_i] * 100
    result = np.sum(error[:, index, 1]**2)
    result = np.sqrt(result / error.shape[0])
    show("Half-hour RMS error: %.2f \n" % result)
    #diary_error[:, index,1] = diary_error[:, index,0]
    nc.sync(root)
    nc.close(root)
Example #2
0
def dailyerrors(root, stations):
	times = [ datetime.fromtimestamp(int(t)) for t in nc.getvar(root, 'time')[:] ]
	days = [ t.date() for t in times ]
	days.sort()
	days_index = [d.day for d in set(days)]
	days_index.sort()
	days_amount = len(days_index)
	nc.getdim(root, 'diarying', days_amount)
	nc.sync(root)
	measurements = nc.getvar(root, 'measurements')
	estimated = nc.getvar(root, 'globalradiation')
	error_diff = nc.getvar(root, 'errordiff', 'f4', ('time', 'yc_cut', 'xc_cut',), 4)
	RMS_daily_error = nc.getvar(root, 'RMSdailyerror', 'f4', ('diarying', 'yc_cut', 'xc_cut',), 4)
	BIAS_daily_error = nc.getvar(root, 'BIASdailyerror', 'f4', ('diarying', 'yc_cut', 'xc_cut',), 4)
	error_diff[:] = np.zeros(estimated.shape)
	RMS_daily_error[:] = np.zeros((days_amount, estimated.shape[1], estimated.shape[2]))
	BIAS_daily_error[:] = np.zeros((days_amount, estimated.shape[1], estimated.shape[2]))
	nc.sync(root)
	for s in stations:
		index = stations.index(s)
		show('Station: %s \n' % stations[index])
		error_diff[:, index, :] = measurements[:, index, :] - estimated[:, index, :]
		nc.sync(root)
		sum_value_in_day = np.zeros((days_amount))
		for i in range(len(days)):
			d_i = days_index.index(days[i].day)
			if not measurements[i, index, 0] == 0.0:
				sum_value_in_day[d_i] += measurements[i,index ,0]
				RMS_daily_error[d_i, index ,:] += np.array([ error_diff[i, index ,0] ** 2,1])
				BIAS_daily_error[d_i, index ,:] +=  error_diff[i, index ,0]
		count = RMS_daily_error[:, index, 1]
		count[count == 0] = 1
		RMS_daily_error[:, index,0] = np.sqrt(RMS_daily_error[:, index, 0] / count) / sum_value_in_day * 100
		BIAS_daily_error[:, index,0] = (BIAS_daily_error[:, index, 0] / count) / sum_value_in_day * 100
		RMS_daily_error[:, index,1] = RMS_daily_error[:, index,0]
		BIAS_daily_error[:, index,1] = BIAS_daily_error[:, index,0]
		print 'RMS :', RMS_daily_error[:, index, 0]
		print 'BIAS', BIAS_daily_error[:, index, 0]
		print 'sum value in day: ', sum_value_in_day[:]
		show("\rDiary RMS daily error: %.2f\n" % (RMS_daily_error[:, index, 0]).mean())

	nc.sync(root)
	nc.close(root)
Example #3
0
def rmse(root, index):
	times = [ datetime.utcfromtimestamp(int(t)) for t in nc.getvar(root, 'time')[:] ]
	days = [ t.date() for t in times ]
	days.sort()
	days_index = [d.day for d in set(days)]
	days_amount = len(days_index)
	nc.getdim(root, 'diarying', days_amount)
	nc.sync(root)
	measurements = nc.getvar(root, 'measurements')
	estimated = nc.getvar(root, 'globalradiation')
	error_diff = nc.getvar(root, 'errordiff', 'f4', ('time', 'yc_cut', 'xc_cut',), 4)
	error = nc.getvar(root, 'error', 'f4', ('time','yc_cut','xc_cut',), 4)
	diary_error = nc.getvar(root, 'diaryerror', 'f4', ('diarying', 'yc_cut', 'xc_cut',), 4)
	error_diff[:] = np.zeros(estimated.shape)
	error[:] = np.zeros(estimated.shape)
	diary_error[:] = np.zeros((days_amount, estimated.shape[1], estimated.shape[2]))
	nc.sync(root)
	#the_max = measurements[:].max()
	error_diff[:, index, :] = measurements[:,index,:] - estimated[:,index,:]
	error[:, index, :] = np.abs(error_diff[:, index, :])
	nc.sync(root)
	max_value_in_day = np.zeros([days_amount]) + 1
	for i in range(len(days)):
		d_i = days_index.index(days[i].day)
		max_value_in_day[d_i] = measurements[i,index,0] if max_value_in_day[d_i] < measurements[i,index,0] else max_value_in_day[d_i]
		diary_error[d_i, index,:] += np.array([ error_diff[i,index,0] ** 2,1])
	count = diary_error[:, index, 1]
	count[count == 0] = 1
	diary_error[:, index,0] = np.sqrt(diary_error[:, index, 0] / count)
	diary_error[:, index,1] = diary_error[:, index,0] /	max_value_in_day * 100
	show("\rDiary RMS error: %.2f" % (diary_error[:, index, 1]).mean())
	for i in range(len(days)):
		d_i = days_index.index(days[i].day)
		error[i,index,1] = error[i,index,1] / max_value_in_day[d_i] * 100
	result = np.sum(error[:, index, 1] ** 2)
	result = np.sqrt(result / error.shape[0])
	show("Half-hour RMS error: %.2f \n" % result)
	#diary_error[:, index,1] = diary_error[:, index,0]
	nc.sync(root)
	nc.close(root)
Example #4
0
        y = core.new_randint(1, x, numbers_log)
        z = x - y
    else:
        # Take one random pair from generated list
        pair = random.choice(multipliers_list)
        # And remove
        multipliers_list.remove(pair)

        # Random order of multipliers
        (x, y) = pair if random.getrandbits(1) == 0 else (pair[1], pair[0])
        z = x * y
        if operation == '/':
            (x, z) = (z, x)

    # Strings with example by numbers and words
    example_numbers = f'{x} {operation} {y} = {z}'
    example_words = int_to_german(
        x) + ' ' + operation_german + ' ' + int_to_german(
            y) + ' gleich ' + int_to_german(z)

    operations_log.append(operation)

    # Turn off this boolean to not repeat generator's running
    first_run = False
    # Send these strings to interface script
    return example_numbers, example_words


# Run simple console interface which show random content with user's parameters
core.show(print_examples, 'examples', True, 'Deutsche Wörter:')
Example #5
0
def cli(profile, show):
    print core.show(profile, show)
Example #6
0
def dailyerrors(root, stations):
    times = [
        datetime.fromtimestamp(int(t)) for t in nc.getvar(root, 'time')[:]
    ]
    days = [t.date() for t in times]
    days.sort()
    days_index = [d.day for d in set(days)]
    days_index.sort()
    days_amount = len(days_index)
    nc.getdim(root, 'diarying', days_amount)
    nc.sync(root)
    measurements = nc.getvar(root, 'measurements')
    estimated = nc.getvar(root, 'globalradiation')
    error_diff = nc.getvar(root, 'errordiff', 'f4', (
        'time',
        'yc_cut',
        'xc_cut',
    ), 4)
    RMS_daily_error = nc.getvar(root, 'RMSdailyerror', 'f4', (
        'diarying',
        'yc_cut',
        'xc_cut',
    ), 4)
    BIAS_daily_error = nc.getvar(root, 'BIASdailyerror', 'f4', (
        'diarying',
        'yc_cut',
        'xc_cut',
    ), 4)
    error_diff[:] = np.zeros(estimated.shape)
    RMS_daily_error[:] = np.zeros(
        (days_amount, estimated.shape[1], estimated.shape[2]))
    BIAS_daily_error[:] = np.zeros(
        (days_amount, estimated.shape[1], estimated.shape[2]))
    nc.sync(root)
    for s in stations:
        index = stations.index(s)
        show('Station: %s \n' % stations[index])
        error_diff[:,
                   index, :] = measurements[:, index, :] - estimated[:,
                                                                     index, :]
        nc.sync(root)
        sum_value_in_day = np.zeros((days_amount))
        for i in range(len(days)):
            d_i = days_index.index(days[i].day)
            if not measurements[i, index, 0] == 0.0:
                sum_value_in_day[d_i] += measurements[i, index, 0]
                RMS_daily_error[d_i, index, :] += np.array(
                    [error_diff[i, index, 0]**2, 1])
                BIAS_daily_error[d_i, index, :] += error_diff[i, index, 0]
        count = RMS_daily_error[:, index, 1]
        count[count == 0] = 1
        RMS_daily_error[:, index, 0] = np.sqrt(
            RMS_daily_error[:, index, 0] / count) / sum_value_in_day * 100
        BIAS_daily_error[:, index, 0] = (BIAS_daily_error[:, index, 0] /
                                         count) / sum_value_in_day * 100
        RMS_daily_error[:, index, 1] = RMS_daily_error[:, index, 0]
        BIAS_daily_error[:, index, 1] = BIAS_daily_error[:, index, 0]
        print 'RMS :', RMS_daily_error[:, index, 0]
        print 'BIAS', BIAS_daily_error[:, index, 0]
        print 'sum value in day: ', sum_value_in_day[:]
        show("\rDiary RMS daily error: %.2f\n" %
             (RMS_daily_error[:, index, 0]).mean())

    nc.sync(root)
    nc.close(root)
Example #7
0
        year_second_part = int(str(year)[2:])
        year_words = int_to_german(
            year_first_part) + 'hundert' + int_to_german(year_second_part)

    # DD.MM.YYYY
    short_date = f'{day}.{str_month}.{year}'

    # Russian format
    russian_date = f'{day} {months_dict["russian"][month - 1]} {year} г.'

    # American format
    english_date = f'{months_dict["english"][month - 1]} {day}, {year}'

    # German format with numbers
    german_date = f'{day}. {months_dict["german"][month - 1]} {year}'

    # The entire date is written by german words
    german_date_words = f'{day_words} {months_dict["german"][month - 1]} {year_words}'

    # Output
    result = f'{short_date} / {english_date}\n' \
             f'   {russian_date}\n' \
             f'   German:\n' \
             f'   {german_date}\n' \
             f'   {german_date_words}\n'
    return result


# Run simple console interface which show random content with user's parameters
core.show(print_dates, 'dates')
Example #8
0
	diary_error[:] = np.zeros((days_amount, estimated.shape[1], estimated.shape[2]))
	nc.sync(root)
	#the_max = measurements[:].max()
	error_diff[:, index, :] = measurements[:,index,:] - estimated[:,index,:]
	error[:, index, :] = np.abs(error_diff[:, index, :])
	nc.sync(root)
	max_value_in_day = np.zeros([days_amount]) + 1
	for i in range(len(days)):
		d_i = days_index.index(days[i].day)
		max_value_in_day[d_i] = measurements[i,index,0] if max_value_in_day[d_i] < measurements[i,index,0] else max_value_in_day[d_i]
		diary_error[d_i, index,:] += np.array([ error_diff[i,index,0] ** 2,1])
	count = diary_error[:, index, 1]
	count[count == 0] = 1
	diary_error[:, index,0] = np.sqrt(diary_error[:, index, 0] / count)
	diary_error[:, index,1] = diary_error[:, index,0] /	max_value_in_day * 100
    show("\rDiary RMS error: {:.2f}".format(diary_error[:, index, 1].mean()))
	for i in range(len(days)):
		d_i = days_index.index(days[i].day)
		error[i,index,1] = error[i,index,1] / max_value_in_day[d_i] * 100
	result = np.sum(error[:, index, 1] ** 2)
	result = np.sqrt(result / error.shape[0])
    show("Half-hour RMS error: {:.2f} \n".format(result))
	#diary_error[:, index,1] = diary_error[:, index,0]
	nc.sync(root)
	nc.close(root)

def dailyerrors(root, stations):
	times = [ datetime.fromtimestamp(int(t)) for t in nc.getvar(root, 'time')[:] ]
	days = [ t.date() for t in times ]
	days.sort()
	days_index = [d.day for d in set(days)]