Example #1
0
def test_mock_covar():

    data_root = remote_data_file()
    kin = manga.MaNGAStellarKinematics.from_plateifu(8138, 12704, cube_path=data_root,
                                                     maps_path=data_root, covar=True)

    # Set the parameters close to the best-fitting parameters from a previous
    # run
    p0 = numpy.array([-0.2, -0.08, 166.3, 53.0, 25.6, 217.0, 2.82, 189.7, 16.2])

    disk = AxisymmetricDisk(rc=HyperbolicTangent(), dc=Exponential())
    v, s = disk.model(p0, x=kin.grid_x, y=kin.grid_y, sb=kin.grid_sb, beam=kin.beam_fft,
                      is_fft=True)
    vremap = kin.remap(kin.bin(v), mask=kin.vel_mask)
    sremap = kin.remap(kin.bin(s), mask=kin.sig_mask)

    # Fix the seed so that the result is deterministic
    # WARNING: Without this, there were instances where the deviate for the
    # dispersion would be entirely masked!  Need to understand how/why that can
    # happen.
    rng = numpy.random.default_rng(seed=909)
    mock_kin = disk.mock_observation(p0, kin=kin, add_err=True, rng=rng)
    mock_vremap = mock_kin.remap('vel')
    mock_sremap = mock_kin.remap(numpy.sqrt(mock_kin.sig_phys2), mask=kin.sig_mask)

    assert numpy.ma.std(mock_vremap-vremap) > 5, 'Velocity error changed'
    assert numpy.ma.std(mock_sremap-sremap) > 7, 'Dispersion error changed'
Example #2
0
def test_mock_err():

    data_root = remote_data_file()
    kin = manga.MaNGAStellarKinematics.from_plateifu(8138, 12704, cube_path=data_root,
                                                     maps_path=data_root)

    # Set the parameters close to the best-fitting parameters from a previous
    # run
    p0 = numpy.array([-0.2, -0.08, 166.3, 53.0, 25.6, 217.0, 2.82, 189.7, 16.2])

    disk = AxisymmetricDisk(rc=HyperbolicTangent(), dc=Exponential())
    v, s = disk.model(p0, x=kin.grid_x, y=kin.grid_y, sb=kin.grid_sb, beam=kin.beam_fft,
                      is_fft=True)
    _, bv, bs = kin.bin_moments(kin.grid_sb, v, s)
    vremap = kin.remap(bv, mask=kin.vel_mask)
    sremap = kin.remap(bs, mask=kin.sig_mask)

    rng = numpy.random.default_rng(seed=909)
    mock_kin = disk.mock_observation(p0, kin=kin, add_err=True, rng=rng)
    mock_vremap = mock_kin.remap('vel')
    mock_sremap = mock_kin.remap(numpy.sqrt(mock_kin.sig_phys2), mask=kin.sig_mask)

    assert numpy.ma.std(mock_vremap-vremap) > 5, 'Velocity error changed'
    assert numpy.ma.std(mock_sremap-sremap) > 7, 'Dispersion error changed'