
    dg                    0   d dl mZ d dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZ d dlZd dlZd dlmZ d dlmZmZ d d	lmZ d d
lmZmZmZ d dl m!Z!m"Z" d dl#m$Z$m%Z% d dl&m'Z'm(Z( d dl)m*Z*m+Z+ d dl,m-Z-m.Z. erd dl/m0Z0 d dl1m2Z2 dHdZ3 G d d          Z4 G d de4          Z5 G d de4          Z6 G d d e4          Z7dId!Z8	 dJdKd'Z9	 	 	 	 	 	 dLdMd3Z:d4 Z;dNd6Z<dOd7Z=dOd8Z>d9 Z?	 dPdQd<Z@d= ZAd> ZBd? ZCd@ ZDdRdAZEdRdBZFdC ZGdD ZHd"dEdFZIdG ZJdS )S    )annotationsN)HashableSequence)partial)Number)TYPE_CHECKINGAnyCallableget_args)utils)_contains_datetime_like_objects	ones_like)apply_ufunc)datetime_to_numericpushtimedelta_to_numeric)OPTIONS_get_keep_attrs)get_chunked_array_typeis_chunked_array)Interp1dOptionsInterpOptions)
OrderedSet	is_scalar)Variablebroadcast_variables)	DataArray)DatasetobjDataset | DataArray | Variabledimr   indexr   c                :   t          |g|          }t          |           |z  }|                                 }|                    |          }|                    |                              |d                   }|                    |d                              || |         i                              |                              |                              | d                              |d         |	                    |g          z
            }|S )zv
    Return an object where each NaN element in 'obj' is replaced by the
    length of the gap the element is in.
    )r!   r   upper)r!   label)
r   r   notnullwhereffillfillnadiffreindexbfillmax)r   r!   r"   arangevalidvalid_arangecumulative_nansnan_block_lengthss           3lib/python3.11/site-packages/xarray/core/missing.py_get_nan_block_lengthsr5      s     cUE""E s^^e#FKKMME<<&&L"((S(1188qBBO 	G44	#s3x	!	!	u	3	vq			b	L,,#,777	8	8      c                  H    e Zd ZU dZded<   ded<   ded<   ded<   d	 Zd
 ZdS )BaseInterpolatorz@Generic interpolator class for normalizing interpolation methodszdict[str, Any]cons_kwargscall_kwargsr
   fstrmethodc                (     | j         |fi | j        S N)r;   r:   selfxs     r4   __call__zBaseInterpolator.__call__A   s    tva,,4+,,,r6   c                N    d                     | j        j        | j                  S )Nz{type}: method={method})typer=   )format	__class____name__r=   )rA   s    r4   __repr__zBaseInterpolator.__repr__D   s+    (//( 0 
 
 	
r6   N)rH   
__module____qualname____doc____annotations__rC   rI    r6   r4   r8   r8   9   sd         JJKKKKKK- - -
 
 
 
 
r6   r8   c                       e Zd ZdZddZd ZdS )NumpyInterpolatorzVOne-dimensional linear interpolation.

    See Also
    --------
    numpy.interp
    linearNc                   |dk    rt          d          || _        t          j        | _        i | _        d|i| _        || _        || _        |j	        j
        dk    rt          j        nt          j        t          j        dz  z   }||| _        || _        d S t          |t                    r/t!          |          dk    r|d         | _        |d         | _        d S t#          |          r|| _        || _        d S t          | d	          )
NrQ   z7only method `linear` is valid for the NumpyInterpolatorperiodc              ?   r      z is not a valid fill_value)
ValueErrorr=   npinterpr;   r9   r:   _xi_yidtypekindnan_left_right
isinstancer   lenr   )rA   xiyir=   
fill_valuerS   r_   s          r4   __init__zNumpyInterpolator.__init__R   s   XVWWW$f-,,bff"&26B;2FDJDKKK
H-- 	H#j//Q2F2F#ADJ$Q-DKKKz"" 	H#DJ$DKKK
FFFGGGr6   c                Z     | j         || j        | j        f| j        | j        d| j        S )N)leftright)r;   r[   r\   r`   ra   r:   r@   s     r4   rC   zNumpyInterpolator.__call__l   sH    tvHH
 +
 
 
 
 	
r6   )rQ   NN)rH   rJ   rK   rL   rg   rC   rN   r6   r4   rP   rP   J   sE         H H H H4
 
 
 
 
r6   rP   c                  &    e Zd ZdZ	 	 	 	 	 	 ddZdS )ScipyInterpolatorznInterpolate a 1-D function using Scipy interp1d

    See Also
    --------
    scipy.interpolate.interp1d
    NTFc	           	     `   ddl m}
 |t          d          |dk    r|t          d          |}|| _        |	| _        i | _        |j        j        dk    rt          j	        nt          j	        t          j	        dz  z   }||dk    r||f}n||} |
