def __init__(self,
                 px_width,
                 px_heidht,
                 focal_point=None,
                 roi_height=None,
                 source_pts=None,
                 lane_width=3.7,
                 lane_length=24,
                 queue_size=32):
        # initialises common variables in the class
        # focal_point : location of the focal point of the lane. Can be the
        #               vanishing point of the image
        # roi_height : height where the lane region of interest is at most
        #              considered
        # source_pts : bottom start points of the lane roi
        # lane_width : physical measurement spacing between road lines. Default = 3.7m

        if focal_point is None:
            self.focal_point = [0, 0]
        else:
            self.focal_point = focal_point

        if roi_height is None:
            self.roi_height = 0.
        else:
            self.roi_height = roi_height

        if source_pts is None:
            self.source_pts = [[0, 0], [0, 0]]
        else:
            self.source_pts = source_pts

        self.roi_pts = np.float32([[0, 0], [0, 0], [0, 0], [0, 0]])
        self.left_fit = None
        self.right_fit = None

        self.h = px_heidht  # vertical pixel count of the camera
        self.w = px_width  # horizontal pixel count of the camera

        self.lane_width = lane_width  # dimension of lane width in meters
        self.width_per_pix = 0
        self.lane_length = lane_length  # dimension of lane length in meters
        self.len_per_pix = 0

        self.left_pts = None
        self.right_pts = None
        self.center_pts = None
        self.y_pts = None

        self.queue_size = queue_size
        self.left_fit_filter = filter.Filter(self.queue_size)
        self.right_fit_filter = filter.Filter(self.queue_size)
        self.rad_filter = filter.Filter(self.queue_size)
        self.car_center_pos = filter.Filter(self.queue_size)
        self.corner_rad = 0
Beispiel #2
0
    def run_filter(self):
        """Runs the filter class work demonstration"""
        name = self.box.get()
        try:
            fraction = float(self.fracbox.get())
            fl1 = fl.Filter(name, fraction)
            fl1.plot(name)
            fl1.low_pass_filter()

            fl2 = fl.Filter(name, fraction)
            fl2.high_pass_filter()
            Transformer.show_all()
            del fl1, fl2, name
            gc.collect()
        except Exception as er:
            print(er)
Beispiel #3
0
def remove_filter_item(item_uri, data_source, destdir):
    import_grimoirelib(destdir)
    import report, GrimoireSQL, filter

    if item_uri not in get_filter_items(data_source, destdir):
        logging.info('%s not found' % (item_uri))
        return

    automator_file = os.path.join(destdir, "conf/main.conf")
    automator = read_main_conf(automator_file)
    db_user = automator['generic']['db_user']
    db_password = automator['generic']['db_password']
    db_name_automator = None
    ds = None

    for dsaux in report.Report.get_data_sources():
        if (dsaux.get_name() == data_source):
            db_name_automator = dsaux.get_db_name()
            ds = dsaux
            break
    if db_name_automator is None:
        logging.error("Can't find the db_name in %s for the data source %s" %
                      (automator_file, data_source))
        sys.exit()
    db_name = automator['generic'][db_name_automator]

    GrimoireSQL.SetDBChannel(database=db_name,
                             user=db_user,
                             password=db_password)
    logging.info('Removing %s from %s' % (item_uri, data_source))
    ds.remove_filter_data(filter.Filter("repository", item_uri))
Beispiel #4
0
 def getFilters(self):
     """Returns the job filters for this show
     @rtype: FilterSeq
     @return: Seq object containing a list of Filters
     """
     response = self.stub.GetFilters(
         show_pb2.ShowGetFiltersRequest(show=self.data),
         timeout=Cuebot.Timeout)
     return [filter.Filter(filter) for filter in response.filters]
Beispiel #5
0
def fandw(raw):
    fil = filter.Filter(rate=30000., low=500., high=9000., order=4)
    traces_f = fil(raw)

    super_threshold_indices = traces_f > 150
    traces_f[super_threshold_indices] = 0
    super_threshold_indices = traces_f < -150
    traces_f[super_threshold_indices] = 0
    return traces_f
Beispiel #6
0
def reterive_data(idx, _filter, exclude, json_obj):
    obj_filter = filter.Filter(json_obj['nodes'], json_obj['links'], idx,
                               _filter, exclude)

    new_links, new_nodes, max_degree_p, max_degree_e = obj_filter.preprocess_data_filter(
    )
    json_obj['nodes'] = new_nodes
    json_obj['links'] = new_links
    json_obj['maxPDegree'] = max_degree_p
    json_obj['maxEDegree'] = max_degree_e
    return jsonify(json_obj)
