Esempio n. 1
0
def states_to_lightcurve(times, obs_vecs, sun_vecs, attitudes, spacecraft_geometry, quats = False):

    lightcurve = []

    iters = len(times)
    count = 0
    for time, obs_vec, sun_vec, attitude in zip(times, obs_vecs, sun_vecs, attitudes):

        #now = utc0 + datetime.timedelta(seconds = time)

        #sun_vec = AF.vect_earth_to_sun(now)

        if quats:
            eta = attitude[0]
            eps = attitude[1:4]
            dcm_body2eci = CF.quat2dcm(eta, eps)
        else:
            dcm_body2eci = CF.euler2dcm(ROTATION, attitude)
        sun_vec_body = dcm_body2eci.T@sun_vec
        obs_vec_body = dcm_body2eci.T@obs_vec
        power = spacecraft_geometry.calc_reflected_power(obs_vec_body, sun_vec_body)

        lightcurve.append(power)

        count += 1
        loading_bar(count/iters, 'Simulating Lightcurve')

    lightcurve = hstack(lightcurve)

    return lightcurve
Esempio n. 2
0
    def AJISAI(self):

        ajisai_file = open('AJISAI_coords', 'rb')
        coords = pickle.load(ajisai_file)
        ajisai_file.close()

        Radius = 1.075
        facets = []
        for lat in coords.keys():
            for lon in coords[lat]:
                rlat = lat / 180 * pi
                rlon = lon / 180 * pi

                facet2body = CF.Cz(rlon).T @ CF.Cy(pi / 2 - rlat)
                position = CF.Cz(rlon) @ CF.Cy(rlat) @ array([1, 0, 0])
                facet = Facet(15 / 100,
                              15 / 100,
                              position,
                              facet2body=facet2body,
                              specular_coef=0.002)
                facets.append(facet)

        AJISAI = Spacecraft_Geometry(facets, sample_dim=1)
        for facet in AJISAI.facets:
            AJISAI.obscuring_facets[facet] = []

        return AJISAI
Esempio n. 3
0
def states_to_lightcurve(obs_vecs, sun_vecs, attitudes, spacecraft_geometry,
                         Exposure_Time):
    '''
    @param times list of dates at which each observation was taken
    @param obs_vecs array of vectors from the observer to the spacecraft
    @param sun_vecs array of vectors from the sun to the spacecraft
    @param attitudes array of modified rodriguez parameters describing the spacecraft attitude
    @param spacecraft_geometry a Spacecraft Geometry object describing the spacecraft geometry
    '''

    lightcurve = []

    iters = len(obs_vecs)
    count = 0
    for obs_vec, sun_vec, attitude in zip(obs_vecs, sun_vecs, attitudes):

        dcm_body2eci = CF.mrp2dcm(attitude)
        sun_vec_body = dcm_body2eci.T @ sun_vec
        obs_vec_body = dcm_body2eci.T @ obs_vec
        power = spacecraft_geometry.calc_reflected_power(
            obs_vec_body, sun_vec_body, Exposure_Time)
        lightcurve.append(power)

        count += 1
        loading_bar(count / iters, 'Simulating Lightcurve')

    lightcurve = hstack(lightcurve)

    return lightcurve
def propagate_mrps(t, state, true_inertia):
    mrps = state[0:3]
    omega = state[3:6]

    d_mrps = CF.mrp_derivative(mrps, omega)
    d_omega = inv(true_inertia)@(-cross(omega, true_inertia@omega))

    return hstack([d_mrps, d_omega])
def propagate_mrps_inertia(t, state):
    mrps = state[0:3]
    omega = state[3:6]

    est_inertia = diag([1, abs(state[6]), abs(state[7])])

    d_mrps = CF.mrp_derivative(mrps, omega)
    d_omega = inv(est_inertia)@(-cross(omega, est_inertia@omega))

    return hstack([d_mrps, d_omega, 0, 0])
