Пример #1
0
    def __init__(self, glob_params, ejecta_params, source_name, **kwargs):

        super(MKN, self).__init__(**kwargs)

        # initializing the global properties of the source
        print('I am initializing the global properties of the source')
        SP = sp.SourceProperties(source_name)
        self.D = SP.D
        self.view_angle = SP.view_angle

        # initialize the angular distribution
        print('I am initializing the angles')
        self.n_slices = glob_params['n slices']
        self.dist_slices = glob_params['dist slices']
        self.AD = ad.AngularDistribution(self.dist_slices, self.n_slices)
        self.angular_distribution, self.omega_distribution = self.AD(
            self.n_slices / 2, glob_params['omega frac']
        )  # due to the symmetry abount the equatorial plane, the number of independent slices is half

        # initialize the filters
        print('I am initializing the filters')
        if (source_name == 'default'):
            self.FT = ft.Filters("properties")
        else:
            self.FT = ft.Filters("measures")
        self.dic_filt, self.lambda_vec, self.mag = self.FT(
            SP.filter_data_folder,
            glob_params["time min"] * units.sec2day + SP.t0,
            glob_params["time max"] * units.sec2day + SP.t0)

        #initialize the time
        print('I am initializing the global time')
        self.time_min = glob_params['time min']
        self.time_max = glob_params['time max']
        self.n_time = glob_params['n time']
        self.tscale = glob_params['scale for t']
        self.t0 = SP.t0
        if (self.tscale == "measures" and source_name == 'default'):
            print('')
            print("no measures available to set the time (default option)")
            print("please use linear or log scale")
            exit()

        self.time = SP.init_time(self.tscale, self.time_min, self.time_max,
                                 self.n_time, self.mag)

        #initialize the observer location
        print('I am initializing the observer orientation')
        self.FF = op.ObserverProjection(self.n_slices, self.dist_slices)

        # register the geometry of the ejecta and create an Ejecta object
        print('I am initializing the components')
        self.E = ej.Ejecta(len(ejecta_params.keys()), ejecta_params.keys(),
                           ejecta_params)
Пример #2
0
 def __init__(self, redditHelper, config):
     logging.info("Initializing aggregator...")
     self.redditHelper = redditHelper
     self.submissions = []
     self.comments = []
     self.subreddits = self.redditHelper.userSubreddits()
     self.filters = filters.Filters(config)
     self.postMan = postman.PostMan(config.get("response"))
     self.dumper = dumper.Dumper(config)
	def __init__(self):
		QThread.__init__(self)
		self.display_size = 2048
		self.buffer_size = 256
		self.rband_buffer_size = 1024
		self.display_buf = deque([0]*self.display_size)
		self.data_buf = deque([0]*self.buffer_size)
		self.display_filters = filters.Filters(self.display_size,8,20)
		self.analyze_filters = filters.Filters(self.buffer_size,5,12)
		self.rband_buf1 = deque([0]*self.rband_buffer_size)
		self.rband_buf2 = deque([0]*self.rband_buffer_size)
		self.rband_buf3 = deque([0]*self.rband_buffer_size)

		self.analysis = Analysis()
		self.respiratory_analysis1 = Analysis()
		self.respiratory_analysis2 = Analysis()
		self.respiratory_analysis3 = Analysis()
		self.count = 0
		self.board = None
Пример #4
0
    def _navigate(self):
        '''Ensure this particular filter report is always selected by "guessing" the _sub_url here'''
        # FIXME: magic here
        if re.match(pages.reports.url_pattern, SE.current_url) is None:
            # not on the reports page -> create a report for this filter name
            filters.Filters().get_filter(self._filter_name).run_report()

        # https://sam.example.com/sam/splice_reports/filters/2/reports -> sam/splice_reports/filters/2/reports
        self._sub_url = '/'.join(SE.current_url.split('/')[3:])

        super(ReportPageObject, self)._navigate()
