Exemple #1
0
    def plot_pass(self, pass_num):
        """Try and plot a pass on a polar plot
        """
        def mapr(r):
            return 80 - r

        jd = self.pass_vis[pass_num].jd
        az = self.pass_vis[pass_num].az
        el = self.pass_vis[pass_num].el

        sy, smo, sd, sh, smn, ss = time.jd2date(jd[0])
        ey, emo, ed, eh, emn, es = time.jd2date(jd[-1])

        start_string = '{:02.0f}:{:02.0f}:{:02.0f}'.format(sh, smn, ss)
        end_string = '{:02.0f}:{:02.0f}:{:02.0f}'.format(eh, emn, es)

        fig = plt.figure()
        ax = plt.subplot(111, projection='polar')

        line = ax.plot(az, mapr(np.rad2deg(el)))[0]
        
        ax.plot(az[0], mapr(np.rad2deg(el[0])), marker='.', color='green', markersize=25)
        ax.plot(az[-1], mapr(np.rad2deg(el[-1])), marker='.', color='red', markersize=25)

        ax.set_yticks(range(-10, 90, 10))
        ax.set_yticklabels(map(str, range(90, -10, -10)))
        ax.set_theta_zero_location("N")
        fig.suptitle("%s" %
                     (self.satname), y=1.05)
        plt.title('%2d/%2d' % (smo, sd))
        plt.title('Start:\n' + start_string, loc='left')
        plt.title('End: \n' + end_string, loc='right')

        plt.show()
Exemple #2
0
def output(sat, pass_vis, filename):
    """Write to output file
    """
    space = '    '
    with open(filename, 'a') as f:

        f.write('%s %05.0f\n' % (sat.satname, sat.satnum))
        f.write(
            'PASS    MON/DAY    HR:MIN(UT)    RHO(KM)    AZ(DEG)    EL(DEG)    SAT          \n')
        f.write(
            '-------------------------------------------------------------------------------\n\n')

        for ii, cur_pass in enumerate(pass_vis):
            for jd, rho, az, el in zip(cur_pass.jd, cur_pass.rho, cur_pass.az, cur_pass.el):
                # convert julian day to normal date
                yr, mo, day, hr, mn, sec = time.jd2date(jd)

                # if sec > 30:
                #     mn = mn + 1
                #     if mn == 60:
                #         hr = hr + 1
                #         mn = 0
                f.write('%4.0f%s' % (ii, space))
                f.write('%3.0f/%3.0f%s' % (mo, day, space))
                f.write('%02.0f:%02.0f:%02.0f%s' % (hr, mn, sec, space))
                f.write('%7.2f%s' % (rho, space))
                f.write('%7.2f%s' % (az * 180 / np.pi, space))
                f.write('%7.2f%s' % (el * 180 / np.pi, space))
                f.write('%13s\n' % (sat.satname))
Exemple #3
0
def output(sat, pass_vis, filename):
    """Write to output file
    """
    space = '    '
    with open(filename, 'a') as f:

        f.write('%s %05.0f\n' % (sat.satname, sat.satnum))
        f.write(
            'PASS    MON/DAY    HR:MIN(UT)    RHO(KM)    AZ(DEG)    EL(DEG)    SAT          \n'
        )
        f.write(
            '-------------------------------------------------------------------------------\n\n'
        )

        for ii, cur_pass in enumerate(pass_vis):
            for jd, rho, az, el in zip(cur_pass.jd, cur_pass.rho, cur_pass.az,
                                       cur_pass.el):
                # convert julian day to normal date
                yr, mo, day, hr, mn, sec = time.jd2date(jd)

                # if sec > 30:
                #     mn = mn + 1
                #     if mn == 60:
                #         hr = hr + 1
                #         mn = 0
                f.write('%4.0f%s' % (ii, space))
                f.write('%3.0f/%3.0f%s' % (mo, day, space))
                f.write('%02.0f:%02.0f:%02.0f%s' % (hr, mn, sec, space))
                f.write('%7.2f%s' % (rho, space))
                f.write('%7.2f%s' % (az * 180 / np.pi, space))
                f.write('%7.2f%s' % (el * 180 / np.pi, space))
                f.write('%13s\n' % (sat.satname))
