コード例 #1
0
def calc_perigee_map(start='2010:114:20:00:00', stop='2010:117:16:00:00', ngrid=50):
    # Get orbital ephemeris in requested time range
    print ('Fetching ephemeris')
    objs = ('orbit', 'lunar', 'solar')
    axes = ('x', 'y', 'z')
    msids = ['{0}ephem0_{1}'.format(obj, axis)
             for obj in objs
             for axis in axes]
    ephems = fetch.MSIDset(msids, start, stop)
    times = ephems[msids[0]].times.copy()
    n_ephem = len(ephems[msids[0]].vals)
    if any(len(ephems[msid].vals) != n_ephem for msid in msids):
        raise ValueError('Unexpected mismatch in ephemeris telemetry sampling')

    ephem_xyzs = {}
    for obj in ('orbit', 'lunar', 'solar'):
        msids = ('{0}ephem0_{1}'.format(obj, axis) for axis in axes)
        ephem_xyzs[obj] = np.array([ephems[msid].vals for msid in msids])

    illum_maps = []
    illum_idxs = []
    antisun, xs, ys = get_antisun_grid(ngrid)
    antisun_pitches, phis = antisun.img2polar(xs, ys)

    for i_ephem, ephem_xyz in enumerate(ephem_xyzs['orbit'].transpose()):
        # Calculate a grid of attitude vectors centered on the anti-sun line and extending
        # from sun-pitch=180 (center) to sun-pitch=45 (edge).  
        orbit_r = np.sqrt(np.sum(ephem_xyzs['orbit'][:, i_ephem]**2))
        if orbit_r > 50000e3:
            continue
        sun_eci = ephem_xyzs['solar'][:, i_ephem] - ephem_xyzs['orbit'][:, i_ephem]
        att_vecs = antisun.img2eci(xs, ys, sun_eci)
        ras, decs = Ska.quatutil.eci2radec(att_vecs)
        illum_map = np.zeros((ngrid, ngrid), dtype=np.float32)
        print i_ephem, n_ephem, ephem_xyz
        for iy in range(ngrid):
            for ix in range(ngrid):
                i_vec = iy * ngrid + ix
                if antisun_pitches[i_vec] < 135:
                    ra, dec = ras[i_vec], decs[i_vec]
                    roll = Ska.Sun.nominal_roll(ra, dec, times[i_ephem])
                    _, att_illums, _ = taco2.calc_earth_vis(ephem_xyz, [ra, dec, roll], max_reflect=5)
                    illum = sum(att_illums)
                else:
                    illum = 0.0
                illum_map[iy, ix] = illum
        illum_idxs.append(i_ephem)
        illum_maps.append(illum_map)
        
    # debug_here()
    return dict(illums=np.array(illum_maps),
                illum_idxs=np.array(illum_idxs),
                times=times,
                antisun=antisun,
                ephem_xyzs=ephem_xyzs,
                )
コード例 #2
0
def calc_illums(queue, chandra_ecis, att):
    """Calculate the illumination (Earth solid angle) at specified ephemeris
    points ``chandra_ecis`` and attitude ``att``.  Put the result into the
    multiprocess ``queue``.
    """
    illums = []
    for chandra_eci in chandra_ecis:
        vis, illum, rays = taco2.calc_earth_vis(chandra_eci, att, max_reflect=5)
        illums.append(sum(illum))
    queue.put(illums)
コード例 #3
0
def calc_vis_values(queue, iproc, times, chandra_ecis, q1s, q2s, q3s, q4s):
    outvals = []
    for t, chandra_eci, q1, q2, q3, q4 in zip(times, chandra_ecis, q1s, q2s, q3s, q4s):
        alt = np.sqrt(np.sum(chandra_eci**2))/1e3
        date = re.sub(r'\.000$', '', DateTime(t).date)
        q_att = Quaternion.normalize([q1,q2,q3,q4])
        vis, illum, rays = taco.calc_earth_vis(chandra_eci, q_att)
        title = '%s alt=%6.0f illum=%s' % (date, alt, illum)
        outvals.append((t, illum[0], sum(illum[1:]), alt, q1, q2, q3, q4))
        if opt.verbose:
            print title, taco.norm(chandra_eci), q1, q2, q3, q4
        elif iproc == 0:
            print 'Progress: %d%%\r' % int((100. * len(outvals)) / len(times) + 0.5),
            sys.stdout.flush()
        if opt.movie:
            plot_vis_image(title, date, rays, vis, iproc)
    queue.put(outvals)