||f| j        ||||d	| j        | _
        d S )
Nr   )interp1dzPmethod is a required argument, please supply a valid scipy.inter1d method (kind)
polynomialz(order is required when method=polynomialrT   rU   rQ   )r^   rf   bounds_errorassume_sortedcopy)scipy.interpolatern   rX   r=   r9   r:   r]   r^   rY   r_   r;   )rA   rd   re   r=   rf   rq   rr   rp   orderkwargsrn   r_   s               r4   rg   zScipyInterpolator.__init__   s    	/.....>4  
 \!!} !KLLLF!,,bff"&26B;2F&H"4"4cJJJ	
 !%'	
 	
 	
 	
r6   )NNTFFNrH   rJ   rK   rL   rg   rN   r6   r4   rl   rl   w   sF          .
 .
 .
 .
 .
 .
r6   rl   c                  $    e Zd ZdZ	 	 	 	 	 ddZdS )SplineInterpolatorzOne-dimensional smoothing spline fit to a given set of data points.

    See Also
    --------
    scipy.interpolate.UnivariateSpline
    splineN   r   c                    ddl m}	 |dk    rt          d          || _        || _        ||d| _        |t          d           |	||fd|i| j        | _        d S )Nr   )UnivariateSplinery   z8only method `spline` is valid for the SplineInterpolator)nuextz.SplineInterpolator does not support fill_valuek)rs   r|   rX   r=   r9   r:   r;   )
rA   rd   re   r=   rf   rt   r}   r~   ru   r|   s
             r4   rg   zSplineInterpolator.__init__   s     	766666XWXXX!"$S11!MNNN!!"bFFEFT5EFFr6   )ry   Nrz   r   Nrv   rN   r6   r4   rx   rx      sI          G G G G G Gr6   rx   c                     t          |          |j        |j                  }|j                                        D ]"\  }}||j        v r | |fd|i|||<   |||<   #|S )zWrapper for datasets)coordsattrsr!   )rE   r   r   	data_varsitemsdims)funcrA   r!   ru   dsnamevars          r4   _apply_over_vars_with_dimr      s~    	d4;dj	9	9	9B^))++  	c#(??tC33S3F33BtHHBtHHIr6   Tuse_coordinate
str | boolstrictboolc           	        ddl m} |du r@|                     |          }t          j        | j        |         t          j                  S |du r|                     |          }nG| j        |         }|j	        dk    rt          d| d|j	         d	          |                                }t          |t          j                  r||_        |r>|j        st          d
|j        d          |j        st          d
|j        d          t          ||t          j        f          rY t'          |d                   ddd          }t          ||          r|j        }t+          t-          ||d          |f          }	 |j                            t          j                  }nB# t0          t          f$ r. t1          d
|j        dt'          |          j         d          w xY w|S )aS  Return index to use for x values in interpolation or curve fitting.

    Parameters
    ----------
    arr : DataArray
        Array to interpolate or fit to a curve.
    dim : str
        Name of dimension along which to fit.
    use_coordinate : str or bool
        If use_coordinate is True, the coordinate that shares the name of the
        dimension along which interpolation is being performed will be used as the
        x values. If False, the x values are set as an equally spaced sequence.
    strict : bool
        Whether to raise errors if the index is either non-unique or non-monotonic (default).

    Returns
    -------
    Variable
        Numerical values for the x-coordinates.

    Notes
    -----
    If indexing is along the time dimension, datetime coordinates are converted
    to time deltas with respect to 1970-01-01.
    r   CFTimeIndexF)r]   TrW   z/Coordinates used for interpolation must be 1D, z is zD.zIndex z! must be monotonically increasingz has duplicate valuesi  ns)offsetdatetime_unit)datar   zL must be castable to float64 to support interpolation or curve fitting, got .)xarray.coding.cftimeindexr   get_axis_numrY   r/   shapefloat64	get_indexr   ndimrX   to_indexrb   pd
