Skip to content

Commit

Permalink
Bug fix in the axes order of position (x, y) in AperturePhotometryModule
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed May 12, 2020
1 parent 13eea43 commit fff1b9a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
6 changes: 5 additions & 1 deletion pynpoint/processing/fluxposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,14 @@ def _photometry(image: np.ndarray,
self.m_radius /= pixscale

if self.m_position is None:
# Returns the center position as (y, x)
self.m_position = center_subpixel(self.m_image_in_port[0, ])

# Store the center position as (x, y)
self.m_position = (self.m_position[1], self.m_position[0])

# Position in CircularAperture is defined as (x, y)
aperture = CircularAperture((self.m_position[1], self.m_position[0]), self.m_radius)
aperture = CircularAperture((self.m_position[0], self.m_position[1]), self.m_radius)

self.apply_function_to_images(_photometry,
self.m_image_in_port,
Expand Down
39 changes: 28 additions & 11 deletions tests/test_processing/test_fluxposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,31 @@ def test_aperture_photometry(self) -> None:
with h5py.File(self.test_dir+'PynPoint_database.hdf5', 'a') as hdf_file:
hdf_file['config'].attrs['CPU'] = 1

module = AperturePhotometryModule(radius=0.1,
position=None,
name_in='photometry',
module = AperturePhotometryModule(name_in='photometry1',
image_in_tag='read',
phot_out_tag='photometry')
phot_out_tag='photometry1',
radius=0.1,
position=None)

self.pipeline.add_module(module)
self.pipeline.run_module('photometry')
self.pipeline.run_module('photometry1')

with h5py.File(self.test_dir+'PynPoint_database.hdf5', 'a') as hdf_file:
hdf_file['config'].attrs['CPU'] = 4

module = AperturePhotometryModule(radius=0.1,
position=None,
name_in='photometry_multi',
module = AperturePhotometryModule(name_in='photometry_multi',
image_in_tag='read',
phot_out_tag='photometry_multi')
phot_out_tag='photometry_multi',
radius=0.1,
position=None)

self.pipeline.add_module(module)
self.pipeline.run_module('photometry_multi')

data = self.pipeline.get_data('photometry')
data = self.pipeline.get_data('photometry1')
assert np.allclose(data[0][0], 0.9853286992326858, rtol=limit, atol=0.)
assert np.allclose(data[39][0], 0.9835251375574492, rtol=limit, atol=0.)
assert np.allclose(np.mean(data), 0.9836439188900222, rtol=limit, atol=0.)
assert np.allclose(np.sum(data), 39.34575675560089, rtol=limit, atol=0.)
assert data.shape == (40, 1)

data_multi = self.pipeline.get_data('photometry_multi')
Expand All @@ -146,6 +146,23 @@ def test_aperture_photometry(self) -> None:
# Does not pass on Travis CI
# assert np.allclose(data, data_multi, rtol=limit, atol=0.)

def test_aperture_photometry_position(self) -> None:

module = AperturePhotometryModule(name_in='photometry2',
image_in_tag='read',
phot_out_tag='photometry2',
radius=0.1,
position=(10., 20.))

self.pipeline.add_module(module)
self.pipeline.run_module('photometry2')

data = self.pipeline.get_data('photometry2')
assert np.allclose(data[0][0], 0.00196930037508753, rtol=limit, atol=0.)
assert np.allclose(data[39][0], -0.00043932193134473924, rtol=limit, atol=0.)
assert np.allclose(np.sum(data), 0.005097664842298726, rtol=limit, atol=0.)
assert data.shape == (40, 1)

def test_angle_interpolation(self) -> None:

with h5py.File(self.test_dir+'PynPoint_database.hdf5', 'a') as hdf_file:
Expand Down

0 comments on commit fff1b9a

Please sign in to comment.