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


Python ephem.Observer方法代码示例

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


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

示例1: __init__

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def __init__(self, carla_weather, dtime=None, animation=False):
        """
        Class constructor
        """
        self.carla_weather = carla_weather
        self.animation = animation

        self._sun = ephem.Sun()  # pylint: disable=no-member
        self._observer_location = ephem.Observer()
        geo_location = CarlaDataProvider.get_map().transform_to_geolocation(carla.Location(0, 0, 0))
        self._observer_location.lon = str(geo_location.longitude)
        self._observer_location.lat = str(geo_location.latitude)

        #@TODO This requires the time to be in UTC to be accurate
        self.datetime = dtime
        if self.datetime:
            self._observer_location.date = self.datetime

        self.update() 
开发者ID:carla-simulator,项目名称:scenario_runner,代码行数:21,代码来源:weather_sim.py

示例2: sun_rise_set_times

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def sun_rise_set_times(datetime_index, coords):
    """
    Returns sunrise and set times for the given datetime_index and coords,
    as a Series indexed by date (days, resampled from the datetime_index).

    """
    sun = ephem.Sun()
    obs = ephem.Observer()
    obs.lat = str(coords[0])
    obs.lon = str(coords[1])

    # Ensure datetime_index is daily
    dtindex = pd.DatetimeIndex(
        datetime_index.to_series().map(pd.Timestamp.date).unique()
    )

    return pd.Series(
        [_get_rise_and_set_time(i, sun, obs) for i in dtindex],
        index=dtindex
    ) 
开发者ID:renewables-ninja,项目名称:gsee,代码行数:22,代码来源:trigon.py

示例3: compute_sun_ned

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def compute_sun_ned(lon_deg, lat_deg, alt_m, timestamp):
    d = datetime.utcfromtimestamp(timestamp)
    #d = datetime.datetime.utcnow()
    
    ed = ephem.Date(d)
    #print 'ephem time utc:', ed
    #print 'localtime:', ephem.localtime(ed)

    ownship = ephem.Observer()
    ownship.lon = '%.8f' % lon_deg
    ownship.lat = '%.8f' % lat_deg
    ownship.elevation = alt_m
    ownship.date = ed

    sun = ephem.Sun(ownship)
    sun_ned = [ math.cos(sun.az), math.sin(sun.az), -math.sin(sun.alt) ]

    return norm(np.array(sun_ned)) 
开发者ID:UASLab,项目名称:ImageAnalysis,代码行数:20,代码来源:illumintation-sensor-test.py

示例4: _ephem_setup

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def _ephem_setup(latitude, longitude, altitude, pressure, temperature,
                 horizon):
    import ephem
    # initialize a PyEphem observer
    obs = ephem.Observer()
    obs.lat = str(latitude)
    obs.lon = str(longitude)
    obs.elevation = altitude
    obs.pressure = pressure / 100.  # convert to mBar
    obs.temp = temperature
    obs.horizon = horizon

    # the PyEphem sun
    sun = ephem.Sun()
    return obs, sun 
开发者ID:pvlib,项目名称:pvlib-python,代码行数:17,代码来源:solarposition.py

示例5: __init__

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def __init__(self, orb, lon, lat, elev=False):
        """
        :param orb: either 'sun' or 'moon'
        :param lon: longitude of observer in degrees
        :param lat: latitude of observer in degrees
        :param elev: elevation of observer in meters
        """
        if ephem is None:
            logger.warning("Could not find/use ephem!")
            return
        self._obs = ephem.Observer()
        """
        PyEphem: An `Observer` instance allows  to compute the positions of
        celestial bodies as seen from a particular position on the Earth's surface.        
        Following attributes can be set after creation (used defaults are given):        
        `date` - the moment the `Observer` is created
        `lat` - zero degrees latitude
        `lon` - zero degrees longitude
        `elevation` - 0 meters above sea level
        `horizon` - 0 degrees
        `epoch` - J2000
        `temp` - 15 degrees Celsius
        `pressure` - 1010 mBar
"""
        self._obs.long = str(lon)
        self._obs.lat = str(lat)
        if elev:
            self._obs.elevation = int(elev)
        if orb == 'sun':
            self._orb = ephem.Sun()
        elif orb == 'moon':
            self._orb = ephem.Moon()
            self.phase = self._phase
            self.light = self._light 