MultiIndexr   is_monotonic_increasing	is_uniqueDatetimeIndexrE   valuesr   r   astype	TypeErrorrH   )arrr!   r   r   r   axisr"   r   s           r4   get_clean_interp_indexr      sP   < 655555$$y4
;;;;c"" 
>*:??6!6 6',z6 6 6      %'' 
 K, 	WUejUUUVVV 	KIejIIIJJJ %+r'7899 
eAha++e[)) 	!LE$U6NNN
 
 

##BJ//z" 
 
 
 KUZ K K37;;3GK K K
 
 	

 Ls   $F( (?G'rQ   Hashable | None
bool | strr=   r   limit
int | Nonemax_gap@int | float | str | pd.Timedelta | np.timedelta64 | dt.timedelta
keep_attrsbool | Nonec                <   ddl m} |t          d          |t          | ||          }	|t	          |          j        }
t          |          st          d          || j        v rJt          | j        |         
                                t          j        |f          r|rt          |          }|s4t          |t          t          j        f          st#          d|
 d          t%          | ||          }t'          |fi |\  }}t)          t*          |fi |}|t-          d	
          }t/          j                    5  t/          j        ddt4                     t/          j        ddt4                      t7          || ||g|gg|gg| j        gdd	|	  	        j        | j         }ddd           n# 1 swxY w Y   ||                    |	          }|B|| j         vrt          d          tC          | ||          }|                    ||k              }|S )z2Interpolate values according to different methods.r   r   Nzdim is a required argumentzmax_gap must be a scalar.zPExpected integer or floating point max_gap since use_coordinate=False. Received r   )r   T)defaultignoreoverflowzinvalid valueparallelized)input_core_dimsoutput_core_dimsoutput_dtypesdask	vectorizer   z6max_gap not implemented for unlabeled coordinates yet.)"r   r   NotImplementedError_get_valid_fill_maskrE   rH   r   rX   _indexesrb   to_pandas_indexr   r   r   r   rY   numberr   r   _get_interpolatorr   func_interpolate_nar   warningscatch_warningsfilterwarningsRuntimeWarningr   r]   	transposer   r(   r   r5   )rA   r!   r   r=   r   r   r   ru   r   validsmax_typer"   interp_classinterpolatorr   r3   s                   r4   	interp_nar   4  s    655555
{!">???%dC77==)!! 	:8999 4=  c"2244r7G6U  ! 	 ! +733G 	g	':;; rgorrr  
 #4^LLLE,V>>v>>L&.GGGGL$T222
		 	"	"    *nEEE/>JJJ
k!USEN"eW:,!

 

 

 TY
                               iidk!!%H   34eDDii)W455Js   A(F66F:=F:c                   |                                 }t          j        |          }| }|                                }|dk    s|t	          |          dz
  k    r|S  | ||         ||         fi |} |||                   ||<   |S )z8helper function to apply interpolation along 1 dimensionr   rW   )rr   r   isnullsumrc   )	r   yrB   ru   outnansnonansn_nansr;   s	            r4   r   r     s    
 &&((C9Q<<DUF XXZZF{{fA
**QvY&	44V44A!D'

CIJr6   r&   c                ~    t          j        | |          } t          | ||          } t          j        | |          S )zinverse of ffillr   )r   n)rY   flipr   )r   r   r   s      r4   _bfillr     sC    
'#D
!
!
!C s
#
#
#C 73T""""r6   c                    t           d         st          d          |                     |          }||n| j        |         } t	          t
          | dd| j        gt          ||                    j        | j	         S )zforward fill missing valuesuse_bottleneckzaffill requires bottleneck to be enabled. Call `xr.set_options(use_bottleneck=True)` to enable it.NallowedTr   r   r   r   r   ru   )
r   RuntimeErrorr   r   r   r   r]   dictr   r   r   r!   r   r   _limits        r4   r)   r)     s    #$ 
H
 
 	

 C  D 'UUSYt_F;ykf4(((    r6   c                    t           d         st          d          |                     |          }||n| j        |         } t	          t
          | dd| j        gt          ||                    j        | j	         S )zbackfill missing valuesr   zabfill requires bottleneck to be enabled. Call `xr.set_options(use_bottleneck=True)` to enable it.Nr   Tr   r   )
