Ignore:
Timestamp:
05/20/11 18:53:58 (13 years ago)
Author:
WataruKawasaki
Message:

New Development: Yes

JIRA Issue: Yes CAS-2828

Ready for Test: Yes

Interface Changes:

What Interface Changed:

Test Programs:

Put in Release Notes:

Module(s): SD

Description: created a tool function sd.scantable.fft() to apply FFT for scantable data.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r2150 r2177  
    10831083        """\
    10841084        Flag the data in 'lag' space by providing a frequency to remove.
    1085         Flagged data in the scantable gets interpolated over the region.
     1085        Flagged data in the scantable get interpolated over the region.
    10861086        No taper is applied.
    10871087
     
    11181118        else:
    11191119            return s
     1120
     1121    @asaplog_post_dec
     1122    def fft(self, getrealimag=False, rowno=[]):
     1123        """\
     1124        Apply FFT to the spectra.
     1125        Flagged data in the scantable get interpolated over the region.
     1126
     1127        Parameters:
     1128       
     1129            getrealimag:    If True, returns the real and imaginary part
     1130                            values of the complex results.
     1131                            If False (the default), returns the amplitude
     1132                            (absolute value) normalised with Ndata/2 and
     1133                            phase (argument, in unit of radian).
     1134
     1135            rowno:          The row number(s) to be processed. int, list
     1136                            and tuple are accepted. By default ([]), FFT
     1137                            is applied to the whole data.
     1138
     1139        Returns:
     1140
     1141            A dictionary containing two keys, i.e., 'real' and 'imag' for
     1142            getrealimag = True, or 'ampl' and 'phase' for getrealimag = False,
     1143            respectively.
     1144            The value for each key is a list of lists containing the FFT
     1145            results from each spectrum.
     1146           
     1147        """
     1148        if getrealimag:
     1149            res = {"real":[], "imag":[]}  # return real and imaginary values
     1150        else:
     1151            res = {"ampl":[], "phase":[]} # return amplitude and phase(argument)
     1152       
     1153        if isinstance(rowno, int):
     1154            rowno = [rowno]
     1155        elif not (isinstance(rowno, list) or isinstance(rowno, tuple)):
     1156            raise TypeError("The row number(s) should be int, list or tuple.")
     1157       
     1158        nrow = len(rowno)
     1159        if nrow == 0: nrow = self.nrow()  # by default, calculate for all rows.
     1160       
     1161        fspec = self._math._fft(self, rowno, getrealimag)
     1162        nspec = len(fspec)/nrow
     1163       
     1164        i = 0
     1165        while (i < nrow):
     1166            v1 = []
     1167            v2 = []
     1168           
     1169            j = 0
     1170            while (j < nspec):
     1171                k = i*nspec + j
     1172                v1.append(fspec[k])
     1173                v2.append(fspec[k+1])
     1174                j += 2
     1175           
     1176            if getrealimag:
     1177                res["real"].append(v1)
     1178                res["imag"].append(v2)
     1179            else:
     1180                res["ampl"].append(v1)
     1181                res["phase"].append(v2)
     1182           
     1183            i += 1
     1184
     1185        return res
    11201186
    11211187    @asaplog_post_dec
Note: See TracChangeset for help on using the changeset viewer.