开发者ID:smarthomeNG,项目名称:smarthome,代码行数:36,代码来源:orb.py

示例6: _ephem_setup

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def _ephem_setup(latitude, longitude, altitude, pressure, temperature):
    # observer
    obs = ephem.Observer()
    obs.lat = str(latitude)
    obs.lon = str(longitude)
    obs.elevation = altitude
    obs.pressure = pressure / 100.
    obs.temp = temperature

    # sun
    sun = ephem.Sun()
    return obs, sun 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:14,代码来源:solar_equations.py

示例7: latlon_for_planet

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def latlon_for_planet(planet_name, date):
    planet = PLANETS[planet_name]
    obs = ephem.Observer()
    obs.date = date
    obs.lat = 0
    obs.lon = 0
    planet.compute(date)
    return degrees(planet.dec), degrees(ephem.degrees(planet.ra - obs.sidereal_time()).znorm) 
开发者ID:trehn,项目名称:termtrack,代码行数:10,代码来源:planets.py

示例8: draw_map

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def draw_map(layer, body, time, night=True, topo=True):
    for x in range(body.width):
        for y in range(body.height):
            if night:
                sun = ephem.Sun()
                obs = ephem.Observer()
                obs.pressure = 0
                lat, lon = body.to_latlon(x, y)
                obs.lat = "{:.8f}".format(lat)
                obs.lon = "{:.8f}".format(lon)
                obs.date = time
                sun.compute(obs)
                # astronomical twilight starts at -18°
                # -0.3141592 = radians(-18)
                night_factor = max(min(sun.alt, 0), -0.3141592) / -0.3141592
            else:
                night_factor = -1

            if body.map[x][y][3] is not None:
                if topo is True:
                    r, g, b, color = body.map[x][y][:4]
                else:
                    r, g, b, color = 0, 249, 114, 48
                if night_factor > -0.001:
                    night_r = 0
                    night_g = g * 0.2
                    night_b = min(b + 40, 255)
                    effective_r = ((1 - night_factor) * r) + (night_factor * night_r)
                    effective_g = ((1 - night_factor) * g) + (night_factor * night_g)
                    effective_b = ((1 - night_factor) * b) + (night_factor * night_b)
                    color = closest_color(effective_r, effective_g, effective_b)
                layer.draw(x, y, "•", color) 
开发者ID:trehn,项目名称:termtrack,代码行数:34,代码来源:draw.py

示例9: run

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def run(hourly_clearness, coords, rise_set_times=None):
    """Run the BRL model

    Parameters
    ----------
    hourly_clearness : pandas Series
        Hourly clearness indices with a datetime index.
    coords : 2-tuple of floats or ints
        Latitude and longitude
    rise_set_times : list
        List of (sunrise, sunset) time tuples, if not given, is
        calculated here.

    Returns
    -------
    result : pandas Series
        Diffuse fractions with the same datetime index as hourly_clearness.

    """
    obs = ephem.Observer()
    obs.lat = str(coords[0])
    obs.lon = str(coords[1])
    if rise_set_times is None:
        rise_set_times = trigon._sun_rise_set(hourly_clearness.index, obs)
    diffuse_fractions = []
    for i in range(0, len(hourly_clearness), 24):
        # for entry in list in hourly clearness indices:
        ks = hourly_clearness.iloc[i:i+24].tolist()
        obs.date = hourly_clearness.index[i]
        # These are indexed by day, so need to scale the index
        sunrise, sunset = rise_set_times[int(i / 24)]
        results = _daily_diffuse(obs, ks, sunrise, sunset)
        diffuse_fractions.extend(results)
    return pd.Series(diffuse_fractions, index=hourly_clearness.index) 
开发者ID:renewables-ninja,项目名称:gsee,代码行数:36,代码来源:brl_model.py

