Apply units to :class:`ParameterizedXLS` data reader.
424631
def apply_units_to_cache(self, data):
        
        # parameter
        parameter_name = self.parameters['parameter']['name']
        parameter_units = str(self.parameters['parameter']['units'])
        data[parameter_name] *= UREG(parameter_units)
        # data
        self.parameters.pop('parameter')
        return super(ParameterizedXLS, self).apply_units_to_cache(data)
657486
def unitized(value, unit, base=DEFAULT_BASE):
    
    exponent = 0 if not unit else UNITS.index(unit) + 1
    return int(value * (base ** exponent))
1233807
def _to_unit_base(self, base_unit, values, unit, from_unit):
        """"""
        self._is_numeric(values)
        namespace = {'self': self, 'values': values}
        if not from_unit == base_unit:
            self.is_unit_acceptable(from_unit, True)
            statement = '[self._{}_to_{}(val) for val in values]'.format(
                self._clean(from_unit), self._clean(base_unit))
            values = eval(statement, namespace)
            namespace['values'] = values
        if not unit == base_unit:
            self.is_unit_acceptable(unit, True)
            statement = '[self._{}_to_{}(val) for val in values]'.format(
                self._clean(base_unit), self._clean(unit))
            values = eval(statement, namespace)
        return values
1241039
def _add_converted_units(self, dataframe, parameter, key='VALUE'):
        """"""
        convert_unit = self.parameters.get_converter(parameter)
        try:
            log.debug("Adding unit converted DATA_VALUE to the data")
            dataframe[key] = dataframe['DATA_VALUE'].apply(convert_unit)
        except KeyError:
            log.warning("Missing 'VALUE': no unit conversion.")
        else:
            dataframe.unit = self.parameters.unit(parameter)
334254
def units(self):
        
        self._units, value = self.get_attr_string(self._units, 'units')
        return value
700203
def slice_atomic_unit(str)
      label = ''
      str.scan(/_?[^_]+/) do |chunk|
        label << chunk
        unit = create_atomic(label)
        return label, unit if unit
      end
      raise MeasurementError.new("Unit '#{str}' not found")
    end
1173736
def convert(self, value, fromunits, tounits):
        ''''''
        if fromunits == tounits:
            return value
        if (fromunits,tounits) in self.unitmap:
            return value * self.unitmap[(fromunits,tounits)]
        if (tounits,fromunits) in self.unitmap:
            return value / self.unitmap[(tounits,fromunits)]
        raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
1046295
def apply_units_to_cache(self, data):
        
        for k, val in self.parameters.iteritems():
            if 'units' in val:
                data[k] = Q_(data[k], val.get('units'))
        return data
1098852
def extract_units(string_in):
    
    start = '('
    stop = ')'
    return string_in[string_in.index(start) + 1:string_in.index(stop)]
438052
def units(self, val):
        """"""
        if isinstance(val, units.Unit):
            self._unit = val
        else:
            self._unit = units(val)
33320
def _pprint(self, element, dim_label, vals):
        

        if vals.dtype.kind not in 'SU':
            dim = element.gridded.get_dimension(dim_label)
            return [dim.pprint_value(v) for v in vals]

        return vals
1296040
def _load_int(self):
        """"""
        values = numpy.fromfile(self.filepath_int)
        if self.NDIM > 0:
            values = values.reshape(self.seriesshape)
        return values
456298
def get_relavent_units(self):
        '''
        
        '''
        relavent_units = {}

        for location,unit in self.units.items():
            if self.unit_is_related(location, self.worksheet):
                relavent_units[location] = unit

        return relavent_units
428731
def as_unit(self, unit, location='suffix', *args, **kwargs):
        
        f = Formatter(
            as_unit(unit, location=location),
            args,
            kwargs
        )
        return self._add_formatter(f)
1337585
def read_units(self, fid):
        """"""
        lin = self.read_line(fid)                   
        while lin[0] != ':':
            parts = lin.split()
            if parts[0]=='mass':
                self.mass = float(parts[1])
            elif parts[0]=='length':
                self.length = float(parts[1])
            elif parts[0]=='angle':
                self.angle = parts[1]
            lin = self.read_line(fid)
        return lin
652774
def get_units(unit, binary=False):
    ''' 
    '''
    result = None

    if unit == 'b':
        result = 1, 'Byte'

    elif binary:    # 2^X
        if   unit == 'k':
            result = 1024, 'Kibibyte'
        elif unit == 'm':
            result = 1048576, 'Mebibyte'
        elif unit == 'g':
            if opts.precision == -1:
                opts.precision = 3
            result = 1073741824, 'Gibibyte'
        elif unit == 't':
            if opts.precision == -1:
                opts.precision = 3
            result = 1099511627776, 'Tebibyte'

    else:           #  10^x
        if   unit == 'k':
            result = 1000, 'Kilobyte'
        elif unit == 'm':
            result = 1000000, 'Megabyte'
        elif unit == 'g':
            if opts.precision == -1:
                opts.precision = 3      # new defaults
            result = 1000000000, 'Gigabyte'
        elif unit == 't':
            if opts.precision == -1:
                opts.precision = 3
            result = 1000000000000, 'Terabyte'

    if not result:
        print(f'Warning: incorrect parameter: {unit}.')
        result = _outunit

    if opts.precision == -1:  # auto
        opts.precision = 0
    return result
944301
def get_units(**kwargs):
    
    units_list = db.DBSession.query(Unit).all()
    units = []
    for unit in units_list:
        new_unit = JSONObject(unit)
        units.append(new_unit)

    return units