@@ -421,6 +421,8 @@ def makeFigureAndAxes(nrows=2) -> tuple[Figure, Any]:
421421def plotData (
422422 axs : npt .NDArray [np .object_ ],
423423 table : Table ,
424+ maxPointsPerDetector : int = 60 ,
425+ minPointsPerDetector : int = 5 ,
424426 prefix : str = "" ,
425427) -> None :
426428 """Plot the data from the table on the provided figure and axes.
@@ -431,16 +433,31 @@ def plotData(
431433 The array of axes objects to plot on.
432434 table : `astropy.table.Table`
433435 The table containing the data to be plotted.
436+ maxPointsPerDetector : `int`, optional
437+ The maximum number of points per detector to plot. If the number of
438+ points in the table is greater than this value, a random subset of
439+ points will be plotted.
440+ minPointsPerDetector : `int`, optional
441+ The minimum number of points per detector to plot. If the number of
442+ points in the table is less than this value,
443+ all points will be plotted.
434444 prefix : `str`, optional
435445 The prefix to be added to the column names of the rotated shapes.
436446 """
447+ table_downsampled = randomRowsPerDetector (table , minPointsPerDetector )
448+ table = randomRowsPerDetector (table , maxPointsPerDetector )
449+
437450 x = table [prefix + "x" ]
438451 y = table [prefix + "y" ]
439452 e1 = table [prefix + "e1" ]
440453 e2 = table [prefix + "e2" ]
441454 e = table ["e" ]
442455 fwhm = table ["FWHM" ]
443456
457+ e1_downsampled = table_downsampled [prefix + "e1" ]
458+ e2_downsampled = table_downsampled [prefix + "e2" ]
459+ e_downsampled = table_downsampled ["e" ]
460+
444461 # Quiver plot
445462 quiver_kwargs = {
446463 "headlength" : 0 ,
@@ -449,20 +466,22 @@ def plotData(
449466 "pivot" : "middle" ,
450467 }
451468
452- shape_angle = 0.5 * np .arctan2 (e2 , e1 ) # spin-2
453- Q_shape = axs [0 , 0 ].quiver (x , y , e * np .cos (shape_angle ), e * np .sin (shape_angle ), ** quiver_kwargs )
469+ shape_angle = 0.5 * np .arctan2 (e2_downsampled , e1_downsampled ) # spin-2
470+ Q_shape = axs [0 , 0 ].quiver (
471+ x , y , e_downsampled * np .cos (shape_angle ), e_downsampled * np .sin (shape_angle ), ** quiver_kwargs
472+ )
454473 axs [0 , 1 ].quiverkey (Q_shape , X = 0.08 , Y = 0.95 , U = 0.2 , label = "0.2" , labelpos = "S" )
455474
456475 # FWHM plot
457- cbar = addColorbarToAxes (axs [0 , 1 ].scatter (x , y , c = fwhm , s = 5 ))
476+ cbar = addColorbarToAxes (axs [0 , 1 ].scatter (x , y , c = fwhm , s = 1 ))
458477 cbar .set_label ("FWHM [arcsec]" )
459478
460479 # Ellipticity plots
461480 emax = np .quantile (np .abs (np .concatenate ([e1 , e2 ])), 0.98 )
462- axs [1 , 0 ].scatter (x , y , c = e1 , vmin = - emax , vmax = emax , cmap = "bwr" , s = 5 )
481+ axs [1 , 0 ].scatter (x , y , c = e1 , vmin = - emax , vmax = emax , cmap = "bwr" , s = 1 )
463482 axs [1 , 0 ].text (0.05 , 0.92 , "e1" , transform = axs [1 , 0 ].transAxes , fontsize = 10 )
464483
465- cbar = addColorbarToAxes (axs [1 , 1 ].scatter (x , y , c = e2 , vmin = - emax , vmax = emax , cmap = "bwr" , s = 5 ))
484+ cbar = addColorbarToAxes (axs [1 , 1 ].scatter (x , y , c = e2 , vmin = - emax , vmax = emax , cmap = "bwr" , s = 1 ))
466485 cbar .set_label ("e" )
467486 axs [1 , 1 ].text (0.89 , 0.92 , "e2" , transform = axs [1 , 1 ].transAxes , fontsize = 10 )
468487
@@ -896,7 +915,8 @@ def makeAzElPlot(
896915 axs : npt .NDArray [np .object_ ],
897916 table : Table ,
898917 camera : Camera ,
899- maxPointsPerDetector : int = 5 ,
918+ maxPointsPerDetector : int = 60 ,
919+ minPointsPerDetector : int = 5 ,
900920 saveAs : str = "" ,
901921) -> None :
902922 """Plot the PSFs on the focal plane, rotated to az/el coordinates.
@@ -931,6 +951,10 @@ def makeAzElPlot(
931951 The maximum number of points per detector to plot. If the number of
932952 points in the table is greater than this value, a random subset of
933953 points will be plotted.
954+ minPointsPerDetector : `int`, optional
955+ The minimum number of points per detector to plot. If the number of
956+ points in the table is less than this value,
957+ all points will be plotted.
934958 saveAs : `str`, optional
935959 The file path to save the figure.
936960 """
@@ -939,8 +963,8 @@ def makeAzElPlot(
939963
940964 if "kurtosis" in table .columns and axs .shape [0 ] > 2 :
941965 plotHigherOrderMomentsData (axs [2 , :], table , prefix = "aa_" )
942- table = randomRowsPerDetector ( table , maxPointsPerDetector )
943- plotData (axs [:2 , :], table , prefix = "aa_" )
966+
967+ plotData (axs [:2 , :], table , maxPointsPerDetector , minPointsPerDetector , prefix = "aa_" )
944968
945969 oneRaftOnly = camera .getName () in ["LSSTComCam" , "LSSTComCamSim" , "TS8" ]
946970 plotLimit = 90 * MM_TO_DEG if oneRaftOnly else 90 * MM_TO_DEG * FULL_CAMERA_FACTOR
0 commit comments