Пример #1
0
 def obj_pos(scan, obj):
     ra, dec = coordinates.ephem_pos(obj, scan.mjd0)
     az, el = coordinates.transform("cel",
                                    "hor", [[ra], [dec]],
                                    time=[scan.mjd0],
                                    site=scan.site)[:, 0]
     return az, el, ra, dec
Пример #2
0
		continue

	hour = info[ind].fields.hour
	tags = sorted(list(set(info[ind].tags)-set([id])))

	# Get input pointing
	bore = d.boresight[:,::sstep]
	offs = d.point_offset.T[:,::dstep]
	ipoint = np.zeros(bore.shape + offs.shape[1:])
	ipoint[0] = utils.ctime2mjd(bore[0,:,None])
	ipoint[1:]= bore[1:,:,None]+offs[:,None,:]
	ipoint = ipoint.reshape(3,-1)
	iref = np.mean(ipoint[1:],1)

	# Transform to equ
	opoint = coordinates.transform("hor","equ", ipoint[1:], time=ipoint[0], site=d.site)
	oref = np.mean(opoint,1)

	print "%s %4.1f %8.3f %7.3f %8.3f %7.3f" % (id, hour, iref[0]/utils.degree, iref[1]/utils.degree, oref[0]/utils.degree, oref[1]/utils.degree),

	# Compute position of each object, and distance to it
	orect = coordinates.ang2rect(opoint, zenith=False)
	for obj in objs:
		objpos  = coordinates.ephem_pos(obj, ipoint[0,0])
		objrect = coordinates.ang2rect(objpos, zenith=False)
		odist   = np.min(np.arccos(np.sum(orect*objrect[:,None],0)))
		print "| %8.3f %7.3f %7.3f" % (objpos[0]/utils.degree, objpos[1]/utils.degree, odist/utils.degree),

	print "| "+" ".join(tags)
	sys.stdout.flush()
Пример #3
0
    offs = d.point_offset.T[:, ::dstep]
    ipoint = np.zeros(bore.shape + offs.shape[1:])
    ipoint[0] = utils.ctime2mjd(bore[0, :, None])
    ipoint[1:] = bore[1:, :, None] + offs[:, None, :]
    ipoint = ipoint.reshape(3, -1)
    iref = np.mean(ipoint[1:], 1)

    # Transform to equ
    opoint = coordinates.transform("hor",
                                   "equ",
                                   ipoint[1:],
                                   time=ipoint[0],
                                   site=d.site)
    oref = np.mean(opoint, 1)

    print "%s %4.1f %8.3f %7.3f %8.3f %7.3f" % (
        id, hour, iref[0] / utils.degree, iref[1] / utils.degree,
        oref[0] / utils.degree, oref[1] / utils.degree),

    # Compute position of each object, and distance to it
    orect = coordinates.ang2rect(opoint, zenith=False)
    for obj in objs:
        objpos = coordinates.ephem_pos(obj, ipoint[0, 0])
        objrect = coordinates.ang2rect(objpos, zenith=False)
        odist = np.min(np.arccos(np.sum(orect * objrect[:, None], 0)))
        print "| %8.3f %7.3f %7.3f" % (objpos[0] / utils.degree, objpos[1] /
                                       utils.degree, odist / utils.degree),

    print "| " + " ".join(tags)
    sys.stdout.flush()