r   r   r   r   r   r   r]   r   r   r   r   s        r4   r-   r-     s    #$ 
H
 
 	

 C  D 'UUSYt_F;ykf4(((    r6   c                |    	 ddl m} t          ||           S # t          $ r}t          d| d          |d}~ww xY w)z*Import interpolant from scipy.interpolate.r   )interpolatezInterpolation with method z requires scipy.N)scipyr   getattrImportError)interpolantr=   r   es       r4   _import_interpolantr     sj    X%%%%%%{K000 X X XOvOOOPPVWWXs    
;6;Fvectorizeable_onlyc                   t          t                    }t          d t          t                    D                       }| dk    r:|                    dd          dk    s |s|                    |            t          }n| |v r| |v r|                    |            t          }n|rt          |  d|           | dk    rt          d	|           }n| d
k    rt          d|           }nv| dk    rt          d|           }n_| dk    r|                    |            t          }n;| dk    rt          d|           }n$t          |  d          t          |  d          ||fS )helper function to select the appropriate interpolator class

    returns interpolator class and keyword arguments for the class
    c              3  >   K   | ]}t          |          D ]}|V  d S r?   )r   ).0vvvs      r4   	<genexpr>z$_get_interpolator.<locals>.<genexpr>  s6      TTQRTT""TTTTTTTr6   rQ   rf   Nextrapolater=   z< is not a vectorizeable interpolator. Available methods are barycentricBarycentricInterpolatorkrogKroghInterpolatorpchipPchipInterpolatorry   akimaAkima1DInterpolatorz" is not a valid scipy interpolatorz is not a valid interpolator)r   r   tupler   getupdaterP   rl   rX   r   rx   )r=   r   ru   interp1d_methodsvalid_methodsr   s         r4   r   r     s     00TTh}&=&=TTTTTM 	(

<..-??" @ 	V$$$(	=	 	 %%%MMM(((,LL 	L < <)9< <   }$$./H&QQLLv./BFKKLLw./BFKKLLxMMM(((-LLw./DfMMLLJJJKKKF@@@AAAr6   c                    ddg}| |v r'|                     |            t          d|           }nt          |  d          ||fS )r   rQ   nearestr   interpnzH is not a valid interpolator for interpolating over multiple dimensions.)r   r   rX   )r=   ru   r  r   s       r4   _get_interpolator_ndr    so    
 y)MV$$$*9f== ( ( (
 
 	

 r6   c                    ||dz   i}t          j        | j        d          } |                                 j        dddi|                    |d                              |d          |k    S )zQhelper function to determine values that can be filled when limit is not
    NonerW   _windowmin_periodsF)rf   )skipnarN   )r   get_temp_dimnamer   r   rolling	constructr   )r   r!   r   kwnew_dims        r4   r   r     s     uqy	B$SXy99G	

		& 	&	&"$	& 	&	7u	-	-	WU	#	#	 r6   c                   i }|                                 D ]\  }\  }}t          j        |j                  }t          j        |j                  }|                                }|                    |gd                                          }	|                    |gd                                          }
t          t          |	dz
  d          |
dz             ||<   |||                  |f||<    | j
        di ||fS )zwSpeed up for linear and nearest neighbor method.
    Only consider a subspace that is needed for the interpolation
    r  r   rV   r   rN   )r   rY   nanminr   nanmaxr   get_indexeritemslicer.   isel)r   indexes_coordsindexesr!   rB   new_xminvalmaxvalr"   iminimaxs              r4   	_localizer  ,  s    G)//11 7 7Za5<((5<((

  &) <<AACC  &) <<AACCS1--tax88 6s38g..r6   c                   t          |           } t          |          }t          t          |                     D ]}t          | |                   rs| |         j                                        }| |                             |t          j                  | |<   ||                             |t          j                  ||<   | |fS )zrMake x and new_x float.
    This is particularly useful for datetime dtype.
    x, new_x: tuple of np.ndarray
    )r   r]   )	listrangerc   r   r   min_to_numericrY   r   )rB   r  ixmins       r4   _floatize_xr%  <  s    
 	QAKKE3q66]] 	K 	K*1Q400 	K Q4;??$$DQ4##4rz#BBAaDQx++4rz+JJE!He8Or6   c                   s|                                  S |                    dd          |d<   | }t                    D ]|} t                    t	          fdD              \  }}t          | }fd| j        D             }|z   }	|t          |d         j                  z   }
