o
    Nrfy                     @   s   d dl ZdddZdd ZdS )    Nc                 C   sd   d| j v r| j d }nddg}d| j v r| j d }n	| d d d j}||dd | d D d	d
dS )Nzmin-posr   zmax-posresolutions1valuesc                 S   s   g | ]}t |qS  )int).0rr   r   _/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/clodius/tiles/mrmatrix.py
<listcomp>   s    z tileset_info.<locals>.<listcomp>false   )min_posmax_posr   Zmirror_tilesbins_per_dimension)attrsshape)fZboundsr   r   r   r   r	   tileset_info   s   

r   c                 C   s   t tt| d  ddd }t| }|d }|t|kr%td|d||d }|| }|| }	|| }
|	| }| d t||  d }||	|||
f }||jd  }||jd	  }|dkse|dkrxt	j
|d|fd|ffd
t	jt	jfd}|S )a  
    Return tiles for the given region.

    Parameters:
    -----------
    f: h5py.File
        File pointer to the hdf5 file containing the matrices
    z: int
        The zoom level
    x: int
        The tile's x position
    y: int
        The tile's y position
    r   Nr   zZoom level out of bounds:zresolutions:r   r      Zconstant)Zconstant_values)sortedmapr   keysr   len
ValueErrorstrr   nppadnan)r   zxyr   ZtsinfoZn_binsZ
tile_widthZtile_x_startZtile_y_startZ
tile_x_endZ
tile_y_endmatdataZx_padZy_padr   r   r	   tiles   s&    r$   )N)numpyr   r   r$   r   r   r   r	   <module>   s    
