Esempio n. 1
0
    def create_im_seq(self,
                      spots,
                      timing,
                      intensities,
                      grouptimes,
                      isProbe,
                      rig,
                      label=''):
        spotlist = []
        for ptn, this_timing, this_intensity in zip(spots, timing,
                                                    intensities):

            #to specify random timing, put timing in nested list of bounds
            #[[onset1,onset2],[dur1,dur2]]
            #timing will have random onset in [onset1,onset2] and random duration in [dur1,dur2]

            xy_is_rand = False

            if isinstance(this_timing[0], list) or isinstance(
                    this_timing[1], list):
                timing_is_rand = True
            else:
                timing_is_rand = False

            if isinstance(this_intensity, list):
                intensity_is_rand = True
            else:
                intensity_is_rand = False

            if timing_is_rand:
                spot_obj = self.createRandomSpot(xy_is_rand, timing_is_rand,
                                                 intensity_is_rand)
                spot_obj.timing_bounds = this_timing
            else:
                spot_obj = spot.Spot(rig, )
                spot_obj.set_timing(this_timing)

            spot_obj.set_ptn(ptn)
            spot_obj.set_intensity(this_intensity)
            spotlist.append(spot_obj)

        if any(isinstance(i, spot.RandomSpot) for i in spotlist):
            self.isRandomSequence = True

        self.spotlist = spotlist
        self.isProbe = isProbe
        self.label = label

        if self.isRandomSequence:
            self.randomize()
        else:
            self.update()
Esempio n. 2
0
    def detectCommand(self):
        self.pause = False
        self.suspend = False
        # it will wait until fronter feature is processed
        if self.lcMark.get() == 1:  # license number check
            self.feature_queue.append(plate.Plate(position=self.UAV.region.center,log=self.log))
            self.lcMark.set(0)

        if self.acMark.get() == 1:  # annual mark check
            self.feature_queue.append(ancheck.Ancheck(log=self.log))
            self.acMark.set(0)

        if self.spMark.get() == 1:
            self.feature_queue.append(spot.Spot(position=self.UAV.region.center,log=self.log))
            self.spMark.set(0)
Esempio n. 3
0
# coding=utf-8
import spot as s

if __name__ == '__main__':

    # input your personal api info
    api_key = ''
    seceret_key = ''
    passphrase = ''

    # make a spot instance
    spot_instance = s.Spot(api_key, seceret_key, passphrase, True)

    # spot function

    # query account
    # example = spot_instance.get_account()

    # query ledger
    # example = spot_instance.get_ledger('ct', before='', after='', limit='')

    # withdraw
    # example = spot_instance.withdraw('usdt', 100, '')

    # order
    example = spot_instance.order('limit',
                                  'sell',
                                  'ct_usdt',
                                  '1',
                                  '10',
                                  funds='')
Esempio n. 4
0
shift = 1
spot_loc = {
    'north': (x + shift, y),
    'south': (x - shift, y),
    'east': (x, y - shift),
    'west': (x, y + shift),
    'NW': (x + shift, y + shift),
    'NE': (x + shift, y - shift),
    'SW': (x - shift, y + shift),
    'SE': (x - shift, y - shift)
}

spots = {}

for loc in spot_loc:
    s = spot.Spot('ALP')
    s.set_xy(spot_loc[loc], gridsize)
    spots[loc] = s.ptn

stimulated = spots['north'] + spots['south'] + spots['east'] + spots['west']
ALP.stop()
ALP.seq_upload(seq_id, [stimulated])
ALP.seq_start(seq_id)
raw_input()

