discminer 0.1.0__tar.gz → 0.2.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {discminer-0.1.0 → discminer-0.2.0}/PKG-INFO +1 -1
- {discminer-0.1.0 → discminer-0.2.0}/_mining/make_channels.py +1 -1
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_attributes_model.py +7 -32
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_azimuthal_profiles.py +13 -51
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_moment+offset.py +2 -6
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_moment+residuals.py +2 -6
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_peak_residuals.py +16 -44
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_radial_profiles.py +84 -84
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_residuals+all.py +5 -4
- {discminer-0.1.0 → discminer-0.2.0}/_mining/plot_residuals+deproj.py +14 -15
- {discminer-0.1.0 → discminer-0.2.0}/_mining/utils.py +81 -8
- discminer-0.2.0/discminer/_version.py +1 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/disc2d.py +7 -4
- {discminer-0.1.0 → discminer-0.2.0}/discminer/grid.py +1 -1
- {discminer-0.1.0 → discminer-0.2.0}/discminer/plottools.py +239 -113
- {discminer-0.1.0 → discminer-0.2.0}/discminer/rail.py +9 -2
- {discminer-0.1.0 → discminer-0.2.0}/discminer.egg-info/PKG-INFO +1 -1
- {discminer-0.1.0 → discminer-0.2.0}/template/README.rst +13 -0
- discminer-0.1.0/discminer/_version.py +0 -1
- {discminer-0.1.0 → discminer-0.2.0}/LICENSE +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/README.md +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/_mining/make_parfile.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/_mining/make_single_moments.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/__init__.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/cart.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/constants.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/core.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/cube.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_box.png +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_cursor.jpeg +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_path.png +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_return.png +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_surface.png +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/button_trash.jpg +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/icons/logo.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/pick.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/testyapf.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/tools/discminer.mplstyle +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/tools/fit_kernel.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/tools/utils.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer/units.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer.egg-info/SOURCES.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer.egg-info/dependency_links.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer.egg-info/requires.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/discminer.egg-info/top_level.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/pyproject.toml +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/setup.cfg +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/setup.py +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/template/download_MAPS.sh +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/template/log_pars_mwc480_12co_0p2_maps_cube_256walkers_10000steps.txt +0 -0
- {discminer-0.1.0 → discminer-0.2.0}/template/prepare_data.py +0 -0
@@ -104,7 +104,7 @@ plt.savefig('channel_maps_model.png', bbox_inches = 'tight', dpi=200)
|
|
104
104
|
plt.close()
|
105
105
|
|
106
106
|
#RESIDUAL CHANNELS
|
107
|
-
noise_mean, mask = get_noise_mask(datacube
|
107
|
+
noise_mean, mask = get_noise_mask(datacube)
|
108
108
|
|
109
109
|
residualscube = Cube(datacube.data-modelcube.data, datacube.header, datacube.vchannels, dpc, beam=datacube.beam)
|
110
110
|
residualscube.filename = 'cube_residuals_%s.fits'%tag
|
@@ -1,7 +1,5 @@
|
|
1
|
-
from discminer.core import Data
|
2
|
-
from discminer.disc2d import General2d
|
3
1
|
from discminer.plottools import use_discminer_style, make_up_ax
|
4
|
-
import
|
2
|
+
from utils import init_data_and_model, get_noise_mask
|
5
3
|
|
6
4
|
import numpy as np
|
7
5
|
import matplotlib.pyplot as plt
|
@@ -27,39 +25,16 @@ custom = pars['custom']
|
|
27
25
|
#****************
|
28
26
|
file_data = meta['file_data']
|
29
27
|
tag = meta['tag']
|
30
|
-
au_to_m = u.au.to('m')
|
31
28
|
|
32
|
-
dpc = meta['dpc']*u.pc
|
33
29
|
Rmax = 1.1*best['intensity']['Rout']*u.au #Max model radius, 10% larger than disc Rout
|
34
30
|
|
35
|
-
|
36
|
-
#LOAD DATA
|
37
|
-
|
38
|
-
datacube =
|
39
|
-
vchannels = datacube.vchannels
|
40
|
-
|
41
|
-
#****************************
|
42
|
-
#INIT MODEL AND PRESCRIPTIONS
|
43
|
-
#****************************
|
44
|
-
model = General2d(datacube, Rmax, Rmin=0, prototype=True)
|
45
|
-
|
46
|
-
model.z_upper_func = cart.z_upper_exp_tapered
|
47
|
-
model.z_lower_func = cart.z_lower_exp_tapered
|
48
|
-
model.velocity_func = model.keplerian_vertical # vrot = sqrt(GM/r**3)*R
|
49
|
-
model.line_profile = model.line_profile_bell
|
50
|
-
|
51
|
-
if 'I2pwl' in meta['kind']:
|
52
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak
|
53
|
-
elif 'I2pwlnosurf' in meta['kind']:
|
54
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak_nosurf
|
55
|
-
else:
|
56
|
-
model.intensity_func = cart.intensity_powerlaw_rout
|
31
|
+
#*******************
|
32
|
+
#LOAD DATA AND MODEL
|
33
|
+
#*******************
|
34
|
+
datacube, model = init_data_and_model()
|
57
35
|
|
58
|
-
|
59
|
-
|
60
|
-
#**************
|
61
|
-
model.params = copy.copy(best)
|
62
|
-
model.params['intensity']['I0'] /= meta['downsamp_factor']
|
36
|
+
noise_mean, mask = get_noise_mask(datacube, thres=2)
|
37
|
+
vchannels = datacube.vchannels
|
63
38
|
model.make_model()
|
64
39
|
|
65
40
|
#**************
|
@@ -1,10 +1,7 @@
|
|
1
|
-
from discminer.
|
1
|
+
from discminer.rail import Rail, Contours
|
2
2
|
from discminer.plottools import (get_discminer_cmap,
|
3
3
|
make_up_ax, mod_major_ticks,
|
4
4
|
use_discminer_style, mod_nticks_cbars)
|
5
|
-
from discminer.rail import Rail, Contours
|
6
|
-
from discminer.disc2d import General2d
|
7
|
-
import discminer.cart as cart
|
8
5
|
|
9
6
|
import numpy as np
|
10
7
|
import matplotlib.pyplot as plt
|
@@ -16,7 +13,7 @@ import copy
|
|
16
13
|
import sys
|
17
14
|
|
18
15
|
from argparse import ArgumentParser
|
19
|
-
from utils import get_1d_plot_decorators
|
16
|
+
from utils import init_data_and_model, get_noise_mask, get_1d_plot_decorators
|
20
17
|
|
21
18
|
use_discminer_style()
|
22
19
|
|
@@ -40,6 +37,7 @@ custom = pars['custom']
|
|
40
37
|
|
41
38
|
vsys = best['velocity']['vsys']
|
42
39
|
incl = best['orientation']['incl']
|
40
|
+
Rout = best['intensity']['Rout']
|
43
41
|
|
44
42
|
clabel, clabel_res, clim0, clim0_res, clim1, clim1_res, unit = get_1d_plot_decorators(args.moment, tag=args.kind)
|
45
43
|
|
@@ -53,58 +51,22 @@ if args.moment=='velocity':
|
|
53
51
|
clabel = r'Velocity %s %s'%(args.kind, unit)
|
54
52
|
else:
|
55
53
|
clabel = r'Deprojected Velocity %s %s'%(args.kind, unit)
|
56
|
-
|
57
|
-
#****************
|
58
|
-
#SOME DEFINITIONS
|
59
|
-
#****************
|
60
|
-
file_data = meta['file_data']
|
61
|
-
tag = meta['tag']
|
62
|
-
au_to_m = u.au.to('m')
|
63
|
-
|
64
|
-
dpc = meta['dpc']*u.pc
|
65
|
-
Rout = best['intensity']['Rout']
|
66
|
-
Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
67
|
-
|
68
|
-
#**********
|
69
|
-
#LOAD DATA
|
70
|
-
#**********
|
71
|
-
datacube = Data(file_data, dpc) # Read data and convert to Cube object
|
72
|
-
noise = np.std( np.append(datacube.data[:5,:,:], datacube.data[-5:,:,:], axis=0), axis=0)
|
73
|
-
mask = np.max(datacube.data, axis=0) < 4*np.mean(noise)
|
74
|
-
vchannels = datacube.vchannels
|
75
54
|
|
76
|
-
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
model.z_upper_func = cart.z_upper_exp_tapered
|
82
|
-
model.z_lower_func = cart.z_lower_exp_tapered
|
83
|
-
model.velocity_func = model.keplerian_vertical
|
84
|
-
model.line_profile = model.line_profile_bell
|
85
|
-
|
86
|
-
if 'I2pwl' in meta['kind']:
|
87
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak
|
88
|
-
elif 'I2pwlnosurf' in meta['kind']:
|
89
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak_nosurf
|
90
|
-
else:
|
91
|
-
model.intensity_func = cart.intensity_powerlaw_rout
|
92
|
-
|
93
|
-
#**************
|
94
|
-
#PROTOTYPE PARS
|
95
|
-
#**************
|
96
|
-
model.params = copy.copy(best)
|
97
|
-
model.params['intensity']['I0'] /= meta['downsamp_factor']
|
55
|
+
#*******************
|
56
|
+
#LOAD DATA AND MODEL
|
57
|
+
#*******************
|
58
|
+
datacube, model = init_data_and_model()
|
98
59
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
model.make_model() #Make model, just needed to load disc geometry
|
60
|
+
noise_mean, mask = get_noise_mask(datacube, thres=2)
|
61
|
+
vchannels = datacube.vchannels
|
62
|
+
model.make_model()
|
103
63
|
|
104
64
|
#*************************
|
105
65
|
#LOAD MOMENT MAPS
|
106
66
|
moment_data = fits.getdata('%s_gaussian_data.fits'%args.moment)
|
107
67
|
moment_model = fits.getdata('%s_gaussian_model.fits'%args.moment)
|
68
|
+
#moment_data = fits.getdata('%s_up_doublebell_mask_data.fits'%args.moment)
|
69
|
+
#moment_model = fits.getdata('%s_up_doublebell_mask_model.fits'%args.moment)
|
108
70
|
|
109
71
|
#**************************
|
110
72
|
#MASK AND COMPUTE RESIDUALS
|
@@ -125,7 +87,7 @@ if args.kind!='residuals' and args.moment=='velocity': #deproject velocity field
|
|
125
87
|
beam_au = datacube.beam_size.to('au').value
|
126
88
|
R_prof = np.arange(2*beam_au, 0.8*Rout, beam_au/4)
|
127
89
|
|
128
|
-
color_bounds = np.array([0.
|
90
|
+
color_bounds = np.array([0.5, 1.0])*Rout
|
129
91
|
|
130
92
|
rail = Rail(model, map2d, R_prof)
|
131
93
|
|
@@ -23,9 +23,6 @@ use_discminer_style()
|
|
23
23
|
|
24
24
|
parser = ArgumentParser(prog='plot moment maps', description='Plot moment map [velocity, linewidth, [peakintensity, peakint]?')
|
25
25
|
args = add_parser_args(parser, moment=True, kind=True, surface=True)
|
26
|
-
|
27
|
-
if args.moment=='peakint':
|
28
|
-
args.moment = 'peakintensity'
|
29
26
|
|
30
27
|
#**********************
|
31
28
|
#JSON AND PARSER STUFF
|
@@ -46,7 +43,6 @@ ctitle, clabel, clim, cfmt, cmap_mom, cmap_res, levels_im, levels_cc, unit = get
|
|
46
43
|
#****************
|
47
44
|
file_data = meta['file_data']
|
48
45
|
tag = meta['tag']
|
49
|
-
au_to_m = u.au.to('m')
|
50
46
|
|
51
47
|
dpc = meta['dpc']*u.pc
|
52
48
|
Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
@@ -55,7 +51,7 @@ Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
|
55
51
|
#LOAD DATA AND GRID
|
56
52
|
#********************
|
57
53
|
datacube = Data(file_data, dpc) # Read data and convert to Cube object
|
58
|
-
noise_mean, mask = get_noise_mask(datacube
|
54
|
+
noise_mean, mask = get_noise_mask(datacube)
|
59
55
|
|
60
56
|
#Useful definitions for plots
|
61
57
|
with open('grid_extent.json') as json_file:
|
@@ -117,7 +113,7 @@ for axi in ax[1:]:
|
|
117
113
|
axi.grid(color='k', ls='--')
|
118
114
|
|
119
115
|
for i,axi in enumerate(ax):
|
120
|
-
Contours.emission_surface(axi, R, phi, extent=extent, R_lev=np.linspace(0.1, 1.0, 10)*Rout*
|
116
|
+
Contours.emission_surface(axi, R, phi, extent=extent, R_lev=np.linspace(0.1, 1.0, 10)*Rout*u.au.to('m'), which=mtags['surf'])
|
121
117
|
|
122
118
|
patch = Rectangle([-zoomwidth]*2, 2*zoomwidth, 2*zoomwidth, edgecolor=zoomcolor, facecolor='none',
|
123
119
|
lw=2.0, ls=(0, (1,1.5)), capstyle='round')
|
@@ -22,9 +22,6 @@ use_discminer_style()
|
|
22
22
|
|
23
23
|
parser = ArgumentParser(prog='plot moment maps', description='Plot moment map [velocity, linewidth, [peakintensity, peakint]?')
|
24
24
|
args = add_parser_args(parser, moment=True, kind=True, surface=True)
|
25
|
-
|
26
|
-
if args.moment=='peakint':
|
27
|
-
args.moment = 'peakintensity'
|
28
25
|
|
29
26
|
#**********************
|
30
27
|
#JSON AND PARSER STUFF
|
@@ -45,7 +42,6 @@ ctitle, clabel, clim, cfmt, cmap_mom, cmap_res, levels_im, levels_cc, unit = get
|
|
45
42
|
#****************
|
46
43
|
file_data = meta['file_data']
|
47
44
|
tag = meta['tag']
|
48
|
-
au_to_m = u.au.to('m')
|
49
45
|
|
50
46
|
dpc = meta['dpc']*u.pc
|
51
47
|
Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
@@ -54,7 +50,7 @@ Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
|
54
50
|
#LOAD DATA AND GRID
|
55
51
|
#********************
|
56
52
|
datacube = Data(file_data, dpc) # Read data and convert to Cube object
|
57
|
-
noise_mean, mask = get_noise_mask(datacube
|
53
|
+
noise_mean, mask = get_noise_mask(datacube)
|
58
54
|
|
59
55
|
#Useful definitions for plots
|
60
56
|
with open('grid_extent.json') as json_file:
|
@@ -129,7 +125,7 @@ for axi in ax:
|
|
129
125
|
for axi in ax[1:]: axi.tick_params(labelleft=False)
|
130
126
|
|
131
127
|
for i,axi in enumerate(ax):
|
132
|
-
Contours.emission_surface(axi, R, phi, extent=extent, R_lev=np.linspace(0.1, 1.0, 10)*Rout*
|
128
|
+
Contours.emission_surface(axi, R, phi, extent=extent, R_lev=np.linspace(0.1, 1.0, 10)*Rout*u.au.to('m'), which=mtags['surf'])
|
133
129
|
|
134
130
|
|
135
131
|
plt.savefig('moment+residuals_%s.png'%mtags['base'], bbox_inches='tight', dpi=200)
|
@@ -1,10 +1,7 @@
|
|
1
|
-
from discminer.core import Data
|
2
1
|
from discminer.plottools import (get_discminer_cmap, append_sigma_panel,
|
3
2
|
make_up_ax, mod_minor_ticks, mod_major_ticks,
|
4
3
|
use_discminer_style, mod_nticks_cbars,
|
5
4
|
make_substructures, make_round_map)
|
6
|
-
from discminer.disc2d import General2d
|
7
|
-
import discminer.cart as cart
|
8
5
|
from discminer.pick import Pick
|
9
6
|
from discminer.rail import Contours
|
10
7
|
|
@@ -15,7 +12,12 @@ from astropy import units as u
|
|
15
12
|
import json
|
16
13
|
import copy
|
17
14
|
|
18
|
-
from utils import
|
15
|
+
from utils import (init_data_and_model,
|
16
|
+
get_noise_mask,
|
17
|
+
add_parser_args,
|
18
|
+
get_2d_plot_decorators,
|
19
|
+
load_moments)
|
20
|
+
|
19
21
|
from argparse import ArgumentParser
|
20
22
|
|
21
23
|
use_discminer_style()
|
@@ -24,9 +26,6 @@ parser = ArgumentParser(prog='Identify and show peak residuals', description='Id
|
|
24
26
|
parser.add_argument('-c', '--clean_thres', default=np.inf, type=float, help="Threshold above which peak residuals will be rejected.")
|
25
27
|
args = add_parser_args(parser, moment=True, kind=True, surface=True, fold=True, projection=True, Rinner=True, Router=True)
|
26
28
|
|
27
|
-
if args.moment=='peakint':
|
28
|
-
args.moment = 'peakintensity'
|
29
|
-
|
30
29
|
#**********************
|
31
30
|
#JSON AND PARSER STUFF
|
32
31
|
#**********************
|
@@ -59,40 +58,13 @@ au_to_m = u.au.to('m')
|
|
59
58
|
dpc = meta['dpc']*u.pc
|
60
59
|
Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
61
60
|
|
62
|
-
|
63
|
-
#LOAD DATA
|
64
|
-
|
65
|
-
datacube =
|
66
|
-
noise = np.std( np.append(datacube.data[:5,:,:], datacube.data[-5:,:,:], axis=0), axis=0)
|
67
|
-
mask = np.max(datacube.data, axis=0) < 4*np.mean(noise)
|
68
|
-
vchannels = datacube.vchannels
|
69
|
-
|
70
|
-
#****************************
|
71
|
-
#INIT MODEL AND PRESCRIPTIONS
|
72
|
-
#****************************
|
73
|
-
model = General2d(datacube, Rmax, Rmin=0, prototype=True)
|
74
|
-
|
75
|
-
model.z_upper_func = cart.z_upper_exp_tapered
|
76
|
-
model.z_lower_func = cart.z_lower_exp_tapered
|
77
|
-
model.velocity_func = model.keplerian_vertical # vrot = sqrt(GM/r**3)*R
|
78
|
-
model.line_profile = model.line_profile_bell
|
79
|
-
|
80
|
-
if 'I2pwl' in meta['kind']:
|
81
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak
|
82
|
-
elif 'I2pwlnosurf' in meta['kind']:
|
83
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak_nosurf
|
84
|
-
else:
|
85
|
-
model.intensity_func = cart.intensity_powerlaw_rout
|
86
|
-
|
87
|
-
#**************
|
88
|
-
#PROTOTYPE PARS
|
89
|
-
#**************
|
90
|
-
model.params = copy.copy(best)
|
91
|
-
model.params['intensity']['I0'] /= meta['downsamp_factor']
|
61
|
+
#*******************
|
62
|
+
#LOAD DATA AND MODEL
|
63
|
+
#*******************
|
64
|
+
datacube, model = init_data_and_model()
|
92
65
|
|
93
|
-
|
94
|
-
|
95
|
-
#**************************
|
66
|
+
noise_mean, mask = get_noise_mask(datacube, thres=2)
|
67
|
+
vchannels = datacube.vchannels
|
96
68
|
model.make_model()
|
97
69
|
|
98
70
|
#*************************
|
@@ -177,23 +149,23 @@ if args.projection=='cartesian':
|
|
177
149
|
levels_resid = np.linspace(-clim, clim, 32)
|
178
150
|
|
179
151
|
if args.surface in ['up', 'upper']:
|
180
|
-
z_func =
|
152
|
+
z_func = model.z_upper_func
|
181
153
|
z_pars = best['height_upper']
|
182
154
|
|
183
155
|
elif args.surface in ['low', 'lower']:
|
184
|
-
z_func =
|
156
|
+
z_func = model.z_lower_func
|
185
157
|
z_pars = best['height_lower']
|
186
158
|
|
187
159
|
fig, ax = make_round_map(folded_map, levels_resid, pick.X*u.au, pick.Y*u.au, R_prof[-1]*u.au,
|
188
160
|
z_func=z_func, z_pars=z_pars, incl=incl, PA=PA, xc=xc, yc=yc,
|
189
|
-
cmap=cmap_res,
|
161
|
+
cmap=cmap_res, clabel=unit, fmt=cfmt,
|
190
162
|
rings=rings,
|
191
163
|
mask_wedge=(90, 270)*u.deg,
|
192
164
|
mask_inner=R_prof[0]*u.au)
|
193
165
|
ax.scatter(lev*cos_peak, lev*sin_peak, edgecolors='none', facecolors=color, alpha=0.2, s=100)
|
194
166
|
ax.scatter(lev*cos_peak, lev*sin_peak, edgecolors='none', facecolors=color, alpha=1.0, s=10)
|
195
167
|
ax.scatter(lev*cos_peak, lev*sin_peak, edgecolors='0.3', facecolors='none', alpha=1.0, s=100)
|
196
|
-
ax.set_title('%s, folded map'%ctitle, fontsize=
|
168
|
+
ax.set_title('%s, folded map'%ctitle, fontsize=16, color='k')
|
197
169
|
|
198
170
|
|
199
171
|
plt.savefig('folded_residuals_deproj_%s_%s.png'%(mtags['base'], args.projection), bbox_inches='tight', dpi=200)
|
@@ -1,30 +1,33 @@
|
|
1
|
-
from discminer.
|
2
|
-
from discminer.plottools import (get_discminer_cmap,
|
1
|
+
from discminer.plottools import (get_discminer_cmap, make_substructures,
|
3
2
|
make_up_ax, mod_minor_ticks, mod_major_ticks,
|
4
3
|
use_discminer_style, mod_nticks_cbars)
|
5
4
|
from discminer.rail import Rail, Contours
|
6
|
-
from discminer.disc2d import General2d
|
7
|
-
import discminer.cart as cart
|
8
5
|
|
9
6
|
import numpy as np
|
10
7
|
import matplotlib.pyplot as plt
|
11
8
|
from scipy.signal import savgol_filter
|
9
|
+
from scipy.interpolate import interp1d
|
12
10
|
|
13
11
|
from astropy import units as u
|
14
12
|
from astropy.io import fits
|
15
13
|
import json
|
16
14
|
import copy
|
17
15
|
|
18
|
-
from utils import
|
16
|
+
from utils import (init_data_and_model,
|
17
|
+
get_noise_mask,
|
18
|
+
get_1d_plot_decorators,
|
19
|
+
load_moments,
|
20
|
+
load_disc_grid,
|
21
|
+
add_parser_args,
|
22
|
+
make_1d_legend,
|
23
|
+
MEDIUM_SIZE)
|
24
|
+
|
19
25
|
from argparse import ArgumentParser
|
20
26
|
|
21
27
|
use_discminer_style()
|
22
28
|
|
23
29
|
parser = ArgumentParser(prog='plot radial profiles', description='Plot radial profiles from moments and residuals [velocity, linewidth, [peakintensity, peakint]?')
|
24
|
-
args = add_parser_args(parser, moment=True, kind=True, surface=True, writetxt=True,
|
25
|
-
|
26
|
-
if args.moment=='peakint':
|
27
|
-
args.moment = 'peakintensity'
|
30
|
+
args = add_parser_args(parser, moment=True, kind=True, surface=True, writetxt=True, mask_minor=True, mask_major=True, Rinner=True, Router=True)
|
28
31
|
|
29
32
|
#**********************
|
30
33
|
#JSON AND PARSER STUFF
|
@@ -39,65 +42,38 @@ custom = pars['custom']
|
|
39
42
|
Mstar = best['velocity']['Mstar']
|
40
43
|
vsys = best['velocity']['vsys']
|
41
44
|
vel_sign = best['velocity']['vel_sign']
|
45
|
+
Rout = best['intensity']['Rout']
|
42
46
|
incl = best['orientation']['incl']
|
43
47
|
|
44
48
|
gaps = custom['gaps']
|
45
49
|
rings = custom['rings']
|
46
|
-
|
50
|
+
Rmax = 1.1*Rout*u.au #Max model radius, 10% larger than disc Rout
|
47
51
|
|
48
52
|
clabel, clabel_res, clim0, clim0_res, clim1, clim1_res, unit = get_1d_plot_decorators(args.moment)
|
49
53
|
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
tag = meta['tag']
|
55
|
-
au_to_m = u.au.to('m')
|
56
|
-
|
57
|
-
dpc = meta['dpc']*u.pc
|
58
|
-
Rmax = 1.1*best['intensity']['Rout']*u.au #Max model radius, 10% larger than disc Rout
|
59
|
-
|
60
|
-
#********
|
61
|
-
#LOAD DATA
|
62
|
-
#********
|
63
|
-
datacube = Data(file_data, dpc) # Read data and convert to Cube object
|
64
|
-
noise = np.std( np.append(datacube.data[:5,:,:], datacube.data[-5:,:,:], axis=0), axis=0)
|
65
|
-
mask = np.max(datacube.data, axis=0) < 4*np.mean(noise)
|
66
|
-
vchannels = datacube.vchannels
|
67
|
-
|
68
|
-
#****************************
|
69
|
-
#INIT MODEL AND PRESCRIPTIONS
|
70
|
-
#****************************
|
71
|
-
model = General2d(datacube, Rmax, Rmin=0, prototype=True)
|
54
|
+
#*******************
|
55
|
+
#LOAD DATA AND MODEL
|
56
|
+
#*******************
|
57
|
+
datacube, model = init_data_and_model()
|
72
58
|
|
73
|
-
|
74
|
-
|
75
|
-
model.
|
76
|
-
model.line_profile = model.line_profile_bell
|
59
|
+
noise_mean, mask = get_noise_mask(datacube, thres=2)
|
60
|
+
vchannels = datacube.vchannels
|
61
|
+
model.make_model()
|
77
62
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
model.intensity_func = cart.intensity_powerlaw_rbreak_nosurf
|
82
|
-
else:
|
83
|
-
model.intensity_func = cart.intensity_powerlaw_rout
|
63
|
+
#*************************
|
64
|
+
#LOAD DISC GEOMETRY
|
65
|
+
R, phi, z = load_disc_grid()
|
84
66
|
|
85
|
-
|
86
|
-
|
87
|
-
#**************
|
88
|
-
model.params = copy.copy(best)
|
89
|
-
model.params['intensity']['I0'] /= meta['downsamp_factor']
|
90
|
-
|
91
|
-
#**************************
|
92
|
-
#MAKE MODEL (2D ATTRIBUTES)
|
93
|
-
#**************************
|
94
|
-
model.make_model()
|
67
|
+
R_s = R[args.surface]*u.m.to('au')
|
68
|
+
phi_s = phi[args.surface]
|
95
69
|
|
96
70
|
#*************************
|
97
71
|
#LOAD MOMENT MAPS
|
98
72
|
moment_data, moment_model, mtags = load_moments(args)
|
99
73
|
if mtags['surf']=='both':
|
100
74
|
surf_ref = 'upper'
|
75
|
+
else:
|
76
|
+
surf_ref = args.surface
|
101
77
|
tag_base = mtags['base']
|
102
78
|
|
103
79
|
#**************************
|
@@ -112,7 +88,7 @@ if args.moment=='velocity':
|
|
112
88
|
#**************************
|
113
89
|
#MAKE PLOTS
|
114
90
|
beam_au = datacube.beam_size.to('au').value
|
115
|
-
R_prof = np.arange(
|
91
|
+
R_prof = np.arange(args.Rinner*beam_au, args.Router*Rout, beam_au/5)
|
116
92
|
xlim0, xlim1 = 0.5*R_prof[0], 1.05*R_prof[-1]
|
117
93
|
|
118
94
|
def writetxt(arr, tag=''):
|
@@ -144,17 +120,20 @@ def make_savgol(prof):
|
|
144
120
|
|
145
121
|
|
146
122
|
if args.moment=='velocity':
|
147
|
-
mask_ang = args.
|
123
|
+
mask_ang = args.mask_minor #+-mask around disc minor axis
|
148
124
|
#*******************
|
149
125
|
#VELOCITY COMPONENTS
|
150
126
|
#*******************
|
127
|
+
|
128
|
+
#VZ
|
151
129
|
rail_vz = Rail(model, moment_residuals, R_prof)
|
152
130
|
vel_z, vel_z_error = rail_vz.get_average(mask_ang=mask_ang, surface=surf_ref)
|
153
131
|
div_factor_z = get_normalisation(mask_ang, component='z')
|
154
132
|
|
155
133
|
vel_z /= div_factor_z
|
156
134
|
vel_z_error /= div_factor_z
|
157
|
-
|
135
|
+
|
136
|
+
#DVPHI
|
158
137
|
rail_phi = Rail(model, moment_residuals_abs, R_prof)
|
159
138
|
vel_phi, vel_phi_error = rail_phi.get_average(mask_ang=mask_ang, surface=surf_ref)
|
160
139
|
div_factor_phi = get_normalisation(mask_ang, component='phi')
|
@@ -162,19 +141,46 @@ if args.moment=='velocity':
|
|
162
141
|
vel_phi /= div_factor_phi
|
163
142
|
vel_phi_error /= div_factor_phi
|
164
143
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
144
|
+
#VPHI
|
145
|
+
rail_phi = Rail(model, np.abs(moment_data-vsys), R_prof)
|
146
|
+
vel_rot, _ = rail_phi.get_average(mask_ang=mask_ang, surface=surf_ref)
|
147
|
+
vel_rot /= div_factor_phi
|
148
|
+
vel_rot_error = vel_phi_error
|
170
149
|
|
150
|
+
#VR
|
151
|
+
mask_r = mask | (np.abs(phi_s) < np.radians(args.mask_major)) | (np.abs(phi_s) > np.radians(180-args.mask_major))
|
152
|
+
moment_data_r = np.where(mask_r, np.nan, moment_data)
|
153
|
+
|
154
|
+
f_vp = interp1d(R_prof, vel_rot)
|
155
|
+
f_vz = interp1d(R_prof, vel_z)
|
156
|
+
R_interp = np.where((R_s>R_prof[0]) & (R_s<R_prof[-1]), R_s, R_prof[0])
|
157
|
+
|
158
|
+
vr = -1/(np.sin(phi_s)*np.sin(incl)) * (moment_data_r - vsys - vel_sign*f_vp(R_interp)*np.cos(phi_s)*np.sin(incl) + f_vz(R_interp)*np.cos(incl))
|
159
|
+
|
160
|
+
rail_vr = Rail(model, vr, R_prof)
|
161
|
+
vel_r, vel_r_error = rail_vr.get_average(mask_ang=0.0, surface=surf_ref, av_func=np.nanmedian)
|
162
|
+
|
163
|
+
#WRITE?
|
171
164
|
if args.writetxt: writetxt([R_prof, vel_z, vel_z_error], tag='vz')
|
165
|
+
if args.writetxt: writetxt([R_prof, vel_r, vel_r_error], tag='vr')
|
172
166
|
if args.writetxt: writetxt([R_prof, vel_phi, vel_phi_error], tag='vphi')
|
167
|
+
if args.writetxt: writetxt([R_prof, vel_rot, vel_phi_error], tag='rotationcurve')
|
173
168
|
|
169
|
+
#PLOT 3D VELOCITIES
|
170
|
+
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(14,4))
|
171
|
+
|
174
172
|
ysav_phi, ysav_phi_deriv = make_savgol(vel_phi)
|
175
|
-
ax.plot(R_prof, ysav_phi, c='dodgerblue', lw=3, label=r'$\phi
|
173
|
+
ax.plot(R_prof, ysav_phi, c='dodgerblue', lw=3, label=r'$\Delta\upsilon_\phi$', zorder=12)
|
176
174
|
ax.fill_between(R_prof, vel_phi+vel_phi_error, vel_phi-vel_phi_error, color='dodgerblue', alpha=0.15, zorder=9)
|
177
175
|
|
176
|
+
ysav_z, ysav_z_deriv = make_savgol(vel_z)
|
177
|
+
ax.plot(R_prof, ysav_z, c='k', lw=3, label=r'$\upsilon_{\rm z}$', zorder=8)
|
178
|
+
ax.fill_between(R_prof, vel_z+vel_z_error, vel_z-vel_z_error, color='k', alpha=0.15, zorder=8)
|
179
|
+
|
180
|
+
ysav_r, ysav_r_deriv = make_savgol(vel_r)
|
181
|
+
ax.plot(R_prof, ysav_r, c='#FFB000', lw=3, label=r'$\upsilon_{\rm R}$', zorder=7)
|
182
|
+
ax.fill_between(R_prof, vel_r+vel_r_error, vel_r-vel_r_error, color='#FFB000', alpha=0.15, zorder=7)
|
183
|
+
|
178
184
|
ax.axhline(0, lw=2, ls='--', color='0.7')
|
179
185
|
|
180
186
|
ax.set_xlabel('Radius [au]')
|
@@ -183,9 +189,9 @@ if args.moment=='velocity':
|
|
183
189
|
ax.set_ylim(clim0_res, clim1_res)
|
184
190
|
mod_major_ticks(ax, axis='x', nbins=10)
|
185
191
|
mod_minor_ticks(ax)
|
186
|
-
ax
|
187
|
-
|
188
|
-
|
192
|
+
make_1d_legend(ax, fontsize=MEDIUM_SIZE+1)
|
193
|
+
|
194
|
+
make_substructures(ax, gaps=gaps, rings=rings, label_gaps=True, label_rings=True)
|
189
195
|
|
190
196
|
plt.savefig('velocity_components_%s.png'%tag_base, bbox_inches='tight', dpi=200)
|
191
197
|
plt.show()
|
@@ -193,30 +199,24 @@ if args.moment=='velocity':
|
|
193
199
|
#*******************
|
194
200
|
#ROTATION CURVE
|
195
201
|
#*******************
|
196
|
-
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(14,4))
|
197
|
-
|
198
|
-
#DATA CURVE
|
199
|
-
rail_phi = Rail(model, np.abs(moment_data-vsys), R_prof)
|
200
|
-
vel_rot, _ = rail_phi.get_average(mask_ang=mask_ang, surface=surf_ref)
|
201
|
-
vel_rot /= div_factor_phi
|
202
|
+
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(14,4))
|
202
203
|
|
204
|
+
#DATA CURVE
|
203
205
|
ysav_rot, ysav_rot_deriv = make_savgol(vel_rot)
|
204
|
-
ax.plot(R_prof, ysav_rot, c='tomato', lw=3.5, label=r'Data
|
205
|
-
ax.fill_between(R_prof, vel_rot+
|
206
|
-
|
207
|
-
if args.writetxt: writetxt([R_prof, vel_rot, vel_phi_error], tag='rotationcurve')
|
208
|
-
|
206
|
+
ax.plot(R_prof, ysav_rot, c='tomato', lw=3.5, label=r'Data', zorder=12)
|
207
|
+
ax.fill_between(R_prof, vel_rot+vel_rot_error, vel_rot-vel_rot_error, color='tomato', alpha=0.15, zorder=9)
|
208
|
+
|
209
209
|
#r"""
|
210
210
|
#MODEL CURVE
|
211
211
|
rail_phi = Rail(model, np.abs(moment_model-vsys), R_prof)
|
212
212
|
vel_phi, _ = rail_phi.get_average(mask_ang=mask_ang, surface=surf_ref)
|
213
213
|
vel_phi /= div_factor_phi
|
214
214
|
ysav_phi, ysav_phi_deriv = make_savgol(vel_phi)
|
215
|
-
ax.plot(R_prof, ysav_phi, c='0.7', lw=4.0, label=r'Model
|
215
|
+
ax.plot(R_prof, ysav_phi, c='0.7', lw=4.0, label=r'Model', zorder=11)
|
216
216
|
#"""
|
217
217
|
|
218
218
|
#PERFECT KEPLERIAN
|
219
|
-
coords = {'R': R_prof*
|
219
|
+
coords = {'R': R_prof*u.au.to('m')}
|
220
220
|
velocity_upper = model.get_attribute_map(coords, 'velocity', surface=surf_ref) * vel_sign
|
221
221
|
ax.plot(R_prof, velocity_upper, c='k', lw=2.5, ls='--', label=r'Keplerian (%.2f Msun)'%Mstar, zorder=13)
|
222
222
|
|
@@ -229,9 +229,9 @@ if args.moment=='velocity':
|
|
229
229
|
ax.set_ylim(clim0, 1.2*np.nanmax(vel_phi))
|
230
230
|
mod_major_ticks(ax, axis='x', nbins=10)
|
231
231
|
mod_minor_ticks(ax)
|
232
|
-
ax
|
232
|
+
make_1d_legend(ax)
|
233
233
|
|
234
|
-
|
234
|
+
make_substructures(ax, gaps=gaps, rings=rings, label_gaps=True, label_rings=True)
|
235
235
|
|
236
236
|
plt.savefig('rotation_curve_%s.png'%tag_base, bbox_inches='tight', dpi=200)
|
237
237
|
plt.show()
|
@@ -257,7 +257,7 @@ else:
|
|
257
257
|
vel_phi, vel_phi_error = rail_phi.get_average(**kw_avg)
|
258
258
|
|
259
259
|
ysav_phi, ysav_phi_deriv = make_savgol(vel_phi)
|
260
|
-
ax.plot(R_prof, ysav_phi, c='tomato', lw=4.0, label=r'Data
|
260
|
+
ax.plot(R_prof, ysav_phi, c='tomato', lw=4.0, label=r'Data', zorder=12)
|
261
261
|
ax.fill_between(R_prof, vel_phi+vel_phi_error, vel_phi-vel_phi_error, color='tomato', alpha=0.15, zorder=9)
|
262
262
|
|
263
263
|
if args.writetxt: writetxt([R_prof, vel_phi, vel_phi_error], tag='data')
|
@@ -267,7 +267,7 @@ else:
|
|
267
267
|
vel_phi, vel_phi_error = rail_phi.get_average(**kw_avg)
|
268
268
|
|
269
269
|
ysav_phi, ysav_phi_deriv = make_savgol(vel_phi)
|
270
|
-
ax.plot(R_prof, ysav_phi, c='dodgerblue', lw=3.5, label=r'Model
|
270
|
+
ax.plot(R_prof, ysav_phi, c='dodgerblue', lw=3.5, label=r'Model', zorder=11)
|
271
271
|
|
272
272
|
if args.writetxt: writetxt([R_prof, vel_phi, vel_phi_error], tag='model')
|
273
273
|
|
@@ -280,9 +280,9 @@ else:
|
|
280
280
|
ax.set_ylim(clim0, clim1)
|
281
281
|
mod_major_ticks(ax, axis='x', nbins=10)
|
282
282
|
mod_minor_ticks(ax)
|
283
|
-
ax
|
283
|
+
make_1d_legend(ax)
|
284
284
|
|
285
|
-
|
285
|
+
make_substructures(ax, gaps=gaps, rings=rings, label_gaps=True, label_rings=True)
|
286
286
|
|
287
287
|
plt.savefig('radial_profile_%s.png'%tag_base, bbox_inches='tight', dpi=200)
|
288
288
|
plt.show()
|
@@ -311,7 +311,7 @@ else:
|
|
311
311
|
mod_major_ticks(ax, axis='x', nbins=10)
|
312
312
|
mod_minor_ticks(ax)
|
313
313
|
|
314
|
-
|
314
|
+
make_substructures(ax, gaps=gaps, rings=rings, label_gaps=True, label_rings=True)
|
315
315
|
|
316
316
|
plt.savefig('radial_profile_residuals_%s.png'%tag_base, bbox_inches='tight', dpi=200)
|
317
317
|
plt.show()
|