Beispiel #7
0
 def findFilter(self, name):
     """Find the filter by name
     @type: string
     @param: name of filter to find
     @rtype: Filter
     @return: filter wrapper of found filter
     """
     response = self.stub.FindFilter(show_pb2.ShowFindShowRequest(
         show=self.data, name=name),
                                     timeout=Cuebot.Timeout)
     return filter.Filter(response.filter)
Beispiel #8
0
 def createFilter(self, name):
     """Create a filter on the show
     @type: string
     @param: Name of the filter to create
     @rtype: show_pb2.ShowCreateFilterResponse
     @return: response is empty
     """
     response = self.stub.CreateFilter(show_pb2.ShowCreateFilterRequest(
         show=self.data, name=name),
                                       timeout=Cuebot.Timeout)
     return filter.Filter(response.filter)
Beispiel #9
0
def search(queryinput, key, provider, cutoff, n):
    e = engine.Engine(provider, key)

    q = query.Query(queryinput)
    qs = q.getQueries()

    g = e.searchAndGram(qs)
    f = filter.Filter(qs, g)
    f.reweightGrams()

    t = tile.Tile(g)
    return t.getAnswers(cutoff, n)
Beispiel #10
0
 def run_list_filter(self):
     """Runs filtering the image with many fraction parameters"""
     name = self.box.get()
     try:
         fractions = self.many_fractions.get().split()
         fractions = [float(fraction) for fraction in fractions]
         fil = fl.Filter(name)
         fil.plot(name)
         fil.series_lpf(fractions)
         fl.Transformer.show_all()
         del fil, name
         gc.collect()
     except Exception as er:
         print(er)
Beispiel #11
0
def main(src, dst):

    src_pic_paths = [
        os.path.join(src, name) for name in os.listdir(src)
        if os.path.splitext(name)[-1] in [".jpg", ".JPG", ".png", ".PNG"]
    ]
    filters = [
        'Naive',  # Naive Filter  原图滤波(相当于无变化)
        'Sharpness_Center',  # Sharpness_Center Filter  中心锐化 滤波
        'Sharpness_Edge',  # Sharpness_Edge Filter  边缘锐化 滤波
        'Edge_Detection_360_degree',  # Edge_Detection_360° Filter  360°边缘检测 滤波
        'Edge_Detection_45_degree',  # Edge_Detection_45° Filter  45°边缘检测 滤波
        'Embossing_45_degree',  # Embossing_45° Filter  45°浮雕 滤波
        'Embossing_Asymmetric',  # Embossing_Asymmetric Filter  非对称浮雕 滤波
        'Averaging_Blur',  # Averaging_Blur Filter  均值模糊 滤波
        'Completed_Blur',  # Completed_Blur Filter  完全模糊 滤波
        'Motion_Blur',  # Motion_Blur Filter  运动模糊 滤波
        'Gaussian_Blur',  # Gaussian_Blur Filter  高斯模糊 滤波
        'DIY'  # DIY Filter  自定义 滤波
    ]

    # ===================================================================
    ## Choose the filter from list: "filter_names"  选择你需要的滤波器

    filter_name = 'Sharpness_Center'
    # filter_name = 'DIY'
    # ===================================================================

    for src_pic_path in src_pic_paths:
        img = cv2.imread(src_pic_path)
        h, w, c = img.shape
        assert c == 3, "Error! Please use the picture of 3 color channels."
        filter_0, filter_1, filter_2 = filter.Filter(filter_name)
        img2 = np.zeros((h, w, c), dtype=np.float)
        for i in range(1, h - 1, 1):
            for j in range(1, w - 1, 1):
                img2[i][j][0] = convolution.conv(img, filter_0, i, j)
                img2[i][j][1] = convolution.conv(img, filter_1, i, j)
                img2[i][j][2] = convolution.conv(img, filter_2, i, j)
        dst_pic_name = filter_name + '.jpg'
        dst_pic_path = os.path.join(dst, dst_pic_name)
        cv2.imwrite(dst_pic_path, img2)

        img3 = cv2.imread(dst_pic_path)
        cv2.imshow(dst_pic_name, img3)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
