numpy.right_shift

Here are the examples of the python api numpy.right_shift taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: mpop Source File: aapp1b.py
Function: calibrate
    def calibrate(self, chns=("1", "2", "3A", "3B", "4", "5"),
                  calibrate=1, pre_launch_coeffs=False, calib_coeffs=None):
        """Calibrate the data
        """
        tic = datetime.datetime.now()

        channels = {'1': [], '2': [], '3A': [], '3B': [], '4': [], '5': []}
        is3b_all = []

        i = 0
        for data in self._data:

            if "1" in chns:
                LOGGER.debug("Calibrating channel 1.")
                if calib_coeffs is not None:
                    coeffs = calib_coeffs['ch1']
                else:
                    coeffs = None
                channels['1'].append(_vis_calibrate(data, 0,
                                                    calibrate,
                                                    pre_launch_coeffs,
                                                    coeffs))
                self.units['1'] = '%'
                if calibrate == 0:
                    self.units['1'] = ''

            if "2" in chns:
                LOGGER.debug("Calibrating channel 2.")
                if calib_coeffs is not None:
                    coeffs = calib_coeffs['ch2']
                else:
                    coeffs = None
                channels['2'].append(_vis_calibrate(data, 1,
                                                    calibrate,
                                                    pre_launch_coeffs,
                                                    coeffs))
                self.units['2'] = '%'
                if calibrate == 0:
                    self.units['2'] = ''

            if "3A" in chns or "3B" in chns:
                # Is it 3A or 3B:
                is3b = np.expand_dims(np.bitwise_and(
                    np.right_shift(data['scnlinbit'], 0), 1) == 1, 1)
                # self._is3b = is3b
                is3b_all.append(is3b)

            if "3A" in chns:
                LOGGER.debug("Calibrating channel 3a.")
                if calib_coeffs is not None:
                    coeffs = calib_coeffs['ch3a']
                else:
                    coeffs = None
                ch3a = _vis_calibrate(data, 2,
                                      calibrate, pre_launch_coeffs,
                                      coeffs)
                channels['3A'].append(np.ma.masked_array(ch3a, is3b * ch3a))

                self.units['3A'] = '%'
                if calibrate == 0:
                    self.units['3A'] = ''

            if "3B" in chns:
                LOGGER.debug("Calibrating channel 3b.")
                ch3b = _ir_calibrate(self._header[i], data, 0, calibrate)
                channels['3B'].append(
                    np.ma.masked_array(ch3b,
                                       np.logical_or((is3b is False) *
                                                     ch3b,
                                                     ch3b < 0.1)))
                if calibrate == 1:
                    self.units['3B'] = 'K'
                elif calibrate == 2:
                    self.units['3B'] = 'W*m-2*sr-1*cm ?'
                else:
                    self.units['3B'] = ''

            if "4" in chns:
                LOGGER.debug("Calibrating channel 4.")
                channels['4'].append(_ir_calibrate(self._header[i],
                                                   data, 1, calibrate))
                if calibrate == 1:
                    self.units['4'] = 'K'
                elif calibrate == 2:
                    self.units['4'] = 'W*m-2*sr-1*cm ?'
                else:
                    self.units['4'] = ''

            if "5" in chns:
                LOGGER.debug("Calibrating channel 5.")
                channels['5'].append(_ir_calibrate(self._header[i],
                                                   data, 2, calibrate))
                if calibrate == 1:
                    self.units['5'] = 'K'
                elif calibrate == 2:
                    self.units['5'] = 'W*m-2*sr-1*cm ?'
                else:
                    self.units['5'] = ''

            i += 1

        # transfer channel data to class attributes
        for ch_ in channels:
            try:
                self.channels[ch_] = np.ma.vstack(channels[ch_])
            except ValueError:
                self.channels[ch_] = None
        if "3A" in chns or "3B" in chns:
            self._is3b = np.vstack(is3b_all)
        if "3A" in chns:
            self.channels['3A'].mask = self._is3b * self.channels['3A']
        if "3B" in chns:
            self.channels['3B'].mask = np.logical_or((self._is3b is False) *
                                                     self.channels['3B'],
                                                     self.channels['3B'] < 0.1)

        LOGGER.debug("Calibration time %s", str(datetime.datetime.now() - tic))

Example 2

Project: omnivore Source File: commands.py
Function: get_data
    def get_data(self, orig):
        return np.right_shift(orig, 1)