t           | j        |	 j	        ||||          }t          |
|| j        d          }t                      }| j        D ]B}|v r'|                    |         d         j                   -|                    |           Ct          |          dk    r
 |j        | }|S )	a  Make an interpolation of Variable

    Parameters
    ----------
    var : Variable
    indexes_coords
        Mapping from dimension name to a pair of original and new coordinates.
        Original coordinates should be sorted in strictly ascending order.
        Note that all the coordinates should be Variable objects.
    method : string
        One of {'linear', 'nearest', 'zero', 'slinear', 'quadratic',
        'cubic'}. For multidimensional interpolation, only
        {'linear', 'nearest'} can be used.
    **kwargs
        keyword arguments to be passed to scipy.interpolate

    Returns
    -------
    Interpolated Variable

    See Also
    --------
    DataArray.interp
    Dataset.interp
    rp   Fc                     g | ]
}|         S rN   rN   r   dr  s     r4   
<listcomp>zinterp.<locals>.<listcomp>w  s    999q*999r6   c                    g | ]}|v|	S rN   rN   )r   r)  r   s     r4   r*  zinterp.<locals>.<listcomp>{  s    ???$!r6   r   T)r   fastpathrW   )rr   r   decompose_interpr  zipr   r   interp_funcr   r   r   r   r   r   addrc   )r   r  r=   ru   resultrB   r  destinationbroadcast_dimsoriginal_dimsnew_dimsinterpedout_dimsr)  r   s    `            @r4   rZ   rZ   P  s   4  xxzz $ZZ>>F>F*>:: 1 1 N##9999D999:5)51 @???SX???&-!DQ)<$=$==CM=).;
 
 (HCIMMM  *|| 	  	 ADyyq 1! 4 9::::Qx==1%V%x0FMr6   c                   |s|                                  S t          |          dk    rt          |fddi|\  }}nt          |fi |\  }}t	          |           rt          |           }| j        t          |          z
  t          t                              t          t          |d         j        z                       z   }fdt          |          D             }d |D             }fd|D             }	d |	D             }	| t                    g||	R }
 |j
        |
 \  }}t          d	 t          ||
dd
d                   D                       }
|dt          |          dz
  dz  z   d
         }|d         j        |d         j        d
ufdt          |d         j                  D             }|dv o}t          | j        j        t$          j                  st$          j        }n| j        }| j        } |j        t.          |g|
R |||d|||ddS t1          | ||||          S )a~  
    multi-dimensional interpolation for array-like. Interpolated axes should be
    located in the last position.

    Parameters
    ----------
    var : np.ndarray or dask.array.Array
        Array to be interpolated. The final dimension is interpolated.
    x : a list of 1d array.
        Original coordinates. Should not contain NaN.
    new_x : a list of 1d array
        New coordinates. Should not contain NaN.
    method : string
        {'linear', 'nearest', 'zero', 'slinear', 'quadratic', 'cubic'} for
        1-dimensional interpolation.
        {'linear', 'nearest'} for multidimensional interpolation
    **kwargs
        Optional keyword arguments to be passed to scipy.interpolator

    Returns
    -------
    interpolated: array
        Interpolated array

    Notes
    -----
    This requiers scipy installed.

    See Also
    --------
    scipy.interpolate.interp1d
    rW   r   Tr   c                &    g | ]\  }}||z   fgS rN   rN   )r   r"   _xnconsts      r4   r*  zinterp_func.<locals>.<listcomp>  s)    KKKb6E>+,KKKr6   c                    g | ]	}|D ]}|
S rN   rN   r   pairr  s      r4   r*  zinterp_func.<locals>.<listcomp>  s%    AAAdDAADTAAAAr6   c                T    g | ]$}|fd t          |j                  D             g%S )c                    g | ]}|z   S rN   rN   )r   r"   r   s     r4   r*  z*interp_func.<locals>.<listcomp>.<listcomp>  s    ;;;5$,;;;r6   )r   r   )r   r:  r   s     r4   r*  zinterp_func.<locals>.<listcomp>  sH     
 
 
ACR;;;;E"'NN;;;<
 
 
r6   c                    g | ]	}|D ]}|
S rN   rN   r=  s      r4   r*  zinterp_func.<locals>.<listcomp>  s%    III$DIIDIIIIr6   c              3  $   K   | ]}|D ]}|V  d S r?   rN   )r   r>  elems      r4   r   zinterp_func.<locals>.<genexpr>  s/      RRdTRRTTRRRRRRRr6   NrV   c                <    i | ]}|z   r|         n|         S rN   rN   )r   r#  r   new_x0_chunksnew_x0_chunks_is_not_nonenew_x0_shapes     r4   
<dictcomp>zinterp_func.<locals>.<dictcomp>  sD     
 
 
 1H*CXmA&&VW
 
 
r6   )rQ   r  F)r/  interp_kwargslocalizeconcatenater]   new_axesmetaalign_arrays)rr   rc   r   r  r   r   r   r  r   	enumerateunify_chunksr   r.  chunksr   
issubclassr]   rE   rY   inexactfloat__meta	blockwise_chunked_aware_interpnd	_interpnd)r   rB   r  r=   ru   r   chunkmanagerout_ind	x_argindsnew_x_argindsargs_	rechunkedrL  rJ  r]   rM  r;  r   rE  rF  rG  s                    @@@@@r4   r/  r/    s   B  xxzz
1vv{{(SSDSFSSff+F==f==f 8
-c22xAuV}}%%U4a9M-N-N(O(OO LKKKillKKK	AAiAAA	
 
 
 
GL
 
 
 JI-IIIU4[[=9=}==0|0$79RRc)T!$Q$Z&@&@RRRRR!s9~~1a7799:aQx~$1$=!
 
 
 
 
 
 
58=))
 
 
 33R9R #)."*55 	IEEIEy%|%#
 
 
  
 
 
 	
 S!UD&111r6   c                   |d         |d         }}  ||| fddi|t          j        |                    }|j        dk    r*|                    | j        d d         |j        z             S |j        dk    r|d         S |S )Nr   rq   TrW   r&   ).r&   )rY   ravelr   reshaper   )r   rB   r  r   ru   rslts         r4   	_interp1drd    s    tU1XuA544355d5f55bhuooFFDzA~~||CIcrcNU[8999zQG}Kr6   c           	        t          ||          \  }}t          |          dk    rt          | ||||          S |                     t	          t          |           | j        t          |          z
                      } t          j        d |D             d          } ||| |fi |}|                    t	          |j         dz   d                    }|                    |j	        d d         |d         j	        z             S )NrW   c                @    g | ]}|j                                         S rN   )r   ra  )r   x1s     r4   r*  z_interpnd.<locals>.<listcomp>
  s$    55529??$$555r6   r&   r   r   )
r%  rc   rd  r   r   r   rY   stackrb  r   )r   rB   r  r   ru   rd   rc  s          r4   rX  rX    s    1e$$HAu
1vv{{af555 --s1vvgsx#a&&'899
:
:C	55u555B	?	?	?B43%%f%%D>>%
Q2233D<<
3B3%(.8999r6   )rJ  c                   	 t          |          dz  }t           j                  |z
  		fdt          |d|                   D             } fd||d         D             }|rt          d t	          t           j                            D                         d t          ||          D             t                     \   t          fdD              \  }} j         t           ||||          S )zWrapper for `_interpnd` through `blockwise` for chunked arrays.

    The first half arrays in `coords` are original coordinates,
    the other half are destination coordinates
    rV   c                D    g | ]\  }}t          d |z    g|          S dim_)r   )r   r!   r:  r;  s      r4   r*  z+_chunked_aware_interpnd.<locals>.<listcomp>  s7    VVV73(&3,(()2	.	.VVVr6   Nc           
         g | ]=}t          fd t          t          |j                            D             |          >S )c                D    g | ]}d t          j                  |z    S rk  )rc   r   )r   r!   r   s     r4   r*  z6_chunked_aware_interpnd.<locals>.<listcomp>.<listcomp>  s/    PPPC/SY#-//PPPr6   )r   r   rc   r   )r   r:  r   s     r4   r*  z+_chunked_aware_interpnd.<locals>.<listcomp>  sY        	PPPP5RX;O;OPPPRTUU  r6   c                    g | ]}d | S rk  rN   )r   r!   s     r4   r*  z+_chunked_aware_interpnd.<locals>.<listcomp>#  s    FFFsFFFr6   c                4    i | ]\  }}|j         d          ||fS )r   )r   )r   r:  _new_xs      r4   rH  z+_chunked_aware_interpnd.<locals>.<dictcomp>%  s(    SSSzr6"'!*r6lSSSr6   c                     g | ]
}|         S rN   rN   r(  s     r4   r*  z+_chunked_aware_interpnd.<locals>.<listcomp>)  s    CCCq*CCCr6   )	rc   r   rO  r   r   r.  r  r   rX  )
r   r/  rI  rJ  r   n_xrB   r  r  r;  s
   `       @@r4   rW  rW    s1    f++
