ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ ]c,@`sJdZddlmZmZmZddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.g,Zdd/lZdd/lZd0d1lm Z d0d2l m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z dd/l!Z"dd3l!m#Z#mZ$dd/l%j j&Z&dd4l'm(Z(dd5l)m*Z*dd6l+m,Z,dd7l-m.Z.d8Z/d/d9Z1e2d:Z3d;Z4d<dld=YZ5d>e5fd?YZ6d@e5fdAYZ7dBe5fdCYZ8dDe5fdEYZ9e9dZ:e9dZ;e9dZ<e7d.Z=Z>e7dZ?e7d Z@e7dZAe6dZBe6dZCdFZDdGZEe"jEjeE_dHZFeFjd/k rCe"jFje"jFjjGdI jHdJeF_nd/d/eIdKZJd/d/eIeIdLZKd/d/eIdMZLd/dNZMd/dOZNdPZOdQZPd/dRZQd/dSZRd/d/dTZSeIeIdUZTeIdVZUeIdWZVeIeIdXZWeIeIdYZXdZZYeId[ZZd/e[e[d\Z\d/e[eIe[d/d]Z]d/e[e"j^e[e"j^d^Z_d_e.fd`YZ`dae`fdbYZaeaZbdcZcd/ddZddeZed/dfZfdgZgdhZhdiZid/djZje jke"jjjejjej_d/eId/eIdkZle jke"jljeljel_d/S(ms Masked arrays add-ons. A collection of utilities for `numpy.ma`. :author: Pierre Gerard-Marchant :contact: pierregm_at_uga_dot_edu :version: $Id: extras.py 3473 2007-10-29 15:18:13Z jarrod.millman $ i(tdivisiontabsolute_importtprint_functiontapply_along_axistapply_over_axest atleast_1dt atleast_2dt atleast_3dtaveraget clump_maskedtclump_unmaskedt column_stackt compress_colst compress_ndtcompress_rowcolst compress_rowst count_maskedtcorrcoeftcovtdiagflattdottdstacktediff1dtflatnotmasked_contiguoustflatnotmasked_edgesthsplitthstacktisintin1dt intersect1dt mask_colst mask_rowcolst mask_rowst masked_alltmasked_all_liketmediantmr_tnotmasked_contiguoustnotmasked_edgestpolyfitt row_stackt setdiff1dtsetxor1dtuniquetunion1dtvandertvstackNi(tcore(t MaskedArraytMAErrortaddtarraytasarrayt concatenatetfilledtcounttgetmaskt getmaskarraytmake_mask_descrtmaskedt masked_arraytmask_ortnomasktonestsorttzerostgetdatatget_masked_subclassRR(tndarrayR3(tnormalize_axis_index(tnormalize_axis_tuple(t_ureduce(tAxisConcatenatorcC`st|tttfS(s6 Is seq a sequence (ndarray, list or tuple)? (t isinstanceRDttupletlist(tseq((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt issequence-scC`st|}|j|S(s Count the number of masked elements along the given axis. Parameters ---------- arr : array_like An array with (possibly) masked elements. axis : int, optional Axis along which to count. If None (default), a flattened version of the array is used. Returns ------- count : int, ndarray The total number of masked elements (axis=None) or the number of masked elements along each slice of the given axis. See Also -------- MaskedArray.count : Count non-masked elements. Examples -------- >>> import numpy.ma as ma >>> a = np.arange(9).reshape((3,3)) >>> a = ma.array(a) >>> a[1, 0] = ma.masked >>> a[1, 2] = ma.masked >>> a[2, 1] = ma.masked >>> a masked_array(data = [[0 1 2] [-- 4 --] [6 -- 8]], mask = [[False False False] [ True False True] [False True False]], fill_value=999999) >>> ma.count_masked(a) 3 When the `axis` keyword is used an array is returned. >>> ma.count_masked(a, axis=0) array([1, 1, 1]) >>> ma.count_masked(a, axis=1) array([0, 2, 1]) (R9tsum(tarrtaxistm((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR5s3 cC`s4ttj||dtj|t|}|S(s Empty masked array with all elements masked. Return an empty masked array of the given shape and dtype, where all the data are masked. Parameters ---------- shape : tuple Shape of the required MaskedArray. dtype : dtype, optional Data type of the output. Returns ------- a : MaskedArray A masked array with all data masked. See Also -------- masked_all_like : Empty masked array modelled on an existing array. Examples -------- >>> import numpy.ma as ma >>> ma.masked_all((3, 3)) masked_array(data = [[-- -- --] [-- -- --] [-- -- --]], mask = [[ True True True] [ True True True] [ True True True]], fill_value=1e+20) The `dtype` parameter defines the underlying data type. >>> a = ma.masked_all((3, 3)) >>> a.dtype dtype('float64') >>> a = ma.masked_all((3, 3), dtype=np.int32) >>> a.dtype dtype('int32') tmask(R<tnptemptyR?R:(tshapetdtypeta((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR!ls/cC`s@tj|jt}tj|jdt|j|_|S(sz Empty masked array with the properties of an existing array. Return an empty masked array of the same shape and dtype as the array `arr`, where all the data are masked. Parameters ---------- arr : ndarray An array describing the shape and dtype of the required MaskedArray. Returns ------- a : MaskedArray A masked array with all data masked. Raises ------ AttributeError If `arr` doesn't have a shape attribute (i.e. not an ndarray) See Also -------- masked_all : Empty masked array with all elements masked. Examples -------- >>> import numpy.ma as ma >>> arr = np.zeros((2, 3), dtype=np.float32) >>> arr array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> ma.masked_all_like(arr) masked_array(data = [[-- -- --] [-- -- --]], mask = [[ True True True] [ True True True]], fill_value=1e+20) The dtype of the masked array matches the dtype of `arr`. >>> arr.dtype dtype('float32') >>> ma.masked_all_like(arr).dtype dtype('float32') RV( RSt empty_liketviewR0R?RUR:RVt_mask(RORW((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR"s2$t_fromnxfunctioncB`s)eZdZdZdZdZRS(sV Defines a wrapper to adapt NumPy functions to masked arrays. An instance of `_fromnxfunction` can be called with the same parameters as the wrapped NumPy function. The docstring of `newfunc` is adapted from the wrapped function as well, see `getdoc`. This class should not be used directly. Instead, one of its extensions that provides support for a specific type of input should be used. Parameters ---------- funcname : str The name of the function to be adapted. The function should be in the NumPy namespace (i.e. ``np.funcname``). cC`s||_|j|_dS(N(t__name__tgetdoct__doc__(tselftfuncname((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt__init__s cC`sctt|jd}t|dd}|r_|jtj|}d}dj|||fSdS(s  Retrieve the docstring and signature from the function. The ``__doc__`` attribute of the function is used as the docstring for the new masked array version of the function. A note on application of the function to the mask is appended. .. warning:: If the function docstring already contained a Notes section, the new docstring will have two Notes sections instead of appending a note to the existing section. Parameters ---------- None R^sLNotes ----- The function is applied to both the _data and the _mask, if any.s N(tgetattrRSR\tNonetmatget_object_signaturetjoin(R_tnpfunctdoctsigtlocdoc((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR]scO`sdS(N((R_targstparams((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt__call__ s(R\t __module__R^RaR]Rm(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR[s  t_fromnxfunction_singlecB`seZdZdZRS(s A version of `_fromnxfunction` that is called with a single array argument followed by auxiliary args that are passed verbatim for both the data and mask calls. cO`stt|j}t|tra||j||}|t|||}t|d|S|tj|||}|t|||}t|d|SdS(NRR( RbRSR\RIRDt __array__R9R<R4(R_txRkRltfunct_dt_m((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRms(R\RnR^Rm(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRost_fromnxfunction_seqcB`seZdZdZRS(s A version of `_fromnxfunction` that is called with a single sequence of arrays followed by auxiliary args that are passed verbatim for both the data and mask calls. cO`stt|j}|tg|D]}tj|^q||}|tg|D]}t|^qS||}t|d|S(NRR(RbRSR\RJR4R9R<(R_RqRkRlRrRWRsRt((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRm)s41(R\RnR^Rm(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRu#st_fromnxfunction_argscB`seZdZdZRS(s A version of `_fromnxfunction` that is called with multiple array arguments. The first non-array-like input marks the beginning of the arguments that are passed verbatim for both the data and mask calls. Array arguments are processed independently and the results are returned in a list. If only one array is found, the return value is just the processed array instead of a list. c O`stt|j}g}t|}x<t|dkrbt|drb|j|jdq'Wg}xZ|D]R}|tj|||}|t |||}|jt |d|qpWt|dkr|dS|S(NiRRi( RbRSR\RKtlenRMtappendtpopR4R9R<( R_RkRlRrtarraystresRqRsRt((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRm9s % (R\RnR^Rm(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRv0st_fromnxfunction_allargscB`seZdZdZRS(s A version of `_fromnxfunction` that is called with multiple array arguments. Similar to `_fromnxfunction_args` except that all args are converted to arrays even if they are not so already. This makes it possible to process scalars as 1-D arrays. Only keyword arguments are passed through verbatim for the data and mask calls. Arrays arguments are processed independently and the results are returned in a list. If only one arg is present, the return value is just the processed array instead of a list. cO`stt|j}g}xT|D]L}|tj||}|t||}|jt|d|qWt|dkr|dS|S(NRRii(RbRSR\R4R9RxR<Rw(R_RkRlRrR{RqRsRt((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRmTs (R\RnR^Rm(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR|Is cC`s\d}xO|t|krWx,t||drI|||||d+qW|d7}q W|S(sFlatten a sequence in place.it__iter__i(Rwthasattr(RLtk((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pytflatten_inplaceqs cO`st|dtdt}|j}t||}dg|d}tj|d}tt|}|j |t d d ||>> a = ma.arange(24).reshape(2,3,4) >>> a[:,0,1] = ma.masked >>> a[:,1,:] = ma.masked >>> print(a) [[[0 -- 2 3] [-- -- -- --] [8 9 10 11]] [[12 -- 14 15] [-- -- -- --] [20 21 22 23]]] >>> print(ma.apply_over_axes(ma.sum, a, [0,2])) [[[46] [--] [124]]] Tuple axis arguments to ufuncs are equivalent: >>> print(ma.sum(a, axis=(0,2)).reshape((1,-1,1))) [[[46] [--] [124]]] c C`st|}t|}|d krQ|j|}|jj|j|}nmtj|}t |jjtj tj frtj |j|jd}ntj |j|j}|j |j krd|d krtdn|jdkrtdn|j d|j |kr+tdntj||jdd |j }|jd|}n|tk r||j}n|jd|d |}tj||d |j||}|r|j |j krtj||j j}n||fS|Sd S( ss Return the weighted average of array over the given axis. Parameters ---------- a : array_like Data to be averaged. Masked entries are not taken into account in the computation. axis : int, optional Axis along which to average `a`. If `None`, averaging is done over the flattened array. weights : array_like, optional The importance that each element has in the computation of the average. The weights array can either be 1-D (in which case its length must be the size of `a` along the given axis) or of the same shape as `a`. If ``weights=None``, then all data in `a` are assumed to have a weight equal to one. If `weights` is complex, the imaginary parts are ignored. returned : bool, optional Flag indicating whether a tuple ``(result, sum of weights)`` should be returned as output (True), or just the result (False). Default is False. Returns ------- average, [sum_of_weights] : (tuple of) scalar or MaskedArray The average along the specified axis. When returned is `True`, return a tuple with the average as the first element and the sum of the weights as the second element. The return type is `np.float64` if `a` is of integer type and floats smaller than `float64`, or the input data-type, otherwise. If returned, `sum_of_weights` is always `float64`. Examples -------- >>> a = np.ma.array([1., 2., 3., 4.], mask=[False, False, True, True]) >>> np.ma.average(a, weights=[3, 1, 0, 0]) 1.25 >>> x = np.ma.arange(6.).reshape(3, 2) >>> print(x) [[ 0. 1.] [ 2. 3.] [ 4. 5.]] >>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3], ... returned=True) >>> print(avg) [2.66666666667 3.66666666667] tf8s;Axis must be specified when shapes of a and weights differ.is81D weights expected when shapes of a and weights differ.is5Length of weights not compatible with specified axis.iRPRVN(i(R4R8RctmeanRVttypeR7RSt asanyarrayt issubclasstintegertbool_t result_typeRURRRt broadcast_totswapaxesR>RRRNtmultiplyR( RWRPtweightstreturnedRQtavgtscltwgtt result_dtype((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRs<3   !    $ % c C`st|dsztjt|dtd|d|d|d|}t|tjrsd|jkrst|dt S|Snt |d t d|d|d|\}}|r|j |S|Sd S( s: Compute the median along the specified axis. Returns the median of the array elements. Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : int, optional Axis along which the medians are computed. The default (None) is to compute the median along a flattened version of the array. out : ndarray, optional Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output but the type will be cast if necessary. overwrite_input : bool, optional If True, then allow use of memory of input array (a) for calculations. The input array will be modified by the call to median. This will save memory when you do not need to preserve the contents of the input array. Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. Note that, if `overwrite_input` is True, and the input is not already an `ndarray`, an error will be raised. keepdims : bool, optional If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. .. versionadded:: 1.10.0 Returns ------- median : ndarray A new array holding the result is returned unless out is specified, in which case a reference to out is returned. Return data-type is `float64` for integers and floats smaller than `float64`, or the input data-type, otherwise. See Also -------- mean Notes ----- Given a vector ``V`` with ``N`` non masked values, the median of ``V`` is the middle value of a sorted copy of ``V`` (``Vs``) - i.e. ``Vs[(N-1)/2]``, when ``N`` is odd, or ``{Vs[N/2 - 1] + Vs[N/2]}/2`` when ``N`` is even. Examples -------- >>> x = np.ma.array(np.arange(8), mask=[0]*4 + [1]*4) >>> np.ma.median(x) 1.5 >>> x = np.ma.array(np.arange(10).reshape(2, 5), mask=[0]*6 + [1]*4) >>> np.ma.median(x) 2.5 >>> np.ma.median(x, axis=-1, overwrite_input=True) masked_array(data = [ 2. 5.], mask = False, fill_value = 1e+20) RRRRPtouttoverwrite_inputtkeepdimsiRRrN( R~RSR#RBRRIRDRR<RRGt_mediantreshape(RWRPRRRRQtrR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR#isB  ! c`stj|jtjr$tj}nd}|rzdkr[|jjd|q|jdd||nt|dd|dkrdntj j dkrt dgj }t dd|tanyt_dataRtnxarrayRKR(RqRPRQRtaxR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s       2/cC`s4t|jdkr$tdnt|d|S(s Suppress the rows and/or columns of a 2-D array that contain masked values. The suppression behavior is selected with the `axis` parameter. - If axis is None, both rows and columns are suppressed. - If axis is 0, only rows are suppressed. - If axis is 1 or -1, only columns are suppressed. Parameters ---------- x : array_like, MaskedArray The array to operate on. If not a MaskedArray instance (or if no array elements are masked), `x` is interpreted as a MaskedArray with `mask` set to `nomask`. Must be a 2D array. axis : int, optional Axis along which to perform the operation. Default is None. Returns ------- compressed_array : ndarray The compressed array. Examples -------- >>> x = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0], ... [1, 0, 0], ... [0, 0, 0]]) >>> x masked_array(data = [[-- 1 2] [-- 4 5] [6 7 8]], mask = [[ True False False] [ True False False] [False False False]], fill_value = 999999) >>> np.ma.compress_rowcols(x) array([[7, 8]]) >>> np.ma.compress_rowcols(x, 0) array([[6, 7, 8]]) >>> np.ma.compress_rowcols(x, 1) array([[1, 2], [4, 5], [7, 8]]) is*compress_rowcols works for 2D arrays only.RP(R4RtNotImplementedErrorR (RqRP((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRFs3cC`s7t|}|jdkr*tdnt|dS(s Suppress whole rows of a 2-D array that contain masked values. This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see `extras.compress_rowcols` for details. See Also -------- extras.compress_rowcols is'compress_rows works for 2D arrays only.i(R4RRR(RW((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR~s cC`s7t|}|jdkr*tdnt|dS(s Suppress whole columns of a 2-D array that contain masked values. This is equivalent to ``np.ma.compress_rowcols(a, 1)``, see `extras.compress_rowcols` for details. See Also -------- extras.compress_rowcols is'compress_cols works for 2D arrays only.i(R4RRR(RW((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s cC`s t|dS(s Mask rows of a 2D array that contain masked values. This function is a shortcut to ``mask_rowcols`` with `axis` equal to 0. See Also -------- mask_rowcols : Mask rows and/or columns of a 2D array. masked_where : Mask where a condition is met. Examples -------- >>> import numpy.ma as ma >>> a = np.zeros((3, 3), dtype=np.int) >>> a[1, 1] = 1 >>> a array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]) >>> a = ma.masked_equal(a, 1) >>> a masked_array(data = [[0 0 0] [0 -- 0] [0 0 0]], mask = [[False False False] [False True False] [False False False]], fill_value=999999) >>> ma.mask_rows(a) masked_array(data = [[0 0 0] [-- -- --] [0 0 0]], mask = [[False False False] [ True True True] [False False False]], fill_value=999999) i(R(RWRP((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s+cC`s t|dS(s Mask columns of a 2D array that contain masked values. This function is a shortcut to ``mask_rowcols`` with `axis` equal to 1. See Also -------- mask_rowcols : Mask rows and/or columns of a 2D array. masked_where : Mask where a condition is met. Examples -------- >>> import numpy.ma as ma >>> a = np.zeros((3, 3), dtype=np.int) >>> a[1, 1] = 1 >>> a array([[0, 0, 0], [0, 1, 0], [0, 0, 0]]) >>> a = ma.masked_equal(a, 1) >>> a masked_array(data = [[0 0 0] [0 -- 0] [0 0 0]], mask = [[False False False] [False True False] [False False False]], fill_value=999999) >>> ma.mask_cols(a) masked_array(data = [[0 -- 0] [0 -- 0] [0 -- 0]], mask = [[False True False] [False True False] [False True False]], fill_value=999999) i(R(RWRP((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRs+cC`stj|j}|d|d }|g}|dk rL|jd|n|dk rh|j|nt|dkrt|}n|S(s! Compute the differences between consecutive elements of an array. This function is the equivalent of `numpy.ediff1d` that takes masked values into account, see `numpy.ediff1d` for details. See Also -------- numpy.ediff1d : Equivalent function for ndarrays. iiiN(RdRtflatRcRRxRwR(ROtto_endtto_begintedRz((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRs    cC`sotj|d|d|}t|tr\t|}|djt|d>> x = array([1, 3, 3, 3], mask=[0, 0, 0, 1]) >>> y = array([3, 1, 1, 1], mask=[0, 0, 0, 1]) >>> intersect1d(x, y) masked_array(data = [1 3 --], mask = [False False True], fill_value = 999999) ii(RdR5R+R@(Rtar2t assume_uniquetaux((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR4s ! cC`s|s!t|}t|}ntj||f}|jdkrI|S|j|j}tjtg|d|d ktgf}|d|d k}||S(s Set exclusive-or of 1-D arrays with unique elements. The output is always a masked array. See `numpy.setxor1d` for more details. See Also -------- numpy.setxor1d : Equivalent function for ndarrays. iii(R+RdR5RR@R6R(RRRRtauxftflagtflag2((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR*Ts    ,c C`s|s-t|dt\}}t|}ntj||f}|jdd}||}|r{|d|d k}n|d|d k}tj||gf} |jddt| } |r| | S| | |SdS(s Test whether each element of an array is also present in a second array. The output is always a masked array. See `numpy.in1d` for more details. We recommend using :func:`isin` instead of `in1d` for new code. See Also -------- isin : Version of this function that preserves the shape of ar1. numpy.in1d : Equivalent function for ndarrays. Notes ----- .. versionadded:: 1.4.0 Rtkindt mergesortiiN(R+RRdR5targsortRw( RRRtinverttrev_idxtartordertsartbool_arRtindx((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRos cC`s4tj|}t||d|d|j|jS(s| Calculates `element in test_elements`, broadcasting over `element` only. The output is always a masked array of the same shape as `element`. See `numpy.isin` for more details. See Also -------- in1d : Flattened version of this function. numpy.isin : Equivalent function for ndarrays. Notes ----- .. versionadded:: 1.13.0 RR(RdR4RRRU(telementt test_elementsRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRscC`sttj||fS(s Union of two arrays. The output is always a masked array. See `numpy.union1d` for more details. See also -------- numpy.union1d : Equivalent function for ndarrays. (R+RdR5(RR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR,s cC`sS|rtj|j}nt|}t|}|t||dtdtS(s Set difference of 1D arrays with unique elements. The output is always a masked array. See `numpy.setdiff1d` for more details. See Also -------- numpy.setdiff1d : Equivalent function for ndarrays. Examples -------- >>> x = np.ma.array([1, 2, 3, 4], mask=[0, 1, 0, 1]) >>> np.ma.setdiff1d(x, [1, 2]) masked_array(data = [3 --], mask = [False True], fill_value = 999999) RR(RdR4RR+RR(RRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR)s   c C`stj|dddtdt}tj|}| rR|jrRtdn|jddkrnt}ntt |}d|}|rt d d f}nd t d f}|d krt j |jt}n t|dtdddt}tj|}| r-|jr-tdn|jsE|jr|j|jkrt j||} | tk r| }|_|_}t|_t|_qqntj||f|}t j t j||f|jt}||jd||8}|||fS( s_ Private function for the computation of covariance and correlation coefficients. tndminiRRVsCannot process masked data.iiRPN(RdR3RtfloatR9RRRUtinttboolRRcRSt logical_nottastypeRt logical_orR>RZt _sharedmaskR5R( Rqtytrowvart allow_maskedtxmaskRPttuptxnotmasktymaskt common_mask((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt _covhelpers8!     *c C`s|dk r-|t|kr-tdn|dkrQ|rHd}qQd}nt||||\}}}|stj|j|d|}t|j|jdt|j }nEtj||jd|}t||jjdt|j }|S(sJ Estimate the covariance matrix. Except for the handling of missing data this function does the same as `numpy.cov`. For more details and examples, see `numpy.cov`. By default, masked values are recognized as such. If `x` and `y` have the same shape, a common mask is allocated: if ``x[i,j]`` is masked, then ``y[i,j]`` will also be masked. Setting `allow_masked` to False will raise an exception if values are missing in either of the input arrays. Parameters ---------- x : array_like A 1-D or 2-D array containing multiple variables and observations. Each row of `x` represents a variable, and each column a single observation of all those variables. Also see `rowvar` below. y : array_like, optional An additional set of variables and observations. `y` has the same form as `x`. rowvar : bool, optional If `rowvar` is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations. bias : bool, optional Default normalization (False) is by ``(N-1)``, where ``N`` is the number of observations given (unbiased estimate). If `bias` is True, then normalization is by ``N``. This keyword can be overridden by the keyword ``ddof`` in numpy versions >= 1.5. allow_masked : bool, optional If True, masked values are propagated pair-wise: if a value is masked in `x`, the corresponding value is masked in `y`. If False, raises a `ValueError` exception when some values are missing. ddof : {None, int}, optional If not ``None`` normalization is by ``(N - ddof)``, where ``N`` is the number of observations; this overrides the value implied by ``bias``. The default value is ``None``. .. versionadded:: 1.5 Raises ------ ValueError Raised if some values are missing and `allow_masked` is False. See Also -------- numpy.cov sddof must be an integeriig?tstrictN( RcR RRRSRtTtconjRtsqueeze( RqRRtbiasRtddofRtfactR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s6   +(cC`sd}|tjk s$|tjk r=tj|tddnt||||\}}}|stj|j|d}t|j|jdt |j } nAtj||jd}t||jjdt |j } yt j | } Wnt k r dSX|jr;t jt jj| | } nwt| } t | _|jd|} |rxHt| dD]} xzt| d| D]e}tt|| ||fjdd}t jt jj|| | |f<| || fA;tMAxisConcatenatorcB`s2eZdZeeZedZdZRS(s Translate slice objects to concatenation along an axis. For documentation on usage, see `mr_class`. See Also -------- mr_class cC`s"t|jjtjd|jS(NRR(R3RRYRStmatrixRR(RO((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pytmakematscC`s4t|trtdntt|j|S(NsUnavailable for masked array.(RItstrR1tsuperR/t __getitem__(R_tkey((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR4s(R\RnR^t staticmethodR5R1R4(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR/s  tmr_classcB`seZdZdZRS(sG Translate slice objects to concatenation along the first axis. This is the masked array version of `lib.index_tricks.RClass`. See Also -------- lib.index_tricks.RClass Examples -------- >>> np.ma.mr_[np.ma.array([1,2,3]), 0, 0, np.ma.array([4,5,6])] array([1, 2, 3, 0, 0, 4, 5, 6]) cC`stj|ddS(Ni(R/Ra(R_((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRas(R\RnR^Ra(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR7scC`szt|}|tks(tj| rBtjd|jdgStj|}t|dkrr|ddgSdSdS(s Find the indices of the first and last unmasked values. Expects a 1-D `MaskedArray`, returns None if all values are masked. Parameters ---------- a : array_like Input 1-D `MaskedArray` Returns ------- edges : ndarray or None The indices of first and last non-masked value in the array. Returns None if all values are masked. See Also -------- flatnotmasked_contiguous, notmasked_contiguous, notmasked_edges, clump_masked, clump_unmasked Notes ----- Only accepts 1-D arrays. Examples -------- >>> a = np.ma.arange(10) >>> flatnotmasked_edges(a) [0,-1] >>> mask = (a < 3) | (a > 8) | (a == 5) >>> a[mask] = np.ma.masked >>> np.array(a[~a.mask]) array([3, 4, 6, 7, 8]) >>> flatnotmasked_edges(a) array([3, 8]) >>> a[:] = np.ma.masked >>> print(flatnotmasked_edges(ma)) None iiiN( R8R>RSRR3Rt flatnonzeroRwRc(RWRQtunmasked((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRs- cC`st|}|dks'|jdkr1t|St|}ttj|jdtj|g|j}t gt |jD]}||j |j ^qt gt |jD]}||j |j ^qgS(s` Find the indices of the first and last unmasked values along an axis. If all values are masked, return None. Otherwise, return a list of two tuples, corresponding to the indices of the first and last unmasked values respectively. Parameters ---------- a : array_like The input array. axis : int, optional Axis along which to perform the operation. If None (default), applies to a flattened version of the array. Returns ------- edges : ndarray or list An array of start and end indexes if there are any masked data in the array. If there are no masked data in the array, `edges` is a list of the first and last index. See Also -------- flatnotmasked_contiguous, flatnotmasked_edges, notmasked_contiguous, clump_masked, clump_unmasked Examples -------- >>> a = np.arange(9).reshape((3, 3)) >>> m = np.zeros_like(a) >>> m[1:, 1:] = 1 >>> am = np.ma.array(a, mask=m) >>> np.array(am[~am.mask]) array([0, 1, 2, 3, 6]) >>> np.ma.notmasked_edges(ma) array([0, 6]) iRRN(R4RcRRR9R3RStindicesRURJRtmint compressedR(RWRPRQRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR&s*   18cC`st|}|tkr+td|jdSd}g}xbtj|jD]K\}}tt |}|s|j t|||n||7}qMW|pdS(s^ Find contiguous unmasked data in a masked array along the given axis. Parameters ---------- a : narray The input array. Returns ------- slice_list : list A sorted sequence of slices (start index, end index). See Also -------- flatnotmasked_edges, notmasked_contiguous, notmasked_edges, clump_masked, clump_unmasked Notes ----- Only accepts 2-D arrays at most. Examples -------- >>> a = np.ma.arange(10) >>> np.ma.flatnotmasked_contiguous(a) slice(0, 10, None) >>> mask = (a < 3) | (a > 8) | (a == 5) >>> a[mask] = np.ma.masked >>> np.array(a[~a.mask]) array([3, 4, 6, 7, 8]) >>> np.ma.flatnotmasked_contiguous(a) [slice(3, 5, None), slice(6, 9, None)] >>> a[:] = np.ma.masked >>> print(np.ma.flatnotmasked_edges(a)) None iN( R8R>RRRct itertoolstgroupbyRRwRKRx(RWRQRRRtgR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyRIs)  "cC`st|}|j}|dkr0tdn|dksH|dkrRt|Sg}|dd}ddg}tdd||>> a = np.arange(9).reshape((3, 3)) >>> mask = np.zeros_like(a) >>> mask[1:, 1:] = 1 >>> ma = np.ma.array(a, mask=mask) >>> np.array(ma[~ma.mask]) array([0, 1, 2, 3, 6]) >>> np.ma.notmasked_contiguous(ma) [slice(0, 4, None), slice(6, 7, None)] is%Currently limited to atmost 2D array.iiN( R4RRRcRRRRURx(RWRPRRtotherRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR%~s)      !cC`sU|jdkr|j}n|d|d Aj}|dd}|drt|dkrstd|jgStd|dg}|jdt|ddd|dddDnat|dkrgSgt|ddd|dddD]\}}t||^q}|drQ|jt|d|jn|S(sv Finds the clumps (groups of data with the same values) for a 1D bool array. Returns a series of slices. iiics`s$|]\}}t||VqdS(N(R(t.0tlefttright((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pys siN( RRtnonzeroRwRRtextendtzipRx(RRRRRBRC((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt_ezclumps   1K  cC`s<t|dt}|tkr1td|jgSt|S(s Return list of slices corresponding to the unmasked clumps of a 1-D array. (A "clump" is defined as a contiguous region of the array). Parameters ---------- a : ndarray A one-dimensional masked array. Returns ------- slices : list of slice The list of slices, one for each continuous region of unmasked elements in `a`. Notes ----- .. versionadded:: 1.4.0 See Also -------- flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges, notmasked_contiguous, clump_masked Examples -------- >>> a = np.ma.masked_array(np.arange(10)) >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked >>> np.ma.clump_unmasked(a) [slice(3, 6, None), slice(7, 8, None)] RZi(RbR>RRRG(RWRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s! cC`s)tj|}|tkrgSt|S(s  Returns a list of slices corresponding to the masked clumps of a 1-D array. (A "clump" is defined as a contiguous region of the array). Parameters ---------- a : ndarray A one-dimensional masked array. Returns ------- slices : list of slice The list of slices, one for each continuous region of masked elements in `a`. Notes ----- .. versionadded:: 1.4.0 See Also -------- flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges, notmasked_contiguous, clump_unmasked Examples -------- >>> a = np.ma.masked_array(np.arange(10)) >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked >>> np.ma.clump_masked(a) [slice(0, 3, None), slice(6, 7, None), slice(8, 10, None)] (RdR8R>RG(RWRR((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR s! cC`s;tj||}t|}|tk r7d||(RqRt_vanderRQ((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR-*s    c C`st|}t|}t|}|jdkrKt|t|}n^|jdkrtt|}|tk rt||dddf}qn td|dk r t|}|jdkrtdn|jd|jdkrtdnt|t|}n|tk rs|} |dk rL|| }nt j || || |||||St j |||||||SdS(sE Any masked values in x is propagated in y, and vice-versa. iiNis Expected a 1D or 2D array for y!s expected a 1-d array for weightss(expected w and y to have the same length( R4R8RR=R R>RRcRURSR'( RqRtdegtrcondtfulltwRRQtmytnot_m((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyR'8s.    %      '((mR^t __future__RRRt__all__R=R"tR/RdR0R1R2R3R4R5R6R7R8R9R:R;R<R=R>R?R@RARBRCRRtnumpyRSRDRtnumpy.core.umathtumathtnumpy.core.multiarrayREtnumpy.core.numericRFtnumpy.lib.function_baseRGtnumpy.lib.index_tricksRHRMRcRR R!R"R[RoRuRvR|RRRR.R(RR RRRRRRtfindtrstripRRR#RR RRR R RRR+RR*RRR,R)RRRR!RR/R7R$RR&RR%RGR R R-tdoc_noteR'(((sB/opt/alt/python27/lib64/python2.7/site-packages/numpy/ma/extras.pyt s          7 4 :7          Q   bRa * 8   - 2 *  !+IY  7 3 5 <  ' , "