Returns (channel, column, row) given an (ra, dec) coordinate.

        Returns (0, 0, 0) or a ValueError if the coordinate is not on silicon.
500381
def getChannelColRow(self, ra, dec, wantZeroOffset=False,
                         allowIllegalReturnValues=True):
        
        try:
            ch = self.pickAChannel(ra, dec)
        except ValueError:
            logger.warning("WARN: %.7f %.7f not on any channel" % (ra, dec))
            return (0, 0, 0)

        col, row = self.getColRowWithinChannel(ra, dec, ch, wantZeroOffset,
                                               allowIllegalReturnValues)
        return (ch, col, row)
1328615
def xy2rd(input,x=None,y=None,coords=None, coordfile=None,colnames=None,separator=None,
            hms=True, precision=6,output=None,verbose=True):
    
    single_coord = False
    # Only use value provided in `coords` if nothing has been specified for coordfile
    if coords is not None and coordfile is None:
        coordfile = coords
        warnings.simplefilter('always',DeprecationWarning)
        warnings.warn("Please update calling code to pass in `coordfile` instead of `coords`.",
            category=DeprecationWarning)
        warnings.simplefilter('default',DeprecationWarning)

    if coordfile is not None:
        if colnames in blank_list:
            colnames = ['c1','c2']
        # Determine columns which contain pixel positions
        cols = util.parse_colnames(colnames,coordfile)
        # read in columns from input coordinates file
        xyvals = np.loadtxt(coordfile,usecols=cols,delimiter=separator)
        if xyvals.ndim == 1:  # only 1 entry in coordfile
            xlist = [xyvals[0].copy()]
            ylist = [xyvals[1].copy()]
        else:
            xlist = xyvals[:,0].copy()
            ylist = xyvals[:,1].copy()
        del xyvals
    else:
        if isinstance(x, np.ndarray):
            xlist = x.tolist()
            ylist = y.tolist()
        elif not isinstance(x,list):
            xlist = [x]
            ylist = [y]
            single_coord = True
        else:
            xlist = x
            ylist = y

    # start by reading in WCS+distortion info for input image
    inwcs = wcsutil.HSTWCS(input)
    if inwcs.wcs.is_unity():
        print("####\nNo valid WCS found in {}.\n  Results may be invalid.\n####\n".format(input))

    # Now, convert pixel coordinates into sky coordinates
    dra,ddec = inwcs.all_pix2world(xlist,ylist,1)

    # convert to HH:MM:SS.S format, if specified
    if hms:
        ra,dec = wcs_functions.ddtohms(dra,ddec,precision=precision)
        rastr = ra
        decstr = dec
    else:
        # add formatting based on precision here...
        rastr = []
        decstr = []
        fmt = "%."+repr(precision)+"f"
        for r,d in zip(dra,ddec):
            rastr.append(fmt%r)
            decstr.append(fmt%d)

        ra = dra
        dec = ddec

    if verbose or (not verbose and util.is_blank(output)):
        print('# Coordinate transformations for ',input)
        print('# X      Y         RA             Dec\n')
        for x,y,r,d in zip(xlist,ylist,rastr,decstr):
            print("%.4f  %.4f    %s  %s"%(x,y,r,d))

    # Create output file, if specified
    if output:
        f = open(output,mode='w')
        f.write("# Coordinates converted from %s\n"%input)
        for r,d in zip(rastr,decstr):
            f.write('%s    %s\n'%(r,d))
        f.close()
        print('Wrote out results to: ',output)

    if single_coord:
        ra = ra[0]
        dec = dec[0]

    return ra,dec
969164
def get_value_by_xy(self, x, y):
        
        if x < self.xMin or x > self.xMax or y < self.yMin or y > self.yMax:
            return None
            # raise ValueError("The x or y value must be within the Min and Max!")
        else:
            row = self.nRows - int(numpy.ceil((y - self.yMin) / self.dx))
            col = int(numpy.floor((x - self.xMin) / self.dx))
            value = self.data[row][col]
            if value == self.noDataValue:
                return None
            else:
                return value
640852
def _convert_radec(self, val):
        
        try:
            ans = val.to('deg')
        except Exception as e:
            self.logger.error('Cannot convert, assume already in degrees')
            ans = val.data
        else:
            ans = ans.value

        return ans
897987
def _idx_col2rowm(d):
    """"""
    if 0 == len(d):
        return 1
    if 1 == len(d):
        return np.arange(d[0])
    # order='F' indicates column-major ordering
    idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
    return idx.flatten(order='F')
1307321
def channel_view(x:Tensor)->Tensor:
    ""
    return x.transpose(0,1).contiguous().view(x.shape[1],-1)
574826
def __get_slice(data, slice_number, axis=0, flipH=False, flipV=False):
    
    if axis == 0:
        data2d =  data[slice_number, :, :]
    elif axis == 1:
        data2d = data[:, slice_number, :]
    elif axis == 2:
        data2d = data[:, :, slice_number]
    else:
        logger.error("axis number error")
        print("axis number error")
        return None

    if flipV:
        if data2d is not None:
            data2d = data2d[-1:0:-1,:]
    if flipH:
        if data2d is not None:
            data2d = data2d[:, -1:0:-1]
    return data2d
595402
def _get_c(cls, df, column, shifts):
        
        column_name = '{}_{}_{}'.format(column, shifts, 'c')
        shifts = abs(cls.to_int(shifts))
        df[column_name] = df[column].rolling(
            center=False, window=shifts).apply(np.count_nonzero)
932136
def num_col(self):
        
        ret = ctypes.c_uint()
        _check_call(_LIB.XGDMatrixNumCol(self.handle,
                                         ctypes.byref(ret)))
        return ret.value
1084220
def to(self, unit):
        """"""
        from astropy.units import rad
        return (self.radians * rad).to(unit)

        # Or should this do:
        from astropy.coordinates import Angle
        from astropy.units import rad
        return Angle(self.radians, rad).to(unit)
1110638
int getAxis(LinuxEventBuffer buffer) {
        int axis = buffer.getEventCode();
        if (flipXY) {
            switch (axis) {
                case LinuxInput.ABS_X: return LinuxInput.ABS_Y;
                case LinuxInput.ABS_Y: return LinuxInput.ABS_X;
                case LinuxInput.ABS_MT_POSITION_X: return LinuxInput.ABS_MT_POSITION_Y;
                case LinuxInput.ABS_MT_POSITION_Y: return LinuxInput.ABS_MT_POSITION_X;
                default:
                    return axis;
            }
        } else {
            return axis;
        }
    }
224505
def as_point(row):
    ''''''
    return Point(row[COLS.X], row[COLS.Y], row[COLS.Z],
                 row[COLS.R], int(row[COLS.TYPE]))
289252
def pickAChannel(self, ra_deg, dec_deg):
        
        # Could improve speed by doing this in the projection plane
        # instead of sky coords
        cRa = self.currentRaDec[:, 3]  # Ra of each channel corner
        cDec = self.currentRaDec[:, 4]  # dec of each channel corner

        dist = cRa * 0
        for i in range(len(dist)):
            dist[i] = gcircle.sphericalAngSep(cRa[i], cDec[i], ra_deg, dec_deg)

        i = np.argmin(dist)
        return self.currentRaDec[i, 2]
742750
def pickAChannelList(self, ra_deg, dec_deg):
        
        try:
            from astropy.coordinates import SkyCoord
            from astropy import units as u
        except ImportError:
            raise ImportError("AstroPy needs to be installed to use this feature.")
        cRa = self.currentRaDec[:, 3]  # Ra of each channel corner
        cDec = self.currentRaDec[:, 4]  # dec of each channel corner
        catalog = SkyCoord(cRa*u.deg, cDec*u.deg)
        position = SkyCoord(ra_deg*u.deg, dec_deg*u.deg)
        idx, _, _ = position.match_to_catalog_sky(catalog)
        return self.currentRaDec[idx, 2]
574673
def _get_val(self, soln, r, c):
        """"""
        for v in range(1, 10):
            if soln[self.X[r, c, v]]:
                return DIGITS[v-1]
        return "X"
334473
def get(self, x, y):
        
        x = normalize(x)
        y = normalize(y)
        dot_index = pixel_map[y % 4][x % 2]
        col, row = get_pos(x, y)
        char = self.chars.get(row, {}).get(col)

        if not char:
            return False

        if type(char) != int:
            return True

        return bool(char & dot_index)
576721
def proc_line_coordinate(self, line):
        """"""
        at_type = line[0:6].strip()  # 0
        at_ser = int(line[6:11].strip())  # 1
        at_name = line[12:16].strip()  # 2
        alt_loc = line[16].strip()  # 3
        res_name = line[17:20].strip()  # 4
        chain_id = line[21].strip()  # 5
        res_seq = int(line[22:26].strip())  # 6
        i_code = line[26].strip()  # 7
        x = float(line[30:38].strip())  # 8
        y = float(line[38:46].strip())  # 9
        z = float(line[46:54].strip())  # 10
        occupancy = float(line[54:60].strip())  # 11
        temp_factor = float(line[60:66].strip())  # 12
        element = line[76:78].strip()  # 13
        charge = line[78:80].strip()  # 14
        if at_name not in PDB_ATOM_COLUMNS:
            PDB_ATOM_COLUMNS[at_name] = line[12:16]
            self.new_labels = True
        return (at_type, at_ser, at_name, alt_loc, res_name, chain_id, res_seq,
                i_code, x, y, z, occupancy, temp_factor, element, charge)