コード例 #4
0
def calc_vis_values(queue, iproc, times, chandra_ecis, q1s, q2s, q3s, q4s):
    outvals = []
    for t, chandra_eci, q1, q2, q3, q4 in zip(times, chandra_ecis, q1s, q2s,
                                              q3s, q4s):
        alt = np.sqrt(np.sum(chandra_eci**2)) / 1e3
        date = re.sub(r'\.000$', '', DateTime(t).date)
        q_att = Quaternion.normalize([q1, q2, q3, q4])
        vis, illum, rays = taco.calc_earth_vis(chandra_eci, q_att)
        title = '%s alt=%6.0f illum=%s' % (date, alt, illum)
        outvals.append((t, illum[0], sum(illum[1:]), alt, q1, q2, q3, q4))
        if opt.verbose:
            print title, taco.norm(chandra_eci), q1, q2, q3, q4
        elif iproc == 0:
            print 'Progress: %d%%\r' % int((100. * len(outvals)) / len(times) +
                                           0.5),
            sys.stdout.flush()
        if opt.movie:
            plot_vis_image(title, date, rays, vis, iproc)
    queue.put(outvals)
コード例 #5
0
orbit_xyz = numpy.array([0., 0., -1000000e3])
p_earth_body = numpy.array([-11913349.37481491,   1600513.79810546,   6787847.04879577])
orbit_xyz = -p_earth_body

illums = []
illums2 = []
pitchs = numpy.linspace(0, 90.0, 45)
esa_directs = []
esa_refls = []

for pitch in pitchs:
    print pitch
    att = [0, pitch, 0]
    vis, illum, rays = taco.calc_earth_vis(orbit_xyz, att, n_radiator_x=3, n_radiator_y=4, ngrid=100, max_reflect=6)
    vis2, illum2, rays2 = taco2.calc_earth_vis(orbit_xyz, att, max_reflect=6)
    illums.append(illum)
    illums2.append(illum2)
    direct, refl, total = Chandra.acis_esa.earth_solid_angle(Quat(att), orbit_xyz)
    esa_directs.append(direct)
    esa_refls.append(refl)


clf()
plot(pitchs, [x[0] for x in illums] , '-b', label='tla direct')
plot(pitchs, [x[0] for x in illums2] , '--b', label='tla direct-2', linewidth=4)

plot(pitchs, [x[1] for x in illums] , '-r', label='tla refl1')
plot(pitchs, [x[1] for x in illums2] , '--r', label='tla refl1-2', linewidth=4)

plot(pitchs, [x[2] for x in illums] , '-g', label='tla refl2')
コード例 #6
0
ファイル: test_taco2.py プロジェクト: jzuhone/acis_taco
# Loop over position of Chandra relative to Earth
iplot = 1
for orbit_xyz in numpy.array([
    [11913349, -1600513, -6787847],  # Test case 1
    [0., 0., -1000000e3],  # Earth along +Z and far away
    [0., 0., -7000e3]
]):  # Earth along +Z and near
    print "Chandra position =", orbit_xyz
    print "RA, Dec, Roll, total, direct, reflected"
    directs = []
    reflects = []
    totals = []
    for pitch in pitchs:
        att = [0, pitch, 0]  # RA, Dec, Roll.  "Dec" set to pitch
        vis, illum, rays = taco2.calc_earth_vis(orbit_xyz, att, max_reflect=10)
        direct = illum[0]
        reflect = sum(illum[1:])
        total = sum(illum)
        directs.append(direct)
        reflects.append(reflect)
        totals.append(total)
        print "%5.1f %5.1f %5.1f %8.4e %8.4e %8.4e" % (att[0], att[1], att[2],
                                                       total, direct, reflect)

    plt.subplot(3, 1, iplot)
    plt.plot(pitchs, totals, '-k', label='Total')
    plt.plot(pitchs, directs, '-b', label='Direct')
    plt.plot(pitchs, reflects, '-r', label='Reflected')
    plt.grid()
    if iplot == 2:
コード例 #7
0
plt.clf()
pitchs = numpy.linspace(0, 90.0, 46)

# Loop over position of Chandra relative to Earth
iplot = 1
for orbit_xyz in numpy.array([[11913349, -1600513,  -6787847], # Test case 1
                              [0., 0., -1000000e3], # Earth along +Z and far away
                              [0., 0., -7000e3]]):   # Earth along +Z and near
    print "Chandra position =", orbit_xyz
    print "RA, Dec, Roll, total, direct, reflected"
    directs = []
    reflects = []
    totals = []
    for pitch in pitchs:
        att = [0, pitch, 0]   # RA, Dec, Roll.  "Dec" set to pitch
        vis, illum, rays = taco2.calc_earth_vis(orbit_xyz, att, max_reflect=10)
        direct = illum[0]
        reflect = sum(illum[1:])
        total = sum(illum)
        directs.append(direct)   
        reflects.append(reflect)
        totals.append(total)
        print "%5.1f %5.1f %5.1f %8.4e %8.4e %8.4e" % (
            att[0], att[1], att[2], total, direct, reflect)

    plt.subplot(3, 1, iplot)
    plt.plot(pitchs, totals , '-k', label='Total' )
    plt.plot(pitchs, directs, '-b', label='Direct' )
    plt.plot(pitchs, reflects, '-r', label='Reflected'  )
    plt.grid()
    if iplot == 2: