@@ -0,0 +1,1935 @@
+#!/usr/bin/env python%0A# encoding: utf-8%0A%22%22%22%0AModule for directly estimating SB by adding up the light of stars in the Brown%0Acatalog and transforming that total light into an SDSS magnitude.%0A%22%22%22%0A%0Afrom astropy import log%0Aimport numpy as np%0A%0Afrom sqlalchemy.orm import aliased%0Afrom starplex.database import connect_to_server, Session%0Afrom starplex.database import Catalog, Bandpass, CatalogStar, Observation%0A%0A%0Adef main():%0A    log.setLevel(%22INFO%22)%0A    fieldname = %22halo35b%22%0A    data = load_photometry(fieldname)%0A    A = compute_area(fieldname)%0A    sb606 = compute_sb(data%5B'cfrac'%5D, data%5B'm606'%5D, A)%0A    sb814 = compute_sb(data%5B'cfrac'%5D, data%5B'm814'%5D, A)%0A    log.info(%22mu_606: %7B:.6f%7D%22.format(sb606))%0A    log.info(%22mu_814: %7B:.6f%7D%22.format(sb814))%0A%0A%0Adef load_photometry(fieldname):%0A    %22%22%22Get photometry from starplex.%22%22%22%0A    connect_to_server('marvin', echo=True)%0A    session = Session()%0A    mag606obs = aliased(Observation)%0A    mag814obs = aliased(Observation)%0A    bp606 = aliased(Bandpass)%0A    bp814 = aliased(Bandpass)%0A    q = session.query(CatalogStar.cfrac, mag606obs.mag, mag814obs.mag)%5C%0A            .join(mag606obs, CatalogStar.observations)%5C%0A            .join(mag814obs, CatalogStar.observations)%5C%0A            .join(Catalog)%5C%0A            .filter(Catalog.name == fieldname)%5C%0A            .join(bp606, mag606obs.bandpass)%5C%0A            .filter(bp606.name == %22f606w%22)%5C%0A            .join(bp814, mag814obs.bandpass)%5C%0A            .filter(bp814.name == %22f814w%22)%0A    dt = %5B('cfrac', np.float), ('m606', np.float), ('m814', np.float)%5D%0A    data = np.array(q.all(), dtype=np.dtype(dt))%0A    log.info(%22Field %7B0%7D has %7B1:d%7D stars%22.format(fieldname, data.shape%5B0%5D))%0A    session.close()%0A    return data%0A%0A%0Adef compute_area(fieldname):%0A    %22%22%22Get the unmasked area for this field from the MSK image.%22%22%22%0A    pass%0A%0A%0Adef compute_sb(cfrac, mag, A):%0A    %22%22%22Compute a surface brightness for a single bandpass.%22%22%22%0A    pass%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Load HST photometry from Starplex catalog