How to use the ephem.now function in ephem

To help you get started, we’ve selected a few ephem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akkana / scripts / analemma.py View on Github external
# self.project_and_draw(theta + math.pi, 0., 1)

            # Central meridian (180 dgrees)
            self.project_and_draw(math.pi, theta, 1)

            # and a few other lines
            # self.project_and_draw(math.pi * .75, theta, 1)
            # self.project_and_draw(math.pi*1.25, theta, 1)

        # Then prepare to draw the sun in yellow:
        ctx.set_source_rgb(*self.sun_color)

        if self.lunar:
            # When is the moon on the meridian today?
            # Remember, it's self.sun even if it really is the moon.
            self.observer.date = ephem.now()
            # self.observer.date = ephem.Date('6/13/2005')
            transit = self.observer.next_transit(self.sun)

            # For testing, try replacing 30 with, say, 5000 to see the
            # motion of the moon over many years.
            for i in range(0, 30):
                self.draw_sun_position(transit)

                # Also draw lunar analemmas 4 hours earlier and later:
                self.draw_sun_position(ephem.Date(transit - 2.5 * ephem.hour))
                self.draw_sun_position(ephem.Date(transit + 2.5 * ephem.hour))

                # Increment the date.
                # How many minutes earlier does the moon rise each day?
                # Of course it varies because of the eccentricity
                # (and other complications) of the moon's orbit,
github gnuradio / gnuradio / gr-radio-astronomy / src / python / usrp_psr_receiver.py View on Github external
def record_hit(self,hits, hcavg, hcmax):
        # Pick up current LMST
        self.locality.date = ephem.now()
        sidtime = self.locality.sidereal_time()

        # Pick up localtime, for generating filenames
        foo = time.localtime()

        # Generate filenames for both data and header file
        hitfilename = "%04d%02d%02d%02d.phit" % (foo.tm_year, foo.tm_mon,
           foo.tm_mday, foo.tm_hour)

        hitf = open(self.prefix+hitfilename, "a")
        hitf.write("receiver center frequency: "+str(self.frequency)+"\n")
        hitf.write("observing frequency: "+str(self.observing_freq)+"\n")
        hitf.write("DM: "+str(self.dm)+"\n")
        hitf.write("doppler: "+str(self.doppler)+"\n")

        hitf.write("sidereal: "+str(ephem.hours(sidtime))+"\n")
github patchvonbraun / simple_ra / simple_ra_utils.py View on Github external
def cur_sidereal(longitude,val):
    global doephem
    if doephem == False:
        return (("12:00:00","9999999999"))
    longstr = "%02d" % int(longitude)
    longstr = longstr + ":"
    longitude = abs(longitude)
    frac = longitude - int(longitude)
    frac *= 60
    mins = int(frac)
    longstr += "%02d" % mins
    longstr += ":00"
    x = ephem.Observer()
    x.date = ephem.now()
    x.long = longstr
    jdate = ephem.julian_date(x)
    tokens=str(x.sidereal_time()).split(":")
    hours=int(tokens[0])
    minutes=int(tokens[1])
    seconds=int(float(tokens[2]))
    sidt = "%02d:%02d:%02d" % (hours, minutes, seconds)
    return ((sidt,jdate))
github gnuradio / gnuradio / gr-radio-astronomy / src / python / usrp_psr_receiver.py View on Github external
def lmst_timeout(self):
         self.locality.date = ephem.now()
         sidtime = self.locality.sidereal_time()
         self.myform['lmst_high'].set_value(str(ephem.hours(sidtime)))
github HERA-Team / aipy / antennas.py View on Github external
def set_ephemtime(self, t=None):
        """Set the current time to a time drived from the ephem package."""
        if t is None: t = ephem.now()
        self.date = t
    def get_projected_baseline(self, i, j=None, body=None):
github panoptes / POCS / panoptes / observatory.py View on Github external
def is_dark(self, dark_horizon=-12):
        """
        Need to calculate day/night for site
        Initial threshold 12 deg twilight
        self.site.date = datetime.datetime.now()
        """
        self.logger.debug('Calculating is_dark.')
        self.site.date = ephem.now()
        self.sun.compute(self.site)

        self.is_dark = self.sun.alt < dark_horizon
        return self.is_dark
github darkstar007 / GroundStation / src / SatelliteEvent.py View on Github external
def update(self, sat):
        self.pointReceiver(sat.alt, sat.az)
        try:
            self.tuneReceiver(self.dopp_fn(ephem.now()))
        except ValueError, e:
            print 'Value error....'
github HERA-Team / aipy / src / phs.py View on Github external
def set_ephemtime(self, t=None):
        """Set current time as derived from the ephem package.  Recalculates
        matrix for projecting baselines into current positions."""
        if t is None: t = ephem.now()
        self.date, self.epoch = t, t
        self._eq2now = coord.rot_m(-self.sidereal_time(), n.array([0.,0.,1.]))
github gnuradio / gnuradio / gr-radio-astronomy / src / python / usrp_ra_receiver.py View on Github external
inter = self.decln
		integ = self.integ
		fc = self.observing
		fc = fc / 1000000
		bw = self.bw
		bw = bw / 1000000
		ga = self.gain
	
		now = time.time()
	
		#
		# If time to write full header info (saves storage this way)
		#
		if (now - self.continuum_then > 20):
			self.sun.compute(self.locality)
			enow = ephem.now()
			sunset = self.locality.next_setting(self.sun)
			sunrise = self.locality.next_rising(self.sun)
			sun_insky = "Down"
			self.sunstate = "Dn"
			if ((sunrise < enow) and (enow < sunset)):
			   sun_insky = "Up"
			   self.sunstate = "Up"
			self.continuum_then = now
		
			continuum_file.write(str(ephem.hours(sidtime))+" "+flt+" Dn="+str(inter)+",")
			continuum_file.write("Ti="+str(integ)+",Fc="+str(fc)+",Bw="+str(bw))
			continuum_file.write(",Ga="+str(ga)+",Sun="+str(sun_insky)+"\n")
		else:
			continuum_file.write(str(ephem.hours(sidtime))+" "+flt+"\n")
	
		continuum_file.close()