当前位置: 首页>>代码示例>>Python>>正文


Python PyKEP.epoch方法代码示例

本文整理汇总了Python中PyKEP.epoch方法的典型用法代码示例。如果您正苦于以下问题:Python PyKEP.epoch方法的具体用法?Python PyKEP.epoch怎么用?Python PyKEP.epoch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyKEP的用法示例。


在下文中一共展示了PyKEP.epoch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mjd_vts

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
 def mjd_vts(self, time):
     """Method converting a MJD epoch to the vts format.
     Returns a tuple: the integer part of the MJD and the fractional
     part (converted to seconds) of the MJD. 
     """
     mjd_integer_part = int(pk.epoch(time).mjd // 1)
     mjd_decimal_part = (pk.epoch(time).mjd % 1) * pk.DAY2SEC
     return mjd_integer_part, mjd_decimal_part
开发者ID:tobspm,项目名称:TSX,代码行数:10,代码来源:motion.py

示例2: vts

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
    def vts(self, dates):
	# pas compris, si un objet est de type "Date", sa méthode t.vts(...) utilise quoi et retourne quoi?
	"""Method converting an epoch to the vts format.
	it returns the integer part of the MJD and
	the fractional part (converted to seconds) of the MJD. 
	"""
	self.time_integer_part = int(pk.epoch(dates).mjd // 1)
	self.time_decimal_part = (pk.epoch(dates).mjd % 1) * pk.DAY2SEC
	return self.time_integer_part, self.time_decimal_part
开发者ID:Boxx-Obspm,项目名称:TSX,代码行数:11,代码来源:date.py

示例3: _compute_constraints_impl

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
    def _compute_constraints_impl(self, x):
        import PyKEP
        start = PyKEP.epoch(x[0])
        end = PyKEP.epoch(x[0] + x[1])

        # Computing starting spaceraft state
        r, v = self.__departure.eph(start)
        v_list = list(v)
        v_list[0] += x[3]
        v_list[1] += x[4]
        v_list[2] += x[5]
        x0 = PyKEP.sims_flanagan.sc_state(r, v_list, self.__sc.mass)

        # Computing ending spaceraft state
        r, v = self.__target.eph(end)
        v_list = list(v)
        v_list[0] += x[6]
        v_list[1] += x[7]
        v_list[2] += x[8]
        xe = PyKEP.sims_flanagan.sc_state(r, v_list, x[2])

        # Building the SF leg
        self.__leg.set(start, x0, x[-3 * self.__nseg:], end, xe)

        # Computing Vinf constraints (careful here, the weights do count). In case of a larger than constarint
        # a factor of 100 has been added
        if (self.__Vinf_0 >= 0):
            v_inf_con_0 = (x[3] * x[3] + x[4] * x[4] + x[5] * x[5] - self.__Vinf_0 *
                           self.__Vinf_0) / (PyKEP.EARTH_VELOCITY * PyKEP.
                                             EARTH_VELOCITY)
        else:
            v_inf_con_0 = -100 * (x[3] * x[3] + x[4] * x[4] + x[5] * x[5] - self.
                                  __Vinf_0 * self.__Vinf_0) / (PyKEP.
                                                               EARTH_VELOCITY * PyKEP.EARTH_VELOCITY)
        if (self.__Vinf_f >= 0):
            v_inf_con_f = (x[6] * x[6] + x[7] * x[7] + x[8] * x[8] - self.__Vinf_f *
                           self.__Vinf_f) / (PyKEP.EARTH_VELOCITY * PyKEP.
                                             EARTH_VELOCITY)
        else:
            v_inf_con_f = -100 * (x[6] * x[6] + x[7] * x[7] + x[8] * x[8] - self.
                                  __Vinf_f * self.__Vinf_f) / (PyKEP.
                                                               EARTH_VELOCITY * PyKEP.EARTH_VELOCITY)

        # Setting all constraints
        retval = list(self.__leg.mismatch_constraints(
        ) + self.__leg.throttles_constraints()) + [v_inf_con_0] + [v_inf_con_f]
        retval[0] /= PyKEP.AU
        retval[1] /= PyKEP.AU
        retval[2] /= PyKEP.AU
        retval[3] /= PyKEP.EARTH_VELOCITY
        retval[4] /= PyKEP.EARTH_VELOCITY
        retval[5] /= PyKEP.EARTH_VELOCITY
        retval[6] /= self.__sc.mass
        return retval
开发者ID:JacobXie,项目名称:pagmo,代码行数:56,代码来源:_pl2pl.py

示例4: _compute_constraints_impl

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
    def _compute_constraints_impl(self, x_full):
        import PyKEP
        sc_mass = self.__start_mass
        eqs = []
        ineqs = []

        for i in range(self.__num_legs):
            x = x_full[i * self.__dim_leg:(i + 1) * self.__dim_leg]

            start = PyKEP.epoch(x[0])
            end = PyKEP.epoch(x[0] + x[1])

            # Computing starting spaceraft state
            r, v = self.__seq[i].eph(start)
            x0 = PyKEP.sims_flanagan.sc_state(r, v, sc_mass)

            # Computing ending spaceraft state
            r, v = self.__seq[i + 1].eph(end)
            xe = PyKEP.sims_flanagan.sc_state(r, v, x[3])

            # Building the SF leg
            self.__legs[i].set_spacecraft(PyKEP.sims_flanagan.spacecraft(sc_mass, .3, 3000.))
            self.__legs[i].set(start, x0, x[-3 * self.__nseg:], end, xe)

            # Setting all constraints
            eqs.extend(self.__legs[i].mismatch_constraints())
            ineqs.extend(self.__legs[i].throttles_constraints())

            eqs[-7] /= PyKEP.AU
            eqs[-6] /= PyKEP.AU
            eqs[-5] /= PyKEP.AU
            eqs[-4] /= PyKEP.EARTH_VELOCITY
            eqs[-3] /= PyKEP.EARTH_VELOCITY
            eqs[-2] /= PyKEP.EARTH_VELOCITY
            eqs[-1] /= self.__start_mass

            sc_mass = x[3]  # update mass to final mass of leg

            if i < self.__num_legs - 1:
                x_next = x_full[(i + 1) * self.__dim_leg:(i + 2) * self.__dim_leg]
                time_ineq = x[0] + x[1] + x[2] - x_next[0]
                ineqs.append(time_ineq / 365.25)
            else:
                final_time_ineq = x[0] + x[1] + x[2] - x_full[0] - x_full[-1]  # <- total time
                ineqs.append(final_time_ineq / 365.25)

        retval = eqs + ineqs
        return retval
开发者ID:CandidoSerrano,项目名称:pykep,代码行数:50,代码来源:_mr_lt_nep.py

示例5: cluster

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
    def cluster(self, t, with_velocity=True, scaling='astro', eps=0.125, min_samples=10):
        """
        USAGE: cl.cluster(self, t, with_velocity=True, scaling='astro', eps=0.125, min_samples=10)

        - t: epoch (in MJD2000)
        - with_velocity: when True clusters by position and velocity, otherwise only position is used
        - scaling: one of
          - None, or
          - 'standard' (removing mean and scale to standard variance), or
          - 'astro' (scaling by PyKEP.AU and PyKEP.EARTH_VELOCITY)
        - eps: max distance between points in a cluster
        - min_samples: minimum number of samples per cluster
        """
        import PyKEP
        import numpy
        from sklearn.preprocessing import StandardScaler
        from sklearn.cluster import DBSCAN

        self._scaling = scaling
        self._epoch = PyKEP.epoch(t)

        if with_velocity:
            self._X = [
                [elem for tupl in p.eph(self._epoch) for elem in tupl] for p in self._asteroids]
        else:
            self._X = [list(p.eph(self._epoch)[0]) for p in self._asteroids]
        self._X = numpy.array(self._X)

        self._scaler = None
        if self._scaling == 'standard':
            self._scaler = StandardScaler().fit(self._X)
            self._X = self._scaler.transform(self._X)
        elif self._scaling == 'astro':
            scaling_vector = [PyKEP.AU] * 3
            if with_velocity:
                scaling_vector += [PyKEP.EARTH_VELOCITY] * 3
            scaling_vector = numpy.array(scaling_vector)
            self._X = self._X / scaling_vector[None, :]

        self._db = DBSCAN(eps=eps, min_samples=min_samples).fit(self._X)
        self._core_samples = self._db.core_sample_indices_

        self.labels = self._db.labels_
        self.n_clusters = len(
            set(self.labels)) - (1 if -1 in self.labels else 0)

        self.members = {}
        self.core_members = {}
        for label in set(self.labels):
            if int(label) == -1:
                continue
            self.members[int(label)] = [index[0]
                                        for index in numpy.argwhere(self.labels == label)]
            self.core_members[int(label)] = [
                index for index in self._core_samples if self.labels[index] == label]

        if self._scaling == 'standard':
            self._X = self._scaler.inverse_transform(self._X)
        elif self._scaling == 'astro':
            self._X = self._X * scaling_vector[None, :]
开发者ID:CandidoSerrano,项目名称:pykep,代码行数:62,代码来源:_dbscan.py

示例6: lambert_leg

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def lambert_leg(P1, P2, t0, tof):
    
    ast1 = ASTEROIDS[P1]
    ast2 = ASTEROIDS[P2]

    r1, v1 = ast1.eph(kep.epoch(t0))
    r2, v2 = ast2.eph(kep.epoch(t0 + tof))

    lambert = kep.lambert_problem(r1, r2, tof * kep.DAY2SEC, ast1.mu_central_body)

    vrel_in = tuple(map(lambda x, y: -x + y, lambert.get_v1()[0], v1))
    vrel_out = tuple(map(lambda x, y: -x + y, lambert.get_v2()[0], v2))

    dv_lambert = np.linalg.norm(vrel_out) + np.linalg.norm(vrel_in)

    a, _, _, dv_damon = kep.damon(vrel_in, vrel_out, tof*kep.DAY2SEC)
    m_star = kep.max_start_mass(np.linalg.norm(a), dv_damon, T_max, Isp)
    
    return dv_lambert, dv_damon, m_star
开发者ID:ritaneves,项目名称:Trajectory,代码行数:21,代码来源:tools.py

示例7: jde_mga_1dsm

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def jde_mga_1dsm(seq, t0, tof, slack=5, pop_size=50, n_evolve=10, dv_launch=6127., verbose=False):
    """Runs jDE with mga_1dsm problem."""
    from PyGMO.problem import mga_1dsm_tof
    from PyGMO.algorithm import jde
    from PyGMO import population

    prob = mga_1dsm_tof(seq=[kep.planet_ss(name) for name in seq],
                                   t0=[kep.epoch(t0-slack), kep.epoch(t0+slack)],
                                   tof=[[t-slack, t+slack] for t in tof],
                                   vinf=[0., dv_launch/1000.],
                                   add_vinf_arr=False)
    algo = jde(gen=500, memory=True)
    pop = population(prob, pop_size)
    if verbose:
        print pop.champion.f[0]
    for i in xrange(n_evolve):
        pop = algo.evolve(pop)
        if verbose:
            print pop.champion.f
开发者ID:ritaneves,项目名称:Trajectory,代码行数:21,代码来源:tools.py

示例8: write_output_vts

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def write_output_vts(output_vts_format_file, trajectory, earth, mars):
	""" Function for generating the trajectory of the CubeSat by traj.xyzv 
	in the VTS format """
	def tab_write(value):
        	output_vts_format_file.write('%s\t' % value)

	for value in trajectory:
        	time = value[0]
        	pos = value[1:4]
		time_integer_part = int(pk.epoch(time).mjd // 1) # integer part of mjd time 
		time_decimal_part = (pk.epoch(time).mjd % 1)*pk.DAY2SEC # converting the decimal part of mjd time to seconds
        	tab_write(time_integer_part)
		tab_write(time_decimal_part)
        	tab_write(pos[0]/1000.)  # the position of the CubeSat along the X axis (in km)
        	tab_write(pos[1]/1000.)
        	tab_write(pos[2]/1000.)
        	tab_write(value[4])      # the velocity of the CubeSat along the X axis (in m/s)
        	tab_write(value[5])
       		tab_write(value[6])
        	output_vts_format_file.write('\n')
开发者ID:tobspm,项目名称:TS,代码行数:22,代码来源:trajectory_io.py

示例9: pretty

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
 def pretty(self, x):
     """Decodes the decision vector x"""
     import PyKEP
     start = PyKEP.epoch(x[0])
     end = PyKEP.epoch(x[0] + x[1])
     r, v = self.__departure.eph(start)
     v_list = list(v)
     v_list[0] += x[3]
     v_list[1] += x[4]
     v_list[2] += x[5]
     x0 = PyKEP.sims_flanagan.sc_state(r, v_list, self.__sc.mass)
     r, v = self.__target.eph(end)
     xe = PyKEP.sims_flanagan.sc_state(r, v, x[2])
     self.__leg.set(start, x0, x[-3 * self.__nseg:], end, xe)
     print("A direct interplantary transfer\n")
     print("FROM:")
     print(self.__departure)
     print("TO:")
     print(self.__target)
     print(self.__leg)
开发者ID:JacobXie,项目名称:pagmo,代码行数:22,代码来源:_pl2pl.py

示例10: cluster

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
    def cluster(self, t, eps=0.125, min_samples=10, metric='orbital', T=180, ref_r=AU, ref_v=EARTH_VELOCITY):
        """
        USAGE: cl.cluster(t, eps=0.125, min_samples=10, metric='orbital', T=180, ref_r=AU, ref_v=EARTH_VELOCITY):

        - t: epoch (in MJD2000)
        - eps: max distance between points in a cluster
        - min_samples: minimum number of samples per cluster
        - metric: one of 'euclidean', 'euclidean_r', orbital'
        - T: average transfer time (used in the definition of the 'orbital' metric)
        - ref_r         reference radius   (used as a scaling factor for r if the metric is 'euclidean' or 'euclidean_r')
        - ref_v         reference velocity (used as a scaling factor for v if the metric is 'euclidean')
        """
        import PyKEP
        import numpy
        from sklearn.cluster import DBSCAN

        self._epoch = PyKEP.epoch(t)

        if metric == 'euclidean':
            self._X = [
                [elem for tupl in p.eph(self._epoch) for elem in tupl] for p in self._asteroids]
            scaling_vector = [ref_r] * 3
            scaling_vector += [ref_v] * 3
        elif metric == 'euclidean_r':
            self._X = [list(p.eph(self._epoch)[0]) for p in self._asteroids]
            scaling_vector = [ref_r] * 3
        elif metric == 'orbital':
            self._T = T
            self._X = [self._orbital_metric(*p.eph(self._epoch)) for p in self._asteroids]
            scaling_vector = [1.] * 6  # no scaling
        self._X = numpy.array(self._X)

        scaling_vector = numpy.array(scaling_vector)
        self._X = self._X / scaling_vector[None, :]

        self._db = DBSCAN(eps=eps, min_samples=min_samples).fit(self._X)
        self._core_samples = self._db.core_sample_indices_

        self.labels = self._db.labels_
        self.n_clusters = len(
            set(self.labels)) - (1 if -1 in self.labels else 0)

        self.members = {}
        self.core_members = {}
        for label in set(self.labels):
            if int(label) == -1:
                continue
            self.members[int(label)] = [index[0]
                                        for index in numpy.argwhere(self.labels == label)]
            self.core_members[int(label)] = [
                index for index in self._core_samples if self.labels[index] == label]

        self._X = self._X * scaling_vector[None, :]
开发者ID:JonathanWillitts,项目名称:pykep,代码行数:55,代码来源:_dbscan.py

示例11: parse_trajectory

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def parse_trajectory(trajectory_file):
    dates = []
    positions = []
    velocities = []
    for line in trajectory_file.read().splitlines():
        values = [float(element) for element in line.split(' ')]
        dates.append(pk.epoch(values[0], 'jd'))
        positions.append([values[1], values[2], values[3]])
        velocities.append([values[4], values[5], values[6]])
    positions = np.array(positions)*1000
    velocities = np.array(velocities)*1000
    return dates, positions, velocities
开发者ID:tobspm,项目名称:TS,代码行数:14,代码来源:trajectory_io.py

示例12: plot_trajectory

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def plot_trajectory(dates, positions, flight_duration):
    earth = pk.planet.jpl_lp('earth')
    mars = pk.planet.jpl_lp('mars')

    fig = pyplot.figure()
    ax = fig.gca(projection='3d')
    unzip = zip(*positions)
    pk.orbit_plots.plot_planet(earth, ax=ax, t0=dates[0])
    mars_arrival = pk.epoch(dates[0].mjd2000 + flight_duration)
    pk.orbit_plots.plot_planet(mars, ax=ax, t0=mars_arrival)
    ax.plot(unzip[0], unzip[1], unzip[2], color='red')
    return ax
开发者ID:tobspm,项目名称:TS,代码行数:14,代码来源:trajectory_io.py

示例13: lambert_leg

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def lambert_leg(p1, p2, t0, tof, vrel=None, dv_launch=0., rendezvous=False):
    """Compute a lambert leg from planet to planet.

    Arguments:
    p1 -- starting planet (str or PyKEP.planet object)
    p2 -- final planet (str or PyKEP.planet object)
    t0 -- start time of leg in MJD2000
    tof -- time of flight in days
    
    Keyword arguments:
    vrel -- caresian coordinates of the relative velocity before the flyby at p1
    dv_launch -- dv discounted at lunch (i.e. if vrel is None)
    rendezvous -- add final dv

    Returns:
    dV, vrel_out, where vrel_out is the relative velocity at the end of the leg at p2
    """
    # check if planets are names or planet objects
    
    p1 = PLANETS[str(p1)]
    p2 = PLANETS[str(p2)]
    r1, v1 = p1.eph(kep.epoch(t0))
    r2, v2 = p2.eph(kep.epoch(t0 + tof))
    lambert = kep.lambert_problem(r1, r2, tof * kep.DAY2SEC, p1.mu_central_body, False, 0)
    
    vrel_in = tuple(map(lambda x, y: x - y, lambert.get_v1()[0], v1))
    vrel_out = tuple(map(lambda x, y: x - y, lambert.get_v2()[0], v2))

    if vrel is None:
        # launch
        dv = max(np.linalg.norm(vrel_in) - dv_launch, 0)
    else:
        # flyby
        #print p1.name, p2.name, np.linalg.norm(vrel_in), np.linalg.norm(vrel_out)
        dv = kep.fb_vel(vrel, vrel_in, p1)

    if rendezvous:
        dv += np.linalg.norm(vrel_out)
        
    return dv, vrel_out
开发者ID:ritaneves,项目名称:Trajectory,代码行数:42,代码来源:tools.py

示例14: plot_orbits

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def plot_orbits(ep, debris1, debris2):
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.set_aspect('equal')
    ax.set_xlim(-1e7, 1e7)
    ax.set_ylim(-1e7, 1e7)
    ax.set_zlim(-1e7, 1e7)
    for deb in debris1:
        try:
            kep.orbit_plots.plot_planet(deb, ax=ax, t0=kep.epoch(ep), s=0, color='r', alpha=0.2)
        except:
            pass

    for deb in debris2:
        try:
            kep.orbit_plots.plot_planet(deb, ax=ax, t0=kep.epoch(ep), s=0, color='b', alpha=0.2)
        except:
            pass

    plt.show()
开发者ID:esa,项目名称:Space_debris_removal_model,代码行数:24,代码来源:breakup.py

示例15: body_eph_gen_vts

# 需要导入模块: import PyKEP [as 别名]
# 或者: from PyKEP import epoch [as 别名]
def body_eph_gen_vts(output_vts_format_file, trajectory, body):
	""" Function for generating the ephemeris of a body by traj.xyzv
	in the VTS format """
	def tab_write(value):
		output_vts_format_file.write('%s\t' % value)

	def car2sph(car_pos):
		r = np.linalg.norm(car_pos)  # km
		lat = np.arcsin(car_pos[2]/r)*180./np.pi   # degree
		lon = np.arctan2(car_pos[1], car_pos[0])*180./np.pi  # degree
		return np.array([lon,lat,r/1000.])
	
	for value in trajectory:
		time = value[0]
		pos = value[1:4]
		sph_temp = car2sph( body.get_relative_position(time, pos) )
		time_integer_part = int(pk.epoch(time).mjd // 1) # integer part of mjd time 
		time_decimal_part = (pk.epoch(time).mjd % 1)*pk.DAY2SEC # converting the decimal part of mjd time to seconds
		tab_write(time_integer_part)
		tab_write(time_decimal_part)
		tab_write(sph_temp[1]) # latitude 
		tab_write(sph_temp[0]) # longitude  
		tab_write(sph_temp[2]) 
		output_vts_format_file.write('\n')
开发者ID:tobspm,项目名称:TS,代码行数:26,代码来源:trajectory_io.py


注:本文中的PyKEP.epoch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。