-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
585 lines (447 loc) · 28.8 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# coding: utf-8
import matplotlib.pyplot as plt
import numpy as np
import os
#rojo claro,verde claro, azul claro, azul oscuro, rosa, naranja, amarillo, verde oscuro, verde oliva, negro, marron, violeta, burdeos, aguamarina, gris, rojo palido
colors = ["#FE0000","#25FD00","#00BAFE","#1400FD","#FD00CE","#FD7600","#FEF900","#2D5D0A","#83B62B","#000000","#800000","#87048F","#820624","#08EC81","#827E83","#D96B4E"]
map_colors = ["Purples","Greens","Blues","Greys","Oranges","Reds","PuRd","RdPu","copper"]
lst_subplt = [1,2,6,7,11,12,16,14,5,3,9,4,15,10,8,13]
# Hasta ahora, va todo bien
#TO DO
#Poner martinelli
def no_normalizar(x):
return x
def normalizar(x):
"""
Normaliza los datos entre 0 y 1.
Normaliza una serie de numeros, representandolos entre 0 y 1
Parametros:
x -- Serie que se quiere normalizar
Retorno:
Lista con los valores normalizados
"""
miin = min(x)
diff = max(x) - miin
if diff == 0:
return [1.0]*len(x)
return [(value - miin)*1.0/diff for value in x] #Se multiplica por 1.0 para que el valor sea considerado un double.
# Normalizar utilizando el Z_Score
def normalizar_Z_Score(x):
"""
Normaliza los datos utilizando el método del ZScore.
Normaliza una serie de numeros, utilizando para ello el método del ZScore.
Parametros:
x -- Serie que se quiere normalizar
Retorno:
Lista con los valores normalizados
"""
media,desviacion = mean(x,axis=0),std(x,axis=0)
return [(value-media)/desviacion for value in x]
def get_files_folder(folder,ext=".dat"):
"""
Devuelve los ficheros de una carpeta
Devuelve el nombre de los ficheros de una carpeta, que tengan un formato concreto
Parametros:
folder -- Carpeta de donde obtener los ficheros
ext -- Extensión de los ficheros
Retorno:
lstFiles -- Lista con los ficheros obtenidos
"""
lstFiles = []
lstDir = os.walk(folder)
for root, dirs, files in lstDir:
for fichero in files:
(nombreFichero, extension) = os.path.splitext(fichero)
if(extension == ext):
lstFiles.append(folder+'/'+nombreFichero+extension if '/' not in folder else folder+nombreFichero+extension)
lstFiles.sort()
return lstFiles
# Imprimir lineas verticales
def plot_vertical_lines(s_ini,switc,n_times,CTE):
"""
Imprime lineas verticales de separación entre odorantes.
Imprime lineas verticales de separación entre los distintos odorantes que componen una captura.
Parametros:
s_ini -- muestras iniciales del experimento
switc -- tiempo en segundos que un odorante es analizado
n_times -- cuanto gases se han analizado
CTE -- si se ha dejado un tiempo de aire entre odorantes.
Retorno:
"""
cont = 0
plt.axvline(cont,color="black",linewidth=0.8)
#cont+=s_ini
#plt.axvline(cont,color="black",linewidth=0.8)
for i in range(n_times):
if CTE > 0:
cont+=CTE
plt.axvline(cont,color="black",linewidth=0.8)
cont+=switc
plt.axvline(cont,color="black",linewidth=0.8)
if CTE > 0:
cont+=CTE
plt.axvline(cont,color="black",linewidth=0.8)
return
def treat_data(file,norm,columns):
data = np.genfromtxt(file,skip_header=1,delimiter=' ').T
switch,s_ini,CTE,ntran = np.genfromtxt(file,skip_footer=len(data[0]),delimiter=' ') #Saco la cabecera
switch,s_ini,CTE,ntran = int(switch),int(s_ini),int(CTE),int(ntran)
lsts = [norm(data[c]) for c in columns]
return lsts,switch,s_ini,CTE,ntran
def plot_lst(lsts,switch,fig,div_plt,sini,colors=colors):
"""
Imprime los valores de las sublistas
Imprime los valores de las sublistas en una gráfica, en varias gráficas o en subgráficas.
Parametros:
lsts -- lista de listas con los valores que se van a imprimir
s_ini -- muestras iniciales de la captura
switch -- tiempo en que cada gas es analizado
ntran -- número de odorantes analizados
CTE -- tiempo en segundos de aire entre gases
norm -- booleano que indica si los datos están normalizados
fig -- booleano para indicar si se van a imprimir todos en la misma gráfica o no
Retorno:
"""
if fig == True:
plt.figure(1)
if div_plt == True:
lst_subpltdata_xaxisrange = list(zip(*[iter(range(len(lsts[0][sini+switch:])))]*switch))
for figure,value in enumerate(lsts): #La cosa de delante es para indicar la figura 1 2 ó 3
#value = norm(value[s_ini:])
if fig == False:
plt.figure(figure+1)
if div_plt == True:
# Hay que poner el [1:], porque la muestra 0, es la transición de las muestras iniciales al primer odorante
lst_subpltdata = list(zip(*[iter(value[sini:])]*switch))[1:]
for subplt,xaxissubpltdata,subpltdata in zip(lst_subplt,lst_subpltdata_xaxisrange,lst_subpltdata):
ax = plt.subplot(4,4,subplt)
ax.plot(xaxissubpltdata,subpltdata,'-',c=colors[figure%len(colors)])
# Lo siguiente reduce el tamaño de los valores de los ejes para que no se solapen
ax.tick_params(axis='both', which='major', labelsize=5)
ax.tick_params(axis='both', which='minor', labelsize=4)
else:
plt.plot(value[sini:],'-',c=colors[figure%len(colors)])
return
def save_plot(s_ini,switch,ntran,CTE,n_figs,xaxis,yaxis,titles,image_folder,div_plt,norm,sub_name=''):
"""
Guarda las gráficas
Guarda las gráficas en ficheros, en la carpeta que se le indica, poniendo los valores de los ejes y los titulos.
Parametros:
lsts -- lista de listas con los valores que se van a imprimir
s_ini -- muestras iniciales de la captura
switch -- tiempo en que cada gas es analizado
ntran -- número de odorantes analizados
CTE -- tiempo en segundos de aire entre gases
norm -- booleano que indica si los datos están normalizados
fig -- booleano para indicar si se van a imprimir todos en la misma gráfica o no
Retorno:
name -- nombre del fichero
"""
sub_namep = sub_name.split("/")[-1]
for i,ylabel,title in zip(range(n_figs),yaxis,titles):
fig = plt.figure(i+1)
if div_plt == True:
fig.suptitle(title, fontsize=16)
fig.text(0.5, 0.04, xaxis, ha='center')
fig.text(0.04, 0.5, ylabel, va='center', rotation='vertical')
name = "norm_div_subplots_Plot_sensor_"+sub_namep+"_"+ylabel+".eps" \
if norm == True else "div_subplots_Plot_sensor_"+sub_namep+"_"+ylabel+".eps"
else:
plot_vertical_lines(s_ini,switch,ntran,CTE)
plt.xlabel(xaxis,fontsize=23)
plt.ylabel(ylabel,fontsize=23)
plt.title(title,fontsize=30)
name = "norm_Plot_sensor_"+sub_namep+"_"+ylabel+".eps" \
if norm == True else "Plot_sensor_"+sub_namep+"_"+ylabel+".eps"
plt.savefig(image_folder+name,format="eps")
plt.close(fig)
return
# Funciona correctamente
def plot_file_columns_together(file,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=False,colors=colors[:len(lsts)],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,
xaxis=xaxis,yaxis=yaxis,titles=titles,image_folder=image_folder,div_plt=False,norm=norm,sub_name=file)
return
def plot_file_columns_together_div_subplots(file,columns,image_folder,norm,xaxis,yaxis,titles):
plot_file_columns_together(file=file,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,
titles=titles,div_plt=True)
return
# Funciona correctamente
def plot_files_separately_columns_together(files,columns,image_folder,norm,xaxis,yaxis,titles):
for file in files:
plot_file_columns_together(file=file,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles)
return
def plot_files_separately_columns_together_div_subplots(files,columns,image_folder,norm,xaxis,yaxis,titles):
for file in files:
plot_file_columns_together(file=file,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,
titles=titles,div_plt=True)
return
# Funciona correctamente
def plot_files_together_columns_together(files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
for pos,file in enumerate(files):
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=div_plt,colors=[colors[pos%len(colors)]],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,xaxis=xaxis,yaxis=yaxis,
titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=file+"_plot_files_together_columns_together")
return
def plot_files_together_columns_together_div_subplots(files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_files_together_columns_together(files=files,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,
titles=titles,div_plt=True)
return
# Funciona correctamente
def plot_folder_files_separately_columns_together(folder,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
tfiles = get_files_folder(folder)
for posfile in files:
plot_file_columns_together(file=tfiles[posfile],columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folder_files_separately_columns_together_div_subplots(folder,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_files_separately_columns_together(folder=folder,files=files,columns=columns,image_folder=image_folder,
norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
return
# Funciona correctamente
def plot_folder_files_together_columns_together(folder,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
tfiles = get_files_folder(folder)
tfiles = [tfiles[posfile] for posfile in files]
plot_files_together_columns_together(files=tfiles,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
def plot_folder_files_together_columns_together_div_subplots(folder,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_files_together_columns_together(folder=folder,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_files_separately_columns_together(folders,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
for folder in folders:
plot_folder_files_separately_columns_together(folder=folder,files=files,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folders_files_separately_columns_together_div_subplots(folders,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_files_separately_columns_together(folders=folders,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_files_together_columns_together(folders,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
for folder,posfiles,map_color in zip(folders,files,map_colors):
tfiles = get_files_folder(folder)
colors = np.linspace(0.3,1,len(posfiles))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
for posfile,color in zip(posfiles,my_colors):
lsts,switch,s_ini,CTE,ntran = treat_data(file=tfiles[posfile],norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=div_plt,colors=[color],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,xaxis=xaxis,yaxis=yaxis,titles=titles,
image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=tfiles[-1]+"_plot_folders_files_together_columns_together")
return
def plot_folders_files_together_columns_together_div_subplots(folders,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_files_together_columns_together(folders=folders,files=files,columns=columns,image_folder=image_folder,
norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_chunks_together_columns_together(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
for pos,map_color in zip(schunks,map_colors):
mymap = plt.get_cmap(map_color)
colors = np.linspace(0.3,1,len(tfiles[pos]))
my_colors = mymap(colors)
for file,color in zip(tfiles[pos],my_colors):
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=div_plt,colors=[color],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,
xaxis=xaxis,yaxis=yaxis,titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name="folder_chunks_columns_together")
return
def plot_folder_chunks_together_columns_together_div_subplots(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_chunks_together_columns_together(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_chunks_separately_columns_together(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
for pos,map_color in zip(schunks,map_colors):
colors = np.linspace(0.3,1,len(tfiles[pos]))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
for file,color in zip(tfiles[pos],my_colors):
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=div_plt,colors=[color],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,
xaxis=xaxis,yaxis=yaxis,titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name="folder_chunks_separately_columns_together_"+str(pos))
return
def plot_folder_chunks_separately_columns_together_div_subplots(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_chunks_separately_columns_together(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_chunks_separately_columns_together(folders,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
for folder in folders:
plot_folder_chunks_separately_columns_together(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folders_chunks_separately_columns_together_div_subplots(folders,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_chunks_separately_columns_together(folders=folders,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_chunks_together_columns_together(folders,chunk_sizes,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
for folder,chunk_size,schunk,map_color in zip(folders,chunk_sizes,schunks,map_colors):
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
colors = np.linspace(0.3,1,len(schunk))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
for pos,color in zip(schunk,my_colors):
for file in tfiles[pos]:
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,fig=True,div_plt=div_plt,colors=[color],sini=s_ini)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=1,xaxis=xaxis,yaxis=yaxis,titles=titles,
image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=file+"_plot_folders_chunks_together_columns_together")
return
def plot_folders_chunks_together_columns_together_div_subplots(folders,chunk_sizes,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_chunks_together_columns_together(folders=folders,chunk_sizes=chunk_sizes,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
def treat_plot_elems(files,norm,columns,colors=colors,div_plt=False):
"""
Realiza la lectura de los ficheros, su normalización y su impresión posterior.
Realiza la lectura de los ficheros, su normalización y su impresión posterior.
Parametros:
file -- fichero cuyos valores queremos representar
image_folder -- carpeta donde guardar las imágenes
Retorno:
"""
for pos,file in enumerate(files):
lsts,switch,s_ini,CTE,ntran = treat_data(file=file,norm=norm,columns=columns)
plot_lst(lsts=lsts,switch=switch,colors=[colors[pos%len(colors)]],fig=False,div_plt=div_plt,sini=s_ini)
return switch,s_ini,CTE,ntran
# Funciona correctamente
def plot_file_columns_separately(file,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
switch,s_ini,CTE,ntran = treat_plot_elems(files=[file],norm=norm,div_plt=div_plt,columns=columns,colors=colors)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),xaxis=xaxis,yaxis=yaxis,
titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=file)
return
def plot_file_columns_separately_div_subplots(file,columns,image_folder,norm,xaxis,yaxis,titles):
plot_file_columns_separately(file=file,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,
yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_files_separately_columns_separately(files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
for file in files:
plot_file_columns_separately(file=file,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,
titles=titles,div_plt=div_plt)
return
def plot_files_separately_columns_separately_div_subplots(files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_files_separately_columns_separately(files=files,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,
yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_files_together_columns_separately(files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
switch,s_ini,CTE,ntran = treat_plot_elems(files=files,norm=norm,div_plt=div_plt,columns=columns,colors=colors)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),xaxis=xaxis,yaxis=yaxis,
titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=files[-1]+"_plot_files_together_columns_separately")
return
def plot_files_together_columns_separately_div_subplots(files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_files_together_columns_separately(files=files,columns=columns,image_folder=image_folder,norm=norm,xaxis=xaxis,
yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_files_separately_columns_separately(folder,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
tfiles = get_files_folder(folder)
for posfile in files:
plot_file_columns_separately(file=tfiles[posfile],columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folder_files_separately_columns_separately_div_subplots(folder,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_files_separately_columns_separately(folder=folder,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_files_together_columns_separately(folder,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
tfiles = get_files_folder(folder)
tfiles = [tfiles[pos] for pos in files]
plot_files_together_columns_separately(files=tfiles,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folder_files_together_columns_separately_div_subplots(folder,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_files_together_columns_separately(folder=folder,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_files_separately_columns_separately(folders,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
for folder in folders:
plot_folder_files_separately_columns_separately(folder=folder,files=files,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folders_files_separately_columns_separately_div_subplots(folders,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_files_separately_columns_separately(folders=folders,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_files_together_columns_separately(folders,files,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
for folder,posfiles,map_color in zip(folders,files,map_colors):
lstfiles,tfiles = [],get_files_folder(folder)
colors = np.linspace(0.3,1,len(posfiles))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
for posfile in posfiles: #treat_plot_elems(file,norm,False,columns,colors=colors)
lstfiles.append(tfiles[posfile])
switch,s_ini,CTE,ntran = treat_plot_elems(files=lstfiles,norm=norm,columns=columns,div_plt=div_plt,colors=my_colors)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),xaxis=xaxis,yaxis=yaxis,titles=titles,
image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=lstfiles[-1]+"_plot_folders_files_together_columns_separately")
return
def plot_folders_files_together_columns_separately_div_subplots(folders,files,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_files_together_columns_separately(folders=folders,files=files,columns=columns,image_folder=image_folder,norm=norm,
xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_chunks_separately_columns_separately(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
for pos,map_color in zip(schunks,map_colors):
colors = np.linspace(0.3,1,len(tfiles[pos]))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
switch,s_ini,CTE,ntran = treat_plot_elems(files=tfiles[pos],norm=norm,columns=columns,div_plt=div_plt,colors=my_colors)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),
xaxis=xaxis,yaxis=yaxis,titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name="chunk_"+str(pos)+"_plot_folder_chunks_separately_columns_separately")
def plot_folder_chunks_separately_columns_separately_div_subplots(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_chunks_separately_columns_separately(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folder_chunks_together_columns_separately(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
for pos,map_color in zip(schunks,map_colors):
colors = np.linspace(0.3,1,len(tfiles[pos]))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
switch,s_ini,CTE,ntran = treat_plot_elems(files=tfiles[pos],norm=norm,columns=columns,div_plt=div_plt,colors=my_colors)
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),
xaxis=xaxis,yaxis=yaxis,titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name="chunk_"+str(pos)+"_plot_folder_chunks_together_columns_separately")
def plot_folder_chunks_together_columns_separately_div_subplots(folder,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folder_chunks_together_columns_separately(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_chunks_separately_columns_separately(folders,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
for folder in folders:
plot_folder_chunks_separately_columns_separately(folder=folder,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=div_plt)
return
def plot_folders_chunks_separately_columns_separately_div_subplots(folders,chunk_size,schunks,columns,image_folder,norm,xaxis,yaxis,titles):
plot_folders_chunks_separately_columns_separately(folders=folders,chunk_size=chunk_size,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)
# Funciona correctamente
def plot_folders_chunks_together_columns_separately(folders,chunk_sizes,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
os.makedirs(image_folder, mode=0o755, exist_ok=True)
for folder,chunk_size,schunk,map_color in zip(folders,chunk_sizes,schunks,map_colors):
tfiles = get_files_folder(folder)
tfiles = list(zip(*[iter(tfiles)]*chunk_size))
colors = np.linspace(0.3,1,len(schunk))
mymap = plt.get_cmap(map_color)
my_colors = mymap(colors)
for pos,color in zip(schunk,my_colors):
switch,s_ini,CTE,ntran = treat_plot_elems(files=tfiles[pos],norm=norm,columns=columns,div_plt=div_plt,colors=[color])
save_plot(s_ini=s_ini,switch=switch,ntran=ntran,CTE=CTE,n_figs=min(len(yaxis),len(titles)),xaxis=xaxis,yaxis=yaxis,
titles=titles,image_folder=image_folder,div_plt=div_plt,norm=norm,sub_name=folder+"_plot_folders_chunks_together_columns_separately")
return
def plot_folders_chunks_together_columns_separately_div_subplots(folders,chunk_sizes,schunks,columns,image_folder,norm,xaxis,yaxis,titles,div_plt=False):
plot_folders_chunks_together_columns_separately(folders=folders,chunk_sizes=chunk_sizes,schunks=schunks,columns=columns,
image_folder=image_folder,norm=norm,xaxis=xaxis,yaxis=yaxis,titles=titles,div_plt=True)