def update_temporalcache(self, loader, cache): const = lambda c: np.array(c).reshape(1, 1, 1) inputs = [ loader.lat[0], loader.lon[0], self.decimalhour, self.gamma, loader.dem, loader.linke, const(self.algorithm.SAT_LON), const(self.algorithm.i0met), const(1367.0), const(8434.5) ] outputs = [ self.declination, self.solarangle, self.solarelevation, self.excentricity, self.gc, self.atmosphericalbedo, self.t_sat, self.t_earth, self.cloudalbedo ] matrixs = list(itertools.chain(*[outputs, inputs])) gpu_exec("update_temporalcache", len(outputs), *matrixs) print "----" maxmin = map(lambda o: (o[:].min(), o[:].max()), outputs) for mm in zip(range(len(maxmin)), maxmin): name = outputs[mm[0]].name if hasattr(outputs[mm[0]], 'name') else mm[0] print name, ': ', mm[1] print "----" nc.sync(cache)
def update_temporalcache(self, loader, cache): const = lambda c: np.array(c).reshape(1, 1, 1) inputs = [loader.lat[0], loader.lon[0], self.decimalhour, self.months, self.gamma, loader.dem, loader.linke, const(self.algorithm.SAT_LON), const(self.algorithm.i0met), const(1367.0), const(8434.5)] outputs = [self.declination, self.solarangle, self.solarelevation, self.excentricity, self.gc, self.atmosphericalbedo, self.t_sat, self.t_earth, self.cloudalbedo] matrixs = list(itertools.chain(*[outputs, inputs])) gpu_exec("update_temporalcache", len(outputs), *matrixs) nc.sync(cache)
def update_temporalcache(self, loader, cache): const = lambda c: np.array(c).reshape(1, 1, 1) inputs = [loader.lat[0], loader.lon[0], self.decimalhour, self.gamma, loader.dem, loader.linke, const(self.algorithm.SAT_LON), const(self.algorithm.i0met), const(1367.0), const(8434.5)] outputs = [self.declination, self.solarangle, self.solarelevation, self.excentricity, self.gc, self.atmosphericalbedo, self.t_sat, self.t_earth, self.cloudalbedo] matrixs = list(itertools.chain(*[outputs, inputs])) gpu_exec("update_temporalcache", len(outputs), *matrixs) print "----" maxmin = map(lambda o: (o[:].min(), o[:].max()), outputs) for mm in zip(range(len(maxmin)), maxmin): name = outputs[mm[0]].name if hasattr(outputs[mm[0]], 'name') else mm[0] print name, ': ', mm[1] print "----" nc.sync(cache)
def create_slots(self, loader, cache, strategy): self.create_1px_dimensions(cache) time = loader.time shape = list(time.shape) shape.append(1) strategy.times = time.reshape(tuple(shape)) strategy.slots = cache.getvar('slots', 'i1', ('time', 'yc_k', 'xc_k')) strategy.slots[:] = strategy.calculate_slots(self.IMAGE_PER_HOUR) nc.sync(cache)
def estimate_globalradiation(self, loader, cache, output): excentricity = cache.excentricity solarangle = cache.solarangle atmosphericalbedo = cache.atmosphericalbedo t_earth = cache.t_earth t_sat = cache.t_sat observedalbedo = self.getalbedo(loader.calibrated_data, self.algorithm.i0met, excentricity, solarangle) apparentalbedo = self.getapparentalbedo(observedalbedo, atmosphericalbedo, t_earth, t_sat) declination = cache.declination[:] logging.info("Calculating the noon window... ") slot_window_in_hours = 4 image_per_day = 24 * self.algorithm.IMAGE_PER_HOUR noon_slot = image_per_day / 2 half_window = self.algorithm.IMAGE_PER_HOUR * slot_window_in_hours/2 min_slot = noon_slot - half_window max_slot = noon_slot + half_window condition = ((cache.slots >= min_slot) & (cache.slots < max_slot)) condition = np.reshape(condition, condition.shape[0]) mask1 = (loader.calibrated_data[condition] <= (self.algorithm.i0met / np.pi) * 0.03) m_apparentalbedo = np.ma.masked_array(apparentalbedo[condition], mask1) # To do the nexts steps needs a lot of memory logging.info("Calculating the ground reference albedo... ") mask2 = m_apparentalbedo < stats.scoreatpercentile(m_apparentalbedo, 5) p5_apparentalbedo = np.ma.masked_array(m_apparentalbedo, mask2) groundreferencealbedo = self.getsecondmin(p5_apparentalbedo) # Calculate the solar elevation using times, latitudes and omega logging.info("Calculating solar elevation... ") r_alphanoon = self.getsolarelevation(declination, loader.lat[0], 0) r_alphanoon = r_alphanoon * 2./3. r_alphanoon[r_alphanoon > 40] = 40 r_alphanoon[r_alphanoon < 15] = 15 solarelevation = cache.solarelevation[:] logging.info("Calculating the ground minimum albedo... ") groundminimumalbedo = self.getsecondmin( np.ma.masked_array( apparentalbedo[condition], solarelevation[condition] < r_alphanoon[condition])) aux_2g0 = 2 * groundreferencealbedo aux_05g0 = 0.5 * groundreferencealbedo condition_2g0 = groundminimumalbedo > aux_2g0 condition_05g0 = groundminimumalbedo < aux_05g0 groundminimumalbedo[condition_2g0] = aux_2g0[condition_2g0] groundminimumalbedo[condition_05g0] = aux_05g0[condition_05g0] logging.info("Calculating the cloud index... ") i = output.ref_globalradiation.shape[0] cloudindex = self.getcloudindex(apparentalbedo[-i:], groundminimumalbedo, cache.cloudalbedo[-i:]) output.ref_cloudindex[:] = cloudindex output.ref_globalradiation[:] = (self.getclearsky(cloudindex) * cache.gc[-i:, :]) nc.sync(output.root)
def estimate_globalradiation(self, loader, cache, output): excentricity = cache.excentricity solarangle = cache.solarangle atmosphericalbedo = cache.atmosphericalbedo t_earth = cache.t_earth t_sat = cache.t_sat observedalbedo = self.getalbedo(loader.calibrated_data, self.algorithm.i0met, excentricity, solarangle) apparentalbedo = self.getapparentalbedo(observedalbedo, atmosphericalbedo, t_earth, t_sat) declination = cache.declination[:] logging.info("Calculating the noon window... ") slot_window_in_hours = 4 image_per_day = 24 * self.algorithm.IMAGE_PER_HOUR noon_slot = image_per_day / 2 half_window = self.algorithm.IMAGE_PER_HOUR * slot_window_in_hours/2 min_slot = noon_slot - half_window max_slot = noon_slot + half_window condition = ((cache.slots >= min_slot) & (cache.slots < max_slot)) condition = np.reshape(condition, condition.shape[0]) mask1 = (loader.calibrated_data[condition] <= (self.algorithm.i0met / np.pi) * 0.03) m_apparentalbedo = np.ma.masked_array(apparentalbedo[condition], mask1) # To do the nexts steps needs a lot of memory logging.info("Calculating the ground reference albedo... ") mask2 = m_apparentalbedo < stats.scoreatpercentile(m_apparentalbedo, 5) p5_apparentalbedo = np.ma.masked_array(m_apparentalbedo, mask2) groundreferencealbedo = self.getsecondmin(p5_apparentalbedo) # Calculate the solar elevation using times, latitudes and omega logging.info("Calculating solar elevation... ") r_alphanoon = self.getsolarelevation(declination, loader.lat[0], 0) r_alphanoon = r_alphanoon * 2./3. r_alphanoon[r_alphanoon > 40] = 40 r_alphanoon[r_alphanoon < 15] = 15 solarelevation = cache.solarelevation[:] logging.info("Calculating the ground minimum albedo... ") groundminimumalbedo = self.getsecondmin( np.ma.masked_array(apparentalbedo[condition], solarelevation[condition] < r_alphanoon[condition])) aux_2g0 = 2 * groundreferencealbedo aux_05g0 = 0.5 * groundreferencealbedo condition_2g0 = groundminimumalbedo > aux_2g0 condition_05g0 = groundminimumalbedo < aux_05g0 groundminimumalbedo[condition_2g0] = aux_2g0[condition_2g0] groundminimumalbedo[condition_05g0] = aux_05g0[condition_05g0] logging.info("Calculating the cloud index... ") i = output.ref_globalradiation.shape[0] cloudindex = self.getcloudindex(apparentalbedo[-i:], groundminimumalbedo, cache.cloudalbedo[-i:]) output.ref_cloudindex[:] = cloudindex output.ref_globalradiation[:] = (self.getclearsky(cloudindex) * cache.gc[-i:,:]) nc.sync(output.root)
def update_temporalcache(self, loader, cache): lat, lon = loader.lat[0], loader.lon[0] self.declination[:] = self.getdeclination(self.gamma) # FIXME: There are two solar elevations. hourlyangle = self.gethourlyangle(lat, lon, self.decimalhour, self.gamma) self.solarangle[:] = self.getzenithangle(self.declination[:], loader.lat, hourlyangle) # FIXME: This rewrite the value of the solarelevations setted before. self.solarelevation[:] = self.getelevation(self.solarangle[:]) self.excentricity[:] = self.getexcentricity(self.gamma) linke = np.vstack([pmap(lambda m: loader.linke[0, m[0][0] - 1, :], self.months.tolist())]) # The average extraterrestrial irradiance is 1367.0 Watts/meter^2 # The maximum height of the non-transparent atmosphere is at 8434.5 mts bc = self.getbeamirradiance(1367.0, self.excentricity[:], self.solarangle[:], self.solarelevation[:], linke, loader.dem) dc = self.getdiffuseirradiance(1367.0, self.excentricity[:], self.solarelevation[:], linke) self.gc[:] = self.getglobalirradiance(bc, dc) satellitalzenithangle = self.getsatellitalzenithangle( loader.lat, loader.lon, self.algorithm.SAT_LON) atmosphericradiance = self.getatmosphericradiance( 1367.0, self.algorithm.i0met, dc, satellitalzenithangle) self.atmosphericalbedo[:] = self.getalbedo(atmosphericradiance, self.algorithm.i0met, self.excentricity[:], satellitalzenithangle) satellitalelevation = self.getelevation(satellitalzenithangle) satellital_opticalpath = self.getopticalpath( self.getcorrectedelevation(satellitalelevation), loader.dem, 8434.5) satellital_opticaldepth = self.getopticaldepth(satellital_opticalpath) self.t_sat[:] = self.gettransmitance(linke, satellital_opticalpath, satellital_opticaldepth, satellitalelevation) solar_opticalpath = self.getopticalpath( self.getcorrectedelevation(self.solarelevation[:]), loader.dem, 8434.5) solar_opticaldepth = self.getopticaldepth(solar_opticalpath) self.t_earth[:] = self.gettransmitance(linke, solar_opticalpath, solar_opticaldepth, self.solarelevation[:]) effectivealbedo = self.geteffectivealbedo(self.solarangle[:]) self.cloudalbedo[:] = self.getcloudalbedo(effectivealbedo, self.atmosphericalbedo[:], self.t_earth[:], self.t_sat[:]) nc.sync(cache)
def __init__(self, filenames): # At first it should have: lat, lon, dem, linke self.root, is_new = nc.open('static.nc') if is_new: logging.info("This is the first execution from the deployment... ") with nc.loader(filenames[0]) as root_ref: self.lat = nc.getvar(root_ref, 'lat') self.lon = nc.getvar(root_ref, 'lon') nc.getvar(self.root, 'lat', source=self.lat) nc.getvar(self.root, 'lon', source=self.lon) self.project_dem() self.project_linke() nc.sync(self.root) self.root = nc.tailor(self.root, dimensions=DIMS)
def __init__(self, filenames, tile_cut={}): # At first it should have: lat, lon, dem, linke self.root, is_new = nc.open("static.nc") if is_new: logging.info("This is the first execution from the deployment... ") with nc.loader(filenames[0]) as root_ref: self.lat = nc.getvar(root_ref, "lat") self.lon = nc.getvar(root_ref, "lon") nc.getvar(self.root, "lat", source=self.lat) nc.getvar(self.root, "lon", source=self.lon) self.project_dem() self.project_linke() nc.sync(self.root) self.root = nc.tailor(self.root, dimensions=tile_cut)
def update_temporalcache(self, loader, cache): lat, lon = loader.lat[0], loader.lon[0] self.declination[:] = self.getdeclination(self.gamma) # FIXME: There are two solar elevations. hourlyangle = self.gethourlyangle(lat, lon, self.decimalhour, self.gamma) self.solarangle[:] = self.getzenithangle(self.declination[:], loader.lat, hourlyangle) # FIXME: This rewrite the value of the solarelevations setted before. self.solarelevation[:] = self.getelevation(self.solarangle[:]) self.excentricity[:] = self.getexcentricity(self.gamma) # The average extraterrestrial irradiance is 1367.0 Watts/meter^2 # The maximum height of the non-transparent atmosphere is at 8434.5 mts bc = self.getbeamirradiance(1367.0, self.excentricity[:], self.solarangle[:], self.solarelevation[:], loader.linke, loader.dem) dc = self.getdiffuseirradiance(1367.0, self.excentricity[:], self.solarelevation[:], loader.linke) self.gc[:] = self.getglobalirradiance(bc, dc) satellitalzenithangle = self.getsatellitalzenithangle(loader.lat, loader.lon, self.algorithm.SAT_LON) atmosphericradiance = self.getatmosphericradiance(1367.0, self.algorithm.i0met, dc, satellitalzenithangle) self.atmosphericalbedo[:] = self.getalbedo(atmosphericradiance, self.algorithm.i0met, self.excentricity[:], satellitalzenithangle) satellitalelevation = self.getelevation(satellitalzenithangle) satellital_opticalpath = self.getopticalpath( self.getcorrectedelevation(satellitalelevation), loader.dem, 8434.5) satellital_opticaldepth = self.getopticaldepth(satellital_opticalpath) self.t_sat[:] = self.gettransmitance(loader.linke, satellital_opticalpath, satellital_opticaldepth, satellitalelevation) solar_opticalpath = self.getopticalpath( self.getcorrectedelevation(self.solarelevation[:]), loader.dem, 8434.5) solar_opticaldepth = self.getopticaldepth(solar_opticalpath) self.t_earth[:] = self.gettransmitance(loader.linke, solar_opticalpath, solar_opticaldepth, self.solarelevation[:]) effectivealbedo = self.geteffectivealbedo(self.solarangle[:]) self.cloudalbedo[:] = self.getcloudalbedo(effectivealbedo, self.atmosphericalbedo[:], self.t_earth[:], self.t_sat[:]) nc.sync(cache)
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)
def create_temporal(self, loader, cache, strategy): create_f = lambda name, source: cache.getvar(name, 'f4', source=source) create = lambda name, source: cache.getvar(name, source=source) strategy.declination = create_f('declination', strategy.slots) strategy.solarangle = create_f('solarangle', loader.ref_data) nc.sync(cache) strategy.solarelevation = create('solarelevation', strategy.solarangle) strategy.excentricity = create_f('excentricity', strategy.slots) strategy.gc = create('gc', strategy.solarangle) strategy.atmosphericalbedo = create('atmosphericalbedo', strategy.solarangle) strategy.t_sat = create('t_sat', loader.ref_lon) strategy.t_earth = create('t_earth', strategy.solarangle) strategy.cloudalbedo = create('cloudalbedo', strategy.solarangle) nc.sync(cache)
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
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)
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)
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)] 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)