Commits
Jorge Lopez authored and Sandra Castro committed 17bc361251b Merge
493 493 | timerangeListTimes, solutionTimeThresholdSeconds,debugSloppyMatch, |
494 494 | ystartOverlayLegend,debug,mysize, fieldsToPlot,myUniqueColor, |
495 495 | timeHorizontalSpacing, fieldIndex,overlayColors, |
496 496 | antennaVerticalSpacing, overlayAntennas, |
497 497 | timerangeList, caltableTitle, |
498 498 | mytime, scansToPlot, scansForUniqueTimes): |
499 499 | """ |
500 500 | Draws the legend at the top of the page, if it is the correct time to do so, |
501 501 | including the overlayTimes, the 'UT' label, and the caltable name. |
502 502 | """ |
503 - | # debugSloppyMatch=True |
503 + | # debugSloppyMatch=True |
504 504 | if (xframe == firstFrame): |
505 505 | # draw title including caltable name |
506 - | pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize, |
507 - | color='k', transform=pb.gcf().transFigure) |
506 + | pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize, color='k', transform=pb.gcf().transFigure) |
508 507 | # support multi-fields with overlay='time' |
509 508 | uTPFPS = [] |
510 509 | uTPFPStimerange = [] |
510 + | |
511 511 | # Find all timerange integers for all fields, not just the ones that were plotted |
512 512 | allTimeranges = [] |
513 513 | for f in range(len(uniqueTimesPerFieldPerSpw[ispwInCalTable])): |
514 514 | for t in uniqueTimesPerFieldPerSpw[ispwInCalTable][f]: |
515 515 | if (t in timerangeListTimes): |
516 516 | allTimeranges.append(list(timerangeListTimes).index(t)) |
517 + | |
518 + | allTimeranges = list(np.sort(np.unique(allTimeranges))) |
519 + | |
517 520 | for f in fieldIndicesToPlot: |
518 521 | for t in uniqueTimesPerFieldPerSpw[ispwInCalTable][f]: |
519 522 | matched, mymatch = sloppyMatch(t, timerangeListTimes, solutionTimeThresholdSeconds, |
520 523 | myprint=debugSloppyMatch, whichone=True) |
521 524 | if (matched): |
522 525 | uTPFPS.append(t) |
523 526 | uTPFPStimerange.append(mymatch) |
524 - | allTimeranges = list(np.sort(np.unique(allTimeranges))) |
527 + | |
525 528 | idx = np.argsort(uTPFPS) |
526 529 | uTPFPStimerange = np.array(uTPFPStimerange)[idx] |
527 530 | uTPFPS = np.sort(uTPFPS) |
528 531 | timeFormat = 3 # HH:MM:SS |
529 532 | maxTimesAcross = maxTimesAcrossTheTop |
530 533 | if (firstFrame == 111): |
531 534 | maxTimesAcross -= 2 |
532 535 | for a in range(len(uTPFPS)): |
533 536 | legendString = utstring(uTPFPS[a],timeFormat) |
534 537 | if (debug): print("----> Defined legendString: %s" % (legendString)) |
546 549 | if (True): |
547 550 | if (debug): |
548 551 | print("3)checking time %d, len(uTPFPS)=%d" % (a,len(uTPFPS))) |
549 552 | if (sloppyMatch(uTPFPS[a],timerangeListTimes, |
550 553 | solutionTimeThresholdSeconds, |
551 554 | mytime, scansToPlot, scansForUniqueTimes, |
552 555 | myprint=debugSloppyMatch)): |
553 556 | myUniqueTime = uTPFPS[a] |
554 557 | if (debug): |
555 558 | print("3)setting myUniqueTime to %d" % (myUniqueTime)) |
559 + | |
556 560 | if (debug): print("----> Drawing legendString: %s" % (legendString)) |
557 561 | if ((len(fieldsToPlot) > 1 or len(timerangeList) > 1) and overlayAntennas==False): |
558 562 | # having overlayAntennas==False here will force all time labels to be black (as desired) |
559 563 | if (debug): |
560 564 | print("len(uTPFPS)=%d, a=%d, len(myUniqueColor)=%d" % (len(uTPFPS),a,len(myUniqueColor))) |
561 565 | # pb.text(x0, y0, legendString,color=overlayColors[timerangeList[a]],fontsize=mysize, |
562 566 | # transform=pb.gcf().transFigure) |
563 567 | if (debug): |
564 568 | print("len(uTPFPStimerange)=%d, a=%d, len(myUniqueColor)=%d" % (len(uTPFPStimerange),a,len(myUniqueColor))) |
565 - | pb.text(x0, y0, legendString,color=overlayColors[timerangeList[allTimeranges.index(uTPFPStimerange[a])]], |
566 - | fontsize=mysize, transform=pb.gcf().transFigure) |
569 + | |
570 + | uTPFPStimerangeValue = uTPFPStimerange[a] |
571 + | try: |
572 + | timerangeListIndex = allTimeranges.index(uTPFPStimerangeValue) |
573 + | except ValueError: |
574 + | casalogPost(debug, "uTPFPStimerangeValue = {} is not in the list allTimeranges".format(uTPFPStimerangeValue)) |
575 + | casalogPost(debug, "Setting timerangeListIndex = 0. This will change the overlay colors index to a default value. The time labels might not look as expected.") |
576 + | casalogPost(debug, "It is possible that certain antennas had a slightly different timestamp.") |
577 + | timerangeListIndex = 0 |
578 + | |
579 + | overlayColorsIndex = timerangeList[timerangeListIndex] |
580 + | pb.text(x0, y0, legendString, color=overlayColors[overlayColorsIndex], fontsize=mysize, transform=pb.gcf().transFigure) |
581 + | |
567 582 | if (debug): |
568 583 | print("done text") |
569 584 | else: |
570 - | pb.text(x0, y0, legendString,fontsize=mysize, transform=pb.gcf().transFigure) |
585 + | pb.text(x0, y0, legendString, fontsize=mysize, transform=pb.gcf().transFigure) |
571 586 | |
572 587 | def lineNumber(): |
573 588 | """Returns the current line number in our program.""" |
574 589 | return inspect.currentframe().f_back.f_lineno |
575 590 | |
576 591 | def drawAtmosphereAndFDM(showatm, showtsky, atmString, subplotRows, mysize, TebbSky, |
577 592 | TebbSkyImage,plotrange, xaxis, atmchan, atmfreq, transmission, |
578 593 | subplotCols, showatmPoints,xframe, channels,LO1,atmchanImage, |
579 594 | atmfreqImage,transmissionImage, firstFrame,showfdm,nChannels,tableFormat, |
580 595 | originalSpw_casa33, chanFreqGHz_casa33,originalSpw,chanFreqGHz, |
661 676 | |
662 677 | def plural(u): |
663 678 | """ |
664 679 | If the length of the array passed is > 1, return 's', otherwise return ''. |
665 680 | """ |
666 681 | if (len(u) > 1): |
667 682 | return('s') |
668 683 | else: |
669 684 | return('') |
670 685 | |
671 - | def casalogPost(debug,mystring): |
686 + | def casalogPost(debug, mystring): |
672 687 | casalog.post(mystring) |
673 688 | if (debug): print(mystring) |
674 689 | |
675 690 | def computeHighestSpwIndexInSpwsToPlotThatHasCurrentScan(spwsToPlot, scansToPlotPerSpw, scan): |
676 691 | highestSpwIndex = -1 |
677 692 | for i,spw in enumerate(spwsToPlot): |
678 693 | if (scan in scansToPlotPerSpw[spw]): |
679 694 | highestSpwIndex = i |
680 695 | return(highestSpwIndex) |
681 696 | |