Ejemplo n.º 1
0
    def test_dir_from_equa(self):

        random.seed(0)

        t1 = dataclasses.I3Time()

        t1.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0.0)
        mjd1 = t1.mod_julian_day_double
        t1.set_utc_cal_date(2030, 1, 1, 0, 0, 0, 0.0)
        mjd2 = t1.mod_julian_day_double

        for n in range(1000):
            t1.set_mod_julian_time_double(random.uniform(mjd1, mjd2))

            eq = astro.I3Equatorial(random.uniform(0, 2 * math.pi),
                                    random.uniform(-math.pi / 2, math.pi / 2))

            d = astro.I3GetDirectionFromEquatorial(eq, t1)
            eqprime = astro.I3GetEquatorialFromDirection(d, t1)

            self.assert_almost_equal(eq.ra * math.cos(eq.dec),
                                     eqprime.ra * math.cos(eqprime.dec), 4e-6)
            self.assert_almost_equal(eq.dec, eqprime.dec, 4e-6)

            self.assert_less(
                astro.angular_distance(eq.ra, eq.dec, eqprime.ra, eqprime.dec),
                5e-6)
Ejemplo n.º 2
0
    def Process(self):
        try:
            c = next(self.lines)
        except StopIteration:
            self.RequestSuspension()
            return

        eq = astro.I3Equatorial(c[0] * I3Units.degree, c[1] * I3Units.degree)
        time = dataclasses.I3Time(2015, 0)
        direction = astro.I3GetDirectionFromEquatorial(eq, time)

        eqq = astro.I3GetEquatorialFromDirection(direction, time)

        particle = dataclasses.I3Particle()
        particle.dir = direction

        header = dataclasses.I3EventHeader()
        header.start_time = time

        frame = icetray.I3Frame("P")
        if self.evthdr:
            frame["I3EventHeader"] = header
        frame["Particle"] = particle

        self.PushFrame(frame)
Ejemplo n.º 3
0
    def test_equa_from_dir(self):

        random.seed(0)

        t1 = dataclasses.I3Time()

        t1.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0.0)
        mjd1 = t1.mod_julian_day_double
        t1.set_utc_cal_date(2030, 1, 1, 0, 0, 0, 0.0)
        mjd2 = t1.mod_julian_day_double

        for n in range(1000):
            t1.set_mod_julian_time_double(random.uniform(mjd1, mjd2))

            d = dataclasses.I3Direction(
                random.uniform(0, math.pi),
                random.uniform(0, 2 * math.pi),
            )

            eq = astro.I3GetEquatorialFromDirection(d, t1)
            dprime = astro.I3GetDirectionFromEquatorial(eq, t1)

            self.assert_almost_equal(d.zenith, dprime.zenith, 5e-6)
            self.assert_almost_equal(d.azimuth * math.sin(d.zenith),
                                     dprime.azimuth * math.sin(d.zenith), 6e-6)

            self.assert_less(
                astro.angular_distance(d.azimuth, math.pi / 2 - d.zenith,
                                       dprime.azimuth,
                                       math.pi / 2 - dprime.zenith), 6e-6)
Ejemplo n.º 4
0
    def test_radec(self):

        src_dec = 22.01450
        for src_ra in np.linspace(0, 360, 1):

            i3src = astro.I3Equatorial(src_ra * I3Units.degree,
                                       src_dec * I3Units.degree)

            i3t0 = dataclasses.I3Time()
            i3t0.set_utc_cal_date(2000, 1, 1, 0, 0, 0, 0)

            for day in np.linspace(0, 10000, 100):
                i3time = i3t0 + day * 86400 * I3Units.s

                i3dir = astro.I3GetDirectionFromEquatorial(i3src, i3time)
                i3az = i3dir.azimuth / I3Units.degree
                i3zen = i3dir.zenith / I3Units.degree

                #this equation from inspecting the output of ephempy
                paz = (189.9640733918 - src_ra + day * 360.985606808) % 360
                pzen = 90 + src_dec

                assert (azimuth_distance(i3az, paz) < 0.2)
                assert (abs(i3zen - pzen) < 0.2)
Ejemplo n.º 5
0
    .format(
        crab_position.ra / I3Units.degree,
        crab_position.dec / I3Units.degree,
    ))

#calculate the location of the crab in galactic coordinates
crab_galactic = astro.I3GetGalacticFromEquatorial(crab_position)
print(
    "Which Means its galactic coordinates are l={:+8.4f} deg, b={:+7.4f} deg".
    format(
        crab_galactic.l / I3Units.degree,
        crab_galactic.b / I3Units.degree,
    ))

#calculat the position of the crab nebula in local coordinates
crab_direction = astro.I3GetDirectionFromEquatorial(crab_position, time)
print(
    "At {} the Crab will be at zenith={:8.4f} deg, azimuth={:7.4f} deg".format(
        str(time),
        crab_direction.zenith / I3Units.degree,
        crab_direction.azimuth / I3Units.degree,
    ))

print

#the center of the galaxy is easy to remember in galactic coordinates
galaxy_center = astro.I3Galactic(0, 0)
print(
    "The Galactic Center's galactic coordinates are l={:+8.4f} deg, b={:+7.4f} deg"
    .format(
        galaxy_center.l / I3Units.degree,