def generate_image(spacecraft_geometry,
                   obs_vec_body,
                   sun_vec_body,
                   exposure_time,
                   win_dim=(2, 2),
                   dpm=50,
                   load_bar=False):
    """
    Debugging tool, used to make animations. Generates a 2D array of grayscale pixels representing an image of A Spacecraft Geometry Object.
    This assumes no FOV effects.

    Parameters:
    Spacecraft_Geometry     = The SpacecraftGeometry object whose image will be generated.
    obs_vec_body            = unit vector in body frame representing the direction the spacecraft is being VIEWED from.
    sun_vec_body            = unit vector in body frame representing the direction the spacecraft is being ILLUMINATED from.
    exposure_time           = float representing the ammount of time the CCD was exposed for in seconds.

    Keyword Parameters:
    win_dim                 = A tuple representing the dimensions of the projected area of the image in meters.
    dpm                     = INteger representing how many pixels per meter to generate. Larger numbers lead to signifnicant slower run times.
    load_bar                = True if the user wants a loading bar to appear when generating an image.
    """

    win_pix = (win_dim[0] * dpm, win_dim[1] * dpm)
    image = zeros(win_pix)
    perspective_distance = 5

    obs_vec_body = obs_vec_body / norm(obs_vec_body)
    camera_pos = obs_vec_body * 5
    ray_direction = -obs_vec_body

    camera_angle = arccos(dot(ray_direction, array([0, 0, 1])))
    camera_rotation = CF.axis_angle2dcm(cross(array([0, 0, 1]), ray_direction),
                                        camera_angle)

    for y, row in enumerate(image):
        if load_bar:
            loading_bar(y / len(image), text='Recticulating Splines')
        for x, pix in enumerate(row):
            x_pos = (x - win_pix[0] / 2) / dpm
            y_pos = (win_pix[1] / 2 - y) / dpm
            pix_pos = camera_rotation @ array([x_pos, y_pos, 0]) + camera_pos

            image[x,
                  y] = spacecraft_geometry.trace_ray(pix_pos, ray_direction,
                                                     sun_vec_body,
                                                     exposure_time)

    m = amax(image)
    # if m == 0:
    #     print('m = 0',obs_vec_body, sun_vec_body)
    if m != 0:
        image = image / m

    return image
Esempio n. 7
0
def propagate_mrps(t, state, inertia):
    mrps = state[0:3]
    omega = state[3:6]
    #inertia = diag([1, state[6], state[7]])

    #dcm_eci2body = CF.mrp2dcm(mrps).T
    d_mrps = CF.mrp_derivative(mrps, omega)
    d_omega = inv(inertia) @ (-cross(omega, inertia @ omega))

    #print(d_mrps, d_omega)
    return hstack([d_mrps, d_omega])
def mrp_measurement_function(state, obsvec, sunvec, exposure_time, Geometry):

    mrps = state[0:3]
    dcm_body2eci = CF.mrp2dcm(mrps)

    obs_vec_body = dcm_body2eci.T @ obsvec
    sun_vec_body = dcm_body2eci.T @ sunvec

    return array([
        Geometry.calc_reflected_power(obs_vec_body, sun_vec_body,
                                      exposure_time)
    ])
Esempio n. 9
0
def generate_image(spacecraft_geometry,
                   obs_vec_body,
                   sun_vec_body,
                   exposure_time,
                   win_dim=(2, 2),
                   dpm=50,
                   load_bar=False):
    """
    camera_axis is the direction that the camera is pointing
    sun axis is the direction that the light is moving (sun to spacecraft)
    """

    win_pix = (win_dim[0] * dpm, win_dim[1] * dpm)
    image = zeros(win_pix)
    perspective_distance = 5

    obs_vec_body = obs_vec_body / norm(obs_vec_body)
    camera_pos = obs_vec_body * 5
    ray_direction = -obs_vec_body

    camera_angle = arccos(dot(ray_direction, array([0, 0, 1])))
    camera_rotation = CF.axis_angle2dcm(cross(array([0, 0, 1]), ray_direction),
                                        camera_angle)

    for y, row in enumerate(image):
        if load_bar:
            loading_bar(y / len(image), text='Recticulating Splines')
        for x, pix in enumerate(row):
            x_pos = (x - win_pix[0] / 2) / dpm
            y_pos = (win_pix[1] / 2 - y) / dpm
            pix_pos = camera_rotation @ array([x_pos, y_pos, 0]) + camera_pos

            image[x,
                  y] = spacecraft_geometry.trace_ray(pix_pos, ray_direction,
                                                     sun_vec_body,
                                                     exposure_time)

    m = amax(image)
    # if m == 0:
    #     print('m = 0',obs_vec_body, sun_vec_body)
    if m != 0:
        image = image / m

    return image
