def fetch(clobber=False):
    """
    Downloads the Chen et al. (2014) dust map.

    Args:
        clobber (Optional[:obj:`bool`]): If ``True``, any existing file will be
            overwritten, even if it appears to match. If ``False`` (the
            default), :obj:`fetch()` will attempt to determine if the dataset
            already exists. This determination is not 100\% robust against data
            corruption.
    """

    dest_dir = fname_pattern = os.path.join(data_dir(), 'chen2014')
    url = 'http://lamost973.pku.edu.cn/site/Photometric-Extinctions-and-Distances/table2.dat'
    dat_fname = os.path.join(dest_dir, 'chen2014.dat')
    h5_fname = os.path.join(dest_dir, 'chen2014.h5')
    md5 = 'f8a2bc46d411c57ca4c76dc344e291f1'

    # Check if file already exists
    if not clobber:
        h5_size = 52768768 # Guess, in Bytes
        h5_dsets = {
            'dists': (30,),
            'pix_lb': (557398, 2),
            'A_r': (557398, 30),
            'A_r_err': (557398, 30)
        }
        if fetch_utils.h5_file_exists(h5_fname, h5_size, dsets=h5_dsets):
            print('File appears to exist already. Call `fetch(clobber=True)` '
                  'to force overwriting of existing file.')
            return

    # Download the table
    print('Downloading {}'.format(url))
    fetch_utils.download_and_verify(url, md5, fname=dat_fname)

    # Convert from ASCII to HDF5 format
    print('Repacking files...')
    ascii2h5(dat_fname, h5_fname)

    # Cleanup
    print('Removing original file...')
    os.remove(dat_fname)
def fetch ( clobber = False ) : dest_dir = fname_pattern = os . path . join ( data_dir ( ) , 'chen2014' ) url = 'http://lamost973.pku.edu.cn/site/Photometric-Extinctions-and-Distances/table2.dat' dat_fname = os . path . join ( dest_dir , 'chen2014.dat' ) h5_fname = os . path . join ( dest_dir , 'chen2014.h5' ) md5 = 'f8a2bc46d411c57ca4c76dc344e291f1' if not clobber : h5_size = 52768768 h5_dsets = { 'dists' : ( 30 , ) , 'pix_lb' : ( 557398 , 2 ) , 'A_r' : ( 557398 , 30 ) , 'A_r_err' : ( 557398 , 30 ) } if fetch_utils . h5_file_exists ( h5_fname , h5_size , dsets = h5_dsets ) : print ( 'File appears to exist already. Call `fetch(clobber=True)` ' 'to force overwriting of existing file.' ) return print ( 'Downloading {}' . format ( url ) ) fetch_utils . download_and_verify ( url , md5 , fname = dat_fname ) print ( 'Repacking files...' ) ascii2h5 ( dat_fname , h5_fname ) print ( 'Removing original file...' ) os . remove ( dat_fname )
Downloads the Chen et al. (2014) dust map.

    Args:
        clobber (Optional[:obj:`bool`]): If ``True``, any existing file will be
            overwritten, even if it appears to match. If ``False`` (the
            default), :obj:`fetch()` will attempt to determine if the dataset
            already exists. This determination is not 100\% robust against data
            corruption.