Пример #5
0
    def filter(self, list, filtertext):

        #filtertext=self.filtertxt.GetValue()
        #filtered=filtertext.split()
        #self.filtertxt.SetValue(str(filtered))
        fobj = filters.Filters()
        f = fobj.check_filter_validity(filtertext)
        if f == True:
            fexpression = filtertext.split()
            a = fobj.filter_data(list, fexpression)
            return a
Пример #6
0
    def send_values(self, event):

        values = self.filtertxt.GetValue()
        fobj = filters.Filters()
        f = fobj.check_filter_validity(values)
        if f == True:
            self.parent.get_filter_values(values)
            self.Destroy()
        else:
            textstyle = wx.TextAttr()
            textstyle.SetBackgroundColour(wx.RED)
            self.filtertxt.SetDefaultStyle(textstyle)
            self.filtertxt.AppendText(' ')
Пример #7
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import angular_distribution as ad
import filters as ft
import lightcurve as lc
import observer_projection as op
import units
import ejecta as ej
import sys

# initialize the filters
print("Initialising filters")
FT = ft.Filters("measures")
dic_filt,lambda_vec,mag = FT()
time_min = 3600.      #
time_max = 2000000.   #
n_time = 20
# initialize global time
time = np.logspace(np.log10(time_min),np.log10(time_max),num=n_time)




# read the chain and plot the maximum likelihood point, for now
chain = np.genfromtxt('quick_test/posterior.dat',names=True)

