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)
def test_eqn_of_time(self): for n in range(3000): i3time = dataclasses.make_I3Time( datetime(2010, 1, 1, 12) + timedelta(n)) sun = astro.I3GetSunDirection(i3time) deltat = -(90 - sun.azimuth / I3Units.degree) * 4 #convert to minutes assert (abs(deltat - equation_of_time(n)) < 0.3)
def calculate_background_pdf(frame): # print("Computing PDF") time = frame.Get("I3EventHeader").start_time t_y = int(str(time)[0:4]) sun_direction = astro.I3GetSunDirection(time) sun_zenith = sun_direction.zenith sun_azimuth = sun_direction.zenith reco_neutrino = frame.Get("IC86_Dunkman_L6_PegLeg_MultiNest8D_NumuCC") reco_zenith = reco_neutrino.dir.zenith reco_energy = reco_neutrino.energy #if year >= 2015: if t_y >= 2015: reco_energy *= 1.04 counter = 0 for pair in energy_range_list: if reco_energy >= pair[0] and reco_energy <= pair[1]: for j in xrange(0, 30): random_azimuth = gRandom.Uniform(0, 2 * pi) solar_angle = calculate_angle(reco_zenith, random_azimuth, sun_zenith, sun_azimuth) * 180 / pi bg_hist_list[counter].Fill(solar_angle) counter += 1
time.set_mod_julian_time_double(56819.20444852863) #calculate the position of the moon moon_direction = astro.I3GetMoonDirection(time) print( "At {} the moon will be at zenith={:8.4f} deg, azimuth={:7.4f} deg".format( str(time), moon_direction.zenith / I3Units.degree, moon_direction.azimuth / I3Units.degree, )) print #calculate the position of the sun sun_direction = astro.I3GetSunDirection(time) print( "At {} the Sun will be at zenith={:8.4f} deg, azimuth={:7.4f} deg".format( str(time), sun_direction.zenith / I3Units.degree, sun_direction.azimuth / I3Units.degree, )) print #This is where the crab lives on the sky crab_position = astro.I3Equatorial(83.63308 * I3Units.degree, 22.01450 * I3Units.degree) print( "The Crab Nebula is located at RA = {:8.4f} deg, Dec ={:+7.4f} deg (J2000)" .format(
from matplotlib.ticker import FormatStrFormatter from icecube.icetray import I3Units from icecube import astro,dataclasses days = range(367) sun_azimuth =[] sun_elevation = [] day = [] for n in days: d = datetime(2000,1,1,12)+timedelta(n-1) day.append(d) i3time = dataclasses.make_I3Time(d) sun = astro.I3GetSunDirection(i3time) sun_azimuth.append(90 - sun.azimuth/I3Units.degree) sun_elevation.append(90 - sun.zenith/I3Units.degree) plt.plot_date(day, -4*plt.array(sun_azimuth)*plt.cos(plt.radians(sun_elevation)), ls='-',marker=None ) plt.title("Equation of Time") plt.ylabel("Sundial Faster [minutes]") plt.figure() plt.plot_date(day,sun_elevation,ls='-',marker=None) plt.ylabel("Sun Elevation") plt.title("Sun Elevation")
from matplotlib.ticker import MultipleLocator, FormatStrFormatter from matplotlib.dates import WeekdayLocator, SU, DateFormatter, HourLocator from datetime import datetime, timedelta from icecube.icetray import I3Units from icecube import dataclasses, astro i3time = dataclasses.I3Time() i3time.set_utc_cal_date(2017, 9, 22, 0, 0, 0, 0.0) # atumnal equinox dstr = i3time.get_utc_string("%d %B %Y") i3_sun_zenith = [] i3_sun_azimuth = [] times = [] N = 10000 for n in range(N + 1): sun_dir = astro.I3GetSunDirection(i3time) i3_sun_zenith.append(sun_dir.zenith / I3Units.degree) i3_sun_azimuth.append(sun_dir.azimuth / I3Units.degree) times.append(i3time.date_time) i3time += I3Units.day / N fig, (ax1, ax2) = plt.subplots(2, sharex=True) ax1.set_title("IceCube Coordinates for the Sun " + dstr) ax1.plot_date(times, i3_sun_zenith, marker=None, ls='-', label="I3") ax1.yaxis.set_major_locator(MultipleLocator(0.1)) ax1.yaxis.set_major_formatter(FormatStrFormatter(u'%4.1f\u00b0')) ax1.set_ylabel("Zenith") ax1.set_ylim(min(i3_sun_zenith), max(i3_sun_zenith)) ax2.plot_date(times, i3_sun_azimuth, marker=None, ls='-', label="I3") ax2.set_ylabel("Azimuth")