Ejemplo n.º 1
0
 def __init__(self, lat, lon, utc=None):
     if utc is None:
         utc = a.now().utc_datetime()
     if isinstance(utc, str):
         utc = datetime.strptime(utc, "%Y-%m-%dT%H:%M:%S.%f%z")
     self.utc = utc
     self.t = a.ts.utc(utc)
     self.lat = float(lat)
     self.lon = float(lon)
     self.finder = TimezoneFinder()
     self.tzName = ''  # Compute the name on demand.
Ejemplo n.º 2
0
 def __init__(self, latitude, longitude, altitude=0, dt=None):
     logging.debug('DayCalc ctor: %s, %s, %s, %s', latitude, longitude,
                   altitude, dt)
     logging.debug('%s, %s, %s, %s', type(latitude), type(longitude),
                   type(altitude), type(dt))
     self.topo = a.api.Topos(latitude, longitude, elevation_m=altitude)
     self.loc = a.earth + self.topo
     if dt is None:
         self.DATE = a.time_to_local_datetime(a.now(), self.loc)
     else:
         self.DATE = dt  # Local time, with time offset
     self.LAT = latitude
     self.LON = longitude
     self.ALT = altitude
     self.init_data()
Ejemplo n.º 3
0
        if not self.RDY:
            self.calc_all()
        fixed_format = '{0}  {1:8s}  {2:8s}  {3:8s}  {4:8s}  {5:8s}  {6:7.2f}  {7:8s}  {8:8s}  {9:8s}  {10:8s}  {11:5.1f}  {12:8s}  {13:8s} {14:8.1f}  {15:8s}'
        tabbed_format = '{0}\t{1:s}\t{2:s}\t{3:s}\t{4:s}\t{5:s}\t{6:7.2f}\t{7:s}\t{8:s}\t{9:s}\t{10:s}\t{11:5.1f}\t{12:s}\t{13:s}\t{14:8.1f}\t{15:s}'
        fmt = fixed_format if fixed else tabbed_format
        print(
            fmt.format(
                self.DATE.date(),
                '' if self.BMAT is None else self.BMAT.strftime('%H:%M:%S'),
                '' if self.BMNT is None else self.BMNT.strftime('%H:%M:%S'),
                '' if self.BMCT is None else self.BMCT.strftime('%H:%M:%S'),
                '' if self.SRISE is None else self.SRISE.strftime('%H:%M:%S'),
                '' if self.SCUL is None else self.SCUL.strftime('%H:%M:%S'),
                0.0 if self.SCALT is None else round(self.SCALT, 2),
                '' if self.SSET is None else self.SSET.strftime('%H:%M:%S'),
                '' if self.EECT is None else self.EECT.strftime('%H:%M:%S'),
                '' if self.EENT is None else self.EENT.strftime('%H:%M:%S'),
                '' if self.EEAT is None else self.EEAT.strftime('%H:%M:%S'),
                0.0 if self.LPHA is None else round(self.LPHA, 1),
                '' if self.MRISE is None else self.MRISE.strftime('%H:%M:%S'),
                '' if self.LCUL is None else self.LCUL.strftime('%H:%M:%S'),
                0.0 if self.LCALT is None else round(self.LCALT, 2),
                '' if self.MSET is None else self.MSET.strftime('%H:%M:%S')))


if '__main__' == __name__:
    lat, lon = a.lat_lon_from_observer(a.home_loc)
    t = a.time_to_local_datetime(a.now(), a.home_loc)
    tester = DayCalc(lat, lon, a.home_topo.elevation.m, t)
    tester.print_report()
Ejemplo n.º 4
0
#!/usr/bin/env python3

import sys
sys.path.append('../')
import astro as a

j = a.whats_up(a.home_loc, a.now())
print(j)
Ejemplo n.º 5
0
            radec = pos.radec(a.ts.J2000)
            line = '{0:10s} {1:15s} {2:15s}  '.format(nameFromIndex(pIndex),
                                                      str(radec[0]),
                                                      str(radec[1]))
            for p2 in range(pSun, pPluto):
                if pIndex == p2:
                    line += ' ' * 10
                else:
                    line += table.get_separation(pIndex, p2)
            print(line)
        print()

    count, text = table.find_conjunctions(MAX_SEP)
    if 0 < count:
        if PRINT_TABLES:
            print('Conjunctions:')
        print(text)
    return count


if '__main__' == __name__:
    x = DAYS_TO_CALC  # How many days to calculate
    dt = a.now().utc_datetime()
    conj_count = 0
    for d in range(x):
        for h in range(24):
            t = a.ts.utc(dt.year, dt.month, dt.day + d, dt.hour + h, 0, 0)
            conj_count += calculate_all(t)
    if 0 < conj_count:
        print('Total conjunctions:   {0}'.format(conj_count))
Ejemplo n.º 6
0
#!/usr/bin/env python3

import sys, socket, json
sys.path.append('../')
import astro as a


HOST = '127.0.0.1'  # The server's hostname or IP address
PORT = 9999         # The port used by the server

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    s.sendall(b'gps')
    data = s.recv(1024)
str = data.decode('utf-8')
gps = json.loads(str)

t = a.now()
loc = a.loc_from_data(gps['lat'], gps['lon'], gps['alt'])

a.print_planets(loc, False, t)