Commits

Pam Harris authored and Ville Suoranta committed 37d015eb1c1 Merge
Pull request #788: CAS-14276 fix plotbandpass exception

Merge in CASA/casa6 from CAS-14276 to master * commit 'e62c959ec065f26e98dc6a4a99ec3f403ae8e9bc': Fix showfdm overlay colors exception

casatasks/src/private/task_plotbandpass.py

Modified
501 501 # if (casadef.subversion_revision > '22653'):
502 502 return(mymsmd.nspw(False))
503 503 # else:
504 504 # return(mymsmd.nspw())
505 505
506 506
507 507 def drawOverlayTimeLegends(xframe,firstFrame,xstartTitle,ystartTitle,caltable,titlesize,
508 508 fieldIndicesToPlot,ispwInCalTable,uniqueTimesPerFieldPerSpw,
509 509 timerangeListTimes, solutionTimeThresholdSeconds,debugSloppyMatch,
510 510 ystartOverlayLegend,debug,mysize, fieldsToPlot,myUniqueColor,
511 - timeHorizontalSpacing, fieldIndex,overlayColors,
511 + timeHorizontalSpacing, fieldIndex, overlayColors,
512 512 antennaVerticalSpacing, overlayAntennas,
513 513 timerangeList, caltableTitle,
514 514 mytime, scansToPlot, scansForUniqueTimes):
515 515 """
516 516 Draws the legend at the top of the page, if it is the correct time to do so,
517 517 including the overlayTimes, the 'UT' label, and the caltable name.
518 518 """
519 519 # debugSloppyMatch=True
520 520 if (xframe == firstFrame):
521 521 # draw title including caltable name
603 603 def lineNumber():
604 604 """Returns the current line number in our program."""
605 605 return inspect.currentframe().f_back.f_lineno
606 606
607 607 def drawAtmosphereAndFDM(showatm, showtsky, atmString, subplotRows, mysize, TebbSky,
608 608 TebbSkyImage,plotrange, xaxis, atmchan, atmfreq, transmission,
609 609 subplotCols, showatmPoints,xframe, channels,LO1,atmchanImage,
610 610 atmfreqImage,transmissionImage, firstFrame,showfdm,nChannels,tableFormat,
611 611 originalSpw_casa33, chanFreqGHz_casa33,originalSpw,chanFreqGHz,
612 612 overlayTimes, overlayAntennas, xant, antennasToPlot, overlaySpws,
613 - baseband, showBasebandNumber, basebandDict, overlayBasebands,
613 + baseband, showBasebandNumber, basebandDict, overlayBasebands, overlayColors,
614 614 drewAtmosphere, showtsys=False, Trx=None):
615 615 """
616 616 If requested by the user at the command line, draw the atmospheric curve
617 617 and the FDM window locations.
618 618 """
619 619 mylineno = lineNumber()
620 620 ylim = pb.ylim() # CAS-8655
621 621 if ((showatm or showtsky) and len(atmString) > 0):
622 622 ylim = DrawAtmosphere(showatm, showtsky, subplotRows, atmString,
623 623 mysize, TebbSky, plotrange, xaxis, atmchan,
640 640 loc=202, showtsys=showtsys, Trx=Trx)
641 641 # The following case is needed for the case that overlay='antenna,time' and
642 642 # the final timerange is flagged on the final antenna.
643 643 # if (overlayTimes==False or overlayAntennas==False or xant==antennasToPlot[-1]):
644 644 # Because this function is now only called from one place, setting this to
645 645 # True is what we want. - 18-Jun-2013
646 646 if (True):
647 647 if (xaxis.find('freq')>=0 and showfdm and nChannels <= 256):
648 648 if (tableFormat == 33):
649 649 showFDM(originalSpw_casa33, chanFreqGHz_casa33,
650 - baseband, showBasebandNumber, basebandDict)
650 + baseband, showBasebandNumber, basebandDict, overlayColors)
651 651 else:
652 652 showFDM(originalSpw, chanFreqGHz,
653 - baseband, showBasebandNumber, basebandDict)
653 + baseband, showBasebandNumber, basebandDict, overlayColors)
654 654 ylim = pb.ylim() # CAS-11062 need to pass the new wider limits back up to calling function
655 655 return ylim # CAS-8655
656 656
657 657 def DrawPolarizationLabelsForOverlayTime(xstartPolLabel,ystartPolLabel,corr_type,polsToPlot,
658 658 channeldiff,ystartMadLabel,subplotRows,gamp_mad,mysize,
659 659 ampmarkstyle,markersize,ampmarkstyle2, gamp_std):
660 660 """
661 661 Currently this is only called for amp vs. X plots. The corresponding code for phase
662 662 vs. X plots is still inside plotbandpass(). But this is okay because overlay='time'
663 663 is mainly intended for Tsys plots.
3407 3407 newylimits = drawAtmosphereAndFDM(showatm,showtsky,atmString,subplotRows,mysize,
3408 3408 TebbSky,TebbSkyImage,plotrange, xaxis,atmchan,
3409 3409 atmfreq,transmission,subplotCols,showatmPoints,
3410 3410 xframe, channels,LO1,atmchanImage,atmfreqImage,
3411 3411 transmissionImage, firstFrame,showfdm,nChannels,
3412 3412 tableFormat,originalSpw_casa33,
3413 3413 chanFreqGHz_casa33,originalSpw,chanFreqGHz,
3414 3414 overlayTimes, overlayAntennas, xant,
3415 3415 antennasToPlot, overlaySpws, baseband,
3416 3416 showBasebandNumber, basebandDict,
3417 - overlayBasebands, drewAtmosphere, showtsys)
3417 + overlayBasebands, overlayColors, drewAtmosphere, showtsys)
3418 3418 drewAtmosphere = True
3419 3419 if (xctr == firstUnflaggedAntennaToPlot or overlayAntennas==False): # changed xant->xctr on 11-mar-2014
3420 3420 DrawPolarizationLabelsForOverlayTime(xstartPolLabel,ystartPolLabel,corr_type,polsToPlot,
3421 3421 channeldiff,ystartMadLabel,subplotRows,gamp_mad,mysize,
3422 3422 ampmarkstyle,markersize,ampmarkstyle2,gamp_std)
3423 3423 else: # not overlaying times
3424 3424 msg = "Skip %s spw%d (%s) all data flagged" % (antstring, ispw, titleString)
3425 3425 casalogPost(True, msg)
3426 3426 if ((overlaySpws or overlayBasebands) and spwctr==spwctrFirstToPlot):
3427 3427 spwctrFirstToPlot += 1
4161 4161 # draw title including caltable name
4162 4162 pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize,
4163 4163 color='k', transform=pb.gcf().transFigure)
4164 4164 if (debug): print("drawOverlayTimeLegends loc 2")
4165 4165 drawOverlayTimeLegends(xframe,firstFrame,xstartTitle,ystartTitle,
4166 4166 caltable,titlesize,fieldIndicesToPlot,
4167 4167 ispwInCalTable,uniqueTimesPerFieldPerSpw,
4168 4168 timerangeListTimes, solutionTimeThresholdSeconds,
4169 4169 debugSloppyMatch,ystartOverlayLegend,debug,mysize,
4170 4170 fieldsToPlot,myUniqueColor,timeHorizontalSpacing,
4171 - fieldIndex,overlayColors, antennaVerticalSpacing,
4171 + fieldIndex, overlayColors, antennaVerticalSpacing,
4172 4172 overlayAntennas, timerangeList, caltableTitle,
4173 4173 mytime, scansToPlotPerSpw[ispw], scansForUniqueTimes)
4174 4174 # mytime, scansToPlot, scansForUniqueTimes) # task version
4175 4175 if (debug): print("done drawOverlayTimeLegends loc 2")
4176 4176 elif (overlayAntennas and overlayTimes): # Oct 23, 2012
4177 4177 # This will only happen for overlay='antenna,time'
4178 4178 if (xframe == firstFrame and mytime == firstTimeMatch and xctr==firstUnflaggedAntennaToPlot and bOverlay==False): # bug fix on 2015-08-19 for CAS-7820
4179 4179 # draw title including caltable name
4180 4180 pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize, color='k',
4181 4181 transform=pb.gcf().transFigure)
4193 4193 print("-----------ispwInCalTable=%d, mytime=%d, len(uniqueTimes) = %d" % (ispwInCalTable, mytime, len(uniqueTimes)))
4194 4194 doneOverlayTime = False
4195 4195 if (doneOverlayTime):
4196 4196 # This is necessary for the case that no antennas were flagged for the single timerange selected
4197 4197 if (debug): print("drawOverlayTimeLegends loc 3")
4198 4198 drawOverlayTimeLegends(xframe,firstFrame,xstartTitle,ystartTitle,caltable,titlesize,
4199 4199 fieldIndicesToPlot,ispwInCalTable,uniqueTimesPerFieldPerSpw,
4200 4200 timerangeListTimes, solutionTimeThresholdSeconds,
4201 4201 debugSloppyMatch,ystartOverlayLegend,debug,mysize,
4202 4202 fieldsToPlot,myUniqueColor,timeHorizontalSpacing,
4203 - fieldIndex,overlayColors, antennaVerticalSpacing,
4203 + fieldIndex, overlayColors, antennaVerticalSpacing,
4204 4204 overlayAntennas, timerangeList, caltableTitle,
4205 4205 mytime, scansToPlotPerSpw[ispw], scansForUniqueTimes)
4206 4206 # mytime, scansToPlot, scansForUniqueTimes) # task version
4207 4207
4208 4208
4209 4209 if (debug): print("####### 2nd place")
4210 4210 # Here is 2nd place where we eliminate any white space on the right and left edge of the plots: 'amp'
4211 4211 #
4212 4212 if (abs(plotrange[2]) > 0 or abs(plotrange[3]) > 0):
4213 4213 SetNewYLimits([plotrange[2],plotrange[3]])
4264 4264 subplotCols, LO1, xframe, firstFrame,
4265 4265 showatmPoints,
4266 4266 channels=channels,mylineno=lineNumber(),
4267 4267 overlaySpws=overlaySpws,
4268 4268 overlayBasebands=overlayBasebands,
4269 4269 drewAtmosphere=drewAtmosphere,loc=204,
4270 4270 showtsys=showtsys, Trx=Trx)
4271 4271 drewAtmosphere = True
4272 4272 if (xaxis.find('freq')>=0 and showfdm and nChannels <= 256):
4273 4273 if (tableFormat == 33):
4274 - showFDM(originalSpw_casa33, chanFreqGHz_casa33, baseband, showBasebandNumber, basebandDict)
4274 + showFDM(originalSpw_casa33, chanFreqGHz_casa33, baseband, showBasebandNumber, basebandDict, overlayColors)
4275 4275 else:
4276 - showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict)
4276 + showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict, overlayColors)
4277 4277 if (debug): print("done drawAtmosphere/FDM check")
4278 4278
4279 4279 if (bOverlay):
4280 4280 # draw polarization labels
4281 4281 x0 = xstartPolLabel
4282 4282 y0 = ystartPolLabel
4283 4283 for p in range(nPolarizations):
4284 4284 if (corrTypeToString(corr_type[p]) in polsToPlot):
4285 4285 pb.text(x0, y0-p*0.03*subplotRows, corrTypeToString(corr_type[p])+'-c1',
4286 4286 color=pcolor[p],size=mysize,transform=pb.gca().transAxes)
4986 4986 # draw title including caltable name
4987 4987 pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize, color='k',
4988 4988 transform=pb.gcf().transFigure)
4989 4989 if (debug): print("drawOverlayTimeLegends loc 4")
4990 4990 drawOverlayTimeLegends(xframe,firstFrame,xstartTitle,ystartTitle,
4991 4991 caltable,titlesize,fieldIndicesToPlot,
4992 4992 ispwInCalTable,uniqueTimesPerFieldPerSpw,
4993 4993 timerangeListTimes, solutionTimeThresholdSeconds,
4994 4994 debugSloppyMatch,ystartOverlayLegend,debug,mysize,
4995 4995 fieldsToPlot,myUniqueColor,timeHorizontalSpacing,
4996 - fieldIndex,overlayColors, antennaVerticalSpacing,
4996 + fieldIndex, overlayColors, antennaVerticalSpacing,
4997 4997 overlayAntennas, timerangeList, caltableTitle,
4998 4998 mytime, scansToPlotPerSpw[ispw], scansForUniqueTimes)
4999 4999 # mytime, scansToPlot, scansForUniqueTimes) # task version
5000 5000
5001 5001 elif (overlayAntennas and overlayTimes): # Oct 23, 2012
5002 5002 # This will only happen for: try to support overlay='antenna,time'
5003 5003 if (xframe == firstFrame and mytime==0 and xctr==firstUnflaggedAntennaToPlot and bOverlay==False):
5004 5004 # draw title including caltable name
5005 5005 pb.text(xstartTitle, ystartTitle, caltableTitle, size=titlesize, color='k',
5006 5006 transform=pb.gcf().transFigure)
5062 5062 LO1, xframe, firstFrame, showatmPoints,
5063 5063 channels=channels, mylineno=lineNumber(),
5064 5064 overlaySpws=overlaySpws,
5065 5065 overlayBasebands=overlayBasebands,
5066 5066 drewAtmosphere=drewAtmosphere, loc=206,
5067 5067 showtsys=showtsys, Trx=Trx)
5068 5068 drewAtmosphere = True
5069 5069
5070 5070 if (xaxis.find('freq')>=0 and showfdm and nChannels <= 256):
5071 5071 if (tableFormat == 33):
5072 - showFDM(originalSpw_casa33, chanFreqGHz_casa33, baseband, showBasebandNumber, basebandDict)
5072 + showFDM(originalSpw_casa33, chanFreqGHz_casa33, baseband, showBasebandNumber, basebandDict, overlayColors)
5073 5073 else:
5074 - showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict)
5074 + showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict, overlayColors)
5075 5075
5076 5076 if (bOverlay):
5077 5077 # draw polarization labels
5078 5078 x0 = xstartPolLabel
5079 5079 y0 = ystartPolLabel
5080 5080 for p in range(nPolarizations):
5081 5081 if (corrTypeToString(corr_type[p]) in polsToPlot):
5082 5082 pb.text(x0, y0-p*0.03*subplotRows, corrTypeToString(corr_type[p])+'-c1',
5083 5083 color=pcolor[p],size=mysize,transform=pb.gca().transAxes)
5084 5084 pb.text(x0, y0-(p*0.03+0.06)*subplotRows, corrTypeToString(corr_type[p])+'-c2',
6159 6159 cr1 = int(np.round(np.max(channels)*stopFraction))
6160 6160 try:
6161 6161 SetNewXLimits([frequencies[cr0], frequencies[cr1]])
6162 6162 except:
6163 6163 print("b)Invalid chanrange (%d-%d). Valid range = 0-%d" % (cr0,cr1,len(frequencies)-1))
6164 6164 return(-1)
6165 6165 if (abs(plotrange[2]) > 0 or abs(plotrange[3]) > 0):
6166 6166 SetNewYLimits([plotrange[2],plotrange[3]])
6167 6167 return(0)
6168 6168
6169 -def showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict):
6169 +def showFDM(originalSpw, chanFreqGHz, baseband, showBasebandNumber, basebandDict, overlayColors):
6170 6170 """
6171 6171 Draws a horizontal bar indicating the location of FDM spws in the dataset.
6172 6172
6173 6173 Still need to limit based on the baseband -- need dictionary passed in.
6174 6174 originalSpw: should contain all spws in the dataset, not just the ones
6175 6175 in the caltable
6176 6176 baseband: the baseband of the current spw
6177 6177 showBasebandNumber: force the display of all FDM spws, and their baseband number
6178 6178 basebandDict: {1:[17,19], 2:[21,23], etc.} or {} for really old datasets
6179 6179 """

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut