new_fits = fits.open(new_fitsname, mode='update')

write_every = 10000

vel_res = cube._pix_size_slice(0) * u.m / u.s

print("And here we go!")
for num, (i, j) in enumerate(ProgressBar(zip(*posns))):
    # Don't bother rolling if there's nothing there
    if not np.isfinite(cube.filled_data[:, i, j]).any():
        continue

    shift = ((model[0].data[i, j] * u.m / u.s - vsys) / vel_res).value

    new_fits[0].data[:, i, j] = \
        fourier_shift(cube.filled_data[:, i, j], shift)

    # Now shift the source mask by the same amount
    # Gibbs ringing occurs at the edges, but the amplitudes will not
    # exceed 0.5. The rounding may cause a difference os +/- on pixel
    # one the edge of the valid regions.
    mask.data[:, i, j] = \
        (fourier_shift(mask.data[:, i, j], shift) > 0.5).astype(np.int)

    if num % write_every == 0:
        new_fits.flush()

# Save the rotation subtracted mask
new_mask_hdu = fits.PrimaryHDU(mask.data, header=mask.header)
new_mask_hdu.writeto(fourteenB_HI_data_path(rotsub_mask_name, no_check=True),
                     clobber=True)
示例#2
0
if os.path.exists(new_fitsname):
    print("Removing old rotsub version.")
    os.system("rm {}".format(new_fitsname))

create_huge_fits(new_fitsname, new_header)

new_fits = fits.open(new_fitsname, mode='update')

write_every = 20000

vel_res = cube._pix_size_slice(0) * u.m / u.s

vsys = gal.vsys.to(u.m / u.s)

print("And here we go!")
for num, (i, j) in enumerate(ProgressBar(zip(*posns))):
    # Don't bother rolling if there's nothing there
    if not np.isfinite(cube.filled_data[:, i, j]).any():
        continue

    shift = ((model[i, j] * u.m / u.s - vsys) / vel_res).value

    new_fits[0].data[:, i, j] = \
        fourier_shift(cube.filled_data[:, i, j], shift)

    if num % write_every == 0:
        new_fits.flush()

new_fits.flush()
new_fits.close()