Beispiel #12
0
    def __call__(self):
        self.filter = filter.Filter()
        self.tk = tkinter.Tk()
        self.tk.title("查询")
        self.tk.geometry('800x300')
        self.tk.resizable(0,0)
        
        self.label1 = tkinter.Label(self.tk, text="请输入查询信息", compound='left')
        self.label1.grid(row=0, column=0, sticky=tkinter.W, pady=10)
        
        self.label4 = tkinter.Label(self.tk, text="项目开始日期", compound='left')
        self.label4.grid(row=3, column=0, sticky=tkinter.W, pady=10)
        self.entry3 = tkinter.Entry(self.tk, width=26)
        self.entry3.grid(row=3, column=1, sticky=tkinter.W, pady=10)
        self.label5 = tkinter.Label(self.tk, text="项目结束日期", compound='left')
        self.label5.grid(row=4, column=0, sticky=tkinter.W, pady=10)
        self.entry4 = tkinter.Entry(self.tk, width=26)
        self.entry4.grid(row=4, column=1, sticky=tkinter.W, pady=10)
        self.label6 = tkinter.Label(self.tk, text="项目负责人", compound='left')
        self.label6.grid(row=5, column=0, sticky=tkinter.W, pady=10)
        self.entry5 = tkinter.Entry(self.tk, width=26)
        self.entry5.grid(row=5, column=1, sticky=tkinter.W, pady=10)
        self.label7 = tkinter.Label(self.tk, text="教授", compound='left')
        self.label7.grid(row=6, column=0, sticky=tkinter.W, pady=10)
        self.entry6 = tkinter.Entry(self.tk, width=26)
        self.entry6.grid(row=6, column=1, sticky=tkinter.W, pady=10)
        self.label8 = tkinter.Label(self.tk, text="部门", compound='left')
        self.label8.grid(row=7, column=0, sticky=tkinter.W, pady=10)
        self.entry7 = tkinter.Entry(self.tk, width=26)
        self.entry7.grid(row=7, column=1, sticky=tkinter.W, pady=10)

        
        self.button5 = tkinter.Button(self.tk, text="根据项目起止日期查询项目", activeforeground="red", command=self.getProjectbyTime)
        self.button5.grid(row = 3, column=3, sticky=tkinter.W)
        self.button6 = tkinter.Button(self.tk, text="根据项目负责人查询项目", activeforeground="red", command=self.getProjectbyProfessor)
        self.button6.grid(row = 4, column=3, sticky=tkinter.W)
        self.button5 = tkinter.Button(self.tk, text="根据项目起止日期和项目负责人查询项目", activeforeground="red", command=self.getProjectbyProfessor_Time)
        self.button5.grid(row = 5, column=3, sticky=tkinter.W)
        self.button6 = tkinter.Button(self.tk, text="根据教授查找负责的学生", activeforeground="red", command=self.getStudentsbyProfessor)
        self.button6.grid(row = 6, column=3, sticky=tkinter.W)
        self.button6 = tkinter.Button(self.tk, text="根据部门名字查找负责的教授以及时间百分比", activeforeground="red", command=self.getProfessorbyDepartment)
        self.button6.grid(row = 7, column=3, sticky=tkinter.W)
        self.button6 = tkinter.Button(self.tk, text="根据部门统计学生信息", activeforeground="red", command=self.getStudentsInfobyDepartment)
        self.button6.grid(row = 8, column=3, sticky=tkinter.W)

        
        self.tk.mainloop()
Beispiel #13
0
    def apply(self):
        global orig_audio, audioFs, output, lowParams, midParams, highParams
        self.update_params()

        f = filter.Filter()
        print("Working...")
        start = time.time()
        filtered = f.filter(orig_audio * 1., audioFs, lowParams, midParams,
                            highParams)
        output = np.clip(filtered, -32767, 32768)
        end = time.time() - start
        print("Done.")
        length = len(orig_audio)
        print(
            f"{end*audioFs:.0f} samples ({end:.3f} seconds) elapsed, processed {length:d} samples ({length/audioFs:.3f} seconds)."
        )

        return