C^^c!F 	WVVVitPSt>U>UVVVA   ,  E
  FFc#)nn0E0EFFFLLSSSE]]SSS (^<<^CCCCNCCCD5 hS!UK???r6   c              #    K   d |                                  D             }g }i }t          |                                            D ]\  }}|                    |g           |t          |          dz
  k    r nO|||         gz  }||dz   d         }d |D             }d |D             }|                    |          s|V  g }i }|V  dS )z\Decompose the interpolation into a succession of independent interpolation keeping the orderc                V    g | ]&\  }}|d          j         dk    r|d          j        n|g'S )rW   r   )r   r   )r   r!   dests      r4   r*  z$decompose_interp.<locals>.<listcomp>4  sH       C Qq((Qse  r6   rW   Nc                    h | ]	}|D ]}|
S rN   rN   r   r   r!   s      r4   	<setcomp>z#decompose_interp.<locals>.<setcomp>C  s%    QQQtDQQSsQQQQr6   c                    h | ]	}|D ]}|
S rN   rN   rx  s      r4   ry  z#decompose_interp.<locals>.<setcomp>D  s%    CCCdCCsCCCCr6   )r   rO  r   rc   intersection)	r  	dest_dimspartial_dest_dimspartial_indexes_coordsr#  index_coords
other_dimss_partial_dest_dimss_other_dimss	            r4   r-  r-  1  s$      '--//  I $^%9%9%;%;<< ( (<%%|n555I"""Eil^+q1uww'
QQ/@QQQCC
CCC"//== 	( )((( "%'"
      r6   )r   r    r!   r   r"   r   r?   )TT)r!   r   r   r   r   r   )NTrQ   NNN)r!   r   r   r   r=   r   r   r   r   r   r   r   )Nr&   )NN)F)r=   r   r   r   )r=   r   )K
