Welcome to legacyzpts’s documentation!

Introduction

This is the documentation for legacyzpts.

The legacyzpts package/API

class legacyzpts.legacy_zeropoints.DecamMeasurer(*args, **kwargs)[source]

DECam CP units: ADU Class to measure a variety of quantities from a single DECam CCD.

Image read will be converted to e- also zpt to e-

colorterm_ps1_to_observed(ps1stars, band)[source]

ps1stars: ps1.median 2D array of median mag for each band

class legacyzpts.legacy_zeropoints.Measurer(fn, aprad=3.5, skyrad_inner=7.0, skyrad_outer=10.0, det_thresh=8.0, match_radius=3.0, sn_min=None, sn_max=None, aper_sky_sub=False, calibrate=False, **kwargs)[source]

Main image processing functions for all cameras.

Parameters:
  • aprad – Aperture photometry radius in arcsec
  • skyrad_inner,skyrad_outer – sky annulus in arcsec
  • det_thresh – minimum S/N for matched filter
  • match_radius – arcsec matching to gaia/ps1
  • sn_min,sn_max – if not None then then {min,max} S/N will be enforced from aperture photoemtry, where S/N = apflux/sqrt(skyflux)
  • aper_sky_sub – do aperture sky subtraction instead of splinesky
add_ccd_info_to_stars_table(stars, ccds)[source]

Adds info to stars table that is inferable from ccd header

Parameters:
  • stars – the stars table
  • ccds – ccds table
add_obj_info_to_stars_table(stars, keep, obj, objra, objdec, apflux, apskyflux, apskyflux_perpix)[source]

Adds arrays from obj to stars table

Parameters:
  • stars – the stars table
  • keep – bool array of obj indices to include in stars table
  • obj
  • objra,objdec,apflux,apskyflux,apskyflux_perpix
create_zero_one_mask(bitmask, good=[])[source]

Return zero_one_mask arraygiven a bad pixel map and good pix values bitmask: ood image good: list of values to treat as good in the bitmask

do_Astrometry(obj, ref_ra, ref_dec, ccds)[source]

Measure ra,dec offsets from Gaia or PS1

Parameters:
  • obj – ps1-matched sources detected with dao phot
  • ref_ra,ref_dec – ra and dec of ther ps1 or gaia sources matched to obj
  • ccds – partially filled _ccds_table
Returns:

fits table for stars err_message: ‘’ if okay, ‘some error text’ otherwise, this will end up being

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/legacy_zeropoints.py:docstring of legacyzpts.legacy_zeropoints.Measurer.do_Astrometry, line 9)

Unexpected indentation.

stored in ccds[‘err_message’]

Return type:

stars_astrom

do_Photometry(obj, ps1, ccds, save_xy=False)[source]

Measure zeropoint relative to PS1

Parameters:
  • obj – ps1-matched sources detected with dao phot
  • ps1 – ps1 source matched to obj
  • ccds – partially filled _ccds_table
  • save_xy – if True save a fits table containing ps1_mag and apmag for matches sources and associated photometric cuts
Returns:

fits table for stars err_message: ‘’ if okay, ‘some error text’ otherwise, this will end up being

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/legacy_zeropoints.py:docstring of legacyzpts.legacy_zeropoints.Measurer.do_Photometry, line 12)

Unexpected indentation.

stored in ccds[‘err_message’]

Return type:

stars_photom

fitstars(img, ierr, xstar, ystar, fluxstar)[source]

Fit each star using a Tractor model.

get_photometric_cuts(obj, cuts_only)[source]

Do aperture photometry and create a photometric cut base on those measurements

Parameters:
  • obj – sources detected with dao phot
  • cuts_only – the final photometric cut will be returned in either case True to not compute extra things
Returns:

two dicts, cuts and phot cuts: keys are [‘good_flux_and_mag’,

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/legacy_zeropoints.py:docstring of legacyzpts.legacy_zeropoints.Measurer.get_photometric_cuts, line 9)

Unexpected indentation.