Beispiel #14
0
def test_filter(): 
    nodes, rels = create_fake_db()

    try:
        print("checking no filter")
        ft = filter.Filter(nodes, rels) 
        n, r = ft.filter_handler(None, None, None, None, None) 
        assert(check_list_contain_equal(nodes, n));
        assert(check_list_contain_equal(rels, r)); 
        print("checking no filter done")
    except AssertionError:
        print("checking no filter failed")

    # check developer
    try:
        print("checking developer")
        n, r = ft.filter_handler(filter.developer_to_id(nodes, 'Developer 1'), None, None, None, None) 
        xn, xr = result_developer_1() 
        assert(check_list_contain_equal(n, xn));
        assert(check_list_contain_equal(r, xr)); 
        print("checking developer done")
    except AssertionError:
        print("checking developer failed")

    try:
        print("checking date 1")
        n, r = ft.filter_handler(None, None, None, datetime.strptime("31-12-2018", '%d-%m-%Y').date(), None) 
        xn, xr = result_date_1() 
        assert(check_list_contain_equal(n, xn));
        assert(check_list_contain_equal(r, xr)); 
        print("checking date 1 done")
    except AssertionError:
        print("checking date 1 failed")

    try:
        print("checking date 2")
        n, r = ft.filter_handler(None, None, None, None, datetime.strptime("31-12-2018", '%d-%m-%Y').date()) 
        xn, xr = result_date_2() 
        assert(check_list_contain_equal(n, xn));
        assert(check_list_contain_equal(r, xr)); 
        print("checking date 2 done")
    except AssertionError:
        print("checking date 2 failed")
    def run(self, query):
        p = parser.Parser()
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)

        # ip_dict = p.find_ips(filename)
        # p.persist_ips(ip_dict)
        self.info(query)
        f = filter.Filter()
        # pp = pprint.PrettyPrinter(indent=4)
        # pp.pprint(f.get_ip(527279671))
        # o = f.parse_dsl(r'"ip" > "89.168.179.90"')
        o = f.parse_dsl(query)
        self.info(o)
        if 'error' in o:
            return o['error']
        else:
            r = f.get_results(o['where_string'], o['values'])
        self.info(r)
        return r
Beispiel #16
0
def filtering_properties():
    data = request.form
    print(data)
    basicFilter = filter.Filter()
    properties = basicFilter.basic_filter(data, db)
    print(properties)
    tags = db.query('tags')
    #print(tags)
    images = db.query('property_images')
    d1 = defaultdict(list)
    d2 = defaultdict(list)
    for tag in tags:
        d1[tag["pid"]].append(tag["tag"])
    for image in images:
        d2[image["pid"]].append(image["image"])
    print(d1)
    print(d2)
    for elem in properties:
        elem['tags'] = d1[elem['pid']]
        elem['images'] = d2[elem['pid']]
    return render_template('listings.html', data=properties[::-1])
Beispiel #17
0
def main():

    original_images = ['Elegent_Girl.jpg']
    filter_names = [
        'Naive', 'Sharpness_Center', 'Sharpness_Edge',
        'Edge_Detection_360_degree', 'Edge_Detection_45_degree',
        'Embossing_45_degree', 'Embossing_Asymmetric', 'Averaging_Blur',
        'Completed_Blur', 'Motion_Blur', 'Gaussian_Blur'
    ]

    # Choose the filter from list:'filter_names'
    filter_name = 'Naive'

    for original_image in original_images:
        original_image_path = os.path.join(os.getcwd()[:-3], 'Image_Origin/',
                                           original_image)
        img = cv2.imread(original_image_path, 3)

        filter_0, filter_1, filter_2 = filter.Filter(filter_name)

        img2 = np.zeros((424, 600, 3), dtype=np.float)

        for i in range(1, 423, 1):
            for j in range(1, 599, 1):

                img2[i][j][0] = convolution.conv(img, filter_0, i, j)
                img2[i][j][1] = convolution.conv(img, filter_1, i, j)
                img2[i][j][2] = convolution.conv(img, filter_2, i, j)

        generated_image = filter_name + '.jpg'

        generated_image_path = os.path.join(os.getcwd()[:-3],
                                            'Image_Generated/',
                                            generated_image)
        cv2.imwrite(generated_image_path, img2)
        img_show = cv2.imread(generated_image_path)

        cv2.imshow(generated_image, img_show)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
Beispiel #18
0
def filter_tweets():
    filePath = "/Users/anirudhnair/Dropbox/WORK/lecNotes/cs410/project/test.json"
    configXml = "/Users/anirudhnair/Documents/workspace/TwitterAnalysis/filter.xml"
    outFile = "/Users/anirudhnair/Dropbox/WORK/lecNotes/cs410/project/test_out.json"
    reader = TweetReader.TweetReader(filePath)
    filter_ = filter.Filter(configXml)
    oFP = open(outFile, 'w')
    totalTweets = 0
    totalFilteredTweets = 0
    while (True):
        tweet_ = reader.next()
        if (tweet_ is None):
            break
        totalTweets = totalTweets + 1
        if (filter_.FilterTweet(tweet_)):
            oFP.write(tweet_.GetJSONStr())
            totalFilteredTweets = totalFilteredTweets + 1

    oFP.close()
    print "Total tweets processed " + str(totalTweets) + " \n"
    print "Total tweets that passed the filter " + str(
        totalFilteredTweets) + " \n"
