Beispiel #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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
0
    def compare_file(self, hor_file, obj):

        hor = read_horizons(hor_file)

        for i, date in enumerate(hor['date']):
            t = dataclasses.make_I3Time(date)
            if obj == 'sun':
                d = astro.I3GetSunDirection(t)
            elif obj == 'moon':
                d = astro.I3GetMoonDirection(t)
            el = 90 - math.degrees(d.zenith)
            az = (90 -
                  math.degrees(d.azimuth + astro.ICECUBE_LONGITUDE)) % 360.

            eq = astro.I3GetEquatorialFromDirection(d, t)

            ra = math.degrees(eq.ra)
            dec = math.degrees(eq.dec)

            gal = astro.I3GetGalacticFromEquatorial(eq)

            l = math.degrees(gal.l)
            b = math.degrees(gal.b)

            #print el - hor['el'][i], az - hor['az'][i], ra - hor['ra'][i], dec - hor['dec'][i],l - hor['l'][i],b -hor['b'][i]

            assert (abs(el - hor['el'][i]) < 0.003)
            assert (azimuth_distance(az, hor['az'][i]) < 1.0)
            assert (abs(ra - hor['ra'][i]) < 0.005)
            assert (abs(dec - hor['dec'][i]) < 0.004)
            assert (abs(l - hor['l'][i]) < 0.02)
            assert (abs(b - hor['b'][i]) < 0.01)
Beispiel #5
0
def dir_to_equa(zenith, azimuth, mjd_list):
    ra = []
    dec = []
    for mjd in mjd_list:
        i3dir = dataclasses.I3Direction(zenith, azimuth)
        i3time = dataclasses.I3Time()
        i3time.set_mod_julian_time_double(mjd)
        eq = astro.I3GetEquatorialFromDirection(i3dir, i3time)
        ra.append(eq.ra)
        dec.append(eq.dec)
        # results.append((eq.ra,eq.dec))
    return ra, dec
Beispiel #6
0
        gc_direction.azimuth / I3Units.degree,
    ))

print

#calculat the position of the crab nebula in local coordinates
muon_direction = dataclasses.I3Direction(101.4572 * I3Units.degree,
                                         312.5199 * I3Units.degree)
print(
    "At {} a very bright muon was observed by IceCube at zenith={:8.4f} deg, azimuth={:7.4f} deg"
    .format(
        str(time),
        muon_direction.zenith / I3Units.degree,
        muon_direction.azimuth / I3Units.degree,
    ))

muon_equatorial = astro.I3GetEquatorialFromDirection(muon_direction, time)
print("The The Muon came from of RA = {:8.4f} deg, Dec ={:+7.4f} deg (J2000)".
      format(
          muon_equatorial.ra / I3Units.degree,
          muon_equatorial.dec / I3Units.degree,
      ))

muon_galactic = astro.I3GetGalacticFromEquatorial(muon_equatorial)
print(
    "Which Means its galactic coordinates are l={:+8.4f} deg, b={:+7.4f} deg".
    format(
        muon_galactic.l / I3Units.degree,
        muon_galactic.b / I3Units.degree,
    ))