Example #1
0
    def fly(self, n_trajectories=1):
        """ runs _generate_flight n_trajectories times
        """
        df_list = []
        traj_i = 0
        try:
            if self.verbose:
                print """Starting simulations with {} heat model and {} decision policy.
                If you run out of patience, press <CTL>-C to stop generating simulations and
                cut to the chase scene.""".format(
                self.heat.heat_model_name, self.decision_policy)

            while traj_i < n_trajectories:
                # print updates
                if self.verbose:
                    sys.stdout.write("\rTrajectory {}/{}".format(traj_i + 1, n_trajectories))
                    sys.stdout.flush()

                array_dict = self._generate_flight()

                # if len(array_dict['velocity_x']) < 5:  # hack to catch when optimizer makes trajectories explode
                #     print "catching explosion"
                #     break

                # add label column to enumerate the trajectories
                array_len = len(array_dict['tsi'])
                array_dict['trajectory_num'] = [traj_i] * array_len

                # mk df, add to list of dfs
                df = pd.DataFrame(array_dict)
                # df = df.set_index(['trajectory_num'])
                df_list.append(df)

                traj_i += 1

                if traj_i == n_trajectories:
                    if self.verbose:
                        sys.stdout.write("\rSimulations finished. Performing deep magic.")
                        sys.stdout.flush()

        except KeyboardInterrupt:
            print "\n Simulations interrupted at iteration {}. Moving along...".format(traj_i)
            pass

        observations = Observations()
        observations.kinematics = pd.concat(df_list)  # concatenate all the data frames at once for performance boost.

        return observations
Example #2
0
def pick_directory():
    """allows a user to pick the directory of images on which to work"""
    global folder_selected, annotations_filename, observations
    if DEBUG: print("Pick a Directory of Images")
    user_selected = filedialog.askdirectory()
    if user_selected:
        folder_selected = user_selected
        messagebox.showinfo("Information",
                            "You picked: {}".format(folder_selected))
        annotations_filename = os.path.join(folder_selected, 'annotations.csv')
        # load observations if these exist
        observations = Observations(annotations_filename)
    else:
        info("Information", "You cancelled folder selection")
def processBatch(a_b):
    a, b = a_b
    d = DatastoreClient()
    p = Patient()
    e = Encounter()
    m = Medication()
    o = Observations()
    dr = DiagnosticReport()
    md = MedicationDispense()
    pr = Procedure()

    all_patient = sorted(p.all_patient())

    for i in range(a, b):
        if i >= len(all_patient):
            break
        id = all_patient[i]
        getPatientRecords(d, p, e, m, o, dr, md, pr, id)

    return True
Example #4
0
def mark_function():
    """initates marking operation"""
    global files
    global filename
    global file_pointer
    global observations
    if DEBUG: print("Mark Images")
    try:
        # get files from current directory
        files = get_image_filenames(folder_selected)

        if len(files) == 0:
            warn("Error", "This folder contains no image files")
        else:
            file_pointer = 0
            # get observations!
            observations = Observations(annotations_filename, folder_selected)
            show_file(file_pointer)

    except Exception as e:
        warn("Exception thrown",
             "Invalid folder.  Please select valid folder.")
Example #5
0
IMAGE_WIDTH = 1024
IMAGE_HEIGHT = 768

# note we can import Tkinter widget
from tkinter import filedialog, messagebox, simpledialog

# set a default folder and files
folder_selected = './jeff_empty_model/zebra'
files = []
file_pointer = 0
DEBUG = False

# ANNOTATIONS FOR THE IMAGE DATA are stored in a local CSV file
annotations_filename = os.path.join(folder_selected, 'annotations.csv')
observations = Observations(annotations_filename)
print("Loaded {} observations".format(len(observations.items)))
current_image = None


def keypress_hook(event_data):
    """if a key is pressed in the app, do corresponding function"""
    # it is not state aware yet, I will want to change that later.
    global file_pointer
    keycode = event_data._tk_event.keycode
    GLOB_KEYCODE = keycode
    if DEBUG: print('keypressed:', keycode, '=', event_data.key)
    if keycode == 39:
        # RIGHT arrow
        observations.save()
        file_pointer += 1
Example #6
0
RIGHT_ARROW_OSX = 8189699
LEFT_ARROW = 39
LEFT_ARROW_OSX = 8124162

# note we can import Tkinter widget
from tkinter import filedialog, messagebox, simpledialog

# set a default folder and files
folder_selected = '.'
files = []
file_pointer = 0
DEBUG = False

# ANNOTATIONS FOR THE IMAGE DATA are stored in a local CSV file
annotations_filename = 'annotations.csv'
observations = Observations(annotations_filename, folder_selected)
current_observation_indices = []
print("Loaded {} observations".format(len(observations.items)))
current_image = None


def keypress_hook(event_data):
    """if a key is pressed in the app, do corresponding function"""
    # it is not state aware yet, I will want to change that later.
    global file_pointer
    keycode = event_data._tk_event.keycode
    if DEBUG: print('keypressed:', keycode, '=', event_data.key)
    if keycode == RIGHT_ARROW or keycode == RIGHT_ARROW_OSX:
        # RIGHT arrow
        observations.save()
        file_pointer += 1
Example #7
0
Created on Fri Jun 22 09:27:55 2018

@author: que
"""


import numpy as np
import gym
import random

RANDOM_FILE = "random.obs"

from  observations import Observations


obs = Observations()

obs.loadFromFile(RANDOM_FILE)
scores_per_game = []
num_games = 0
high_score=0




env = gym.make("Breakout-v0")
env.reset()
env.render()
    
    
current_game_score = 0
Example #8
0
        "The program has built in Earth ephemeris for dates 01.01.2018 - 01.01.2021."
    )
    print(
        "Only dates after 31.12.2016 are properly calculated (see: timestamp.py line 42)."
    )

    quit(0)

observations_fname = sys.argv[1]
i = int(sys.argv[2])
j = int(sys.argv[3])
k = int(sys.argv[4])
ijk = (i, j, k)

earthPosition = EarthPosition("earth.csv")
observations = Observations(observations_fname)

icrsposition = IcrsPosition(earthPosition, observations)

phi = icrsposition.phi_angle(ijk)

positions = icrsposition.positions(ijk)

radtodeg = 360 / (2 * np.pi)

i = 0
for p in positions:
    i += 1
    print(f'Solution: {i}:')
    orbitalElements = OrbitalElements(p)
    elem = orbitalElements.elements()
Example #9
0
import curses

import numpy as np
import gym

MANUAL_FILE = "manual.obs"
BALL_UPDATE= 28000  # Update the ball every 28000 cycles

from  observations import Observations


obs = Observations()

obs.loadFromFile(MANUAL_FILE)
scores_per_game = []
num_games = 0
high_score=0



def main(win):
    global num_games
    global scores_per_game
    global high_score
    env = gym.make("Breakout-v0")
    env.reset()
    env.render()
    running = False
    
    current_game_score = 0
    win.nodelay(True)