def update_layout2(start_date, end_date, developer, file, filetype):
    xnodes, xrelations = db.get_all_data(merge=False)

    ft = filter.Filter(xnodes, xrelations)

    # #TODO: need to convert developer string to id

    d = None
    f = None
    t = None

    if developer != 'Select developer':
        d = filter.developer_to_id(xnodes, developer)

    if file != 'Select file':
        f = filter.file_to_id(xnodes, file)

    if filetype != 'Select filetype':
        t = filter.filetype_to_id(xnodes, filetype)
        print(t)

    try:
        d1 = datetime.strptime(start_date, '%d-%m-%Y')
        d1 = d1.date()
    except ValueError:
        #to do: output that the input is wrong
        d1 = None
        # print("Wrong input d1")
    try:
        d2 = datetime.strptime(end_date, '%d-%m-%Y')
        d2 = d2.date()
    except ValueError:
        #to do: output that the input is wrong
        d2 = None
        # print("Wrong input d2")

    n, r = ft.filter_handler(d, f, t, d1, d2)

    return n + r
Beispiel #20
0
import filter as fl


if __name__ == '__main__':
    # example: moonlanding.png;  0.05 0.07 0.1 0.2 0.3
    print('Input source file\'s name here:')
    src = input()
    print('Input the fractions list to filter with,\nseparate with whitespaces:')
    fractions = input().split()
    fractions = [float(fraction) for fraction in fractions]
    try:
        fil = fl.Filter(src)
        fil.plot(src)
        fil.series_lpf(fractions)
        fl.Transformer.show_all()
    except FileNotFoundError as er:
        print(er)
Beispiel #21
0
 def file_filter_buf(self, file_path):
     file = fltr.Filter()
     file.filtered(file_path)
Beispiel #22
0
import sys
import os
import filter
from flask import Flask, request, render_template, redirect

# Init app
app = Flask(__name__)

PATH = os.path.dirname(os.path.abspath(__file__))
INDEX_PATH = '/templates/index.html'

f = filter.Filter('static/spells.json')


def get_inquiry(inquiry_form):
    # Read the inquiry form

    # Add each entry to the inquiry
    inq = {}
    for field in inquiry_form:
        # If key exists, append entry
        if field in inq:
            inq[field] += [inquiry_form[field]]
        else:  # create new entry
            inq[field] = [inquiry_form[field]]
    return inq


def inquire(inquiry):
    # Perform a filter as instructed
Beispiel #23
0
def main():
    num = [0.00025421634845499124,
           -0.00079187872147285572,
           0.00141377112114653320,
           -0.00167945032088055311,
           0.00176640706253605641,
           -0.00167945032088055311,
           0.00141377112114653320,
           -0.00079187872147285572,
           0.00025421634845499124]

    den = [1,
           -6.142345166576267168068,
           16.682363664620424970053,
           -26.134169993147157384782,
           25.804074652366246311885,
           -16.430866660921950028750,
           6.584876413720856191957,
           -1.517738749625560545908,
           0.153965563480438771826]

    b = num
    a = den
    filt = fi.Filter(b, a=a)

    step = [1] * 160
    impulse = [1] + [0] * 159
    Om = 0.3  # * pi (rad / sample)
    fs = 100
    f = Om / 2 * fs
    print(f, f/10)
    xn1, tn, xt1, t = fi.generate_signal(f, fs, 0.2, 0, 5)
    xn2, tn2, xt2, t2 = fi.generate_signal(f / 10, fs, 1, 0, 5)
    xn = fi.add_signals(xn1, xn2)
    xt = fi.add_signals(xt1, xt2)

    step_response = filt.filter_list(step)
    filt.clear()
    impulse_response = filt.filter_list(impulse)
    filt.clear()
    yn = filt.filter_list(xn)

    mag, phase, W = fi.get_frequency_response(b, a=a)
    db = fi.amplitude2db(mag)

    plt.figure()
    plt.plot(W, db)

    plt.figure()
    plt.plot(W, phase)

    plt.figure()
    plt.plot(step_response)

    plt.figure()
    plt.plot(impulse_response)

    plt.figure()
    plt.plot(t, xt)
    plt.plot(tn, yn)

    plt.show()
