def show(self, y, m, d, t, cnt):
		proftype = chart.Chart.YEAR
		if self.zodprofs:
			prof = profections.Profections(self.chart, y, m, d, t, cnt)
			pchart = chart.Chart(self.chart.name, self.chart.male, self.chart.time, self.chart.place, chart.Chart.PROFECTION, '', self.options, False, proftype)
			pchart.calcProfPos(prof)
		else:
			if not self.usezodprojs and (y+cnt == self.chart.time.year or (y+cnt-self.chart.time.year) % 12 == 0) and m == self.chart.time.month and d == self.chart.time.day:
				pchart = self.chart
			else:
				prof = munprofections.MunProfections(self.chart, y, m, d, t, cnt)
				proflondeg, proflonmin, proflonsec = util.decToDeg(prof.lonZ)
				profplace = chart.Place(mtexts.txts['Profections'], proflondeg, proflonmin, proflonsec, prof.east, self.chart.place.deglat, self.chart.place.minlat, self.chart.place.seclat, self.chart.place.north, self.chart.place.altitude)
				pchart = chart.Chart(self.chart.name, self.chart.male, self.chart.time, profplace, chart.Chart.PROFECTION, '', self.options, False, proftype, self.options.usezodprojsprof)
				pchartpls = chart.Chart(self.chart.name, self.chart.male, self.chart.time, self.chart.place, chart.Chart.PROFECTION, '', self.options, False, proftype, self.options.usezodprojsprof)
				#modify planets, ...
				pchart.planets.calcMundaneProfPos(pchart.houses.ascmc2, pchartpls.planets.planets, self.chart.place.lat, self.chart.obl[0])

				#modify lof
				pchart.fortune.calcMundaneProfPos(pchart.houses.ascmc2, pchartpls.fortune, self.chart.place.lat, self.chart.obl[0])

				#recalc AspMatrix
				pchart.calcAspMatrix()

		self.parent.change(pchart, self.caption, y+cnt, m, d, t)
		self.yeartxt.SetValue(str(y+cnt))
		self.monthtxt.SetValue(str(m))
		if self.zodprofs or self.usezodprojs:
			self.daytxt.SetValue(str(d))
Ejemplo n.º 2
0
    def _create_chart(self, data):
        chart = charts.Chart(charts.HORIZONTAL_BAR)
        colors = profile.get_color()
        logging.debug(colors)
        chart_color = colors.get_fill_color()
        logging.debug(chart_color)
        chart_line_color = colors.get_stroke_color()
        logging.debug(chart_line_color)

        eventbox = Gtk.EventBox()
        charts_area = ChartArea(chart)
        eventbox.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('white'))
        eventbox.add(charts_area)
        eventbox.show()
        self._vbox.pack_end(eventbox, True, True, 0)

        chart_data = []
        i = 0
        for entry in data:
            label = entry[0]
            value = len(entry[1])
            chart_data.append((label, float(value)))
            i += 1
            if i > 15:
                break
        chart.data_set(chart_data)
        chart.width = Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE
        chart.height = Gdk.Screen.height() - 2 * style.GRID_CELL_SIZE
        chart.set_color_scheme(color=chart_color)
        chart.set_line_color(chart_line_color)
        chart.render()
        charts_area.queue_draw()
        self.show_all()
Ejemplo n.º 3
0
    def __init__(self, parent):
        Gtk.Box.__init__(self, False, 0)
        self.parent = parent

        try:
            current_locale, encoding = locale.getdefaultlocale()
            locale_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
            translate = gettext.translation (cn.App.application_shortname, locale_path, [current_locale] )
            _ = translate.gettext
        except FileNotFoundError:
            _ = str

        chart = ch.Chart()
        self.function = fn.Function()
        algo = al.Algorithm()
        self.algo_parameters = apm.AlgorithmParameters(self.function, algo, chart)
        self.func_parameters = fpm.FunctionParameters(self.function, algo, chart)
        self.result = rsl.Result(self.function, algo)
        hpaned = Gtk.Paned()
        hpaned.set_position(800)
        hpaned.add1(chart.sw)

        vbox = Gtk.VBox()
        vbox.add(self.algo_parameters.frame)
        vbox.add(self.func_parameters.frame)
        vbox.add(self.result.frame)



        hpaned.add2(vbox)

        self.pack_start(hpaned, True, True, 0)
Ejemplo n.º 4
0
def main():
    # Get arguments
    args = parser.parse_args()

    # Show the usage of the command if no options were used (we can imagine that the user doesn't know how to use it).
    if args.database == 'got' and args.root == '' and args.animationtime == 1:
        print(parser.print_help())

    # Load the main database we are going to use to create the graph
    db_name = args.database
    edges_db = None
    if db_name == 'got':
        edges_db = db.Database('got_edges')
    elif db_name == 'trump':
        edges_db = db.Database('trump_edges')
    elif db_name == 'marvel':
        edges_db = db.Database('marvel_edges')
    else:
        edges_db = db.Database(db_name + '_edges')

    # Create the graph
    g = create_graph(edges_db)

    # The root is the starting point of the spread
    # if None, get a random starting point
    root = args.root
    if root == '':
        root = g.vertices()[random.randint(0, len(g.vertices()) - 1)]

    # Chart to plot spread numbers
    chart_instance = chart.Chart()

    # Start the GUI process to render the spread
    gui.show_graph(g, breadth_first_search_step_by_step, root,
                   abs(args.animationtime), chart_instance, args.lockdown)
