-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSFPA_plots.py
More file actions
691 lines (592 loc) · 28.7 KB
/
CSFPA_plots.py
File metadata and controls
691 lines (592 loc) · 28.7 KB
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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
import matplotlib.pyplot as plt
import numpy as np
import os
from CSFPA_dataIO import RetrieveVars, kwavenum, TESPowerCalc, GridPowerCalc, OutputTESPower
import pickle #ignore warning, seems like RetrieveVars uses it
from mpl_toolkits.axes_grid1 import make_axes_locatable
pklrep = '/home/james/files4CSFPA/qbdataioOUTFILES/'
#def TotalIntensityPlot(PixCenX,PixCenY,IntT,xycoords,IT):
def TotalIntensityPlot(plotfname):
pklrep = '/home/james/files4CSFPA/qbdataioOUTFILES/' + plotfname
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklrep)
######################Total Intensity plot - Normalised
TESPower = TESPowerCalc(plotfname)
GPow = GridPowerCalc(plotfname)
plt.figure()
plt.subplot(121)
plt.scatter(PixCenX*1000,PixCenY*1000, c=TESPower, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Bolometers Total Intensity", fontsize=10)
plt.subplot(122)
plt.scatter(xycoords[:,1], xycoords[:,0], c=GPow, cmap='jet', marker='.', s=1)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Model Power Data", fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Intensity (1 W Source)")
plt.show()
os.system('spd-say "BING! BING! BING!"')
return
def IntensityXPlot(plotfname):
pklrep = '/home/james/files4CSFPA/qbdataioOUTFILES/' + plotfname
######################IntensityX plot
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklrep)
plt.figure(facecolor='xkcd:pale green')
plt.subplot(121, facecolor='#d8dcd6')#xkcd reference for this colour
plt.scatter(PixCenX,PixCenY, c=IntX/max(IntX), s=25, cmap='jet',marker='s')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("{} as Bolometers Intensity X dir".format(plotfname),fontsize=10)
plt.subplot(122, facecolor='#d8dcd6')#xkcd reference for this colour
plt.scatter(xycoords[:,0],xycoords[:,1], c=Ix/max(Ix), cmap='jet',marker='.')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("{}".format(plotfname),fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Intensity X")
plt.show()
return
def IntensityYPlot(plotfname):
pklrep = '/home/james/files4CSFPA/qbdataioOUTFILES/' + plotfname
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklrep)
######################Intensity Y plot
plt.figure()
plt.subplot(121)
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntY/max(IntY), s=8, cmap='plasma',marker='s')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("CF1 Source as Bolometers Intensity Y dir",fontsize=10)
plt.subplot(122)
plt.scatter(xycoords[:,0],xycoords[:,1], c=Iy/max(Iy), cmap='plasma',marker='.')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("CF1 Source - MODAL",fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Intensity Y")
plt.show()
return
def MagXPlot(plotfname):
#load saved variables
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(plotfname)
#load raw data from file
dataCF = np.loadtxt(filename, skiprows=1)
plt.figure(facecolor='xkcd:pale green')
plt.subplot(121, facecolor='#d8dcd6')
plt.scatter(PixCenX,PixCenY, c=MagXarr/max(MagXarr), s=25, cmap='jet',marker='s')
plt.axis([-0.055, 0.055, -0.055, 0.055])
plt.axis('equal')
plt.title("{} as Bolometers".format(plotfname),fontsize=10)
#plt.plot(0, 0, 'o', mfc='none',markersize=57.16*2,color='black')
plt.subplot(122, facecolor='#d8dcd6')
plt.scatter(xycoords[:,0],xycoords[:,1], c=dataCF[:,4]/(max(dataCF[:,4])), cmap='jet',marker='.')
#plt.scatter(xycoords[:,0],xycoords[:,1], c=MagXarr/(max(MagXarr)), cmap='plasma',marker='.')
#plt.plot(0, 0, 'o', mfc='none',markersize=57.16*2,color='black')
plt.axis([-0.055, 0.055, -0.055, 0.055])
plt.axis('equal')
plt.title("Source - {}".format(filename),fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Mag X")
plt.show()
return
def MagYPlot(plotfname, filename):
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(plotfname)
#load raw data from file
dataCF = np.loadtxt(filename, skiprows=1)
############################### plot normalised data ################
plt.figure()
plt.subplot(121)
plt.scatter(PixCenX*1000,PixCenY*1000, c=MagYarr/max(MagYarr), s=8, cmap='jet',marker='s')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Mag Y {} as Bolometers".format(filename),fontsize=10)
plt.subplot(122)
plt.scatter(xycoords[:,0],xycoords[:,1], c=dataCF[:,6]/(max(dataCF[:,6])), cmap='jet',marker='.')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Mag Y {}".format(filename),fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Mag Y")
plt.show()
return
def PhaXPlot(plotfname):
#Double check this result. Looks quite odd pattern on TESs
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(plotfname)
#load raw data from file
dataCF = np.loadtxt(filename, skiprows=1)
############################### plot normalised data ################
plt.figure()
plt.subplot(121)
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaXarr/max(PhaXarr), s=8, cmap='plasma',marker='s')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Phase X CF Source as Bolometers",fontsize=10)
plt.subplot(122)
plt.scatter(xycoords[:,0],xycoords[:,1], c=dataCF[:,5]/(max(dataCF[:,5])), cmap='plasma',marker='.')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Phase X CF Source - MODAL",fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Phase X")
plt.show()
return
def PhaYPlot():
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars()
#load raw data from file
dataCF = np.loadtxt(filename, skiprows=1)
############################### plot normalised data ################
plt.figure()
plt.subplot(121)
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaYarr/max(PhaYarr), cmap='plasma',marker='s')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Phase Y CF Source as Bolometers",fontsize=10)
plt.subplot(122)
plt.scatter(xycoords[:,0],xycoords[:,1], c=dataCF[:,7]/(max(dataCF[:,7])), cmap='plasma',marker='.')
plt.axis([-0.06, 0.06, -0.06, 0.06])
plt.axis('equal')
plt.title("Phase Y CF Source - MODAL",fontsize=10)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Phase Y")
plt.show()
return
def IntXCompPlot(pkl1,pkl2):
#initially going to hardcode for intensity or magnitude
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl1)
IntX1 = IntX/max(IntX) #NB cross and co polar are mixed up here between MODAL and GRASP
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntX1, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl2)
IntX2 = IntX/max(IntX)
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntX2, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
comp = (IntX1 - IntX2)*100
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = 0
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#do histogram here
#binarr = [-0.35, -0.25, -0.15, -0.05, 0.05, 0.015]
#binarr = [-0.325, -0.275, -0.225, -0.175, -0.125, -0.075, -0.025, 0.025, 0.075, 0.125]
#binarr = [-32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5]
#binarr = [0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25]
comp = np.abs(comp)
#analysisarray = np.abs(analysisarray)
print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
n, bins, patches = plt.hist(analysisarray)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison")
plt.show()
return
def IntYCompPlot(pkl1,pkl2):
#initially going to hardcode for intensity or magnitude
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl1)
IntY1 = IntY/max(IntY) #NB cross and co polar are mixed up here between MODAL and GRASP
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntY1, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl2)
IntY2 = IntY/max(IntY)
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntY2, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
comp = (IntY1 - IntY2)*100
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = 0
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='PiYG',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#do histogram here
#binarr = [-0.35, -0.25, -0.15, -0.05, 0.05, 0.015]
#binarr = [-0.325, -0.275, -0.225, -0.175, -0.125, -0.075, -0.025, 0.025, 0.075, 0.125]
#binarr = [-32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5]
#binarr = [0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25]
comp = np.abs(comp)
#analysisarray = np.abs(analysisarray)
print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
n, bins, patches = plt.hist(analysisarray)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison")
plt.show()
return
def TotIntCompPlot(pkl1,pkl2):
#initially going to hardcode for intensity or magnitude
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl1)
IntT1 = IntT/max(IntT)
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntT1, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl2)
IntT2 = IntT/max(IntT) #Normalise to first files peak
plt.scatter(PixCenX*1000,PixCenY*1000, c=IntT2, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
IntT1[IntT1 == 0] = 0.000001
IntT2[IntT2 == 0] = 0.000001
comp = ((IntT1 - IntT2) / IntT1) * 100 #can delete this % conversion
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = np.mean(comp)
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='RdPu',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#do histogram here
#binarr = [-0.35, -0.25, -0.15, -0.05, 0.05, 0.015]
#binarr = [-0.325, -0.275, -0.225, -0.175, -0.125, -0.075, -0.025, 0.025, 0.075, 0.125]
#binarr = [-32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5]
#binarr = [0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25]
#binarr = [0, 1, 2, 3, 4, 5, 6, 7, 8]
#comp = np.abs(comp)
#analysisarray = np.abs(analysisarray)
print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
n, bins, patches = plt.hist(analysisarray)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison - Total Intensity")
plt.show()
return
def PhaXCompPlot(pkl1,pkl2):
pklfrep1 = pklrep + pkl1
pklfrep2 = pklrep + pkl2
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklfrep1)
PhaX1 = PhaXarr#/max(PhaXarr) # cross and co polar mixed up
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaX1, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklfrep2)
PhaX2 = PhaYarr#/max(PhaXarr)
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaX2, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
comp = (PhaX1 - PhaX2) / PhaX1 * 100
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = np.mean(comp)
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='PiYG',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#do histogram here
#binarr = [-0.35, -0.25, -0.15, -0.05, 0.05, 0.015]
#binarr = [-0.325, -0.275, -0.225, -0.175, -0.125, -0.075, -0.025, 0.025, 0.075, 0.125]
#binarr = [-32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5]
#binarr = [0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25]
#analysisarray = np.abs(analysisarray)
analysisarray = analysisarray[~np.isnan(analysisarray)]
#print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
n, bins, patches = plt.hist(analysisarray)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison")
plt.show()
return
def PhaYCompPlot(pkl1,pkl2):
#initially going to hardcode for intensity or magnitude
#Is this a Pha Y plot?
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl1)
PhaY1 = PhaYarr/max(PhaYarr) # cross and co polar mixed up
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaY1, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl2)
PhaY2 = PhaYarr/max(PhaYarr)
plt.scatter(PixCenX*1000,PixCenY*1000, c=PhaY2, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
PhaY1[PhaY1 == 0] = 0.000001
PhaY2[PhaY2 == 0] = 0.000001
comp = PhaY1 / PhaY2
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = 0
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#analysisarray = np.abs(analysisarray)
analysisarray = analysisarray[~np.isnan(analysisarray)]
#print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
binarr = [-3, -2, -1, 0, 1, 2, 3]
n, bins, patches = plt.hist(analysisarray, bins=binarr)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison")
plt.show()
return
def MagXCompPlot(pkl1,pkl2):
pklfrep1 = pklrep + pkl1
pklfrep2 = pklrep + pkl2
#initially going to hardcode for intensity or magnitude
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklfrep1)
MagX1 = MagXarr#/max(MagXarr) #since cross and co polar are mixed up
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=MagX1, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl1),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklfrep2)
MagX2 = MagYarr#/max(MagYarr)
plt.scatter(PixCenX*1000,PixCenY*1000, c=MagX2, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("FP - {}".format(pkl2),fontsize=10)
plt.subplot(223, facecolor='#d8dcd6')
comp = (MagX1 - MagX2) / MagX1 * 100
analysisarray = ([])
#okay so here i am finding all of the outer pixels and setting to zero
#this allows me to analyse valid pixels between grasp and modal
#maybe i should delete these elements of the array to make data analysis easier
for i in range(len(PixCenX)):
if np.sqrt(PixCenX[i]**2 + PixCenY[i]**2) > 0.05:
comp[i] = np.mean(comp)
PixCenX[i] = 0.05
PixCenY[i] = 0.05
else:
analysisarray = np.append(comp[i], analysisarray)
#print "radius test", np.sqrt(PixCenX[i]**2 + PixCenY[i]**2)
#plt.scatter(PixCenX[i]*1000,PixCenY[i]*1000, c=comp[i], cmap='jet',marker='s')
plt.scatter(PixCenX*1000,PixCenY*1000, c=comp, cmap='jet',marker='s',s=5)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
plt.subplot(224, facecolor='#d8dcd6')
#do histogram here
#binarr = [-0.35, -0.25, -0.15, -0.05, 0.05, 0.015]
#binarr = [-0.325, -0.275, -0.225, -0.175, -0.125, -0.075, -0.025, 0.025, 0.075, 0.125]
#binarr = [-32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5, 12.5]
#binarr = [0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25]
analysisarray = np.abs(analysisarray)
#analysisarray = analysisarray[~np.isnan(analysisarray)]
print "analysis info, max, length, mean", np.max(analysisarray), len(analysisarray), np.mean(analysisarray)
n, bins, patches = plt.hist(analysisarray)
print "hist data", n, bins, patches
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="% Difference Comparison")
plt.show()
return
def FPComparisonPlotRAW(pkl1,pkl2):
#initially going to hardcode for intensity or magnitude
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl1)
IntX1 = IT/max(IT) # cx and co mixed
print "pkl1 max intensity", max(IT)
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(xycoords[:,1]*1000, xycoords[:,0]*1000, c=IntX1, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("pkl1",fontsize=10)
#delete vars
del MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pkl2)
IntX2 = IT/max(IT) # norm to first plot
print "pkl2 max intensity", max(IT)
plt.subplot(222, facecolor='#d8dcd6')
plt.scatter(xycoords[:,0]*1000, xycoords[:,1]*1000, c=IntX2, cmap='jet',marker='s')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("pkl2",fontsize=10)
#initialise comparison array and plot
#IntX1[IntX1 == 0] = min(IntX1)
#IntX2[IntX2 == 0] = min(IntX1)
comp = (( IntX1 - IntX2 ) / IntX1) *100
plt.subplot(223, facecolor='#d8dcd6')
plt.scatter(xycoords[:,0]*1000, xycoords[:,1]*1000, c=comp, cmap='RdYlGn',marker='s') #RdPu, YlGnBu
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("Data Comparison",fontsize=10)
#Now do histogram
plt.subplot(224, facecolor='#d8dcd6')
print "analysis info, max, length, mean", np.max(comp), len(comp), np.mean(comp)
n, bins, patches = plt.hist(comp)
print "hist data", n, bins, patches
#Set colorbar
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Model % Diff Comparison")
plt.show()
return
def TESPowAnalysis(plotfname):
pklrep = '/home/james/files4CSFPA/qbdataioOUTFILES/' + plotfname
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(pklrep)
######################Total Intensity plot - Normalised
TESPower = TESPowerCalc(plotfname)
GPow = GridPowerCalc(plotfname)
plt.figure(facecolor='xkcd:pale green')
plt.subplot(221, facecolor='#d8dcd6')
plt.scatter(PixCenX*1000,PixCenY*1000, c=TESPower, cmap='jet',marker='s',s=4)
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("{} Bolometers Total Instensity".format(plotfname),fontsize=10)
plt.subplot(222, facecolor='#d8dcd6')
plt.scatter(xycoords[:,0],xycoords[:,1], c=GPow, cmap='jet',marker='.')
plt.axis([-60, 60, -60, 60])
plt.axis('equal')
plt.title("RAW - {}".format(filename),fontsize=10)
plt.subplot(212, facecolor='#d8dcd6')
plt.plot(TESPower, marker='_', linestyle="", markersize=0.75)
#output TES Power to file
OutputTESPower(TESPower, filename)
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.05, 0.8])
plt.colorbar(cax=cax,label="Intensity")
plt.show()
os.system('spd-say "BING! BING! BING!"')
return
def TESPowPlot(plotfname):
rep = '/home/james/files4CSFPA/qbdataioOUTFILES/'
repfile = rep + plotfname
#load pickle data
MagXarr, PhaXarr, ReXarr, ImXarr, MagYarr, PhaYarr, ReYarr, ImYarr, vtxcntarr, PixCenX, PixCenY, IntX, IntY, IntT, Ix, Iy, IT, xycoords, filename = RetrieveVars(repfile)
#load qbdata for TES and Save function
qbrep = '/home/james/files4CSFPA/Fromqbdataio/'
qbrepfile = qbrep + filename
#load TES power array
TESPower = TESPowerCalc(plotfname)
GPow = GridPowerCalc(plotfname)
#plot tes power
fig = plt.figure(facecolor='xkcd:pale green')
fig.suptitle("File Analysis: '{}'".format(plotfname),fontsize=12)
ax1 = fig.add_subplot(221, facecolor='#d8dcd6', aspect='equal')
ax1.set_title("Bolometers Total Instensity",fontsize=10)
sc = ax1.scatter(PixCenX,PixCenY, c=TESPower, cmap='jet',marker='s',s=4)
cbar = fig.colorbar(sc, label="Intensity per Bolometer (W)")
ax2 = fig.add_subplot(222, facecolor='#d8dcd6', aspect='equal')
sc = ax2.scatter(xycoords[:,0],xycoords[:,1], c=GPow, cmap='jet',marker='.')
ax2.set_title("RAW Grasp Total Instensity", fontsize=10)
cbar = fig.colorbar(sc, label="Intensity per GRASP data point (W)")
ax3 = fig.add_subplot(212, facecolor='#d8dcd6')
tp = ax3.plot(TESPower, marker='_', linestyle="", markersize=0.75)
ax3.set_title("TES Detector Power Plot")
ax3.set_ylabel("Intensity per Bolometer (W)")
ax3.set_xlabel("TES Bolometer Number (qubicsoft order)")
ax3.set_xlim(1,992)
plt.show()
#output TES Power to file + use filename for file naming system
OutputTESPower(TESPower, filename)
return
def PowDiffCalc(file1,file2):
#compare power difference between models
rep = '/home/james/files4CSFPA/qbdataioOUTFILES/'
repfile1 = rep + file1
repfile2 = rep + file2
data1 = np.loadtxt(repfile1, skiprows=1)
data2 = np.loadtxt(repfile2, skiprows=1)
diff = ( (data1[:,1] - data2[:,1]) / data1[:,1] ) * 100
plt.plot(diff, marker='_', linestyle="")
plt.xlabel("Bolometer Number")
plt.ylabel("% Difference")
plt.title("% difference between old/new CAL_SOU coordinates")
plt.show()
return
def FPCompV2(gpkl, modaldat):
return