Beispiel #24
0
 def fileFilter(self):
     file = fltr.Filter()
     file.filtered(self.path_entry.get())
Beispiel #25
0
    def __init__(self, list_of_variables_for_threads, bluetooth_server):
        super(DataAcquisition, self).__init__()         # Inherit threading vitals

        # Declaration of global variables
        self.go = list_of_variables_for_threads["go"]
        self.list_of_variables_for_threads = list_of_variables_for_threads
        self.bluetooth_server = bluetooth_server
        self.run_measurement = self.list_of_variables_for_threads['run_measurement']
        self.window_slide = self.list_of_variables_for_threads["window_slide"]
        self.initiate_write_respitory_rate = list_of_variables_for_threads["initiate_write_heart_rate"]
        self.resp_rate_csv = []
        # Setup for collecting data from Acconeer's radar files
        self.args = example_utils.ExampleArgumentParser().parse_args()
        example_utils.config_logging(self.args)
        # if self.args.socket_addr:
        #     self.client = JSONClient(self.args.socket_addr)
        #     print("RADAR Port = " + self.args.socket_addr)
        # else:
        #     print("Radar serial port: " + self.args.serial_port)
        #     port = self.args.serial_port or example_utils.autodetect_serial_port()
        #     self.client = RegClient(port)
        self.client = JSONClient('0.0.0.0')
        print("args: " + str(self.args))
        self.client.squeeze = False
        self.config = configs.IQServiceConfig()
        self.config.sensor = self.args.sensors
        print(self.args.sensors)
        # self.config.sensor = 1
        # Settings for radar setup
        self.config.range_interval = [0.4, 1.4]  # Measurement interval
        # Frequency for collecting data. To low means that fast movements can't be tracked.
        self.config.sweep_rate = 20  # Probably 40 is the best without graph
        # For use of sample freq in other threads and classes.
        self.list_of_variables_for_threads["sample_freq"] = self.config.sweep_rate
        # The hardware of UART/SPI limits the sweep rate.
        self.config.gain = 0.7  # Gain between 0 and 1. Larger gain increase the SNR, but come at a cost
        # with more instability. Optimally is around 0.7
        self.info = self.client.setup_session(self.config)  # Setup acconeer radar session
        self.data_length = self.info["data_length"]  # Length of data per sample

        # Variables for tracking method
        self.first_data = True      # first time data is processed
        self.dt = 1 / self.list_of_variables_for_threads["sample_freq"]
        self.low_pass_const = self.low_pass_filter_constants_function(
            0.25, self.dt)  # Constant for a small
        # low-pass filter to smooth the changes. tau changes the filter weight, lower tau means shorter delay.
        # Usually tau = 0.25 is good.
        self.number_of_averages = 2  # Number of averages for tracked peak
        self.plot_time_length = 10  # Length of plotted data
        # Number of time samples when plotting
        self.number_of_time_samples = int(self.plot_time_length / self.dt)
        self.tracked_distance_over_time = np.zeros(
            self.number_of_time_samples)  # Array for distance over time plot
        self.local_peaks_index = []  # Index of big local peaks
        self.track_peak_index = []  # Index of last tracked peaks
        self.track_peaks_average_index = None  # Average of last tracked peaks
        self.threshold = 1  # Threshold for removing small local peaks. Start value not important

        # Returned variables
        self.tracked_distance = None  # distance to the tracked peak (m)
        self.tracked_amplitude = None
        self.tracked_phase = None
        self.tracked_data = None  # the final tracked data that is returned

        # Variables for phase to distance and plotting
        self.low_pass_amplitude = None  # low pass filtered amplitude
        self.low_pass_track_peak = None
        self.track_peak_relative_position = None  # used for plotting
        # the relative distance that is measured from phase differences (mm)
        self.relative_distance = 0  # relative distance to signal process
        self.real_time_breathing_amplitude = 0  # to send to the application
        self.last_phase = 0  # tracked phase from previous loop
        # saves old values to remove bias in real time breathing plot
        self.old_realtime_breathing_amplitude = np.zeros(1000)
        self.c = 2.998e8  # light speed (m/s)
        self.freq = 60e9  # radar frequency (Hz)
        self.wave_length = self.c / self.freq  # wave length of the radar
        self.delta_distance = 0  # difference in distance between the last two phases (m)
        self.delta_distance_low_pass = 0  # low pass filtered delta distance for plotting
        self.noise_run_time = 0  # number of run times with noise, used to remove noise
        self.not_noise_run_time = 0  # number of run times without noise

        # other
        # how often values are plotted and sent to the app
        self.modulo_base = int(self.list_of_variables_for_threads["sample_freq"] / 10)
        if self.modulo_base == 0:
            self.modulo_base = 1
        print('modulo base', self.modulo_base)
        self.run_times = 0  # number of times run in run
        self.calibrating_time = 5  # Time sleep for passing through filters. Used for Real time breathing

        # Graphs
        self.plot_graphs = False  # if plot the graphs or not
        if self.plot_graphs:
            self.pg_updater = PGUpdater(self.config)
            self.pg_process = PGProcess(self.pg_updater)
            self.pg_process.start()
        # acconeer graph
        self.low_pass_vel = 0
        self.hist_vel = np.zeros(self.number_of_time_samples)
        self.hist_pos = np.zeros(self.number_of_time_samples)
        self.last_data = None  # saved old data

        # filter
        self.highpass_HR = filter.Filter('highpass_HR')
        self.lowpass_HR = filter.Filter('lowpass_HR')
        self.highpass_RR = filter.Filter('highpass_RR')
        self.lowpass_RR = filter.Filter('lowpass_RR')

        self.HR_filtered_queue = list_of_variables_for_threads["HR_filtered_queue"]
        self.RR_filtered_queue = list_of_variables_for_threads["RR_filtered_queue"]
        # TODO remove
        self.RTB_final_queue = list_of_variables_for_threads["RTB_final_queue"]

        self.amp_data = []