Esempio n. 10
0
obs_vecs = load(truth_dir + '/obsvec.npy')[::50]
sun_vecs = load(truth_dir + '/sunvec.npy')[::50]
attitudes = load(truth_dir + '/mrps' + result_num + '.npy')[::50]
Exposure_Time = Simulation_Configuration['Exposure Time']

num_frames = len(obs_vecs)
START_INDEX = -5000

frames = []
count = 0
max_val = 0
for mrps, obs_vec, sun_vec in zip(attitudes[START_INDEX:],
                                  obs_vecs[START_INDEX:],
                                  sun_vecs[START_INDEX:]):
    dcm_eci2body = CF.mrp2dcm(mrps).T
    #dcm_eci2body = CF.mrp2dcm(mrps).T
    image = RF.generate_image(Geometry,
                              dcm_eci2body @ obs_vec,
                              dcm_eci2body @ sun_vec,
                              Exposure_Time,
                              win_dim=(6, 6),
                              dpm=20)
    im_max = amax(image)
    if im_max > max_val:
        max_val = im_max
    frames.append(image)
    count += 1
    loading_bar(count / num_frames, 'Rendering gif')

frames = [frame / max_val for frame in frames]
Esempio n. 11
0
        true_lightcurve = load(os.path.join(passfile, 'lightcurve'+run_number+'.npy'))

        true_mrps = load(os.path.join(passfile, 'mrps'+run_number+'.npy'))
        true_rates = load(os.path.join(passfile, 'angular_rate'+run_number+'.npy'))

        obs_vecs = load(os.path.join(passfile, 'obsvec.npy'))
        sun_vecs = load(os.path.join(passfile, 'sunvec.npy'))

        est_lightcurve = load(os.path.join(result_dir, 'results'+run_number+'_estimated_curve.npy'))
        means = load(os.path.join(result_dir, 'results'+run_number+'_raw_means.npy'))
        covariances = load(os.path.join(result_dir, 'results'+run_number+'_raw_covariance.npy'))
        residuals = load(os.path.join(result_dir, 'results'+run_number+'_raw_residuals.npy'))

        stp = int(floor(1/DT))

        eci_rate_true = vstack(list([CF.mrp2dcm(m)@rate for m, rate in zip(true_mrps, true_rates)]))
        eci_rate_ests = []
        for est, tru in zip(means, eci_rate_true):
            eci_rate_est = CF.mrp2dcm(est[0:3])@est[3:6]
            a = norm(eci_rate_est - tru)
            b = norm(-eci_rate_est - tru)
            if b < a:
                eci_rate_ests.append(-eci_rate_est)
            else:
                eci_rate_ests.append(eci_rate_est)
        eci_rate_ests = vstack(eci_rate_ests)


        obs_frame_true_rate = []
        obs_frame_est_rate = []
        for obs, sun, truth, est in zip(obs_vecs, sun_vecs, eci_rate_true, eci_rate_ests):
Esempio n. 12
0
    states = load('true_states.npy')
    sc_positions = load('sc_pos.npy')
    tel_positions = load('tel_pos.npy')
    sun_positions = load('sun_pos.npy')

    print(len(states))

    frames = []

    for state, sc_pos, tel_pos, sun_pos, i in zip(states, sc_positions,
                                                  tel_positions, sun_positions,
                                                  range(len(states))):
        eta = state[0]
        eps = state[1:4]
        C_eci2body = CF.quat2dcm(eps, eta).T
        obs_vec_eci = sc_pos - tel_pos
        obs_vec_eci = obs_vec_eci / norm(obs_vec_eci)
        sun_vec_eci = sc_pos - sun_pos
        sun_vec_eci = sun_vec_eci / norm(sun_vec_eci)

        obs_vec_body = C_eci2body @ obs_vec_eci
        sun_vec_body = C_eci2body @ sun_vec_eci

        image = generate_image(facets, obs_vec_body, sun_vec_body, dpm=10)
        frames.append(image.astype(uint8))
        print(str(i) + '/' + str(len(states)), end='\r')
    print('')

    fig = plt.figure()
    ax = plt.axes()
