def customColorBar(height,width,scale_hsv,alpha_bar_line=0.01,number_of_lines=5): array_color_bar = np.zeros([width,height,3],dtype=np.uint8) if(width*alpha_bar_line*2>1): bar_width_border=int(width*alpha_bar_line*2) else: bar_width_border=1*2 if(width*alpha_bar_line>1): bar_width_line=int(width*alpha_bar_line) else: bar_width_line=1 compartiment=height/(number_of_lines-1) for j in range(0,height): for i in range(0,width): pixel_rgb=cm.hsv2rgb(ExpansionHistogram(j,0,height,scale_hsv[0],scale_hsv[1]),100,80,normalised=False) for z in range(0,3): if(i<bar_width_border or i>width-1-bar_width_border): array_color_bar[i][j][z]=0 elif(j<bar_width_border or j%compartiment > compartiment-bar_width_line or j%compartiment < bar_width_line or j>height-bar_width_border-1): array_color_bar[i][j][z]=0 else: array_color_bar[i][j][z]=int(round(pixel_rgb[z]*255)) image_color_bar=Image.fromarray(array_color_bar) return image_color_bar
map_csv_format).replace(".csv", "") #Chargement des données issues des résultats de probesMeanYear with open(path_map_in, "r") as map_raw: map_raw_lines = map_raw.readlines() map_coordinates = [[ float(x.split(",")[0]), float(x.split(",")[1]) ] for x in map_raw_lines[1:]] #Détermine la matrice de couleur en RGB du type matrice[i][j]=(R,G,B) map_values = [[ np.asarray( cm.hsv2rgb( (ExpansionHistogram(float(y), scale[0], scale[1], scale_hsv[0], scale_hsv[1])), 100, 80, normalised=False)) * 255 for y in x.split(",")[3:] ] for x in map_raw_lines[1:]] ### Récupère les limites du rectangle des probes max_val_x = float( max(map_coordinates, key=lambda x: float(x[0]))[0]) min_val_x = float( min(map_coordinates, key=lambda x: float(x[0]))[0]) max_val_y = float( max(map_coordinates, key=lambda x: float(x[1]))[1]) min_val_y = float( min(map_coordinates, key=lambda x: float(x[1]))[1]) #initialisation du pas à une valeur très haute jamais atteinte
for map_csv_format in map_csv_format_list : print(" -",map_csv_format) path_map_in=os.path.join(path_mean_file,map_csv_format) makeDirectory(os.path.join(path_treated_data_directory,pollutant,"cartes_de_pollution")) path_map_out=os.path.join(path_treated_data_directory,pollutant,"cartes_de_pollution",map_csv_format).replace(".csv","") with open(path_map_in,"r") as map_raw: map_raw_lines=map_raw.readlines() map_coordinates=[[float(x.split(",")[0]),float(x.split(",")[1])] for x in map_raw_lines[1:]] map_values=[[np.asarray(cm.hsv2rgb((ExpansionHistogram(float(y),scale[0],scale[1],scale_hsv[0],scale_hsv[1])),100,80,normalised=False))*255 for y in x.split(",")[3:] ] for x in map_raw_lines[1:]] ### Récupère les limites du rectangle des probes max_val_x=float(max(map_coordinates,key = lambda x: float(x[0]))[0]) min_val_x=float(min(map_coordinates,key = lambda x: float(x[0]))[0]) max_val_y=float(max(map_coordinates,key = lambda x: float(x[1]))[1]) min_val_y=float(min(map_coordinates,key = lambda x: float(x[1]))[1]) #initialisation du pas à une valeur très haute jamais atteinte pas_x=10e+5 pas_y=10e+5 ### Récupère le pas entre deux probes consécutives for i in range(0,len(map_coordinates)-1): pas_x_intermediaire=abs(float(map_coordinates[i+1][0])-float(map_coordinates[i][0]))
elif ("PM10" in pollutant): scale = scale_PM10 elif ("PM2.5" in pollutant): scale = scale_PM2_5 else: continue with open(path_map_in, "r") as map_raw: map_raw_lines = map_raw.readlines()[1:] map_raw_lines = [[ float(x.split(",")[0]), float(x.split(",")[1]), cm.hsv2rgb( (ExpansionHistogram(float(x.split(",")[2]), scale[0], scale[1], scale_hsv[0], scale_hsv[1])), 100, 100, normalised=False) ] for x in map_raw_lines] max_val_x = float(max(map_raw_lines, key=lambda x: float(x[0]))[0]) min_val_x = float(min(map_raw_lines, key=lambda x: float(x[0]))[0]) max_val_y = float(max(map_raw_lines, key=lambda x: float(x[1]))[1]) min_val_y = float(min(map_raw_lines, key=lambda x: float(x[1]))[1]) pas_x = 10e+5 pas_y = 10e+5 for i in range(0, len(map_raw_lines) - 1): pas_x_intermediaire = abs(
def convert_hsv_saturation(self, saturation_value): rgb_value = colors.hsv2rgb(0, saturation_value, 100, False) return rgb_value
def convert_hsv_hue(self, hue_value): rgb_value = colors.hsv2rgb(hue_value, 100, 100, False) return rgb_value