示例10: getalt

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def getalt(ra, dec, yr, mon, day, hr, minu, sec=0, lon='-111:35:59', lat='31:57:12',
		elev=2000, retSun=False, retDistMoon=False):
	"""computes the altitude in degrees of a given object at the given utc time
	ra dec in degress	
	yr mon day hr minu in utc
	lon lat are in degrees and lon is positive to the East
	retSun means that you'll get height of the sun above the horizon
	retDistMoon means that you'll also get the distance to the moon
	"""
	
	obs = ephem.Observer();
	obs.lon = lon # longitude 
	obs.lat = lat #latitude
	obs.elevation=elev;
	fb = ephem.FixedBody();
	fb._ra=np.deg2rad(ra);
	fb._dec=np.deg2rad(dec)
	obs.date=ephem.Date('%d/%02d/%d %d:%d:0'%(yr,mon,day,hr,minu))
	fb.compute(obs);
	alt = np.rad2deg(1*fb.alt)
	az = np.rad2deg(1*fb.az);
	if retSun:
		fbSun = ephem.Sun();
		fbSun.compute(obs);
		altSun = np.rad2deg(1*(fbSun.alt))
	if retDistMoon:
		fbMoon = ephem.Moon();
		fbMoon.compute(obs);
		altMoon = np.rad2deg(1*fbMoon.alt)
		azMoon = np.rad2deg(1*fbMoon.az);
		distMoon = sphdist.sphdist(az,alt,azMoon,altMoon)
	if retSun or retDistMoon:
		ret = [alt]
	else:	
		ret = alt
	if retSun:
		ret.append(altSun)
	if retDistMoon:
		ret.append(distMoon)
	return ret 
开发者ID:segasai,项目名称:astrolibpy,代码行数:42,代码来源:staralt.py

示例11: __init__

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def __init__(self, header):

    ovro = ephem.Observer()
    (ovro.lat, ovro.lon, ovro.elev) = ('37.23978', '-118.281667', 1184.120)

    if header.datestamp == "UNKNOWN" or header.t_offset == "UNKNOWN":
      self.lst = "UNKNOWN"
      self.date_str = "UNKNOWN"
      self.time_str = "UNKNOWN"
      self.localtime_str = "UNKNOWN"
      self.lst_str = "UNKNOWN"
      self.dec_str = "UNKNOWN"
      return


    # Calculate times including LST
    dt = datetime.datetime.strptime(header.datestamp, "%Y-%m-%d-%H:%M:%S")+datetime.timedelta(seconds=header.t_offset)
    ovro.date = dt
    self.lst = ovro.sidereal_time()
    localt = self.time_at_timezone(dt, "America/Los_Angeles")
    self.date_str = "%04d%02d%02d"%(dt.year,dt.month,dt.day)
    self.time_str = "%02d%02d%02d"%(dt.hour,dt.minute,dt.second)
    self.localtime_str = "%02d%02d%02d"%(localt.hour,localt.minute,localt.second)
    ra, dec = ovro.radec_of(0, np.pi/2)
    self.lst_str = str(float(ra) / 2 / np.pi * 24)
    self.dec_str = str(float(repr(dec))*180/np.pi)
    #print ("UTC START:   %s"%dada_file.datestamp)
    #print ("TIME OFFSET: %s"%datetime.timedelta(seconds=dada_file.t_offset))
    #print ("NEW START:   (%s, %s)"%(date_str, time_str)) 
开发者ID:ledatelescope,项目名称:bifrost,代码行数:31,代码来源:make_header.py

示例12: start_sat_track

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def start_sat_track(self):
        if trackSettings.trackingsat is False:
            trackSettings.trackingsat = True
        else:
            trackSettings.trackingsat = False
            self.startButton4.configure(text='Start Tracking Satellite')
            if trackSettings.telescopetype == 'ASCOM' and trackSettings.trackingsat is False:
                self.tel.MoveAxis(0, 0.0)
                self.tel.MoveAxis(1, 0.0)
                self.tel.AbortSlew()
        if trackSettings.tracking is False:
            print('Connect the Scope First!')
            self.textbox.insert(END, 'Connect the Scope First!\n')
            self.textbox.see('end')
        if self.collect_images is False:
            print('Start Camera First!')
            self.textbox.insert(END, 'Start Camera First!\n')
            self.textbox.see('end')
        if trackSettings.fileSelected is False:
            print('Select TLE File First!')
            self.textbox.insert(END, 'Select TLE File First!\n')
            self.textbox.see('end')
        if trackSettings.tracking is True and self.collect_images is True and trackSettings.trackingsat is True and trackSettings.fileSelected is True:
            with open(trackSettings.orbitFile) as f:
                lines = [line.rstrip('\n') for line in f]
                for idx, line in enumerate(lines):
                    line1 = lines[0]
                    line2 = lines[1]
                    line3 = lines[2]
                self.observer = ephem.Observer()
                self.observer.lat = str(self.entryLat.get())
                self.observer.lon = str(self.entryLon.get())
                self.observer.elevation = 0
                self.observer.pressure = 1013
                self.sat = ephem.readtle(line1,line2,line3)
            self.sattrackthread = threading.Thread(target=self.sat_track)
            self.startButton4.configure(text='Stop Tracking Satellite')
            self.sattrackthread.start() 