Esempio n. 13
0
outfile = open('AJISAI_coords', 'wb')
pickle.dump(Ms, outfile)
outfile.close()
print('File saved')

# fig = plt.figure()
# ax = Axes3D(fig)
Radius = 1.075
facets = []
for lat in Ms.keys():
    for lon in Ms[lat]:
        rlat = lat / 180 * pi
        rlon = lon / 180 * pi

        facet2body = CF.Cz(rlon).T @ CF.Cy(pi / 2 - rlat)
        position = CF.Cz(rlon) @ CF.Cy(rlat) @ array([1, 0, 0])
        facet = RF.Facet(15 / 100, 15 / 100, position, facet2body=facet2body)
        facets.append(facet)

AJISAI = RF.Spacecraft_Geometry(facets, sample_dim=1)
for facet in AJISAI.facets:
    AJISAI.obscuring_facets[facet] = []

image = RF.generate_image(AJISAI,
                          array([1, 0, 0]),
                          array([1, 1, 1]),
                          .01,
                          win_dim=(3, 3),
                          dpm=100,
                          load_bar=True)
Esempio n. 14
0
                         'results' + run_number + '_estimated_curve.npy'))
        means = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_means.npy'))
        covariances = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_covariance.npy'))
        residuals = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_residuals.npy'))

        stp = int(floor(1 / DT))

        eci_rate_true = vstack(
            list([
                CF.mrp2dcm(true_mrps[0]) @ true_rates[0]
                for m, rate in zip(true_mrps, true_rates)
            ]))
        eci_rate_ests = []
        for est, tru in zip(means, eci_rate_true):
            eci_rate_est = CF.mrp2dcm(est[0:3]) @ est[3:6]
            a = norm(eci_rate_est - tru)
            b = norm(-eci_rate_est - tru)
            if b < a:
                eci_rate_ests.append(-eci_rate_est)
            else:
                eci_rate_ests.append(eci_rate_est)
        eci_rate_ests = vstack(eci_rate_ests)

        obs_frame_true_rate = []
        obs_frame_est_rate = []
