Convert the Burstein & Heiles (1982) dust map from ASCII to HDF5.

def ascii2h5(bh_dir=None):
    """
    Convert the Burstein & Heiles (1982) dust map from ASCII to HDF5.
    """

    if bh_dir is None:
        bh_dir = os.path.join(data_dir_default, 'bh')

    fname = os.path.join(bh_dir, '{}.ascii')

    f = h5py.File('bh.h5', 'w')

    for region in ('hinorth', 'hisouth'):
        data = np.loadtxt(fname.format(region), dtype='f4')

        # Reshape and clip
        data.shape = (210, 201) # (R, N)
        data = data[:201]   # Last 9 records are empty

        # Use NaNs where no data
        data[data < -9000] = np.nan

        dset = f.create_dataset(
            region,
            data=data,
            chunks=True,
            compression='gzip',
            compression_opts=3
        )

        dset.attrs['axes'] = ('R', 'N')
        dset.attrs['description'] = (
            'HI 21cm column densities, in units of 10*NHYD. '
            'R = 100 + [(90^o-|b|) sin(l)]/[0.3 degrees]. '
            'N = 100 + [(90^o-|b|) cos (l)]/[0.3 degrees].'
        )

    for region in ('rednorth', 'redsouth'):
        data = np.loadtxt(fname.format(region), dtype='f4')

        # Reshape and clip
        data.shape = (94, 1200) # (R, N)
        data = data[:93]   # Last record is empty

        # Use NaNs where no data
        data[data < -9000] = np.nan

        dset = f.create_dataset(
            region,
            data=data,
            chunks=True,
            compression='gzip',
            compression_opts=3
        )

        dset.attrs['axes'] = ('R', 'N')
        dset.attrs['description'] = (
            'E(B-V), in units of 0.001 mag. '
            'R = (|b| - 10) / (0.6 degrees). '
            'N = (l + 0.15) / 0.3 - 1.'
        )

    f.attrs['description'] = (
        'The Burstein & Heiles (1982) dust map.'
    )

    f.close()