Beispiel #26
0
t = np.linspace(1, 100, pkter)

sample_freq = 20
length_seq = 1000
sample_spacing = 1 / sample_freq

t = np.arange(length_seq) * sample_spacing

x = np.zeros(len(t))
x[0:round(len(t) / 2)] = np.sin(f * 2 * np.pi * t[0:round(len(t) / 2)]) + 5
x[round(len(t) /
        2):len(t)] = np.sin(f * 2 * np.pi * t[round(len(t) / 2):len(t)]) + 2
x = x + np.sin(1 * 2 * np.pi * t)

plt.plot(t, x)
plt.grid()
plt.show()

testfilter_high = filter.Filter('highpass_RR')
testfilter_low = filter.Filter('lowpass_RR')

y = np.zeros(len(x))

for i in range(len(x)):
    y[i] = testfilter_high.filter(x[i])
    y[i] = testfilter_low.filter(y[i])

plt.plot(t, y)
plt.grid()
plt.show()
    basics_filename = SYS_DATA['BasicsFilename']
    ratings_filename = SYS_DATA['RatingsFilename']

    build.download_imdb_data(basics_filename)
    build.download_imdb_data(ratings_filename)

    basics = build.read_data(basics_filename)
    ratings = build.read_data(ratings_filename)

    merged = build.merge(basics, ratings)

    build.sanitize(merged)

    print('Got {} records'.format(merged.size))
    build.write_file(merged, DATA_FILE_NAME)

# Setup filters
filter = filter.Filter(CONFIG_FILE, DATA_FILE_NAME, ENCODING, IMDB_ID,
                       SYS_DATA['BaseBrowserURL'])

# Run filters
filter.run_filters()