开发者ID:AstronomyLiveYt,项目名称:SatTraker,代码行数:40,代码来源:SatTrakerBetaV5.py

示例13: export2pyephem

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def export2pyephem(self, center='500@10', equinox=2000.):
        """Call JPL HORIZONS website to obtain orbital elements based on the
        provided targetname, epochs, and center code and create a
        PyEphem (http://rhodesmill.org/pyephem/) object. This function
        requires PyEphem to be installed.

        :param center: str;
           center body (default: 500@10 = Sun)
        :param equinox: float;
           equinox (default: 2000.0)
        :result: list;
           list of PyEphem objects, one per epoch
        :example: >>> import callhorizons
                  >>> import numpy
                  >>> import ephem
                  >>>
                  >>> ceres = callhorizons.query('Ceres')
                  >>> ceres.set_epochrange('2016-02-23 00:00', '2016-02-24 00:00', '1h')
                  >>> ceres_pyephem = ceres.export2pyephem()
                  >>>
                  >>> nau = ephem.Observer() # setup observer site
                  >>> nau.lon = -111.653152/180.*numpy.pi
                  >>> nau.lat = 35.184108/180.*numpy.pi
                  >>> nau.elevation = 2100 # m
                  >>> nau.date = '2015/10/5 01:23' # UT
                  >>> print ('next rising: %s' % nau.next_rising(ceres_pyephem[0]))
                  >>> print ('next transit: %s' % nau.next_transit(ceres_pyephem[0]))
                  >>> print ('next setting: %s' % nau.next_setting(ceres_pyephem[0]))
        """

        try:
            import ephem
        except ImportError:
            raise ImportError(
                'export2pyephem requires PyEphem to be installed')

        # obtain orbital elements
        self.get_elements(center)

        objects = []
        for el in self.data:
            n = 0.9856076686/np.sqrt(el['a']**3)  # mean daily motion
            epoch_djd = el['datetime_jd']-2415020.0  # Dublin Julian date
            epoch = ephem.date(epoch_djd)
            epoch_str = "%d/%f/%d" % (epoch.triple()[1], epoch.triple()[2],
                                      epoch.triple()[0])

            # export to PyEphem
            objects.append(ephem.readdb("%s,e,%f,%f,%f,%f,%f,%f,%f,%s,%i,%f,%f" %
                                        (el['targetname'], el['incl'], el['node'],
                                         el['argper'], el['a'], n, el['e'],
                                            el['meananomaly'], epoch_str, equinox,
                                            el['H'], el['G'])))

        return objects 
开发者ID:mommermi,项目名称:callhorizons,代码行数:57,代码来源:callhorizons.py

