Changeset 2713 for trunk/python


Ignore:
Timestamp:
12/28/12 15:52:45 (12 years ago)
Author:
WataruKawasaki
Message:

New Development: Yes

JIRA Issue: Yes CAS-3618

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: new method for scantable to calculate AIC, AICc, BIC and GCV.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r2687 r2713  
    25392539            raise RuntimeError(msg)
    25402540
     2541    @asaplog_post_dec
     2542    def calc_aic(self, value=None, blfunc=None, order=None, mask=None,
     2543                 whichrow=None, uselinefinder=None, edge=None,
     2544                 threshold=None, chan_avg_limit=None):
     2545        """\
     2546        Calculates and returns model selection criteria for a specified
     2547        baseline model and a given spectrum data.
     2548        Available values include Akaike Information Criterion (AIC), the
     2549        corrected Akaike Information Criterion (AICc) by Sugiura(1978),
     2550        Bayesian Information Criterion (BIC) and the Generalised Cross
     2551        Validation (GCV).
     2552
     2553        Parameters:
     2554            value:         name of model selection criteria to calculate.
     2555                           available ones include 'aic', 'aicc', 'bic' and
     2556                           'gcv'. default is 'aicc'.
     2557            blfunc:        baseline function name. available ones include
     2558                           'chebyshev', 'cspline' and 'sinusoid'.
     2559                           default is 'chebyshev'.
     2560            order:         parameter for basline function. actually stands for
     2561                           order of polynomial (order) for 'chebyshev',
     2562                           number of spline pieces (npiece) for 'cspline' and
     2563                           maximum wave number for 'sinusoid', respectively.
     2564                           default is 5 (which is also the default order value
     2565                           for [auto_]chebyshev_baseline()).
     2566            mask:          an optional mask. default is [].
     2567            whichrow:      row number. default is 0 (the first row)
     2568            uselinefinder: use sd.linefinder() to flag out line regions
     2569                           default is True.
     2570            edge:           an optional number of channel to drop at
     2571                            the edge of spectrum. If only one value is
     2572                            specified, the same number will be dropped
     2573                            from both sides of the spectrum. Default
     2574                            is to keep all channels. Nested tuples
     2575                            represent individual edge selection for
     2576                            different IFs (a number of spectral channels
     2577                            can be different)
     2578                            default is (0, 0).
     2579            threshold:      the threshold used by line finder. It is
     2580                            better to keep it large as only strong lines
     2581                            affect the baseline solution.
     2582                            default is 3.
     2583            chan_avg_limit: a maximum number of consequtive spectral
     2584                            channels to average during the search of
     2585                            weak and broad lines. The default is no
     2586                            averaging (and no search for weak lines).
     2587                            If such lines can affect the fitted baseline
     2588                            (e.g. a high order polynomial is fitted),
     2589                            increase this parameter (usually values up
     2590                            to 8 are reasonable). Most users of this
     2591                            method should find the default value sufficient.
     2592                            default is 1.
     2593
     2594        Example:
     2595            aic = scan.calc_aic(blfunc='chebyshev', order=5, whichrow=0)
     2596        """
     2597
     2598        try:
     2599            varlist = vars()
     2600
     2601            if value          is None: value          = 'aicc'
     2602            if blfunc         is None: blfunc         = 'chebyshev'
     2603            if order          is None: order          = 5
     2604            if mask           is None: mask           = []
     2605            if whichrow       is None: whichrow       = 0
     2606            if uselinefinder  is None: uselinefinder  = True
     2607            if edge           is None: edge           = (0, 0)
     2608            if threshold      is None: threshold      = 3
     2609            if chan_avg_limit is None: chan_avg_limit = 1
     2610
     2611            return self._calc_aic(value, blfunc, order, mask,
     2612                                  whichrow, uselinefinder, edge,
     2613                                  threshold, chan_avg_limit)
     2614           
     2615        except RuntimeError, e:
     2616            raise_fitting_failure_exception(e)
    25412617
    25422618    @asaplog_post_dec
Note: See TracChangeset for help on using the changeset viewer.