Ejemplo n.º 5
0
    def __create_chart(self):
        self.sky_panel = wx.Panel(self)
        sky_sizer = wx.BoxSizer(wx.VERTICAL)

        # control bar
        ctrl_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.chart_crdsys = wx.ComboBox(
            self.sky_panel,
            wx.ID_ANY,
            choices=[
                "Horizontal (Azimuth, Altitude)",
                "Equatorial (Right Asc, Declination)"
            ],
            style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.chart_crdsys.SetSelection(0)
        ctrl_sizer.Add(self.chart_crdsys, 1, wx.EXPAND)

        # create field of view display
        fov_label = wx.StaticText(self.sky_panel, label="   Field of View: ")
        ctrl_sizer.Add(fov_label)
        self.chart_fov = wx.SpinCtrl(self.sky_panel,
                                     value="100",
                                     min=1,
                                     max=340)
        ctrl_sizer.Add(self.chart_fov)

        # create OpenGL canvas
        self.sky_chart = chart.Chart(self.sky_panel, self.chart_fov,
                                     self.converter, self.planets)
        sky_sizer.Add(self.sky_chart, 1, wx.EXPAND)
        sky_sizer.Add(ctrl_sizer, 0, wx.EXPAND)

        self.sky_panel.SetSizer(sky_sizer)
        return self.sky_panel
Ejemplo n.º 6
0
def calculateDailyChart(chrt, year, month, day, hour):
    day_time = chart.event.DateTime(year, month, day, hour, 0, 0, chrt.time.bc,
                                    chrt.time.cal, chrt.time.zt,
                                    chrt.time.plus, chrt.time.zh, chrt.time.zm,
                                    chrt.time.daylightsaving, chrt.place)
    return chart.Chart(chrt.name, chrt.male, day_time, chrt.place, chrt.htype,
                       chrt.notes, chrt.options)
Ejemplo n.º 7
0
	def onCalc(self, evt):
		#create chart with currdatetime
		time = chart.Time(int(self.year.GetValue()), int(self.month.GetValue()), int(self.day.GetValue()), int(self.hour.GetValue()), int(self.minute.GetValue()), int(self.sec.GetValue()), self.chart.time.bc, self.chart.time.cal, self.chart.time.zt, self.chart.time.plus, self.chart.time.zh, self.chart.time.zm, self.chart.time.daylightsaving, self.chart.place)

		self.horoscope = chart.Chart(self.chart.name, self.chart.male, time, self.chart.place, self.chart.htype, self.chart.notes, self.chart.options)

		#calcpds
		keytxt = ''
		if self.chart.options.pdkeydyn:
			keytxt = mtexts.typeListDyn[self.chart.options.pdkeyd]
		else:
			keytxt = mtexts.typeListStat[self.chart.options.pdkeys]

		txt = mtexts.typeListDirs[self.chart.options.primarydir]+'; '+keytxt+'\n'+mtexts.txts['BusyInfo']

		self.progbar = wx.ProgressDialog(mtexts.txts['Calculating'], txt, parent=self, style=wx.PD_CAN_ABORT|wx.PD_APP_MODAL)
		self.progbar.Fit()

		self.pds = None
		self.pdready = False
		self.abort = primdirs.AbortPD()
		thId = thread.start_new_thread(self.calcPDs, (self.pdrange, self.direction, self))

		self.timer = wx.Timer(self)
		self.Bind(wx.EVT_TIMER, self.OnTimer)
		self.timer.Start(500)
Ejemplo n.º 8
0
 def add_chart(self):
     """Add a chart to the application."""
     _row = len(self.charts)
     new_chart = chart_.Chart(self.chart_frame, self.running)
     new_chart.grid(row=_row, column=0, sticky=tk.NSEW)
     self.charts.append(new_chart)
     pubsub.publish('focus', new_chart)
     self.focus_chart = new_chart
     # allow charts to expand vertically
     # (horizontal expansion has already been set)
     self.chart_frame.rowconfigure(_row, weight=3)
     return new_chart
Ejemplo n.º 9
0
 def show(self, y, m, d, h, mi, s):
     time = chart.Time(y, m, d, h, mi, s, self.chart.time.bc,
                       self.chart.time.cal, self.chart.time.zt,
                       self.chart.time.plus, self.chart.time.zh,
                       self.chart.time.zm, self.chart.time.daylightsaving,
                       self.chart.place, False)
     chrt = chart.Chart(self.chart.name, self.chart.male, time,
                        self.chart.place, chart.Chart.TRANSIT, '',
                        self.options, False)
     self.parent.change(chrt, self.caption)
     del self.chart
     self.chart = chrt
Ejemplo n.º 10
0
	def show(self, age):
		wait = wx.BusyCursor()
		y = self.chart.time.year#+age
		m = self.chart.time.month
		d = self.chart.time.day
		t = self.chart.time.time

		if self.feb29:
			d -= 1

		self.agetxt.SetValue(str(age))

		pcharts = []

		cyc = 0
		while(cyc < 12):
			if self.zodiacalprofs:
				prof = profections.Profections(self.chart, y, m, d, t, age+cyc)
				pchart = chart.Chart(self.chart.name, self.chart.male, self.chart.time, self.chart.place, chart.Chart.PROFECTION, '', self.options, False, self.proftype)
				pchart.calcProfPos(prof)
			else:
				if not self.usezodprojs and (y+age+cyc == self.chart.time.year or (y+age+cyc-self.chart.time.year) % 12 == 0) and m == self.chart.time.month and d == self.chart.time.day:
					pchart = self.chart
				else:
					prof = munprofections.MunProfections(self.chart, y+age+cyc, m, d, t)
					proflondeg, proflonmin, proflonsec = util.decToDeg(prof.lonZ)
					profplace = chart.Place(mtexts.txts['Profections'], proflondeg, proflonmin, proflonsec, prof.east, self.chart.place.deglat, self.chart.place.minlat, self.chart.place.seclat, self.chart.place.north, self.chart.place.altitude)
					pchart = chart.Chart(self.chart.name, self.chart.male, self.chart.time, profplace, chart.Chart.PROFECTION, '', self.options, False, self.proftype, self.options.usezodprojsprof)
					pchartpls = chart.Chart(self.chart.name, self.chart.male, self.chart.time, self.chart.place, chart.Chart.PROFECTION, '', self.options, False, self.proftype, self.options.usezodprojsprof)
					#modify planets, ...
					pchart.planets.calcMundaneProfPos(pchart.houses.ascmc2, pchartpls.planets.planets, self.chart.place.lat, self.chart.obl[0])
	
					#modify lof
					pchart.fortune.calcMundaneProfPos(pchart.houses.ascmc2, pchartpls.fortune, self.chart.place.lat, self.chart.obl[0])
	
			pcharts.append((pchart, y+age+cyc, m, d, t))
			cyc += 1

		self.parent.change(age, pcharts, self.options)
Ejemplo n.º 11
0
    def _add_chart_cb(self, widget, type=charts.VERTICAL_BAR):
        self.current_chart = charts.Chart(type)

        def update_btn():
            if (type == charts.PIE and
                    not self.chart_type_buttons[3].get_active() and
                    not self.chart_type_buttons[7].get_active()):
                self.chart_type_buttons[3].set_active(True)
                self.chart_type_buttons[7].set_active(True)

        GObject.idle_add(update_btn)

        self.update_chart()
Ejemplo n.º 12
0
	def onDecr(self, event):
		self.age -= 1
		self.daytxt.SetValue(str(self.age))
		direct = True
		age = self.age
		if self.age < 0:
			age *= -1
			direct = False
		sdir = secdir.SecDir(self.chart, age, direct, self.soltime)
		y, m, d, hour, minute, second = sdir.compute()

		time = chart.Time(y, m, d, hour, minute, second, False, self.chart.time.cal, self.zt, self.chart.time.plus, self.zh, self.zm, False, self.chart.place, False)
		chrt = chart.Chart(self.chart.name, self.chart.male, time, self.chart.place, chart.Chart.TRANSIT, '', self.options, False)
		self.parent.change(chrt, self.caption)
def main():
    bal = balance.Balance("balance.csv")
    cht = chart.Chart("chart.csv", bal)
    mty = Ministry(cht)
    unused = mty.unused_accounts()

    from pprint import pprint

    def names(numbers):
        return [cht.account(num).name() for num in numbers]

    display = {}
    for key in unused:
        display[key] = names(unused[key])
    pprint(display)
Ejemplo n.º 14
0
    def change(self, chrt, y, m, d, ho, mi, se, pdtypetxt, pdkeytxt, txtdir,
               da):
        self.chartPDs = chrt
        self.w.chartPDs = chrt

        tim = chart.Time(y, m, d, ho, mi, se, self.chartRadix.time.bc,
                         chart.Time.GREGORIAN, chart.Time.GREENWICH, True, 0,
                         0, False, self.chartRadix.place, False)
        chrtIng = chart.Chart(self.chartRadix.name, self.chartRadix.male, tim,
                              self.chartRadix.place, chart.Chart.PDINCHART, '',
                              self.options, False)
        self.chartIngress = chrtIng
        self.w.chartIngress = chrtIng
        self.w.drawBkg()
        self.w.Refresh()

        #Update Caption
        txt = pdtypetxt + ' ' + pdkeytxt + ' ' + txtdir + ' ' + str(
            y) + '.' + str(m).zfill(2) + '.' + str(d).zfill(2) + ' ' + str(
                ho).zfill(2) + ':' + str(mi).zfill(2) + ':' + str(se).zfill(
                    2) + '  ' + str(da)
        self.SetTitle(txt)
Ejemplo n.º 15
0
    def onShowBtn(self, event):
        if (self.Validate() and self.sdate.Validate()):
            if util.checkDate(int(self.year.GetValue()),
                              int(self.month.GetValue()),
                              int(self.day.GetValue())):
                arc = 0.0
                date = 2000.5

                direct = self.positiverb.GetValue()
                if (self.arcrb.GetValue()):
                    arc = float(self.da.GetValue())
                    jd, age = self.calcTime(arc, direct)
                    y, m, d, h = astrology.swe_revjul(jd, 1)
                    ho, mi, se = util.decToDeg(h)
                    self.year.SetValue(str(y))
                    self.month.SetValue(str(m))
                    self.day.SetValue(str(d))

                    self.hour.SetValue(str(ho))
                    self.minute.SetValue(str(mi))
                    self.second.SetValue(str(se))
                else:
                    y = int(self.year.GetValue())
                    m = int(self.month.GetValue())
                    d = int(self.day.GetValue())
                    ho = int(self.hour.GetValue())
                    mi = int(self.minute.GetValue())
                    se = int(self.second.GetValue())
                    t = float(ho) + float(mi) / 60.0 + float(se) / 3600.0
                    calflag = astrology.SE_GREG_CAL
                    if self.chart.time.cal == chart.Time.JULIAN:
                        calflag = astrology.SE_JUL_CAL
                    jd = astrology.swe_julday(y, m, d, t, calflag)
                    if self.chart.time.jd >= jd:
                        dlgm = wx.MessageDialog(
                            None, mtexts.txts['TimeSmallerThanBirthTime'],
                            mtexts.txts['Error'], wx.OK | wx.ICON_EXCLAMATION)
                        dlgm.ShowModal()
                        dlgm.Destroy()
                        return False

                    arc = self.calcArc(jd, direct)
                    self.da.SetValue(str(arc))

                da = arc
                if not direct:
                    da *= -1

                pdinch = pdsinchart.PDsInChart(
                    self.chart, da)  #self.yz, mz, dz, tz ==> chart
                pdh, pdm, pds = util.decToDeg(pdinch.tz)
                cal = chart.Time.GREGORIAN
                if self.chart.time.cal == chart.Time.JULIAN:
                    cal = chart.Time.JULIAN
                tim = chart.Time(pdinch.yz, pdinch.mz, pdinch.dz, pdh, pdm,
                                 pds, self.chart.time.bc, cal,
                                 chart.Time.GREENWICH, True, 0, 0, False,
                                 self.chart.place, False)

                if not self.terrestrial:
                    if self.options.pdincharttyp == pdsinchartdlgopts.PDsInChartsDlgOpts.FROMMUNDANEPOS:
                        pdchart = chart.Chart(self.chart.name, self.chart.male,
                                              tim, self.chart.place,
                                              chart.Chart.PDINCHART, '',
                                              self.options,
                                              False)  #, proftype, nolat)
                        pdchartpls = chart.Chart(self.chart.name,
                                                 self.chart.male,
                                                 self.chart.time,
                                                 self.chart.place,
                                                 chart.Chart.PDINCHART, '',
                                                 self.options, False)

                        #modify planets ...
                        if self.options.primarydir == primdirs.PrimDirs.PLACIDIANSEMIARC or self.options.primarydir == primdirs.PrimDirs.PLACIDIANUNDERTHEPOLE:
                            pdchart.planets.calcMundaneProfPos(
                                pdchart.houses.ascmc2,
                                pdchartpls.planets.planets,
                                self.chart.place.lat, self.chart.obl[0])
                        else:
                            pdchart.houses = houses.Houses(
                                tim.jd, 0, pdchart.place.lat,
                                pdchart.place.lon, 'R', pdchart.obl[0],
                                self.options.ayanamsha, pdchart.ayanamsha)
                            pdchart.planets.calcRegioPDsInChartsPos(
                                pdchart.houses.ascmc2,
                                pdchartpls.planets.planets,
                                self.chart.place.lat, self.chart.obl[0])

                        #modify lof
                        if self.options.primarydir == primdirs.PrimDirs.PLACIDIANSEMIARC or self.options.primarydir == primdirs.PrimDirs.PLACIDIANUNDERTHEPOLE:
                            pdchart.fortune.calcMundaneProfPos(
                                pdchart.houses.ascmc2, pdchartpls.fortune,
                                self.chart.place.lat, self.chart.obl[0])
                        else:
                            pdchart.fortune.calcRegioPDsInChartsPos(
                                pdchart.houses.ascmc2, pdchartpls.fortune,
                                self.chart.place.lat, self.chart.obl[0])

                    elif self.options.pdincharttyp == pdsinchartdlgopts.PDsInChartsDlgOpts.FROMZODIACALPOS:
                        pdchart = chart.Chart(self.chart.name, self.chart.male,
                                              tim, self.chart.place,
                                              chart.Chart.PDINCHART, '',
                                              self.options, False,
                                              chart.Chart.YEAR, True)

                        pdchartpls = chart.Chart(
                            self.chart.name, self.chart.male, self.chart.time,
                            self.chart.place, chart.Chart.PDINCHART, '',
                            self.options, False, chart.Chart.YEAR, True)
                        #modify planets ...
                        if self.options.primarydir == primdirs.PrimDirs.PLACIDIANSEMIARC or self.options.primarydir == primdirs.PrimDirs.PLACIDIANUNDERTHEPOLE:
                            pdchart.planets.calcMundaneProfPos(
                                pdchart.houses.ascmc2,
                                pdchartpls.planets.planets,
                                self.chart.place.lat, self.chart.obl[0])
                        else:
                            pdchart.houses = houses.Houses(
                                tim.jd, 0, pdchart.place.lat,
                                pdchart.place.lon, 'R', pdchart.obl[0],
                                self.options.ayanamsha, pdchart.ayanamsha)
                            pdchart.planets.calcRegioPDsInChartsPos(
                                pdchart.houses.ascmc2,
                                pdchartpls.planets.planets,
                                self.chart.place.lat, self.chart.obl[0])

                        #modify lof
                        if self.options.primarydir == primdirs.PrimDirs.PLACIDIANSEMIARC or self.options.primarydir == primdirs.PrimDirs.PLACIDIANUNDERTHEPOLE:
                            pdchart.fortune.calcMundaneProfPos(
                                pdchart.houses.ascmc2, pdchartpls.fortune,
                                self.chart.place.lat, self.chart.obl[0])
                        else:
                            pdchart.fortune.calcRegioPDsInChartsPos(
                                pdchart.houses.ascmc2, pdchartpls.fortune,
                                self.chart.place.lat, self.chart.obl[0])

                    else:  #Full Astronomical Procedure
                        pdchart = chart.Chart(self.chart.name, self.chart.male,
                                              tim, self.chart.place,
                                              chart.Chart.PDINCHART, '',
                                              self.options,
                                              False)  #, proftype, nolat)

                        pdchartpls = chart.Chart(self.chart.name,
                                                 self.chart.male,
                                                 self.chart.time,
                                                 self.chart.place,
                                                 chart.Chart.PDINCHART, '',
                                                 self.options, False)

                        pdpls = pdchartpls.planets.planets
                        if self.options.pdinchartsecmotion:
                            pdpls = pdchart.planets.planets

                        raequasc, declequasc, dist = astrology.swe_cotrans(
                            pdchart.houses.ascmc[houses.Houses.EQUASC], 0.0,
                            1.0, -self.chart.obl[0])
                        pdchart.planets.calcFullAstronomicalProc(
                            da, self.chart.obl[0], pdpls, pdchart.place.lat,
                            pdchart.houses.ascmc2, raequasc)  #planets
                        pdchart.fortune.calcFullAstronomicalProc(
                            pdchartpls.fortune, da, self.chart.obl[0])
                else:
                    if self.options.pdinchartterrsecmotion:
                        pdchart = chart.Chart(self.chart.name, self.chart.male,
                                              tim, self.chart.place,
                                              chart.Chart.PDINCHART, '',
                                              self.options,
                                              False)  #, proftype, nolat)
                    else:
                        pdchart = chart.Chart(self.chart.name, self.chart.male,
                                              self.chart.time,
                                              self.chart.place,
                                              chart.Chart.PDINCHART, '',
                                              self.options,
                                              False)  #, proftype, nolat)
                        raequasc, declequasc, dist = astrology.swe_cotrans(
                            pdchart.houses.ascmc[houses.Houses.EQUASC], 0.0,
                            1.0, -self.chart.obl[0])
                        pdchart.planets.calcMundaneWithoutSM(
                            da, self.chart.obl[0], pdchart.place.lat,
                            pdchart.houses.ascmc2, raequasc)

                    pdchart.fortune.recalcForMundaneChart(
                        self.chart.fortune.fortune[fortune.Fortune.LON],
                        self.chart.fortune.fortune[fortune.Fortune.LAT],
                        self.chart.fortune.fortune[fortune.Fortune.RA],
                        self.chart.fortune.fortune[fortune.Fortune.DECL],
                        pdchart.houses.ascmc2, pdchart.raequasc,
                        pdchart.obl[0], pdchart.place.lat)

                keytxt = mtexts.typeListDyn[self.options.pdkeyd]
                if not self.options.pdkeydyn:
                    keytxt = mtexts.typeListStat[self.options.pdkeys]
                txtdir = mtexts.txts['D']
                if not direct:
                    txtdir = mtexts.txts['C']

                self.parent.change(
                    pdchart, y, m, d, ho, mi, se,
                    mtexts.typeListDirs[self.options.primarydir], keytxt,
                    txtdir, math.fabs(da))
            else:
                dlgm = wx.MessageDialog(
                    None, mtexts.txts['InvalidDate'] + ' (' +
                    self.year.GetValue() + '.' + self.month.GetValue() + '.' +
                    self.day.GetValue() + '.)', mtexts.txts['Error'],
                    wx.OK | wx.ICON_EXCLAMATION)
                dlgm.ShowModal()
                dlgm.Destroy()
Ejemplo n.º 16
0
def calculateNearestEclipse(ecplanet,
                            chrt,
                            year,
                            month,
                            day,
                            hour,
                            minute=0,
                            second=0):
    out = []
    time = hour + minute / 60.0 + second / 3600.0
    tjd = swisseph.julday(year, month, day, time, astrology.SE_GREG_CAL)

    # Calculate the global eclipse nearest to the specified date
    if ecplanet == 'sun':
        retflag = swisseph.sol_eclipse_when_glob(
            tjd, astrology.SEFLG_SWIEPH, astrology.SE_ECL_ALLTYPES_SOLAR, True)
        planet_id = astrology.SE_SUN
    elif ecplanet == 'moon':
        retflag = swisseph.lun_eclipse_when(tjd, astrology.SEFLG_SWIEPH,
                                            astrology.SE_ECL_ALLTYPES_LUNAR,
                                            True)
        planet_id = astrology.SE_MOON
    else:
        print('No valid eclipse ecplanet input at calculateNearestEclipse\n')
        exit(1)

    # Get date and eclipse type
    ejd = retflag[1][0]
    eclflag = retflag[0][0]
    # Convert julian to gregorian date
    eyear, emonth, eday, ejtime = swisseph.revjul(ejd, astrology.SE_GREG_CAL)
    ehour, eminute, esecond = util.decToDeg(ejtime)

    if (eclflag & astrology.SE_ECL_TOTAL):
        ecltype = 'total'
    elif (eclflag & astrology.SE_ECL_ANNULAR):
        ecltype = 'annular'
    elif (eclflag & astrology.SE_ECL_ANNULAR_TOTAL):
        ecltype = 'anntotal'
    elif (eclflag & astrology.SE_ECL_PARTIAL):
        ecltype = 'partial'
    elif (eclflag & astrology.SE_ECL_PENUMBRAL):
        ecltype = 'penumbral'
    else:
        ecltype = ''

    ecldate = 'GMT: %s - %s - %d-%d-%d %d:%d:%d' % (
        ecplanet, ecltype, eyear, emonth, eday, ehour, eminute, esecond)

    # Calculate the sun position for GMT
    if eclipses_cache.has_key(ecldate):
        lon = eclipses_cache[ecldate]
    else:
        day_time = chart.event.DateTime(eyear, emonth, eday, ehour, eminute,
                                        esecond, False, 0, 0, False, 0, 0, 0,
                                        chrt.place)
        day_chart = chart.Chart(chrt.name, chrt.male, day_time, chrt.place,
                                chrt.htype, chrt.notes, chrt.options)
        lon = day_chart.planets.planets[planet_id].data[planets.Planet.LONG]
        eclipses_cache[ecldate] = lon

    # add to out buffer
    out.append("%.2f\t%s\t" % (lon, ecltype))
    # send out
    sys.stdout.write(''.join(out))
Ejemplo n.º 17
0
    def _add_chart_cb(self, widget, type=charts.VERTICAL_BAR):
        self.current_chart = charts.Chart(type)

        self.update_chart()
Ejemplo n.º 18
0
        lat = asteroid.data[planets.Planet.LAT]
        speed = asteroid.data[planets.Planet.SPLON]
        decl = asteroid.dataEqu[planets.Planet.DECLEQU]
        out.append("%.2f\t%.2f\t%.3f\t%.2f\t" % (lon, lat, decl, speed))

    sys.stdout.write(''.join(out))


opts = options.Options()
swisseph.set_ephe_path('../SWEP/Ephem')
# instance of place, time and chart generation
# Based on Greenwich place and UTC time.
place = chart.Place(None, 51, 29, 24, True, 0, 0, 0, True, 0)
time = chart.event.DateTime(2020, 8, 20, 0, 0, 0, False, 0, 0, True, 0, 0,
                            False, place)
chrt = chart.Chart("Daily Chart", False, time, place, 0, "", opts)

print("Date\tHour\t" \
    "SULON\tSULAT\tSUDEC\tSUSP\t" \
    "MOLON\tMOLAT\tMODEC\tMOSP\t" \
    "MELON\tMELAT\tMEDEC\tMESP\t" \
    "VELON\tVELAT\tVEDEC\tVESP\t" \
    "MALON\tMALAT\tMADEC\tMASP\t" \
    "JULON\tJULAT\tJUDEC\tJUSP\t" \
    "SALON\tSALAT\tSADEC\tSASP\t" \
    "URLON\tURLAT\tURDEC\tURSP\t" \
    "NELON\tNELAT\tNEDEC\tNESP\t" \
    "PLLON\tPLLAT\tPLDEC\tPLSP\t" \
    "NNLON\tNNLAT\tNNDEC\tNNSP\t" \
    "SNLON\tSNLAT\tSNDEC\tSNSP\t" \
    "CELON\tCELAT\tCEDEC\tCESP\t" \
Ejemplo n.º 19
0
def genfigs(symbols,
            days=165,
            start=None,
            end=None,
            verbose=0,
            sma_sizes=chart.DEFAULT_SMA_PERIODS,
            macd_sizes=chart.DEFAULT_MACD_PERIODS,
            folder='figs',
            color_scheme='default',
            image_format='png',
            figsize=(8.89, 5.0),
            dpi=144,
            open_preview=False,
            force_net=False):
    # Get the latest data
    if symbols == '^OLD':
        stock = data.file(None,
                          start=start,
                          end=end,
                          days=days,
                          verbose=verbose)
        symbols = list(stock.columns.levels[1])
    elif force_net is False:
        stock = data.file(symbols,
                          start=start,
                          end=end,
                          days=days,
                          verbose=verbose)
    else:
        # Total data length to retrieve to have complete valid SMA
        L = int(days + max(sma_sizes))
        if verbose:
            print('Retrieving data for {} for L = {} ...'.format(symbols, L))
        stock = data.net(symbols, start=start, end=end, days=L)

    # Shorten the chart if there is no data available
    if days > len(stock):
        if verbose:
            print('days = {} -> {}'.format(days, len(stock)))
        days = len(stock)

    # Show parts of the data if we are in verbose mode
    if verbose:
        print('symbols = {} ({})   start = {}   end = {}   days = {}'.format(
            symbols, len(symbols), start, end, days))

    # Get the core count
    batch_size = min(multiprocessing.cpu_count(), len(symbols))

    # Set up the chart
    print('Preparing background (batch size = {}) ...'.format(batch_size))
    views = []
    for _ in range(batch_size):
        view = chart.Chart(n=days,
                           figsize=figsize,
                           dpi=dpi,
                           color_scheme=color_scheme)
        views.append(view)

    # Create the output folder if it doesn't exist
    if not os.path.exists(folder):
        os.makedirs(folder)

    # Go through the symbols
    t1 = time.time()
    procs = []
    command = 'open'
    if len(symbols) > 1:
        symbols = stock.columns.levels[1].tolist()
    for i, symbol in enumerate(symbols):
        if len(symbols) > 1:
            data_frame = data.get_frame(stock, symbol)
        else:
            data_frame = stock
        if verbose > 1:
            print(data_frame)
        # Derive the filename
        filename = '{}/{}.{}'.format(folder, symbol, image_format)
        oc = data_frame.loc[:, (['open', 'close'])].values[-1]
        if oc[1] - oc[0] > 0:
            color = '\033[38;5;46m'
        else:
            color = '\033[38;5;196m'
        print('{}{}\033[0m -> \033[38;5;206m{}\033[0m'.format(
            color, symbol.rjust(5), filename))
        # Update data and save an image
        proc = multiprocessing.Process(target=savefig,
                                       args=(views[i % batch_size], data_frame,
                                             filename))
        procs.append(proc)
        proc.start()
        # Wait for all of them to finish
        if len(procs) == batch_size:
            for proc in procs:
                proc.join()
            procs = []
        command += ' ' + filename

    # Finish whatever that is left in the queue
    if len(procs) > 0:
        for proc in procs:
            proc.join()

    t0 = time.time()

    if verbose > 1:
        print('Elapsed time: {0:.3f} s'.format(t0 - t1))

    if open_preview:
        os.system(command)
Ejemplo n.º 20
0
idx = lat.find(u'N')  #
if idx == -1:
    idx = lat.find(u'S')  #
    north = False

if idx == -1:
    print("Invalid lat string provided")
    sys.exit()
else:
    latdeg = int(lat[0:idx])
    idx += 1
    latmin = int(lat[idx:])

# place, time and chart generation
place = chart.Place('Place Name', deglon, degmin, 0, east, latdeg, latmin, 0,
                    north, altitude)
year, month, day, hour, minute, second = dt.tm_year, dt.tm_mon, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec
#place.tz
tzh, tzm, tzs = util.decToDeg(float(tz))
if tz[0] == '-':
    tzplus = False
else:
    tzplus = True

time = chart.event.DateTime(year, month, day, hour, minute, second, False,
                            astrology.SE_JUL_CAL, chart.event.DateTime.ZONE,
                            tzplus, tzh, tzm, False, place)
chrt = chart.Chart(chart_name, False, time, place, opts.hsys, 'notes', opts)
# Print chart positions
print(printPlanetsData(chrt))
Ejemplo n.º 21
0
    "JULON\tJULAT\tJUDEC\tJUSP\t" \
    "SALON\tSALAT\tSADEC\tSASP\t" \
    "URLON\tURLAT\tURDEC\tURSP\t" \
    "NELON\tNELAT\tNEDEC\tNESP\t" \
    "PLLON\tPLLAT\tPLDEC\tPLSP\t" \
    "NNLON\tNNLAT\tNNDEC\tNNSP\t" \
    "SNLON\tSNLAT\tSNDEC\tSNSP\t" \
    "ASLON\tASLAT\tASDEC\tASSP\t" \
    "MCLON\tMCLAT\tMCDEC\tMCSP\t"

with open('Hors/birthdates.csv', 'rb') as f:
    reader = csv.DictReader(f, delimiter='\t', quoting=csv.QUOTE_NONE)
    for row in reader:
        # Need to import for each iteration or it brokes
        import time
        dt = time.strptime(row['Date'], '%Y-%m-%d %H:%M:%S')
        # place, time and chart generation
        ny_place = chart.Place('New York', 74, 0, 21, False, 40, 42, 51, True,
                               10)
        year, month, day, hour, minute, second = dt.tm_year, dt.tm_mon, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec
        zone_hour, zone_minute, zone_second = util.decToDeg(float(row['ZH']))
        symbol = row['Symbol']
        time = chart.event.DateTime(year, month, day, hour, minute, second,
                                    False, astrology.SE_JUL_CAL,
                                    chart.event.DateTime.ZONE, False,
                                    zone_hour, 0, False, ny_place)
        chrt = chart.Chart(symbol, False, time, ny_place, opts.hsys, 'notes',
                           opts)
        # Print chart positions
        printPlanetsData(chrt)
Ejemplo n.º 22
0
# Data length to ensure proper SMA calculation
L = K + max(sma_sizes)

# Get offline data
quotes = data.file()

# Method 0 or 1: 0 - recreate the chart everytime; 1 - update only the data portion
delta = [0, 0]
for method in [0, 1]:

    print('\033[38;5;190mMethod {}\033[0m:'.format(method))

    # Set up the chart in method 1
    if method is 1:
        view = chart.Chart(n=K)

    # Make sure we get enough data so that all SMA curves are valid
    sss = quotes.iloc[-L:]

    t1 = time.time()

    # Go through the symbols
    for symbol in sss.columns.levels[1].tolist():
        ss = data.get_frame(sss, symbol)
        if method is 0:
            # Recreate the chart everytime in method 0
            view = chart.showChart(ss)
        else:
            view.set_data(ss)
        print('-> \033[38;5;51m{}\033[0m'.format(symbol.rjust(4)))
Ejemplo n.º 23
0
    [
        4.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 2.0, 2.0, 2.0, 4.0, 2.0, 2.0, 2.0,
        2.0, 2.0, 2.0, 2.0, 2.0
    ],
    [
        4.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 2.0, 2.0, 2.0, 4.0, 2.0, 2.0, 2.0,
        2.0, 2.0, 2.0, 2.0, 2.0
    ],
]

# instance of place, time and chart generation
place = chart.Place(place, deglon, minlon, 0, east, deglat, minlat, seclat,
                    north, altitude)
time = chart.event.DateTime(year, month, day, hour, minute, second, bc, cal,
                            zt, plus, zh, zm, daylightsaving, place, False)
chrt = chart.Chart(name, male, time, place, htype, notes, opts, False)

# calculate astrodinas
# chrt.astrodinas()
#chrt.printAspMatrix();
# read places DB to get NY place
#pdb = placedb.PlaceDB()
#pdb.read()
#pdb.searchPlace('New York, USA')
#trans.extraPlace(pdb.search_result)

header = "Date\tHour\tPT\tAS\tPR\tHR\tHT\tSI\tLON\tLAT\tSP\tPRLON\tS\t" \
        "SU\tSUR\tSULO\tSULA\tSUSP\tSUD\tSURD\tSUS\tSUT\t" \
        "MO\tMOR\tMOLO\tMOLA\tMOSP\tMOD\tMORD\tMOS\tMOT\t" \
        "ME\tMER\tMELO\tMELA\tMESP\tMED\tMERD\tMES\tMET\t" \
        "VE\tVER\tVELO\tVELA\tVESP\tVED\tVERD\tVES\tVET\t" \
Ejemplo n.º 24
0
    #robinhood
    transactions = dataStore.get_robinhood_transactions(
        "F:\\Download\\robinhoodhistory")
    stock_dict = analyst.get_stock_dict(transactions)
    dataStore.download_data(
        "I:\workspace\schwab-transactions-processor\Excel\data",
        stock_dict.keys(),
        override=False)
    analyst.create_transaction_json(
        r"I:\workspace\schwab-transactions-processor\Excel\data\robinhood",
        transactions,
        override=True)
    for k in analyst.get_max_profit_map(transactions):
        try:
            print "{}".format(k)
            c = chart.Chart()
            stock = k[0]
            days = dataStore.get_data_from_json(
                "I:\workspace\schwab-transactions-processor\Excel\data", stock,
                700)
            history = dataStore.get_history_from_json(
                r"I:\workspace\schwab-transactions-processor\Excel\data\robinhood",
                stock)
            c.draw_kline(
                days, history,
                r"I:\workspace\schwab-transactions-processor\Excel\charts\robinhood\{}.html"
                .format(stock))
        except Exception:
            traceback.print_exc()
            pass