’no_badpix_in_ap_0’,’no_badpix_in_ap_0_5’,’is_iso’]

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/legacy_zeropoints.py:docstring of legacyzpts.legacy_zeropoints.Measurer.get_photometric_cuts, line 10)

Block quote ends without a blank line; unexpected unindent.

phot: keys are [“apflux”,”apmags”,”apskyflux”,”apskyflux_perpix”]

get_ps1_cuts(ps1)[source]

Returns bool of PS1 sources to keep ps1: catalogue with ps1 data

get_sky_and_sigma(img, nsigma=3)[source]

returns 2d sky image and sky rms

get_zero_one_mask(bitmask, good=[])[source]

Convert bitmask into a zero and ones mask, 1 = bad, 0 = good bitmask: ood image good: (optional) list of values to treat as good in the bitmask

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/legacy_zeropoints.py:docstring of legacyzpts.legacy_zeropoints.Measurer.get_zero_one_mask, line 4)

Unexpected indentation.
default is to use appropiate values for the camera
isolated_radec(ra, dec, nn=2, minsep=0.0002777777777777778)[source]

return indices of ra,dec for which the ra,dec points are AT LEAST a distance minsep away from their nearest neighbor point

make_plots(stars, dmag, zpt, transp)[source]

stars – stars table

read_image()[source]

Read the image and header; scale the image.

return_on_error(err_message='', ccds=None, stars_photom=None, stars_astrom=None)[source]

Sets ccds table err message, zpt to nan, and returns appropriately for self.run()

Parameters:
  • err_message – length <= 30
  • stars_photom, stars_astrom (ccds,) – (optional) tables partially filled by run()
run(ext=None, save_xy=False, psfex=False, splinesky=False)[source]

Computes statistics for 1 CCD

Parameters:
  • ext – ccdname
  • save_xy – save daophot x,y and x,y after various cuts to dict and save to json
Returns:

ccds, stars_photom, stars_astrom

sensible_sigmaclip(arr, nsigma=4.0)[source]

sigmaclip returns unclipped pixels, lo,hi, where lo,hi are the mean(goodpix) +- nsigma * sigma

class legacyzpts.legacy_zeropoints.Mosaic3Measurer(*args, **kwargs)[source]

Class to measure a variety of quantities from a single Mosaic3 CCD. UNITS: e-/s

colorterm_ps1_to_observed(ps1stars, band)[source]

ps1stars: ps1.median 2D array of median mag for each band

scale_image(img)[source]

Convert image from electrons/sec to electrons.

class legacyzpts.legacy_zeropoints.NinetyPrimeMeasurer(*args, **kwargs)[source]

Class to measure a variety of quantities from a single 90prime CCD. UNITS – CP e-/s

colorterm_ps1_to_observed(ps1stars, band)[source]

ps1stars: ps1.median 2D array of median mag for each band

get_expnum(primhdr)[source]

converts 90prime header key DTACQNAM into the unique exposure number

scale_image(img)[source]

Convert image from electrons/sec to electrons.

legacyzpts.legacy_zeropoints._ccds_table(camera='decam')[source]

Initialize the CCDs table.

Description and Units at: https://github.com/legacysurvey/legacyzpts/blob/master/DESCRIPTION_OF_OUTPUTS.md

legacyzpts.legacy_zeropoints._measure_image(args)[source]

Utility function to wrap measure_image function for multiprocessing map.

legacyzpts.legacy_zeropoints._stars_table(nstars=1)[source]

Initialize the stars table.

Description and Units at: https://github.com/legacysurvey/legacyzpts/blob/master/DESCRIPTION_OF_OUTPUTS.md

legacyzpts.legacy_zeropoints.cols_for_converted_zpt_table(which='all')[source]

Return list of columns for -zpt.fits table converted to idl names

Parameters:which

all, numeric,

nonzero_diff (numeric and expect non-zero diff with reference when compute it)

legacyzpts.legacy_zeropoints.cols_for_legacypipe_table(which='all')[source]

Return list of -legacypipe.fits table colums

Parameters:
  • which – all, numeric,
  • (numeric and expect non-zero diff with reference (nonzero_diff) –
  • compute it) (when) –