Esempio n. 15
0
    def __init__(self):
        pZ = Facet(1, 1, array([0, 0, .5]), facet2body=identity(3), name='+Z')
        nZ = Facet(1, 1, array([0, 0, -.5]), facet2body=CF.Cy(pi), name='-Z')
        pX = Facet(1,
                   1,
                   array([.5, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(1,
                   1,
                   array([-.5, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(1,
                   1,
                   array([0, .5, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(1,
                   1,
                   array([0, -.5, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')
        wingnX = Facet(1,
                       .5,
                       array([-1, 0, 0]),
                       facet2body=CF.Cx(pi / 2),
                       name='-X wing',
                       double_sided=True)
        wingpX = Facet(1,
                       .5,
                       array([1, 0, 0]),
                       facet2body=CF.Cx(pi / 2),
                       name='+X wing',
                       double_sided=True)

        self.BOX_WING = Spacecraft_Geometry(
            [pX, nX, pY, nY, pZ, nZ, wingnX, wingpX], sample_dim=.1)

        self.BOX = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ], sample_dim=.1)

        plate = Facet(1,
                      1,
                      array([0, 0, 0]),
                      facet2body=identity(3),
                      name='plate',
                      double_sided=True)
        self.PLATE = Spacecraft_Geometry([plate])

        segments = 20
        angle = 2 * pi / segments
        radius = 1.5
        side_length = radius * sin(angle / 2) * radius
        lenght = 9
        cylinder_facets = []
        for theta in linspace(0, 2 * pi, segments)[:-1]:
            pos = CF.Cz(theta) @ array([1, 0, 0])
            facet2body = CF.Cz(theta) @ CF.Cy(pi / 2)
            cylinder_facets.append(
                Facet(lenght,
                      side_length,
                      pos,
                      facet2body=facet2body,
                      name='cylinder'))

        pZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, lenght / 2]),
                   name='+Z',
                   facet2body=identity(3))
        pZ.area = pi * radius**2
        nZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, -lenght / 2]),
                   name='-Z',
                   facet2body=CF.Cx(pi))
        nZ.area = pi * radius**2
        cylinder_facets.append(pZ)
        cylinder_facets.append(nZ)

        self.CYLINDER = Spacecraft_Geometry(cylinder_facets, sample_dim=.5)

        spec_coef = 0
        diffuse_coef = .002
        segments = 20
        angle = 2 * pi / segments
        radius = 1.3
        side_length = radius * sin(angle / 2) * 2
        lenght = 11.6
        cylinder_facets = []
        for theta in linspace(0, 2 * pi, segments)[:-1]:
            pos = CF.Cz(theta) @ array([radius, 0, 0])
            facet2body = CF.Cz(theta) @ CF.Cy(pi / 2)
            cylinder_facets.append(
                Facet(lenght,
                      side_length,
                      pos,
                      facet2body=facet2body,
                      name='cylinder',
                      specular_coef=spec_coef,
                      diffuse_coef=diffuse_coef))

        pZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, lenght / 2]),
                   name='+Z',
                   facet2body=identity(3),
                   specular_coef=spec_coef,
                   diffuse_coef=diffuse_coef)
        pZ.area = pi * radius**2
        nZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, -lenght / 2]),
                   name='-Z',
                   facet2body=CF.Cx(pi),
                   specular_coef=spec_coef,
                   diffuse_coef=diffuse_coef)
        nZ.area = pi * radius**2
        cylinder_facets.append(pZ)
        cylinder_facets.append(nZ)

        #https://www.spacelaunchreport.com/ariane4.html
        #data from second stage
        self.ARIANE40 = Spacecraft_Geometry(cylinder_facets, sample_dim=.5)

        diffuse_coef = .0002

        segments = 20
        angle = 2 * pi / segments
        radius = 1.2
        side_length = radius * sin(angle / 2) * 2
        lenght = 6.5
        cylinder_facets = []
        for theta in linspace(0, 2 * pi, segments)[:-1]:
            pos = CF.Cz(theta) @ array([radius, 0, 0])
            facet2body = CF.Cz(theta) @ CF.Cy(pi / 2)
            cylinder_facets.append(
                Facet(lenght,
                      side_length,
                      pos,
                      facet2body=facet2body,
                      specular_coef=0,
                      diffuse_coef=diffuse_coef,
                      name='cylinder'))

        pZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, lenght / 2]),
                   name='+Z',
                   facet2body=identity(3),
                   specular_coef=0,
                   diffuse_coef=diffuse_coef)
        pZ.area = pi * radius**2
        nZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, -lenght / 2]),
                   name='-Z',
                   facet2body=CF.Cx(pi),
                   specular_coef=0,
                   diffuse_coef=diffuse_coef)
        nZ.area = pi * radius**2
        cylinder_facets.append(pZ)
        cylinder_facets.append(nZ)

        self.SL8 = Spacecraft_Geometry(cylinder_facets, sample_dim=.5)

        pZ = Facet(3.0,
                   1.0,
                   array([0, 0, 1.0]),
                   facet2body=identity(3),
                   name='+Z')
        nZ = Facet(3.0,
                   1.0,
                   array([0, 0, -1.0]),
                   facet2body=CF.Cy(pi),
                   name='-Z')
        pX = Facet(2.0,
                   1.0,
                   array([1.5, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(2.0,
                   1.0,
                   array([-1.5, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(3.0,
                   2.0,
                   array([0, .5, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(3.0,
                   2.0,
                   array([0, -.5, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')

        self.RECTANGLE = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ],
                                             sample_dim=.1)

        pZ = Facet(5.0,
                   1.0,
                   array([0, 0, 1.0]),
                   facet2body=identity(3),
                   name='+Z')
        nZ = Facet(5.0,
                   1.0,
                   array([0, 0, -1.0]),
                   facet2body=CF.Cy(pi),
                   name='-Z')
        pX = Facet(2.0,
                   1.0,
                   array([2.5, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(2.0,
                   1.0,
                   array([-2.5, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(5.0,
                   2.0,
                   array([0, .5, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(5.0,
                   2.0,
                   array([0, -.5, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')

        self.LONG_RECTANGLE = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ],
                                                  sample_dim=.1)

        xdim = .1
        ydim = .1
        zdim = .3
        pZ = Facet(xdim,
                   ydim,
                   array([0, 0, zdim / 2]),
                   facet2body=identity(3),
                   name='+Z')
        nZ = Facet(xdim,
                   ydim,
                   array([0, 0, -zdim / 2]),
                   facet2body=CF.Cy(pi),
                   name='-Z')
        pX = Facet(zdim,
                   ydim,
                   array([xdim / 2, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(zdim,
                   ydim,
                   array([-xdim / 2, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(xdim,
                   zdim,
                   array([0, ydim / 2, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(xdim,
                   zdim,
                   array([0, -ydim / 2, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')

        self.EXOCUBE = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ],
                                           sample_dim=.01)

        spec_coef = .002

        segments = 20
        angle = 2 * pi / segments
        radius = 1.5 / 2
        side_length = 2 * sin(angle / 2) * radius
        lenght = 7.9
        cylinder_facets = []
        for theta in linspace(0, 2 * pi, segments)[:-1]:
            pos = CF.Cz(theta) @ array([radius, 0, 0])
            facet2body = CF.Cz(theta) @ CF.Cy(pi / 2)
            outer_facet = Facet(lenght,
                                side_length,
                                pos,
                                facet2body=facet2body,
                                name='cylinder',
                                specular_coef=spec_coef)
            cylinder_facets.append(outer_facet)

        pZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, lenght / 2]),
                   name='+Z',
                   facet2body=identity(3),
                   specular_coef=spec_coef)
        pZ.area = pi * radius**2
        nZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, -lenght / 2]),
                   name='-Z',
                   facet2body=CF.Cx(pi),
                   specular_coef=spec_coef)
        nZ.area = pi * radius**2
        cylinder_facets.append(pZ)
        cylinder_facets.append(nZ)

        pX_panel = Facet(6,
                         1.5,
                         array([6 / 2 + radius, 0, lenght / 2 - 1.5 / 2]),
                         name='+X Panel',
                         facet2body=CF.Cx(pi / 2),
                         double_sided=True,
                         specular_coef=spec_coef)
        nX_panel = Facet(6,
                         1.5,
                         array([-6 / 2 - radius, 0, lenght / 2 - 1.5 / 2]),
                         name='-X Panel',
                         facet2body=CF.Cx(pi / 2),
                         double_sided=True,
                         specular_coef=spec_coef)
        cylinder_facets.append(pX_panel)
        cylinder_facets.append(nX_panel)

        dumypanel = Facet(lenght,
                          radius / 2,
                          array([0, 0, 0]),
                          facet2body=CF.Cy(pi / 2),
                          name='Fake Shadow',
                          specular_coef=0)

        self.SERT2 = Spacecraft_Geometry(cylinder_facets, sample_dim=.1)

        self.SERT2.obscuring_facets[pX_panel] = [dumypanel]
        self.SERT2.obscuring_facets[nX_panel] = [dumypanel]
Esempio n. 16
0
        print(facet.name, facet.center, facet.unit_normal)

    num_frames = len(obs_vecs)
    print(num_frames)

    # obs_body = array([ 0.67027951, -0.02873575, -0.74155218])
    # sun_body = array([-0.01285413, -0.99098831,  0.13332702])
    # image = generate_image(SC, obs_body, sun_body, win_dim = (4,4), dpm = 5)
    # plt.imshow(image, cmap = 'Greys')
    # plt.show()

    frames = []
    count = 0
    max_val = 0
    for quat, obs_vec, sun_vec in zip(attitudes, obs_vecs, sun_vecs):
        dcm_eci2body = CF.quat2dcm(quat[0], quat[1:4]).T
        image = generate_image(SC,
                               dcm_eci2body @ obs_vec,
                               dcm_eci2body @ sun_vec,
                               win_dim=(4, 4),
                               dpm=5)
        im_max = amax(image)
        if im_max > max_val:
            max_val = im_max
        frames.append(image)
        count += 1
        loading_bar(count / num_frames, 'Rendering gif')

    frames = [frame / max_val for frame in frames]

    imageio.mimsave('./boxwing_vis.gif', frames, fps=10)
Esempio n. 17
0
    def __init__(self):
        pZ = Facet(1, 1, array([0, 0, .5]), facet2body=identity(3), name='+Z')
        nZ = Facet(1, 1, array([0, 0, -.5]), facet2body=CF.Cy(pi), name='-Z')
        pX = Facet(1,
                   1,
                   array([.5, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(1,
                   1,
                   array([-.5, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(1,
                   1,
                   array([0, .5, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(1,
                   1,
                   array([0, -.5, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')
        wingnX = Facet(1,
                       .5,
                       array([-1, 0, 0]),
                       facet2body=CF.Cx(pi / 2),
                       name='-X wing',
                       double_sided=True)
        wingpX = Facet(1,
                       .5,
                       array([1, 0, 0]),
                       facet2body=CF.Cx(pi / 2),
                       name='+X wing',
                       double_sided=True)

        self.BOX_WING = Spacecraft_Geometry(
            [pX, nX, pY, nY, pZ, nZ, wingnX, wingpX], sample_dim=.1)

        self.BOX = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ], sample_dim=.1)

        plate = Facet(1,
                      1,
                      array([0, 0, 0]),
                      facet2body=identity(3),
                      name='plate',
                      double_sided=True)
        self.PLATE = Spacecraft_Geometry([plate])

        segments = 20
        angle = 2 * pi / segments
        radius = 1.5
        side_length = 1.8 * sin(angle / 2) * radius
        lenght = 9
        cylinder_facets = []
        for theta in linspace(0, 2 * pi, segments)[:-1]:
            pos = CF.Cz(theta) @ array([1, 0, 0])
            facet2body = CF.Cz(theta) @ CF.Cy(pi / 2)
            cylinder_facets.append(
                Facet(lenght,
                      side_length,
                      pos,
                      facet2body=facet2body,
                      name='cylinder'))

        pZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, lenght / 2]),
                   name='+Z',
                   facet2body=identity(3))
        nZ = Facet(1.4 / sqrt(2),
                   1.4 / sqrt(2),
                   array([0, 0, -lenght / 2]),
                   name='-Z',
                   facet2body=CF.Cx(pi))
        cylinder_facets.append(pZ)
        cylinder_facets.append(nZ)

        self.CYLINDER = Spacecraft_Geometry(cylinder_facets, sample_dim=.5)

        pZ = Facet(3.0,
                   1.0,
                   array([0, 0, 1.0]),
                   facet2body=identity(3),
                   name='+Z')
        nZ = Facet(3.0,
                   1.0,
                   array([0, 0, -1.0]),
                   facet2body=CF.Cy(pi),
                   name='-Z')
        pX = Facet(2.0,
                   1.0,
                   array([1.5, 0, 0]),
                   facet2body=CF.Cy(pi / 2),
                   name='+X')
        nX = Facet(2.0,
                   1.0,
                   array([-1.5, 0, 0]),
                   facet2body=CF.Cy(-pi / 2),
                   name='-X')
        pY = Facet(3.0,
                   2.0,
                   array([0, .5, 0]),
                   facet2body=CF.Cx(-pi / 2),
                   name='+Y')
        nY = Facet(3.0,
                   2.0,
                   array([0, -.5, 0]),
                   facet2body=CF.Cx(pi / 2),
                   name='-Y')

        self.RECTANGLE = Spacecraft_Geometry([pX, nX, pY, nY, pZ, nZ],
                                             sample_dim=.1)
Esempio n. 18
0
        est_lightcurve = load(
            os.path.join(result_dir,
                         'results' + run_number + '_estimated_curve.npy'))
        means = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_means.npy'))
        covariances = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_covariance.npy'))
        residuals = load(
            os.path.join(result_dir,
                         'results' + run_number + '_raw_residuals.npy'))

        eci_rate_ests = []
        for est in means:
            eci_rate_est = CF.mrp2dcm(est[0:3]) @ est[3:6]
            eci_rate_ests.append(eci_rate_est)
        eci_rate_ests = vstack(eci_rate_ests)

        obs_frame_est_rate = []
        for obs, sun, est in zip(obs_vecs, sun_vecs, eci_rate_ests):

            x = obs / norm(obs)
            z = cross(sun, obs) / norm(cross(sun, obs))
            y = cross(z, x)

            eci2obs = vstack([x, y, z])
            obs_frame_est_rate.append(eci2obs @ est)

        obs_frame_est_rate = vstack(obs_frame_est_rate)