Exemple #4
0
    def plot_pass(self, pass_num):
        """Try and plot a pass on a polar plot
        """
        def mapr(r):
            return 80 - r

        jd = self.pass_vis[pass_num].jd
        az = self.pass_vis[pass_num].az
        el = self.pass_vis[pass_num].el

        sy, smo, sd, sh, smn, ss = time.jd2date(jd[0])
        ey, emo, ed, eh, emn, es = time.jd2date(jd[-1])

        start_string = '{:02.0f}:{:02.0f}:{:02.0f}'.format(sh, smn, ss)
        end_string = '{:02.0f}:{:02.0f}:{:02.0f}'.format(eh, emn, es)

        fig = plt.figure()
        ax = plt.subplot(111, projection='polar')

        line = ax.plot(az, mapr(np.rad2deg(el)))[0]

        ax.plot(az[0],
                mapr(np.rad2deg(el[0])),
                marker='.',
                color='green',
                markersize=25)
        ax.plot(az[-1],
                mapr(np.rad2deg(el[-1])),
                marker='.',
                color='red',
                markersize=25)

        ax.set_yticks(range(-10, 90, 10))
        ax.set_yticklabels(map(str, range(90, -10, -10)))
        ax.set_theta_zero_location("N")
        fig.suptitle("%s" % (self.satname), y=1.05)
        plt.title('%2d/%2d' % (smo, sd))
        plt.title('Start:\n' + start_string, loc='left')
        plt.title('End: \n' + end_string, loc='right')

        plt.show()
Exemple #5
0
class TestTimeGSTValladoEx3_3():
    dateexp = (1995, 2, 24, 12, 0, 0)
    jdexp = 2449773.0
    gstexp = np.deg2rad(333.893486)
    jd, mjd = time.date2jd(dateexp[0], dateexp[1], dateexp[2], dateexp[3], dateexp[4], dateexp[5])
    date = time.jd2date(jdexp)
    gst, _ = time.gstlst(jd, 0)

    def test_jd(self):
        np.testing.assert_allclose(self.jd, self.jdexp)

    def test_date(self):
        np.testing.assert_allclose(self.date, self.dateexp)

    def test_gst(self):
        np.testing.assert_allclose(self.gst, self.gstexp)
Exemple #6
0
"""Script to solve Problem 1 HW4 2017

Shankar Kulumani
"""

import numpy as np
from astro import kepler, time, constants
import pdb

# time of last perihelion passage from JPL
jd_per = 2446467.395317050925
date_per = time.jd2date(jd_per)

nu_obs = np.deg2rad(260)
# properties of Halley's comet
au2km = constants.au2km
a = au2km * 17.834144  # au
ecc = 0.9671429
p = kepler.semilatus_rectum(a, ecc)
inc = np.deg2rad(162.262690579161)
raan = np.deg2rad(58.42008097656843)
argp = np.deg2rad(111.3324851045177)
M = np.deg2rad(38.3842644764388)

E, nu, _ = kepler.kepler_eq_E(M, ecc)
mu = constants.sun.mu

# properties at perihelion
print('Properties at Perihelion')
output = 'Properties at Perihelion\n'
output += kepler.orbit_el(p, ecc, inc, raan, argp, 0, mu, True)
Exemple #7
0
            r_site_eci = np.array([
                r_site_eci_turned[0][0], r_site_eci_turned[1][0],
                r_site_eci_turned[2][0]
            ])
            """Check Visibility At Time"""
            GST, LST = time.gstlst(stp, lon)
            import pdb
            pdb.set_trace()
            visible_check = PREDICT.visible(r_sat_eci, r_site_eci, lat, lon,
                                            LST, stp)
            """Determine Where to Look At Time"""
            if (visible_check == 1):
                print("Y Script")
                rang, azm, elev = PREDICT.rhoazel(r_sat_eci, r_site_eci, lat,
                                                  lon, GST)
                year, month, day, hour, minute, second = time.jd2date(stp)
                Line_out = [
                    'Where to Look at {}/{}/{}\t {}:{}:{} JD:\n\tRange(km): {}\n\tAzmuth(deg): {}\n\tElevation(deg): {}\n'
                    .format(int(month), int(day), int(year), int(hour),
                            int(minute), int(second), rang, np.rad2deg(azm),
                            np.rad2deg(elev))
                ]
                finalfile.writelines(Line_out)
            """Update Time and Position"""
            n_s, e_s, raan_s, w_s, theta_s, M_s = PREDICT.update(
                time_stepsec, n_s, nrate_0, e_s, e_dot, raan_s, raan_dot, w_s,
                w_dot, M_s)

            stp = stp + time_stepJD
            continue
Exemple #8
0
def test_jd2date_1900():
    expected_date = (1899, 12, 31, 0, 0, 0)
    actual_date = time.jd2date(2415019.5)
    np.testing.assert_allclose(actual_date, expected_date, rtol=1e-4)
Exemple #9
0
def test_jd2date_vallado_p409():
    expected_date = (1995, 5, 20, 3, 17, 2.0255)
    actual_date = time.jd2date(2449857.636829)
    np.testing.assert_allclose(actual_date, expected_date, rtol=1e-3)