| LSSTApplications
    20.0.0
    LSSTDataManagementBasePackage | 
 
 
 
|  | 
| def | plot_flux_distributions (plt, old_mag, new_mag, old_weighted_rms, new_weighted_rms, faint, bright, old_PA1, new_PA1, name='', outdir='.plots') | 
|  | 
| def | plot_all_wcs_deltas (plt, data_refs, visits, old_wcs_list, per_ccd_plot=False, name='', outdir='.plots') | 
|  | 
| def | make_xy_wcs_grid (x_dim, y_dim, wcs1, wcs2, num=50) | 
|  | 
| def | wcs_convert (xv, yv, wcs) | 
|  | 
| def | plot_all_wcs_quivers (plt, data_refs, visits, old_wcs_list, name, outdir='.plots') | 
|  | 
| def | plot_wcs_quivers (ax, wcs1, wcs2, x_dim, y_dim) | 
|  | 
| def | plot_wcs_magnitude (plt, data_refs, visits, old_wcs_list, name, outdir='.plots') | 
|  | 
| def | plot_wcs (plt, wcs1, wcs2, x_dim, y_dim, center=(0, 0), name="", outdir='.plots') | 
|  | 
| def | plot_rms_histogram (plt, old_rms_relative, old_rms_absolute, new_rms_relative, new_rms_absolute, old_rel_total, old_abs_total, new_rel_total, new_abs_total, name="", outdir='.plots') | 
|  | 
|  | 
|  | MatchDict = collections.namedtuple('MatchDict', ['relative', 'absolute']) | 
|  | 
◆ make_xy_wcs_grid()
      
        
          | def lsst.jointcal.utils.make_xy_wcs_grid | ( |  | x_dim, | 
        
          |  |  |  | y_dim, | 
        
          |  |  |  | wcs1, | 
        
          |  |  |  | wcs2, | 
        
          |  |  |  | num = 50 | 
        
          |  | ) |  |  | 
      
 
Return num x/y grid coordinates for wcs1 and wcs2.
 
Definition at line 534 of file utils.py.
  535     """Return num x/y grid coordinates for wcs1 and wcs2.""" 
  536     x = np.linspace(0, x_dim, num)
 
  537     y = np.linspace(0, y_dim, num)
 
  540     return x1, y1, x2, y2
 
 
 
 
◆ plot_all_wcs_deltas()
      
        
          | def lsst.jointcal.utils.plot_all_wcs_deltas | ( |  | plt, | 
        
          |  |  |  | data_refs, | 
        
          |  |  |  | visits, | 
        
          |  |  |  | old_wcs_list, | 
        
          |  |  |  | per_ccd_plot = False, | 
        
          |  |  |  | name = '', | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Various plots of the difference between old and new Wcs.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with.
data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef
    A list of data refs to plot.
visits : list of visit id (usually int)
    list of visit identifiers, one-to-one correspondent with catalogs.
old_wcs_list : list of lsst.afw.image.wcs.Wcs
    A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs.
per_ccd_plot : bool, optional
    Make per-ccd plots of the "wcs different" (warning: slow!)
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 498 of file utils.py.
  499                         name='', outdir='.plots'):
 
  501     Various plots of the difference between old and new Wcs. 
  505     plt : matplotlib.pyplot instance 
  506         pyplot instance to plot with. 
  507     data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef 
  508         A list of data refs to plot. 
  509     visits : list of visit id (usually int) 
  510         list of visit identifiers, one-to-one correspondent with catalogs. 
  511     old_wcs_list : list of lsst.afw.image.wcs.Wcs 
  512         A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs. 
  513     per_ccd_plot : bool, optional 
  514         Make per-ccd plots of the "wcs different" (warning: slow!) 
  516         Name to include in plot titles and save files. 
  517     outdir : str, optional 
  518         Directory to write the saved plots to. 
  525         for i, ref 
