Пример #1
0
 def conv_to_Iq(self, qidi, mask, dz=True, w=3, tol=3, cor=0):
     """ convert solution scattering/powder diffraction data into 1D scattering curve
     the q axis is given by grid (1d array)
     calls the C-code in RQconv
     the cor parameter can take positive or negative values
     if cor>0, the 1D data will be corrected for (divided by) the factor due to polarization
     and the non-normal incident X-rays onto the detector
     if cor<0, the 1D data will be multipled by this factor instead. this is useful to
     build this correction into the flat field correction
     """
     # apply the mask before passing the data to RQconv
     # RQconv should discard all data with zero intensity
     dm = np.zeros((self.height, self.width), np.int32) + 1
     # dm = 1-np.asarray(mask.map,np.int32)
     if dz:
         print("dezinger ...")
         RQconv.dezinger(self.data.astype(np.int32), dm, w, tol)
     # NOTE: use self.data+1, instead of self.data, to avoid confusion betwee
     # zero-count pixels and masked pixels. The added 1 count will be subtracted in RQconv
     # print (dm*2-1==0).any()
     # dm = (dm*2-1)*self.data
     dm = np.multiply(dm, (1 - mask.map) * (self.data + 1)).astype(np.int32)
     # plt.figure()
     # plt.imshow(dm)
     RQconv.conv_to_Iq(dm, self.exp, qidi, cor)
Пример #2
0
 def set_exp_para(self, exp):
     if exp.flip:
         self.im = np.fliplr(np.rot90(self.im))
         self.data = np.asarray(self.im).copy()
         (self.height, self.width) = np.shape(self.data)
     self.exp = exp
     RQconv.calc_rot(self.exp)
Пример #3
0
 def merge2(self, dset):
     """ intended to merge dset with self, doesn't work, see notes in RQconv.c
     """
     if not self.data.shape == dset.data.shape:
         print("merging 2D data sets have different shapes:")
         print(self.shape, " and ", dset.data.shape, "\n")
         exit()
     RQconv.merge(self.data, dset.data)
Пример #4
0
 def conv_to_Iqrqz(self):
     # calls the C-code in RQconv
     self.q_data_available = True
     if self.qdata is not None:
         del self.qdata
     RQconv.pre_conv_Iqrqz(self.data.astype(np.int32), self.exp)
     self.qdata = np.ones((self.exp.nz, self.exp.nr), dtype=np.int32)
     RQconv.conv_to_Iqrqz(self.data.astype(np.int32), self.qdata, self.exp)
Пример #5
0
 def cor_IAdep_2D(self, mask=None, corCode=3, invert=False):
     """ if invert==True, the data is mulitplied by the correction factor, instead of being divided by
         this is useful for obtaining the correction factor itself for each pixel
     """
     dm = np.ones((self.height, self.width), np.int32)
     if mask is not None:
         dm *= (1 - mask.map) * self.data
     else:
         dm *= self.data
     RQconv.cor_IAdep_2D(dm, self.exp, corCode, invert)
     self.data = dm
Пример #6
0
    def qrqz2xy(self, qr, qz):
        """calls the C-code in RQconv
        need to deal with the special situation when the (qr, qz) is not visible on the detector
        use the smallest allowable qr at the same qz instead
        this is done in RQconv, with the last argument in RQconv.qrqz2xy set to 1
        """

        ret = RQconv.qrqz2xy(self.data.astype(np.int32), self.exp, qr, qz, 1)
        return ret.x, ret.y
Пример #7
0
 def val(self, fx, fy):
     """ intensity at the pixel position (fx, fy), interpolatd from the neighbors 
     """
     """
     ix = int(fx)
     iy = int(fy)
     if ix<0 or iy<0 or ix>=self.width or iy>=self.height : return(0)
     t = (1.-(fx-ix))*(1.-(fy-iy))*self.data[iy,ix]
     t += (fx-ix)*(1.-(fy-iy))*self.data[iy+1,ix]
     t += (1.-(fx-ix))*(fy-iy)*self.data[iy,ix+1]
     t += (fx-ix)*(fy-iy)*self.data[iy+1,ix+1]
     return t
     """
     return RQconv.get_value(self.data, fx, fy)
Пример #8
0
 def xy2q(self, x, y):
     """calls the C-code in RQconv
     """
     return RQconv.xy2q(self.data, self.exp, x, y)
Пример #9
0
 def xy2qrqz(self, x, y):
     """calls the C-code in RQconv
     """
     ret = RQconv.xy2qrqz(self.data, self.exp, x, y)
     return ret.x, ret.y
Пример #10
0
 def qphi2xy(self, q, phi):
     """calls the C-code in RQconv
     """
     # print q,phi
     ret = RQconv.qphi2xy(self.data.astype(np.int32), self.exp, q, phi)
     return ret.x, ret.y