#mask = mask & (~absorption_mask)

min_background = 100
background_guess = med.value
background_guess[background_guess < min_background] = min_background
guesses = np.empty((4, ) + cubeK.shape[1:], dtype='float')
guesses[0, :] = background_guess
guesses[1, :] = -100
guesses[2, :] = 56
guesses[3, :] = 1.5

vcontcube_K7 = contcubeK.with_spectral_unit(
    u.km / u.s, rest_value=220.53932 * u.GHz,
    velocity_convention='radio').spectral_slab(42 * u.km / u.s,
                                               72 * u.km / u.s)
pcube_cont_K7 = pyspeckit.Cube(cube=vcontcube_K7)
start_point = (43, 43)  # np.unravel_index(np.nanargmax(peak*mask), peak.shape)
sp = pcube_cont_K7.get_spectrum(start_point[0], start_point[1])
sp.plotter()
sp.specfit(
    fittype='vheightgaussian',
    guesses=guesses[:, 43, 43],
    limitedmax=[T, T, T, T, T],
    limitedmin=[T, T, T, T, T],
    maxpars=[500, 0, 61, 6],
    minpars=[0, -500, 52, 0],
)

k7fitfn = 'e2e_CH3CN_K7_Gaussian_Absorption_fits'
if os.path.exists(k7fitfn):
    pcube_cont_K7.load_model_fit(k7fitfn, npars=4)
コード例 #2
0
    ).minimal_subcube()
    med = cube.percentile(25, axis=0)
    cube.allow_huge_operations = True
    cube = cube - med
    cube.write(cubefn)
else:
    cube = SpectralCube.read(cubefn).minimal_subcube()
cubeK = cube.to(
    u.K, u.brightness_temperature(cube.beam, cube.wcs.wcs.restfrq * u.Hz))
err = cubeK[:30].std(axis=0)
peak = cubeK.max(axis=0)
mask = (peak > 1 * u.K) & (peak > 6 * err)

subcube = cubeK.spectral_slab(-50 * u.km / u.s, 200 * u.km / u.s)

pcube = pyspeckit.Cube(cube=subcube)

vguesses = subcube.spectral_axis[subcube.argmax(axis=0)]
colguesses = np.ones_like(mask) * 1e15
temguesses = np.ones_like(mask) * 150.
widths = np.ones_like(mask) * 5.0
guesses = np.array([vguesses.value, widths, temguesses, colguesses])

mask &= ((vguesses < 95 * u.km / u.s) & (vguesses > -25 * u.km / u.s))
# For laptop
#mask &= (peak>10*u.K)

start_point = np.unravel_index(np.nanargmax(peak * mask), peak.shape)

position_order = 1. / peak.value
position_order[np.isnan(peak)] = np.inf
コード例 #3
0
# SKIP EMISSION                   errmap=err.value, multicore=4)
# SKIP EMISSION     pcube.write_fit('north_CH3CN_Emission_fits.fits', clobber=True)

min_background = 100
background_guess = med.value
background_guess[background_guess < min_background] = min_background
guesses = np.empty((5, ) + cubeK.shape[1:], dtype='float')
guesses[0, :] = 61
guesses[1, :] = 2
guesses[2, :] = 250.
guesses[3, :] = 1e16
guesses[4, :] = background_guess

# again, try cropping out the k=0,1 lines under the assumption that they do not
# trace the disk
pcube_cont = pyspeckit.Cube(cube=contcubeK[:400, :, :])
start_point = (302, 341
               )  # np.unravel_index(np.nanargmax(peak*mask), peak.shape)
sp = pcube_cont.get_spectrum(start_point[0], start_point[1])
sp.plotter()
sp.specfit(
    fittype='ch3cn_absorption',
    guesses=guesses[:, 66, 71],
    limitedmax=[T, T, T, T, T],
    limitedmin=[T, T, T, T, T],
    maxpars=[100, 5, 1500, 1e18, 10000],
    minpars=[0, 0.1, 50, 1e13, 100],
)

if os.path.exsits('north_CH3CN_Absorption_fits'):
    pcube_cont.load_model_fit('north_CH3CN_Absorption_fits', npars=5)
コード例 #4
0
    u.K, u.brightness_temperature(cube.beam, cube.wcs.wcs.restfrq * u.Hz))
cubeK = cube.to(
    u.K, u.brightness_temperature(cube.beam, cube.wcs.wcs.restfrq * u.Hz))
med = cubeK.percentile(25, axis=0)
cubeK.allow_huge_operations = True
cubeK = cubeK - med

# BAD error estimate
err = cubeK.std(axis=0)
err[:] = 5 * u.K
peak = (cubeK).max(axis=0)
mask = (peak > 200 * u.K)  # & (peak > 6*err)
absorption_mask = cubeK.min(axis=0) < -150 * u.K
mask = mask & (~absorption_mask)

pcube = pyspeckit.Cube(cube=cubeK[:400, :, :])  # crop out k=0,1

if os.path.exists('e2e_CH3CN_Emission_fits.fits'):
    pcube.load_model_fit('e2e_CH3CN_Emission_fits.fits', npars=4)
else:
    vguesses = 62 * u.km / u.s
    colguesses = np.ones_like(mask) * 1e16
    temguesses = np.ones_like(mask) * 250.
    widths = np.ones_like(mask) * 2.0
    #guesses = np.array([vguesses.value, widths, temguesses, colguesses])
    guesses = [62, 2.0, 250., 1e16]

    # For laptop
    #mask &= (peak>10*u.K)

    start_point = (43, 43
コード例 #5
0
#cubeK.allow_huge_operations=True
#cubeK = cubeK - med

# determine where absorption...
skew = cubeK.apply_numpy_function(scipy.stats.skew, axis=0)

# BAD error estimate
err = cubeK.std(axis=0)
err[:] = 5 * u.K
peak = (cubeK).max(axis=0)
nadir = (cubeK).min(axis=0)
#mask = (peak > 200*u.K) & (skew > 0.1)
absorption_mask = (skew < -0.1)
#mask = mask & (~absorption_mask)

pcube = pyspeckit.Cube(cube=cubeK)

if os.path.exists('e2e_multigauss_fits.fits'):
    pcube.load_model_fit('e2e_multigauss_fits.fits', npars=4)
else:
    #vguesses = 62*u.km/u.s
    #widths = np.ones_like(mask)*2.0
    #guesses = np.array([vguesses.value, widths, temguesses, colguesses])
    #guesses = [62, 2.0, 250., 1e16]
    guesses = np.zeros([17, cubeK.shape[1], cubeK.shape[2]])
    guesses[0, :, :] = 62
    guesses[1, :, :] = 2.0
    guesses[2:, absorption_mask] = -100
    guesses[2:, ~absorption_mask] = 100
    guesses[16, :, :] = med * (med > 0)