Skip to content

Commit

Permalink
Bug fix position angle direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed Feb 9, 2020
1 parent aac259b commit e5fa6b4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions diskmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Tomas Stolker'
__license__ = 'MIT'
__version__ = '0.0.5'
__version__ = '0.0.6'
__maintainer__ = 'Tomas Stolker'
__email__ = '[email protected]'
__status__ = 'Development'
__status__ = 'Development'
39 changes: 26 additions & 13 deletions diskmap/diskmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ def __init__(self,
raise ValueError('The dimensions of the image should have the same size.')

self.pixscale = pixscale # [arcsec]
self.incl = inclination # [deg]
self.pos_ang = pos_angle # [deg]
self.incl = math.radians(inclination) # [rad]
self.pos_ang = math.radians(pos_angle) # [rad]
self.distance = distance # [pc]

self.npix = self.image.shape[0]

self.incl = math.radians(self.incl) # [rad]
self.pos_ang = math.radians(self.pos_ang-90.) # [rad]

self.grid = 501 # should be odd

self.radius = None
Expand All @@ -87,7 +84,9 @@ def map_disk(self,
f(x) = a + b*x^c, with ``a`` and ``b`` in au.
radius : tuple(float, float, int)
Radius points that are sampled, provided as (r_in, r_out, n_r), with ``r_in`` and
``r_out`` in au.
``r_out`` in au. The outer radius should be set large enough such that a radius is
sampled for each pixel in the field of view. To check if any NaNs are present, have
a look at the `_radius.fits` output.
surface : str
Parameterization type for the disk surface ('power-law' or 'file').
filename : star
Expand Down Expand Up @@ -149,12 +148,15 @@ def power_law_height(x_power, a_power, b_power, c_power):
for i, r_item in enumerate(disk_radius):
for j, p_item in enumerate(disk_phi):

x_temp = r_item * np.sin(p_item)
y_temp = disk_height[i]*math.sin(self.incl) - \
x_tmp = r_item * np.sin(p_item)
y_tmp = disk_height[i]*math.sin(self.incl) - \
r_item*np.cos(p_item)*math.cos(self.incl)

x_rot = x_temp*math.cos(self.pos_ang) - y_temp*math.sin(self.pos_ang)
y_rot = x_temp*math.sin(self.pos_ang) + y_temp*math.cos(self.pos_ang)
x_rot = x_tmp*math.cos(math.pi-self.pos_ang) - \
y_tmp*math.sin(math.pi-self.pos_ang)

y_rot = x_tmp*math.sin(math.pi-self.pos_ang) + \
y_tmp*math.cos(math.pi-self.pos_ang)

x_im.append(x_rot)
y_im.append(y_rot)
Expand Down Expand Up @@ -268,8 +270,15 @@ def deproject_disk(self):

for i in range(self.npix):
for j in range(self.npix):
x_disk.append(self.radius[i, j]*np.cos(self.azimuth[i, j]-self.pos_ang)+math.pi/2.)
y_disk.append(self.radius[i, j]*np.sin(self.azimuth[i, j]-self.pos_ang)+math.pi/2.)
x_tmp = self.radius[i, j]*np.cos(self.azimuth[i, j])
y_tmp = self.radius[i, j]*np.sin(self.azimuth[i, j])

x_disk.append(x_tmp*math.cos(math.pi/2.-self.pos_ang) -
y_tmp*math.sin(math.pi/2.-self.pos_ang))

y_disk.append(x_tmp*math.sin(math.pi/2.-self.pos_ang) +
y_tmp*math.cos(math.pi/2.-self.pos_ang))

im_disk.append(self.image[i, j])

# Sort disk plane points along x-axis
Expand Down Expand Up @@ -322,7 +331,11 @@ def deproject_disk(self):

count += 1

fit_im = griddata(image_xy, im_disk, grid)
try:
fit_im = griddata(image_xy, im_disk, grid)
except ValueError:
raise ValueError('The radius sampling should cover the complete field of view of the '
'image. Try increasing the outer \'radius\' value in \'map_disk\'.')

self.im_deproj = np.zeros((self.npix, self.npix))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='diskmap',
version='0.0.5',
version='0.0.6',
description='Scattered light mapping of protoplanetary disks',
long_description=open('README.rst').read(),
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit e5fa6b4

Please sign in to comment.