in enumerate(data_refs):
 
  526             md = ref.get(
'calexp_md')
 
  528             plot_wcs(plt, old_wcs_list[i], ref.get(
'jointcal_wcs'),
 
  529                      dims.getX(), dims.getY(),
 
  530                      center=(md.getScalar(
'CRVAL1'), md.getScalar(
'CRVAL2')), name=
'dataRef %d'%i,
 
 
 
 
◆ plot_all_wcs_quivers()
      
        
          | def lsst.jointcal.utils.plot_all_wcs_quivers | ( |  | plt, | 
        
          |  |  |  | data_refs, | 
        
          |  |  |  | visits, | 
        
          |  |  |  | old_wcs_list, | 
        
          |  |  |  | name, | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Make quiver plots of the WCS deltas for each CCD in each visit.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with.
data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef
    A list of data refs to plot.
visits : list of visit id (usually int)
    list of visit identifiers, one-to-one correspondent with catalogs.
old_wcs_list : list of lsst.afw.image.wcs.Wcs
    A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs.
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 555 of file utils.py.
  557     Make quiver plots of the WCS deltas for each CCD in each visit. 
  561     plt : matplotlib.pyplot instance 
  562         pyplot instance to plot with. 
  563     data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef 
  564         A list of data refs to plot. 
  565     visits : list of visit id (usually int) 
  566         list of visit identifiers, one-to-one correspondent with catalogs. 
  567     old_wcs_list : list of lsst.afw.image.wcs.Wcs 
  568         A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs. 
  570         Name to include in plot titles and save files. 
  571     outdir : str, optional 
  572         Directory to write the saved plots to. 
  578         ax = fig.add_subplot(111)
 
  579         for old_wcs, ref 
in zip(old_wcs_list, data_refs):
 
  580             if ref.dataId[
'visit'] != visit:
 
  582             md = ref.get(
'calexp_md')
 
  585                                  dims.getX(), dims.getY())
 
  588         length = (0.1*u.arcsecond).
to(u.radian).value
 
  589         ax.quiverkey(Q, 0.9, 0.95, length, 
'0.1 arcsec', coordinates=
'figure', labelpos=
'W')
 
  592         plt.title(
'visit: {}'.
format(visit))
 
  593         filename = os.path.join(outdir, 
'{}-{}-quivers.pdf')
 
  594         plt.savefig(filename.format(name, visit))
 
 
 
 
◆ plot_flux_distributions()
      
        
          | def lsst.jointcal.utils.plot_flux_distributions | ( |  | plt, | 
        
          |  |  |  | old_mag, | 
        
          |  |  |  | new_mag, | 
        
          |  |  |  | old_weighted_rms, | 
        
          |  |  |  | new_weighted_rms, | 
        
          |  |  |  | faint, | 
        
          |  |  |  | bright, | 
        
          |  |  |  | old_PA1, | 
        
          |  |  |  | new_PA1, | 
        
          |  |  |  | name = '', | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Plot various distributions of fluxes and magnitudes.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with
old_mag : np.array
    old magnitudes
new_mag : np.array
    new magnitudes
old_weighted_rms : np.array
    old rms weighted by the mean (rms(data)/mean(data))
new_weighted_rms : np.array
    old rms weighted by the mean (rms(data)/mean(data))
faint : float
    Faint end of range that PA1 was computed from.
bright : float
    Bright end of range that PA1 was computed from.
old_PA1 : float
    Old value of PA1, to plot as horizontal line.
new_PA1 : float
    New value of PA1, to plot as horizontal line.
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 436 of file utils.py.
  437                             faint, bright, old_PA1, new_PA1,
 
  438                             name='', outdir='.plots'):
 
  439     """Plot various distributions of fluxes and magnitudes. 
  443     plt : matplotlib.pyplot instance 
  444         pyplot instance to plot with 
  449     old_weighted_rms : np.array 
  450         old rms weighted by the mean (rms(data)/mean(data)) 
  451     new_weighted_rms : np.array 
  452         old rms weighted by the mean (rms(data)/mean(data)) 
  454         Faint end of range that PA1 was computed from. 
  456         Bright end of range that PA1 was computed from. 
  458         Old value of PA1, to plot as horizontal line. 
  460         New value of PA1, to plot as horizontal line. 
  462         Name to include in plot titles and save files. 
  463     outdir : str, optional 
  464         Directory to write the saved plots to. 
  468     seaborn.set_style(
'whitegrid')
 
  474     plt.plot(old_mag, old_weighted_rms, 
'.', color=old_color, label=
'old')
 
  475     plt.plot(new_mag, new_weighted_rms, 
'.', color=new_color, label=
'new')
 
  476     plt.axvline(faint, ls=
':', color=old_color)
 
  477     plt.axvline(bright, ls=
':', color=old_color)
 
  478     plt.axhline(old_PA1, ls=
'--', color=old_color)
 
  479     plt.axhline(new_PA1, ls=
'--', color=new_color)
 
  480     plt.legend(loc=
'upper left')
 
  481     plt.title(
'Where is the systematic flux rms limit?')
 
  482     plt.xlabel(
'magnitude')
 
  483     plt.ylabel(
'rms/mean per source')
 
  484     filename = os.path.join(outdir, 
'{}-photometry-PA1.pdf')
 
  485     plt.savefig(filename.format(name))
 
  488     seaborn.distplot(old_weighted_rms, fit=scipy.stats.lognorm, kde=
False, label=
"old", color=old_color)
 
  489     seaborn.distplot(new_weighted_rms, fit=scipy.stats.lognorm, kde=
False, label=
"new", color=new_color)
 
  490     plt.title(
'Source RMS pre/post-jointcal')
 
  491     plt.xlabel(
'rms(flux)/mean(flux)')
 
  493     plt.legend(loc=
'upper right')
 
  494     filename = os.path.join(outdir, 
'{}-photometry-rms.pdf')
 
  495     plt.savefig(filename.format(name))
 
 
 
 
◆ plot_rms_histogram()
      
        
          | def lsst.jointcal.utils.plot_rms_histogram | ( |  | plt, | 
        
          |  |  |  | old_rms_relative, | 
        
          |  |  |  | old_rms_absolute, | 
        
          |  |  |  | new_rms_relative, | 
        
          |  |  |  | new_rms_absolute, | 
        
          |  |  |  | old_rel_total, | 
        
          |  |  |  | old_abs_total, | 
        
          |  |  |  | new_rel_total, | 
        
          |  |  |  | new_abs_total, | 
        
          |  |  |  | name = "", | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Plot histograms of the source separations and their RMS values.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with.
old_rms_relative : np.array
    old relative rms/star
old_rms_absolute : np.array
    old absolute rms/star
new_rms_relative : np.array
    new relative rms/star
new_rms_absolute : np.array
    new absolute rms/star
old_rel_total : float
    old relative rms over all stars
old_abs_total : float
    old absolute rms over all stars
new_rel_total : float
    new relative rms over all stars
new_abs_total : float
    new absolute rms over all stars
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 715 of file utils.py.
  716                        new_rms_relative, new_rms_absolute,
 
  717                        old_rel_total, old_abs_total, new_rel_total, new_abs_total,
 
  718                        name="", outdir='.plots'):
 
  719     """Plot histograms of the source separations and their RMS values. 
  723     plt : matplotlib.pyplot instance 
  724         pyplot instance to plot with. 
  725     old_rms_relative : np.array 
  726         old relative rms/star 
  727     old_rms_absolute : np.array 
  728         old absolute rms/star 
  729     new_rms_relative : np.array 
  730         new relative rms/star 
  731     new_rms_absolute : np.array 
  732         new absolute rms/star 
  733     old_rel_total : float 
  734         old relative rms over all stars 
  735     old_abs_total : float 
  736         old absolute rms over all stars 
  737     new_rel_total : float 
  738         new relative rms over all stars 
  739     new_abs_total : float 
  740         new absolute rms over all stars 
  742         Name to include in plot titles and save files. 
  743     outdir : str, optional 
  744         Directory to write the saved plots to. 
  752     plotOptions = {
'lw': 2, 
'range': (0, 0.1)*u.arcsecond, 
'normed': 
True,
 
  753                    'bins': 30, 
'histtype': 
'step'}
 
  755     plt.title(
'relative vs. absolute: %d vs. %d'%(len(old_rms_relative), len(old_rms_absolute)))
 
  757     plt.hist(old_rms_absolute, color=color_abs, ls=ls_old, label=
'old abs', **plotOptions)
 
  758     plt.hist(new_rms_absolute, color=color_abs, ls=ls_new, label=
'new abs', **plotOptions)
 
  760     plt.hist(old_rms_relative, color=color_rel, ls=ls_old, label=
'old rel', **plotOptions)
 
  761     plt.hist(new_rms_relative, color=color_rel, ls=ls_new, label=
'new rel', **plotOptions)
 
  763     plt.axvline(x=old_abs_total.value, linewidth=1.5, color=color_abs, ls=ls_old)
 
  764     plt.axvline(x=new_abs_total.value, linewidth=1.5, color=color_abs, ls=ls_new)
 
  765     plt.axvline(x=old_rel_total.value, linewidth=1.5, color=color_rel, ls=ls_old)
 
  766     plt.axvline(x=new_rel_total.value, linewidth=1.5, color=color_rel, ls=ls_new)
 
  768     plt.xlim(plotOptions[
'range'])
 
  769     plt.xlabel(
'arcseconds')
 
  770     plt.legend(loc=
'best')
 
  771     filename = os.path.join(outdir, 
'{}-histogram.pdf')
 
  772     plt.savefig(filename.format(name))
 
 
 
 
◆ plot_wcs()
      
        
          | def lsst.jointcal.utils.plot_wcs | ( |  | plt, | 
        
          |  |  |  | wcs1, | 
        
          |  |  |  | wcs2, | 
        
          |  |  |  | x_dim, | 
        
          |  |  |  | y_dim, | 
        
          |  |  |  | center = (0, 0), | 
        
          |  |  |  | name = "", | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Plot the "distortion map": wcs1-wcs2 delta of points in the CCD grid.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with.
wcs1 : lsst.afw.image.wcs.Wcs
    First WCS to compare.
wcs2 : lsst.afw.image.wcs.Wcs
    Second WCS to compare.
x_dim : int
    Size of array in X-coordinate to make the grid over.
y_dim : int
    Size of array in Y-coordinate to make the grid over.
center : tuple, optional
    Center of the data, in on-chip coordinates.
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 681 of file utils.py.
  681 def plot_wcs(plt, wcs1, wcs2, x_dim, y_dim, center=(0, 0), name=
"", outdir=
'.plots'):
 
  682     """Plot the "distortion map": wcs1-wcs2 delta of points in the CCD grid. 
  686     plt : matplotlib.pyplot instance 
  687         pyplot instance to plot with. 
  688     wcs1 : lsst.afw.image.wcs.Wcs 
  689         First WCS to compare. 
  690     wcs2 : lsst.afw.image.wcs.Wcs 
  691         Second WCS to compare. 
  693         Size of array in X-coordinate to make the grid over. 
  695         Size of array in Y-coordinate to make the grid over. 
  696     center : tuple, optional 
  697         Center of the data, in on-chip coordinates. 
  699         Name to include in plot titles and save files. 
  700     outdir : str, optional 
  701         Directory to write the saved plots to. 
  707     plt.plot((x1 - x2) + center[0], (y1 - y2) + center[1], 
'-')
 
  708     plt.xlabel(
'delta RA (arcsec)')
 
  709     plt.ylabel(
'delta Dec (arcsec)')
 
  711     filename = os.path.join(outdir, 
'{}-wcs.pdf')
 
  712     plt.savefig(filename.format(name))
 
 
 
◆ plot_wcs_magnitude()
      
        
          | def lsst.jointcal.utils.plot_wcs_magnitude | ( |  | plt, | 
        
          |  |  |  | data_refs, | 
        
          |  |  |  | visits, | 
        
          |  |  |  | old_wcs_list, | 
        
          |  |  |  | name, | 
        
          |  |  |  | outdir = '.plots' | 
        
          |  | ) |  |  | 
      
 
Plot the magnitude of the WCS change between old and new visits as a heat map.
Parameters
----------
plt : matplotlib.pyplot instance
    pyplot instance to plot with.
data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef
    A list of data refs to plot.
visits : list of visit id (usually int)
    list of visit identifiers, one-to-one correspondent with catalogs.
old_wcs_list : list of lsst.afw.image.wcs.Wcs
    A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs.
name : str
    Name to include in plot titles and save files.
outdir : str, optional
    Directory to write the saved plots to.
 
Definition at line 621 of file utils.py.
  622     """Plot the magnitude of the WCS change between old and new visits as a heat map. 
  626     plt : matplotlib.pyplot instance 
  627         pyplot instance to plot with. 
  628     data_refs : list of lsst.daf.persistence.butlerSubset.ButlerDataRef 
  629         A list of data refs to plot. 
  630     visits : list of visit id (usually int) 
  631         list of visit identifiers, one-to-one correspondent with catalogs. 
  632     old_wcs_list : list of lsst.afw.image.wcs.Wcs 
  633         A list of the old (pre-jointcal) WCSs, one-to-one corresponding to data_refs. 
  635         Name to include in plot titles and save files. 
  636     outdir : str, optional 
  637         Directory to write the saved plots to. 
  641         fig.set_tight_layout(
True)
 
  642         ax = fig.add_subplot(111)
 
  648         for old_wcs, ref 
in zip(old_wcs_list, data_refs):
 
  649             if ref.dataId[
'visit'] != visit:
 
  651             md = ref.get(
'calexp_md')
 
  654                                               old_wcs, ref.get(
'jointcal_wcs'))
 
  657             extent = (x1[0, 0], x1[-1, -1], y1[0, 0], y1[-1, -1])
 
  658             xmin = 
min(x1.min(), xmin)
 
  659             ymin = 
min(y1.min(), ymin)
 
  660             xmax = 
max(x1.max(), xmax)
 
  661             ymax = 
max(y1.max(), ymax)
 
  662             magnitude = (np.linalg.norm((uu, vv), axis=0)*u.radian).
to(u.arcsecond).value
 
  663             img = ax.imshow(magnitude, vmin=0, vmax=0.3,
 
  664                             aspect=
'auto', extent=extent, cmap=plt.get_cmap(
'magma'))
 
  670         cbar = plt.colorbar(img)
 
  671         cbar.ax.set_ylabel(
'distortion (arcseconds)')
 
  676         plt.title(
'visit: {}'.
format(visit))
 
  677         filename = os.path.join(outdir, 
'{}-{}-heatmap.pdf')
 
  678         plt.savefig(filename.format(name, visit))
 
 
 
 
◆ plot_wcs_quivers()
      
        
          | def lsst.jointcal.utils.plot_wcs_quivers | ( |  | ax, | 
        
          |  |  |  | wcs1, | 
        
          |  |  |  | wcs2, | 
        
          |  |  |  | x_dim, | 
        
          |  |  |  | y_dim | 
        
          |  | ) |  |  | 
      
 
Plot the delta between wcs1 and wcs2 as vector arrows.
Parameters
----------
ax : matplotlib.axis
    Matplotlib axis instance to plot to.
wcs1 : lsst.afw.image.wcs.Wcs
    First WCS to compare.
wcs2 : lsst.afw.image.wcs.Wcs
    Second WCS to compare.
x_dim : int
    Size of array in X-coordinate to make the grid over.
y_dim : int
    Size of array in Y-coordinate to make the grid over.
 
Definition at line 597 of file utils.py.
  599     Plot the delta between wcs1 and wcs2 as vector arrows. 
  604         Matplotlib axis instance to plot to. 
  605     wcs1 : lsst.afw.image.wcs.Wcs 
  606         First WCS to compare. 
  607     wcs2 : lsst.afw.image.wcs.Wcs 
  608         Second WCS to compare. 
  610         Size of array in X-coordinate to make the grid over. 
  612         Size of array in Y-coordinate to make the grid over. 
  618     return ax.quiver(x1, y1, uu, vv, units=
'x', pivot=
'tail', scale=1e-3, width=1e-5)
 
 
 
 
◆ wcs_convert()
      
        
          | def lsst.jointcal.utils.wcs_convert | ( |  | xv, | 
        
          |  |  |  | yv, | 
        
          |  |  |  | wcs | 
        
          |  | ) |  |  | 
      
 
Convert two arrays of x/y points into an on-sky grid.
 
Definition at line 543 of file utils.py.
  544     """Convert two arrays of x/y points into an on-sky grid.""" 
  545     xout = np.zeros((xv.shape[0], yv.shape[0]))
 
  546     yout = np.zeros((xv.shape[0], yv.shape[0]))
 
  547     for i, x 
in enumerate(xv):
 
  548         for j, y 
in enumerate(yv):
 
  549             sky = wcs.pixelToSky(x, y)
 
  550             xout[i, j] = sky.getRa()
 
  551             yout[i, j] = sky.getDec()
 
 
 
 
◆ MatchDict
      
        
          | lsst.jointcal.utils.MatchDict = collections.namedtuple('MatchDict', ['relative', 'absolute']) | 
      
 
 
 
def plot_all_wcs_quivers(plt, data_refs, visits, old_wcs_list, name, outdir='.plots')
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
def plot_wcs(plt, wcs1, wcs2, x_dim, y_dim, center=(0, 0), name="", outdir='.plots')
def plot_all_wcs_deltas(plt, data_refs, visits, old_wcs_list, per_ccd_plot=False, name='', outdir='.plots')
def plot_wcs_magnitude(plt, data_refs, visits, old_wcs_list, name, outdir='.plots')
def plot_wcs_quivers(ax, wcs1, wcs2, x_dim, y_dim)
lsst::geom::Box2I bboxFromMetadata(daf::base::PropertySet &metadata)
Determine the image bounding box from its metadata (FITS header)
def plot_flux_distributions(plt, old_mag, new_mag, old_weighted_rms, new_weighted_rms, faint, bright, old_PA1, new_PA1, name='', outdir='.plots')
def make_xy_wcs_grid(x_dim, y_dim, wcs1, wcs2, num=50)
def plot_rms_histogram(plt, old_rms_relative, old_rms_absolute, new_rms_relative, new_rms_absolute, old_rel_total, old_abs_total, new_rel_total, new_abs_total, name="", outdir='.plots')
def wcs_convert(xv, yv, wcs)