Пример #4
0
def build_tod_stats(entry, Naz=8, Nt=2):
    """Collect summary information for the tod in the given entry, returning
	it as a bunch. If some information can't be found, then those fields will
	be set to a placeholder value (usually NaN), but the fields will still all
	be present."""
    # At the very least we need the pointing, so no try catch around this
    d = actdata.read(entry, ["boresight", "site"])
    d += actdata.read_point_offsets(entry, no_correction=True)
    d = actdata.calibrate(d, exclude=["autocut"])

    # Get the array center and radius
    acenter = np.mean(d.point_offset, 0)
    arad = np.mean((d.point_offset - acenter)**2, 0)**0.5

    t, baz, bel = 0.5 * (np.min(d.boresight, 1) + np.max(d.boresight, 1))
    #t, baz, bel = np.mean(d.boresight,1)
    az = baz + acenter[0]
    el = bel + acenter[1]
    dur, waz, wel = np.max(d.boresight, 1) - np.min(d.boresight, 1)
    if waz > 180 * utils.degree:
        print("bad waz %8.3f for %s" % (waz / utils.degree, entry.id))
    mjd = utils.ctime2mjd(t)
    hour = t / 3600. % 24
    day = hour >= day_range[0] and hour < day_range[1]
    night = not day
    jon = (t - jon_ref) / (3600 * 24)

    ra, dec = coordinates.transform(tsys, "cel", [az, el], mjd, site=d.site)
    # Get the array center bounds on the sky, assuming constant elevation
    ts = utils.ctime2mjd(t + dur / 2 * np.linspace(-1, 1, Nt))
    azs = az + waz / 2 * np.linspace(-1, 1, Naz)
    E1 = coordinates.transform(tsys,
                               "cel", [azs, [el] * Naz],
                               time=[ts[0]] * Naz,
                               site=d.site)[:, 1:]
    E2 = coordinates.transform(tsys,
                               "cel", [[azs[-1]] * Nt, [el] * Nt],
                               time=ts,
                               site=d.site)[:, 1:]
    E3 = coordinates.transform(tsys,
                               "cel", [azs[::-1], [el] * Naz],
                               time=[ts[-1]] * Naz,
                               site=d.site)[:, 1:]
    E4 = coordinates.transform(tsys,
                               "cel", [[azs[0]] * Nt, [el] * Nt],
                               time=ts[::-1],
                               site=d.site)[:, 1:]
    bounds = np.concatenate([E1, E2, E3, E4], 1)
    bounds[0] = utils.rewind(bounds[0])
    ## Grow bounds by array radius
    #bmid = np.mean(bounds,1)
    #for i in range(2):
    #	bounds[i,bounds[i]<bmid[i]] -= arad[i]
    #	bounds[i,bounds[i]>bmid[i]] += arad[i]
    tot_id = entry.id + (":" + entry.tag if entry.tag else "")
    res = bunch.Bunch(id=tot_id,
                      nsamp=d.nsamp,
                      t=t,
                      mjd=mjd,
                      jon=jon,
                      hour=hour,
                      day=day,
                      night=night,
                      dur=dur,
                      az=az / utils.degree,
                      el=el / utils.degree,
                      baz=baz / utils.degree,
                      bel=bel / utils.degree,
                      waz=waz / utils.degree,
                      wel=wel / utils.degree,
                      ra=ra / utils.degree,
                      dec=dec / utils.degree,
                      bounds=bounds / utils.degree)

    if "gseason" in entry:
        res[entry.gseason] = True

    # Planets
    for obj in [
            "Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn",
            "Uranus", "Neptune"
    ]:
        res[obj] = coordinates.ephem_pos(obj,
                                         utils.ctime2mjd(t)) / utils.degree

    # Get our weather information, if available
    try:
        d += actdata.read(entry, ["apex"])
        d = actdata.calibrate_apex(d)
        res["pwv"] = d.apex.pwv
        res["wx"] = d.apex.wind[0]
        res["wy"] = d.apex.wind[1]
        res["wind_speed"] = d.apex.wind_speed
        res["T"] = d.apex.temperature
    except errors.DataMissing:
        res["pwv"] = np.NaN
        res["wx"] = np.NaN
        res["wy"] = np.NaN
        res["wind_speed"] = np.NaN
        res["T"] = np.NaN

    # Try to get our cut info, so that we can select on
    # number of detectors and cut fraction
    try:
        npre = d.nsamp * d.ndet
        d += actdata.read(entry, ["cut"])
        res["ndet"] = d.ndet
        res["cut"] = 1 - d.nsamp * d.ndet / float(npre)
    except errors.DataMissing:
        res["ndet"] = 0
        res["cut"] = 1.0

    # Try to get hwp info
    res["hwp"] = False
    res["hwp_name"] = "none"
    try:
        epochs = actdata.try_read(files.read_hwp_epochs, "hwp_epochs",
                                  entry.hwp_epochs)
        t, _, ar = entry.id.split(".")
        t = float(t)
        if ar in epochs:
            for epoch in epochs[ar]:
                if t >= epoch[0] and t < epoch[1]:
                    res["hwp"] = True
                    res["hwp_name"] = epoch[2]
    except errors.DataMissing:
        pass

    return res
Пример #5
0
 def __call__(self, name):
     mjd = utils.ctime2mjd(self.data["t"])
     mjd[~np.isfinite(mjd)] = 0
     pos = coordinates.ephem_pos(name, mjd)
     pos /= utils.degree
     return pos
Пример #6
0
	def obj_pos(scan, obj):
		ra, dec = coordinates.ephem_pos(obj, scan.mjd0)
		az, el  = coordinates.transform("cel","hor",[[ra],[dec]],time=[scan.mjd0], site=scan.site)[:,0]
		return az, el, ra, dec