From e5fa6b42666cc71a9cb7355b66ce5753ee170b7d Mon Sep 17 00:00:00 2001 From: Tomas Stolker Date: Sun, 9 Feb 2020 09:33:09 +0100 Subject: [PATCH] Bug fix position angle direction --- diskmap/__init__.py | 4 ++-- diskmap/diskmap.py | 39 ++++++++++++++++++++++++++------------- setup.py | 2 +- 3 files changed, 29 insertions(+), 16 deletions(-) mode change 100644 => 100755 setup.py diff --git a/diskmap/__init__.py b/diskmap/__init__.py index a9ee640..d4f6d0f 100644 --- a/diskmap/__init__.py +++ b/diskmap/__init__.py @@ -2,7 +2,7 @@ __author__ = 'Tomas Stolker' __license__ = 'MIT' -__version__ = '0.0.5' +__version__ = '0.0.6' __maintainer__ = 'Tomas Stolker' __email__ = 'tomas.stolker@phys.ethz.ch' -__status__ = 'Development' \ No newline at end of file +__status__ = 'Development' diff --git a/diskmap/diskmap.py b/diskmap/diskmap.py index 482eaa6..799ee7e 100644 --- a/diskmap/diskmap.py +++ b/diskmap/diskmap.py @@ -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 @@ -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 @@ -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) @@ -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 @@ -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)) diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 85842be..907bb46 --- a/setup.py +++ b/setup.py @@ -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',