legacyzpts.legacy_zeropoints.convert_stars_table(T, camera=None, star_table=None)[source]

converts -star.fits table to idl matches table

Note, unlike converte_zeropoints_table, must treat each band
separately so loop over the bands
Parameters:
  • T – legacy stars fits_table, can be a single stars table or a merge of many stars tables
  • camera – CAMERAS
  • star_table – photom or astrom
legacyzpts.legacy_zeropoints.convert_stars_table_one_band(T, camera=None, star_table=None, zp_fid=None, pixscale=0.262)[source]

Converts legacy star fits table (T) to idl names and units

legacyzpts.legacy_zeropoints.T

legacy star fits table

legacyzpts.legacy_zeropoints.star_table

photom or astrom

legacyzpts.legacy_zeropoints.zp_fid

fiducial zeropoint for the band

legacyzpts.legacy_zeropoints.pixscale

pixscale

legacyzpts.legacy_zeropoints.expnum2exptime

dict mapping expnum to exptime

Example

kwargs= primary_hdr(zpt_fn) T= fits_table(stars_fn) newT= convert_stars_table(T, zp_fid=kwargs[‘zp_fid’], pixscale=kwargs[‘pixscale’])

legacyzpts.legacy_zeropoints.convert_zeropoints_table(T, camera=None)[source]

Make column names and units of -zpt.fits identical to IDL zeropoints

Parameters:T – fits_table of some -zpt.fits like fits file
legacyzpts.legacy_zeropoints.create_legacypipe_table(ccds_fn, camera=None)[source]

input _ccds_table fn output a table formatted for legacypipe/runbrick

legacyzpts.legacy_zeropoints.extra_ccd_keys(camera='decam')[source]

Returns list of camera-specific keywords for the ccd table

legacyzpts.legacy_zeropoints.get_extlist(camera, fn, debug=False, choose_ccd=None)[source]
Parameters:
  • fn – image fn to read hdu from
  • debug – use subset of the ccds
  • choose_ccd – if not None, use only this ccd given
Returns:

list of hdu names

legacyzpts.legacy_zeropoints.get_parser()[source]

return parser object, tells it what options to look for options can come from a list of strings or command line

legacyzpts.legacy_zeropoints.main(image_list=None, args=None)[source]

Produce zeropoints for all CP images in image_list image_list – iterable list of image filenames args – parsed argparser objection from get_parser()

legacyzpts.legacy_zeropoints.measure_image(img_fn, run_calibs=False, **measureargs)[source]

Wrapper on the camera-specific classes to measure the CCD-level data on all the FITS extensions for a given set of images.

legacyzpts.legacy_zeropoints.parse_coords(s)[source]

stackoverflow: https://stackoverflow.com/questions/9978880/python-argument-parser-list-of-list-or-tuple-of-tuples

legacyzpts.legacy_zeropoints.read_primary_header(fn)[source]

Reads the FITS primary header (HDU 0) from the given filename. This is just a faster version of fitsio.read_header(fn).

legacyzpts.legacy_zeropoints.runit(imgfn, zptfn, starfn_photom, starfn_astrom, **measureargs)[source]

Generate a legacypipe-compatible CCDs file for a given image.

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/doc/index.rst, line 31)

autodoc: failed to import module ‘legacyzpts.qa.compare_idlzpts’; the following exception was raised: Traceback (most recent call last): File “/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/conda/latest/lib/python3.5/site-packages/sphinx/ext/autodoc.py”, line 658, in import_object __import__(self.modname) File “/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/qa/compare_idlzpts.py”, line 34, in <module> from legacyzpts.qa.paper_plots import LegacyZpts, myscatter File “/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/qa/paper_plots.py”, line 32, in <module> from legacyzpts.common import merge_tables_fns File “/home/docs/checkouts/readthedocs.org/user_builds/legacyzpts/checkouts/latest/py/legacyzpts/common.py”, line 16, in <module> from legacyzpts.legacy_zeropoints import get_90prime_expnum ImportError: cannot import name ‘get_90prime_expnum’

Indices and tables