__future__r   datetimedtr   collections.abcr   r   	functoolsr   numbersr   typingr   r	   r
   r   numpyrY   pandasr   xarray.corer   xarray.core.commonr   r   xarray.core.computationr   xarray.core.duck_array_opsr   r   r   xarray.core.optionsr   r   xarray.core.parallelcompatr   r   xarray.core.typesr   r   xarray.core.utilsr   r   xarray.core.variabler   r   xarray.core.dataarrayr   xarray.core.datasetr   r5   r8   rP   rl   rx   r   r   r   r   r   r)   r-   r   r   r  r   r  r%  rZ   r/  rd  rX  rW  r-  rN   r6   r4   <module>r     s   " " " " " "      . . . . . . . .             9 9 9 9 9 9 9 9 9 9 9 9               I I I I I I I I / / / / / / V V V V V V V V V V 8 8 8 8 8 8 8 8 O O O O O O O O < < < < < < < < 3 3 3 3 3 3 3 3 > > > > > > > > ,//////++++++   :
 
 
 
 
 
 
 
"*
 *
 *
 *
 *
( *
 *
 *
Z6
 6
 6
 6
 6
( 6
 6
 6
rG G G G G) G G GD
 
 
 
 KOR R R R Rn  !%$PT"J J J J JZ  (# # # #   .   .X X X 7<0  0  0  0  0 f     &  / / /   (= = = =@c2 c2 c2 c2L  : : :  PT @ @ @ @ @@! ! ! ! !r6   