예제 #1
0
    def dict_to_parms(self, params, id=None):
        '''
        '''

        if id:
            data = Params(params).get_conf(id_conf=id)
        else:
            data = Params(params).get_conf(dtype='rc')

        # self.name = data['name']
        self.ipp = data['ipp']
        self.ntx = data['ntx']
        self.clock_in = data['clock_in']
        self.clock_divider = data['clock_divider']
        self.clock = data['clock']
        self.time_before = data['time_before']
        self.time_after = data['time_after']
        self.sync = data['sync']
        self.sampling_reference = data['sampling_reference']
        self.total_units = self.ipp * self.ntx * self.km2unit
        self.save()
        self.clean_lines()

        positions = {'tx': 0, 'tr': 0}
        for i, id in enumerate(data['lines']):
            line_data = params['lines']['byId'][id]
            line_type = RCLineType.objects.get(name=line_data['line_type'])
            if line_type.name == 'codes':
                code = RCLineCode.objects.get(name=line_data['params']['code'])
                line_data['params']['code'] = code.pk
            if line_type.name == 'tx':
                position = positions['tx']
                positions['tx'] += 1
            elif line_type.name == 'tr':
                position = positions['tr']
                positions['tr'] += 1
            else:
                position = 0
            line, dum = RCLine.objects.update_or_create(
                rc_configuration=self,
                channel=i,
                position=position,
                defaults={
                    'line_type': line_type,
                    'params': json.dumps(line_data['params'])
                })

        for i, line in enumerate(self.get_lines()):
            line_params = json.loads(line.params)
            if 'TX_ref' in line_params:
                if line_params['TX_ref'] in (0, '0'):
                    line_params['TX_ref'] = '0'
                else:
                    ref_id = '{}'.format(line_params['TX_ref'])
                    ref_line = params['lines']['byId'][ref_id]
                    line_params['TX_ref'] = RCLine.objects.get(
                        rc_configuration=self,
                        params=json.dumps(ref_line['params'])).pk
                line.params = json.dumps(line_params)
                line.save()
예제 #2
0
    def parms_to_dict(self):

        params = Params({})
        params.add(self.jsonify(), 'campaigns')

        for exp in Experiment.objects.filter(campaign = self):
            params.add(exp.jsonify(), 'experiments')
            configurations = Configuration.objects.filter(experiment=exp, type=0)

            for conf in configurations:
                params.add(conf.jsonify(), 'configurations')
                if conf.device.device_type.name=='rc':
                    for line in conf.get_lines():
                        params.add(line.jsonify(), 'lines')

        return params.data
예제 #3
0
    def dict_to_parms(self, parameters, id=None):

        params = Params(parameters)

        if id:
            data = params.get_conf(id_conf=id)
        else:
            data = params.get_conf(dtype=self.device.device_type.name)

        if data['device_type']=='rc':
            self.clean_lines()
            lines = data.pop('lines', None)
            for line_id in lines:
                pass

        for key, value in data.items():
            if key not in ('id', 'device_type'):
                setattr(self, key, value)

        self.save()
예제 #4
0
    def dict_to_parms(self, params, id=None):

        if id is not None:
            data = Params(params).get_conf(id_conf=id)
        else:
            data = Params(params).get_conf(dtype='jars')
            data['filter_parms'] = params['filter_parms']

        # self.name = data['name']
        self.exp_type = data['exp_type']
        #----PDATA----
        if self.exp_type == 1:
            self.incohe_integr = data['incohe_integr']
            self.spectral_number = data['spectral_number']
            self.spectral = data['spectral']
            self.fftpoints = data['fftpoints']
            self.save_ch_dc = data['save_ch_dc']
        else:
            self.raw_data_blocks = data['raw_data_blocks']
        #----PDATA----
        self.cards_number = data['cards_number']
        self.channels_number = data['channels_number']
        self.channels = data['channels']
        self.data_type = data['data_type']
        self.profiles_block = data['profiles_block']
        self.acq_profiles = data['acq_profiles']
        self.ftp_interval = data['ftp_interval']
        self.cohe_integr_str = data['cohe_integr_str']
        self.cohe_integr = data['cohe_integr']
        #----DECODE----
        self.decode_data = data['decode_data']
        self.post_coh_int = data['post_coh_int']
        #----DECODE----
        self.create_directory = data['create_directory']
        self.include_expname = data['include_expname']
        self.save_data = data['save_data']
        self.filter_parms = json.dumps(data['filter_parms'])

        self.save()
예제 #5
0
    def to_dict(self):

        out = Params()
        out.add(self.data, 'configurations')
        for line_data in self.lines:
            out.add(line_data, 'lines')

        return out.data
예제 #6
0
    def parms_to_dict(self):

        params = Params({})
        params.add(self.jsonify(), 'configurations')

        if self.device.device_type.name=='rc':
            for line in self.get_lines():
                params.add(line.jsonify(), 'lines')

        return params.data