def process_acs_field(brick, fieldnum): """Compute ACS SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_acs', 'f475w', 'f814w') try: A, header = compute_area("f475w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f814w", brick, fieldnum) except NoWeightmap: raise NoDataError sb475, e475 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb814, e814 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return { "name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f475w": sb475, "f814w": sb814, "f475w_err": e475, "f814w_err": e814 }
def process_uv_field(brick, fieldnum): """Compute UV SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_uv', 'f275w', 'f336w') try: A, header = compute_area("f275w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f336w", brick, fieldnum) except NoWeightmap: raise NoDataError sb275, e275 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb336, e336 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return { "name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f275w": sb275, "f336w": sb336, "f275w_err": e275, "f336w_err": e336 }
def process_ir_field(brick, fieldnum): """Compute IR SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_ir', 'f110w', 'f160w') try: A, header = compute_area("f110w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f160w", brick, fieldnum) except NoWeightmap: raise NoDataError sb110, e110 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb160, e160 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return { "name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f110w": sb110, "f160w": sb160, "f110w_err": e110, "f160w_err": e160 }
def process_uv_field(brick, fieldnum): """Compute UV SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_uv', 'f275w', 'f336w') try: A, header = compute_area("f275w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f336w", brick, fieldnum) except NoWeightmap: raise NoDataError sb275, e275 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb336, e336 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return {"name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f275w": sb275, "f336w": sb336, "f275w_err": e275, "f336w_err": e336}
def process_field(fieldname): """Compute SB for a single Brown HST field.""" data = load_photometry(fieldname, 'brown', 'f606w', 'f814w') image_path = brown_image_path(fieldname, "f606w") msk_path = brown_phot_path(fieldname, kind="msk") header = fits.getheader(image_path) A = compute_area(fits.getdata(msk_path), header) sb606, e606 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb814, e814 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) log.info(fieldname) log.info("R {:.4f} kpc".format(rad.kpc)) log.info("mu_606: {:.6f}".format(sb606)) log.info("mu_814: {:.6f}".format(sb814)) return {"name": fieldname, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f606w": sb606, "f814w": sb814, "f606w_err": e606, "f814w_err": e814}
def process_acs_field(brick, fieldnum): """Compute ACS SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_acs', 'f475w', 'f814w') try: A, header = compute_area("f475w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f814w", brick, fieldnum) except NoWeightmap: raise NoDataError sb475, e475 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb814, e814 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return {"name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f475w": sb475, "f814w": sb814, "f475w_err": e475, "f814w_err": e814}
def process_ir_field(brick, fieldnum): """Compute IR SB in this brick+field.""" fieldname = "phat_b{0:02d}_f{1:02d}".format(brick, fieldnum) data = load_photometry(fieldname, 'phat_ir', 'f110w', 'f160w') try: A, header = compute_area("f110w", brick, fieldnum) except NoWeightmap: try: A, header = compute_area("f160w", brick, fieldnum) except NoWeightmap: raise NoDataError sb110, e110 = compute_sb(data['m1'], data['e1'], data['cfrac'], A) sb160, e160 = compute_sb(data['m2'], data['e2'], data['cfrac'], A) ra0, dec0, rad = compute_field_coord(header) return {"name": fieldname, "brick": brick, "field": fieldnum, "ra": ra0, "dec": dec0, "radius": rad.kpc, "f110w": sb110, "f160w": sb160, "f110w_err": e110, "f160w_err": e160}
def process_wircam_field(fieldname, n_seg, use_vega, disable_intercal): """Process a single WIRCam field.""" log.info("Processing {0}".format(fieldname)) # Get path to J-band reference image refpath = "/Volumes/Zaphod/m31/pipe/blockphot/wircam/"\ "blocks/{}_J_nightset.fits".format(fieldname) # refwpath = "/Volumes/Zaphod/m31/pipe/blockphot/blocks/{}_J_nightset."\ # "weight.fits".format(fieldname) cols = defaultdict(list) with fits.open(refpath) as ref_fits: header = ref_fits[0].header pix_scale = np.sqrt( header['CD1_1'] ** 2. + header['CD1_2'] ** 2.) * 3600. img = ref_fits[0].data for i, (radec_seg, yx_seg) in enumerate(image_segments(header, n_seg)): # process each RA, Dec subsection area = compute_area(img, yx_seg, pix_scale) # sq arcsec try: phot = load_photometry( fieldname, i, radec_seg, use_vega, disable_intercal) except NoDataError: continue ra0, dec0 = segment_center(radec_seg) cols['field'].append(fieldname) cols['tile'].append(i) cols['nstars'].append(len(phot)) cols['ra'].append(ra0) cols['dec'].append(dec0) for band in ['J', 'Ks']: _sb, _err = compute_sb(phot[band], phot["{0}_err".format(band)], phot['cfrac'], area) cols[band].append(_sb) cols["{}_err".format(band)].append(_err) # Write out table of all segments for this field names = ['field', 'tile', 'nstars', 'ra', 'dec', 'J', 'J_err', 'Ks', 'Ks_err'] collist = [cols[k] for k in names] tbl = Table(collist, names=names) tbl = tbl[tbl['nstars'] >= 100] # cut off low-density regions path_root = "wircam_sb_{0}".format(fieldname) if use_vega: path_root += "_vega" else: path_root += "_ab" if disable_intercal: path_root += "_nointercal" else: path_root += "_intercal" tbl.write(path_root + ".txt", format='ascii.commented_header')