示例14: calc_toa_gain_offset

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def calc_toa_gain_offset(meta):
    """
    Compute (gain, offset) tuples for each band of the specified image metadata
    """
    # Set satellite index to look up cal factors
    sat_index = meta['satid'].upper() + "_" + meta['bandid'].upper()

    # Set scale for at sensor radiance
    # Eq is:
    # L = GAIN * DN * (ACF/EBW) + Offset
    # ACF abscal factor from meta data
    # EBW effectiveBandwidth from meta data
    # Gain provided by abscal from const
    # Offset provided by abscal from const
    acf = np.asarray(meta['abscalfactor'])  # Should be nbands length
    ebw = np.asarray(meta['effbandwidth'])  # Should be nbands length
    gain = np.asarray(constants.DG_ABSCAL_GAIN[sat_index])
    scale = (acf / ebw) * gain
    offset = np.asarray(constants.DG_ABSCAL_OFFSET[sat_index])

    e_sun_index = meta['satid'].upper() + "_" + meta['bandid'].upper()
    e_sun = np.asarray(constants.DG_ESUN[e_sun_index])
    sun = ephem.Sun()
    img_obs = ephem.Observer()
    img_obs.lon = meta['latlonhae'][1]
    img_obs.lat = meta['latlonhae'][0]
    img_obs.elevation = meta['latlonhae'][2]
    img_obs.date = datetime.datetime.fromtimestamp(meta['img_datetime_obj_utc']['$date'] / 1000.0).strftime(
        '%Y-%m-%d %H:%M:%S.%f')
    sun.compute(img_obs)
    d_es = sun.earth_distance

    # Pull sun elevation from the image metadata
    # theta_s can be zenith or elevation - the calc below will us either
    # a cos or s in respectively
    # theta_s = float(self.meta_dg.IMD.IMAGE.MEANSUNEL)
    theta_s = 90 - float(meta['mean_sun_el'])
    scale2 = (d_es ** 2 * np.pi) / (e_sun * np.cos(np.deg2rad(theta_s)))

    # Return scaled data
    # Radiance = Scale * Image + offset, Reflectance = Radiance * Scale2
    return zip(scale, scale2, offset)

#from skimage.transform._geometric import GeometricTransform 
开发者ID:DigitalGlobe,项目名称:gbdxtools,代码行数:46,代码来源:util.py

示例15: compute

# 需要导入模块: import ephem [as 别名]
# 或者: from ephem import Observer [as 别名]
def compute(self, time, plus_seconds=0):
        target_time = time + timedelta(seconds=plus_seconds)
        self._satellite.compute(target_time)
        self.altitude = self._satellite.elevation
        self.latitude = degrees(self._satellite.sublat)
        self.longitude = degrees(self._satellite.sublong)
        self.mean_anomaly = (
            self.mean_anomaly_at_epoch +
            self.mean_motion * (
                (target_time - self.epoch).total_seconds() %
                self.orbital_period.total_seconds()
            )
        ) % (2 * pi)
        self.eccentric_anomaly = keplers_equation(self.mean_anomaly, self.eccentricity)
        self.true_anomaly = 2 * atan2(
            sqrt(1 + self.eccentricity) * sin(self.eccentric_anomaly / 2),
            sqrt(1 - self.eccentricity) * cos(self.eccentric_anomaly / 2)
        )
        self.time_since_periapsis = timedelta(seconds=self.mean_anomaly / self.mean_motion)
        self.time_to_periapsis = timedelta(seconds=self.orbital_period.total_seconds() -
                                                   self.time_since_periapsis.total_seconds())
        self.time_since_apoapsis = timedelta(seconds=(self.mean_anomaly + pi) % (2 * pi) /
                                                     self.mean_motion)
        self.time_to_apoapsis = timedelta(seconds=self.orbital_period.total_seconds() -
                                                  self.time_since_apoapsis.total_seconds())
        self.velocity = orbital_velocity(self.semi_major_axis, self.altitude, self.latitude)

        self._satellite.compute(target_time + self.time_to_periapsis)
        self.periapsis_latitude = degrees(self._satellite.sublat)
        self.periapsis_longitude = degrees(self._satellite.sublong)

        self._satellite.compute(target_time + self.time_to_apoapsis)
        self.apoapsis_latitude = degrees(self._satellite.sublat)
        self.apoapsis_longitude = degrees(self._satellite.sublong)

        if (
            self.observer_latitude is not None and
            self.observer_longitude is not None
        ):
            observer = ephem.Observer()
            observer.date = target_time
            observer.elevation = self.observer_elevation
            observer.lat = str(self.observer_latitude)
            observer.lon = str(self.observer_longitude)
            self._satellite.compute(observer)
            self.observer_azimuth = float(self._satellite.az.norm)
            self.observer_altitude = float(self._satellite.alt.znorm)
            self.acquisition_of_signal = self._satellite.rise_time
            self.loss_of_signal = self._satellite.set_time 
开发者ID:trehn,项目名称:termtrack,代码行数:51,代码来源:satellite.py


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