# set of global parameters not to be fit
glob_params = {'v_min':1.e-7,
               'n_v':10,
               'vscale':'linear',
Пример #8
0
    def setup(self):
        # CONFIG PARAMETERS
        try:
            with open('config.ini') as self._cfg:
                self._config.read_file(self._cfg)
                self._hname = self._config.get("TestHost", "hostname")
                self._dd_dir = self._config.get("Dir", "dd_dir")
                self._src = self._config.get("Sources", "sources")
                self._a_filters = (self._config.get("Filters",
                                                    "filters")).split(', ')
                self._n_batch = self._config.get("Batch", "n_batch")
                if self._n_batch:
                    self._n_batch = int(self._n_batch)

            print("\n[NOTICE] Check your settings in 'config.ini' file. ")

        except (IOError, OSError):
            print("[ERROR] Unable to find config file (config.ini)")
            sys.exit()

        # NETWORK TEST
        try:
            print("\n>>Test network connection...")
            self._hostname = hostname.Test_hostname()
            self._hostname.set_hostname(self._hname)
            self._hostname.get_hostname()
            self._hostname.test_conn()

        except (IOError, OSError):
            print("[ERROR] Unable to get test_hostname.")

        # Logging...
        self._setup_log = utility.Logger()
        self._setup_log.set_file('log.txt')
        self._setup_log.get_file()

        # BEGIN SETUP
        #########################
        try:
            # DIRECTORY
            self._dd_directory = directory.Download_dir()
            self._dd_directory.set_directory(self._dd_dir)
            self._dd_directory = self._dd_directory.get_directory()

            # BATCH FOR TASK POOL
            self._batch = batch.Batch()
            self._batch.set_batch(self._n_batch)
            self._batch = self._batch.get_batch()

            # FILTERS
            self._filters = filters.Filters()
            self._filters.set_filters(self._a_filters)
            self._filters = self._filters.get_filters()

            # SOURCES
            # There is no need to set a default action. If the source file doesn't exist or it's corrupted,
            # the script will terminate its operation instantly.
            print("\n>>Source File:")
            print(self._src)
            self._sources = sources.Sources()
            self._sources.set_urls(self._src)
            self._sources = self._sources.get_urls()

            print("\n>>Options")
            print("Download directory: ", self._dd_dir)

            # If filters is empty in config.ini, don't apply filters.
            if self._a_filters[0] == '' and len(self._a_filters) == 1:
                self._filtered_urls = self._sources
                print("No filter rules applied.\n")
            else:
                print("Filter rules: ", self._a_filters, "\n")
                self._filtered_urls = utility.Filtered_urls()
                self._filtered_urls = self._filtered_urls.apply_filters(
                    self._a_filters, self._sources)

            # for logging...
            self._conf_log = "\n[CONFIG] [time: " + str(
                (datetime.now()
                 ).strftime('%Y/%m/%d %H:%M:%S')) + "] Setup complete. [OK]"
            self._setup_log.logger(self._conf_log)

        except BaseException:
            print("[ERROR] Unable to complete script setup.")
            self._fail_conf_log = "\n[ERROR] [time: " + str(
                (datetime.now()
                 ).strftime('%Y/%m/%d %H:%M:%S')) + "] Setup Failed!!!"
            self._setup_log.logger(self._fail_conf_log)
            sys.exit()

        return self._filtered_urls, self._dd_directory, self._n_batch
Пример #9
0
import cv2
import filters

if __name__ == '__main__':
    src = cv2.imread('../RAWPIC/3.jpg', cv2.IMREAD_COLOR)
    my_filter = filters.Filters(src)

    show = my_filter.bilateral_filter(10.0, 4.0, 4)
    cv2.imwrite('ans.jpg', show)
Пример #10
0
import time, glob, requests, cv2, operator, random, datetime, up, filters, secrets, time, os
import numpy as np

colors = {
    'happiness': (0, 255, 0),
    'sadness': (255, 255, 0),
    'anger': (255, 0, 0)
}
filters = filters.Filters()


def processRequest(json, data, headers, params):
    headers = dict()
    headers['Ocp-Apim-Subscription-Key'] = secrets.OXFORD
    headers['Content-Type'] = 'application/octet-stream'

    retries = 0
    maxNumRetries = 10
    result = None
    while True:
        response = requests.request(
            'post',
            'https://api.projectoxford.ai/emotion/v1.0/recognize',
            json=json,
            data=data,
            headers=headers,
            params=params)
        if response.status_code == 429:
            print "Message: %s" % (response.json()['error']['message'])
            if retries <= maxNumRetries:
                time.sleep(1)
Пример #11
0
 def __init__(self):
     self.filt = filters.Filters()
     self.data_buffer = []
     self.count = 0
     self.udp_packet = []
Пример #12
0
import requests
import picamera
import time
import json
import utils
import filters
import sys
from PIL import ImageEnhance, Image, ImageChops

filter_num_str = sys.argv[1]
filter_num = int(filter_num_str)
img = Image.open('/home/pi/Desktop/ohsnap/img/snap.jpg')
filters = filters.Filters(img)

if (filter_num == 1):
    filters.Enhance()
elif (filter_num == 2):
    filters.BW()
elif (filter_num == 3):
    filters.custom1()
elif (filter_num == 4):
    filters.custom2()
elif (filter_num == 5):
    filters.satura()
else:
    filters.Enhance()
    filters.BW()
    filters.custom1()
    filters.custom2()
    filters.satura()
Пример #13
0
def run(options):

    # Start time
    start_time = datetime.datetime.now()

    # Print welcome message and information
    helper.welcome(__version__)

    # Read configuration file
    config = parsers.read_config_file(options.config)

    # Read input data
    data = helper.read_data(options, config)

    # Initialize output files
    out_included = open('{}_denovo_candidates.txt'.format(options.output), 'w')
    out_excluded = open('{}_filtered_out.txt'.format(options.output), 'w')

    # Decide whether to write MaxEntScan and ExAC columns
    write_maxentscan = config['MAXENTSCAN_DATA_FILE'] != ''
    write_exac = config['EXAC_DATA_FILE'] != ''

    # Write output file headers
    helper.output_header(out_included, write_maxentscan, write_exac, False)
    if options.full_details:
        helper.output_header(out_excluded, write_maxentscan, write_exac, True)
    else:
        helper.output_header_simplified(out_excluded)

    # Initialize Filters object
    filt = filters.Filters(options.full_details)

    # Initialize counters
    counter = 0
    counter_included = 0
    counter_excluded = 0

    # Initialize progress info
    helper.init_progress()

    # Iterate through the variants called in the child
    for var_key, variants in data['child_var'].iteritems():

        for variant in variants:
            counter += 1

            # Print progress info
            helper.print_progress(counter, len(data['child_var']))

            # MaxEntScan scores of the variant
            maxentscan_scores = data['maxentscan'].get_scores(
                var_key) if data['maxentscan'] is not None else None

            # ExAC column values of the variant
            if data['exac'] is None:
                exac_values = None
            else:
                gene = variant['gene']
                exac_values = data['exac'][gene] if gene in data[
                    'exac'] else {}

            # Apply filters to the variant
            result = filt.apply_filters(var_key, variant, config, data)

            # Output result
            if result['filter'] == '.':
                helper.output(out_included, var_key, variant, result,
                              maxentscan_scores, exac_values, False)
                counter_included += 1
            else:
                if options.full_details:
                    helper.output(out_excluded, var_key, variant, result,
                                  maxentscan_scores, exac_values, True)
                else:
                    helper.output_simplified(out_excluded, var_key, variant,
                                             result)
                counter_excluded += 1

    # Finalize progress info
    helper.finalize_progress()

    # Close output files
    out_included.close()
    out_excluded.close()

    # Runtime
    run_time = str(datetime.datetime.now() - start_time)

    # Print goodbye message and information
    helper.goodbye(counter_included, counter_excluded, options.output,
                   run_time)
Пример #14
0
    def __init__(
            self,
            # number of different components of the ejecta
            Nshell,
            # dictionary of global parameters defining basic properties of the ejecta
            glob_params,
            # dictionary of global parameters defining basic properties of the ejecta to be sampled
            glob_vars,
            # dictionary of ejecta parameters defining its composition and geometry
            ejecta_params,
            # dictionary of shell parameters defining basic properties of the shell
            shell_params,
            source_name,
            **kwargs):

        super(MKN, self).__init__(**kwargs)

        # initializing the global properties of the source
        print('I am initializing the global properties of the source')
        SP = sp.SourceProperties(source_name)
        self.D = SP.D
        self.view_angle = SP.view_angle

        # initialize the angular distribution
        print('I am initializing the angles')
        self.n_slices = glob_params['n slices']
        self.dist_slices = glob_params['dist slices']
        self.AD = ad.AngularDistribution(self.dist_slices, self.n_slices)
        self.angular_distribution, self.omega_distribution = self.AD(
            self.n_slices / 2
        )  # due to the symmetry abount the equatorial plane, the number of independent slices is half

        # initialize the filters
        print('I am initializing the filters')
        if (source_name == 'default'):
            self.FT = ft.Filters("properties")
        else:
            self.FT = ft.Filters("measures")
        self.dic_filt, self.lambda_vec, self.mag = self.FT(
            SP.filter_data_folder)

        #initialize the time
        print('I am initializing the global time')
        self.time_min = glob_params['time min']
        self.time_max = glob_params['time max']
        self.n_time = glob_params['n time']
        self.tscale = glob_params['scale for t']
        self.t0 = SP.t0
        if (self.tscale == "measures" and source_name == 'default'):
            print('')
            print("no measures available to set the time (default option)")
            print("please use linear or log scale")
            exit()

        self.time = SP.init_time(self.tscale, self.time_min, self.time_max,
                                 self.n_time, self.mag)

        #initialize the observer location
        print('I am initializing the observer orientation')
        self.FF = op.ObserverProjection(self.n_slices, self.dist_slices)
        #        self.flux_factor = self.FF(SP.view_angle)

        # register the geometry of the ejecta and create an Ejecta object
        self.glob_params = glob_params
        self.glob_vars = glob_vars
        self.ejecta_params = ejecta_params
        self.shell_params = shell_params
        self.ejecta = ej.Ejecta(len(self.ejecta_params),
                                self.ejecta_params.keys(), self.ejecta_params)

        print('I am initializing the components')
        self.E = ej.Ejecta(Nshell, self.ejecta_params.keys(),
                           self.ejecta_params)
Пример #15
0
 def __init__(self, options):
     self._filters = filters.Filters(options)