def adjustColourSchemeZeroBoundaries(self, colour_scheme_boundaries) :
if self.map_colour_scheme == '90%_range' : # shift left method
colour_scheme_boundaries_zero_index = (colour_scheme_boundaries >= 0).nonzero()[0][0]
colour_scheme_boundaries -= colour_scheme_boundaries[colour_scheme_boundaries_zero_index]
else : # fixed_range: minimal stretch method
# Resolve selected parameter/group codes
parameter_group_code = self.parameter_group_selection_map[self.parameter_group_text.get()]
parameter_code = self.parameter_via_group_selection_map[parameter_group_code][self.parameter_via_group_text[parameter_group_code].get()]
# Select fixed colour scheme via parameter codes and delta settings
if self.utilise_delta.get() :
if self.delta_as_percent.get() and self.parameter_fixed_range_colour_scheme[parameter_group_code][parameter_code].has_key('%delta') :
fixed_range_colour_scheme = self.parameter_fixed_range_colour_scheme[parameter_group_code][parameter_code]['%delta']
else :
fixed_range_colour_scheme = self.parameter_fixed_range_colour_scheme[parameter_group_code][parameter_code]['delta']
else :
fixed_range_colour_scheme = self.parameter_fixed_range_colour_scheme[parameter_group_code][parameter_code]['value']
# Resolve colour scheme zero boundaries
first_index = int(fixed_range_colour_scheme['first_boundary'] != None and fixed_range_colour_scheme['min'] == None)
last_index = 11 - int(fixed_range_colour_scheme['last_boundary'] != None and fixed_range_colour_scheme['max'] == None)
if colour_scheme_boundaries.round(12).min() >= 0 :
data_min = 0.0
scheme_interval = (colour_scheme_boundaries[last_index] - data_min)/last_index
data_max = colour_scheme_boundaries[last_index] + scheme_interval*(11 - last_index)
colour_scheme_boundaries_zero_index = 0
elif colour_scheme_boundaries.round(12).max() <= 0 :
data_max = 0.0
scheme_interval = (data_max - colour_scheme_boundaries[first_index])/(11 - first_index)
data_min = colour_scheme_boundaries[first_index] - scheme_interval*first_index
colour_scheme_boundaries_zero_index = 11
else :
first_positive_index = (colour_scheme_boundaries >= 0).nonzero()[0][0]
lower_stretch = None
upper_stretch = None
if first_positive_index < last_index :
lower_stretch = (last_index - first_index)*colour_scheme_boundaries[first_positive_index]/(last_index - first_positive_index)
if first_positive_index > first_index + 1 :
upper_stretch = (last_index - first_index)*colour_scheme_boundaries[first_positive_index - 1]/(first_index - first_positive_index + 1)
if upper_stretch == None or (lower_stretch != None and round(lower_stretch, 12) <= round(upper_stretch, 12)) :
colour_scheme_boundaries[first_index] -= lower_stretch
colour_scheme_boundaries_zero_index = first_positive_index
else :
colour_scheme_boundaries[last_index] += upper_stretch
colour_scheme_boundaries_zero_index = first_positive_index - 1
scheme_interval = (colour_scheme_boundaries[last_index] - colour_scheme_boundaries[first_index])/(last_index - first_index)
data_min = colour_scheme_boundaries[first_index] - scheme_interval*first_index
data_max = colour_scheme_boundaries[last_index] + scheme_interval*(11 - last_index)
colour_scheme_boundaries = np.arange(data_min, data_max+0.1*scheme_interval, scheme_interval).round(12)
return (colour_scheme_boundaries_zero_index, colour_scheme_boundaries)
## Generic Methods ####################################################################################################################################################
# Generic Method: Ensures menu selection triggers entry field validation focusout events
评论列表
文章目录