# Run app, pick a film for the user on request
while True:
    text = input('press ENTER for a movie...')
    if text == '':
        filter.pick()
    else:
        pass
    def ticketsQuery(self, submitData, loop=False):

        print('((((((((((((((((()))))))))))))))))))')
        print(submitData)
        print(loop)
        print('((((((((((((((((()))))))))))))))))))')

        self.processEvents()
        autoOrderTicket = self.config.getDictsSequence('defaultSetting',
                                                       'autoOrderTicket')

        def validateAutoBookTicket(autoOrderTicket, sortedTrains):

            if int(
                    autoOrderTicket
            ) == 1 and not sortedTrains['seat'] is None and not sortedTrains[
                    'filterTrain'] is None and len(
                        sortedTrains['filterTrain']) > 0:
                return True
            else:
                return False

        if 'filterTrain' in submitData:

            self.bookTicket(submitData['filterTrain'], seat=submitData['seat'])

        else:
            print(submitData)
            queryData = collections.OrderedDict()
            queryData["orderRequest.train_date"] = submitData[
                'orderRequest.train_date']
            queryData['orderRequest.from_station_telecode'] = submitData[
                'orderRequest.from_station_telecode']
            queryData['orderRequest.to_station_telecode'] = submitData[
                'orderRequest.to_station_telecode']
            queryData['orderRequest.train_no'] = submitData[
                'orderRequest.trainCodeText']
            # queryData['trainPassType'] = submitData['trainPassType']
            queryData['trainClass'] = submitData['trainClassArr']
            queryData['includeStudent'] = submitData['includeStudent']
            queryData['seatTypeAndNum'] = ''
            queryData['orderRequest.start_time_str'] = submitData[
                'orderRequest.start_time_str']
            queryData['orderRequest.roundTrainDate'] = getattr(
                submitData, 'orderRequest.roundTrainDate',
                submitData['orderRequest.train_date'])
            trains = self.queryCore.ticketQuery(queryData)
            self.config.set('ticketQuerySetting', submitData)

            #存储订票信息
            self.db.set('ticketQuerySetting', submitData, 'ticketQuerySetting')
            self.processEvents()

            #fliter
            trainFilter = filter.Filter()

            sortedTrains = trainFilter.filter(
                submitData['orderRequest.start_time_str'], trains, self.config,
                loop)

            if sortedTrains is not None and len(sortedTrains) > 0:
                if validateAutoBookTicket(autoOrderTicket, sortedTrains):
                    data = {
                        'train': sortedTrains['trains'],
                        'filterTrain': sortedTrains['filterTrain'],
                        'seat': sortedTrains['seat'],
                        'loop': loop
                    }
                else:
                    data = {
                        'train': sortedTrains['trains'],
                        'filterTrain': '',
                        'seat': '',
                        'loop': loop
                    }

                self.signalUpdateTrainDate.emit(data)

                if not sortedTrains['seat'] is None:
                    if loop:
                        if int(autoOrderTicket) == 1:
                            return True
                        else:
                            return False
                    else:
                        self.bookTicket(sortedTrains['filterTrain'],
                                        seat=sortedTrains['seat'])
                else:
                    return False
            else:
                return False
Beispiel #29
0
if __name__ == '__main__':
    print("\n\t\tДанные для входа находятся в файле 'account.txt'" + "\n")
    print("\t\tДанные записываются в формате ->app_id login password" + "\n")

    # Авторизация
    a = sing_in.SignIn()
    session_vk = a.authorization_vk()

    print("Авторизация прошла успешно\n")
    print("Начинаем парсинг группы...\n")

    p = parsing.Parsing()
    result_parsing = p.parsing(session_vk)

    print("Парсинг выполнен успешно\n")

    f = filter.Filter(result_parsing)
    man, girl = f.filter_sex()

    print("В группе мужчин =", man, " и девушек =", girl, "\n")

    birth_data_age = []
    birth_data_count = []
    birth_data_age, birth_data_count = f.filter_bdate()

    pl = plots.Plots()
    pl.round_plot(birth_data_age, birth_data_count)

    print("\nДиаграмма построена\n")
    input("\nНажмите Enter, чтобы выйти\n")
Beispiel #30
0
# Project Libraries
from song_aggregate import SongAggregateScraper
import filter as fltr

# General Libraries
from unittest import TestCase

SAVEFILE = 'test_filter_file'
english_filter = fltr.Filter('english-1000-word-filter',
                             fltr.Action.REMOVE_EXCEPT,
                             fltr.list_from_file('english_1000', 4))
length_filter = fltr.Filter('length-filter',
                            fltr.Action.FILTER_BY_LENGTH,
                            cutoff_lb=7,
                            cutoff_ub=250)
brutish_music_filter = fltr.Filter(
    'brutish_filter', fltr.Action.SUBSTRING_MATCH,
    fltr.list_from_file('music_words') | fltr.list_from_file('mood_words'))


class TestFilters(TestCase):
    def english_filter_3rd_song(self, filtered_comments):
        """ results of english filter applied to 3rd song """
        self.assertEqual(6, len(filtered_comments), "english filtered length")
        self.assertTrue('positive' in filtered_comments[0].lower(),
                        "english in comment")
        self.assertTrue('single' in filtered_comments[1].lower(),
                        "english in comment")
        self.assertTrue('best' in filtered_comments[2].lower(),
                        "english in comment")
        self.assertTrue('continue' in filtered_comments[3].lower(),