stimulated = spots['north']
ALP.stop()
ALP.seq_upload(seq_id, [stimulated])
ALP.seq_start(seq_id)
raw_input()
Esempio n. 5
0
    def create_xy_seq(self,
                      spots,
                      spotsizes,
                      timing,
                      intensities,
                      grouptimes,
                      rand_args,
                      isProbe,
                      rig,
                      label=''):
        """
        takes list of spot coordinates e.g.[[a1,a2],[b1,b2]]
        and spot timings, [[onseta,offseta],[onsetb,offsetb]]
        creates spot.Spot object for each 
        and then a sequence object to encapsulate
        sequence will be RandomSequence if any spots are random
        """
        min_spacing = 0
        spotlist = []

        if len(grouptimes) != len(spots):
            grouptimes = [[]] * len(spots)
        self.rand_args = rand_args

        for xy, size, this_timing, this_intensity, grouptime in zip(
                spots, spotsizes, timing, intensities, grouptimes):
            if xy == ['random']:
                xy_is_rand = True
            else:
                xy_is_rand = False

            if xy == ['empty']:
                size = 0
                xy = [0, 0]

            #to specify random timing, put timing in nested list of bounds
            #[[onset1,onset2],[dur1,dur2]]
            #timing will have random onset in [onset1,onset2] and random duration in [dur1,dur2]

            if isinstance(this_timing[0], list) or isinstance(
                    this_timing[1], list):
                timing_is_rand = True
            else:
                timing_is_rand = False

            self.timing_is_rand = timing_is_rand  #to be used for grouptimes later

            if isinstance(this_intensity, list):
                intensity_is_rand = True
            else:
                intensity_is_rand = False

            if xy_is_rand or timing_is_rand or intensity_is_rand:
                spot_obj = self.createRandomSpot(xy_is_rand, timing_is_rand,
                                                 intensity_is_rand)

                if xy_is_rand:
                    spot_obj.init_xy(size, min_spacing)
                else:
                    spot_obj.set_xy(xy, size)

                if timing_is_rand:
                    spot_obj.timing_bounds = this_timing
                    spot_obj.grouptime = grouptime
                else:
                    spot_obj.set_timing(this_timing)

                if intensity_is_rand:
                    spot_obj.intensity_bounds = this_intensity
                else:
                    spot_obj.set_intensity(this_intensity)

            else:
                spot_obj = spot.Spot(rig)
                spot_obj.set_xy(xy, size)
                spot_obj.set_timing(this_timing)
                spot_obj.set_intensity(this_intensity)

            spotlist.append(spot_obj)

        self.spotlist = spotlist
        self.isProbe = isProbe
        self.label = label

        if (self.rand_args['omit'] > 0) or (self.rand_args['replace'] > 0):
            self.isRandomSequence = True
            self.original_spotlist = deepcopy(
                spotlist)  #create copy for omission/replacement later

        if self.rand_args['scramble'] == 1:
            self.isRandomSequence = True

        if sum(np.array(self.rand_args.values()) > 0) > 1:
            if self.rand_args['meanT'] != 0:
                print 'Multiple rand args initialized, with meanT', self.rand_args[
                    'meanT']
            else:
                raise ValueError('More than one rand arg initialized. Check ' +
                                 self.label)

        if self.rand_args[
                'randt'] > 0:  #select different partitions by randt param
            self.isRandomSequence = True
            self.original_spotlist = deepcopy(
                spotlist)  #create copy for timing rand later
            sample_number = self.rand_args['randt']

            old_target = [tuple(s.timing) for s in self.original_spotlist]
            old_target.sort()

            self.shifter = time_shifter.partition_shifter(
                sample_number, old_target)

        if self.rand_args[
                'randdur'] > 0:  #select different partitions rand dur schemes
            self.isRandomSequence = True
            self.original_spotlist = deepcopy(
                spotlist)  #create copy for timing rand later
            scheme_number = self.rand_args['randdur']
            self.shifter = time_shifter.duration_shifter(scheme_number)

        if self.rand_args['randxyt'] > 0:  #replace and shift
            self.isRandomSequence = True
            self.original_spotlist = deepcopy(spotlist)

        if any(isinstance(i, spot.RandomSpot) for i in spotlist):
            self.isRandomSequence = True
            self.randomize()
        else:
            self.update()
Esempio n. 6
0
from django.db.utils import OperationalError

while True:
    try:
        new_spot = None
        d = None
        try:
            #print >> sys.stderr, "Connecting..."
            d = DXClusterReader(timeout=60)
            #print >> sys.stderr, "Connected!"
            while True:
                print "Awaiting a new spot"
                new_spot = d.get_next_spot()
                print "Received a new spot!"
                s = spot.Spot(new_spot)
                print s

                spot_object = Spot()
                spot_object.spotter = s.spotter_call
                spot_object.station = s.dx_call
                spot_object.frequency = s.frequency
                spot_object.comment = s.comment
                spot_object.time = s.time
                spot_object.locator = s.locator

                save_attempt = 0
                while True:
                    save_attempt += 1
                    if save_attempt > 10:
                        raise OperationalError