Skip to content

Commit

Permalink
Further advanced sdi test coverage. Fixed minor bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
S.K. Kiefer committed May 14, 2020
1 parent a0f8034 commit c0c78b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
6 changes: 2 additions & 4 deletions pynpoint/util/residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ def combine_residuals(method: str,

# if desiered create one final image
if not i_want_to_seperate_wavelengths(processing_type):
output = _residuals(method=method,
res_rot=np.asarray(wave_res),
residuals=residuals,
angles=angles)
output = _residuals(method='median',
res_rot=np.asarray(wave_res))
else:
output = np.asarray(wave_res)

Expand Down
26 changes: 15 additions & 11 deletions tests/test_processing/test_psfsubtraction_sdi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import warnings
import h5py

import numpy as np

Expand Down Expand Up @@ -86,17 +87,19 @@ def test_read_data(self):

def test_psf_subtraction_pca_sdi(self):

processing_types = ['ADI', 'SDI', 'SDI+ADI', 'ADI+SDI']
processing_types = ['ADI', 'SDI', 'SDI+ADI', 'ADI+SDI', 'Tnan']

expected = [[-3.9661462067317356e-08, 9.813240333505746e-08, 6.920690625734549e-08, -3.792473707685877e-08],
[2.1744099321374343e-08, -1.956821429551539e-07, -3.106340537276925e-07, 8.690272190373355e-08],
[-6.743135285330971e-08, -3.835617222375879e-07, 6.258907827506765e-07, -3.315712845815245e-08],
[-4.608125341486133e-08, -1.014224025773705e-07, -6.027023567648257e-07, -1.1293200783123714e-08]]
[-4.608125341486133e-08, -1.014224025773705e-07, -6.027023567648257e-07, -1.1293200783123714e-08],
[0.0011152669134962224, 0.0011030610345340278, 0.001114351549402792, 0.0011150859312946666]]

shape_expc = [(2, 6, 30, 30),
(2, 6, 30, 30),
(2, 2, 6, 30, 30),
(2, 2, 6, 30, 30)]
(2, 2, 6, 30, 30),
(2, 30, 30)]

# change sience to sience_prep after available
for i, p_type in enumerate(processing_types):
Expand All @@ -120,22 +123,18 @@ def test_psf_subtraction_pca_sdi(self):
data = self.pipeline.get_data('res_mean_single_sdi_' + p_type)
assert np.allclose(np.mean(data), expected[i][0], rtol=limit, atol=0.)
assert data.shape == shape_expc[i]
print(np.mean(data))

data = self.pipeline.get_data('res_median_single_sdi_' + p_type)
assert np.allclose(np.mean(data), expected[i][1], rtol=limit, atol=0.)
assert data.shape == shape_expc[i]
print(np.mean(data))

data = self.pipeline.get_data('res_weighted_single_sdi_' + p_type)
assert np.allclose(np.mean(data), expected[i][2], rtol=limit, atol=0.)
assert data.shape == shape_expc[i]
print(np.mean(data))

data = self.pipeline.get_data('res_clip_single_sdi_' + p_type)
assert np.allclose(np.mean(data), expected[i][3], rtol=limit, atol=0.)
assert data.shape == shape_expc[i]
print(np.mean(data))

# # res array outs are not supported yet
# data = self.pipeline.get_data('res_arr_single_sdi_' + p_type)
Expand All @@ -148,18 +147,23 @@ def test_psf_subtraction_pca_sdi(self):
# assert data.shape == (5, 30, 30)

def test_multi_psf_subtraction_pca_sdi(self):

processing_types = ['ADI', 'SDI', 'SDI+ADI', 'ADI+SDI']

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

processing_types = ['ADI', 'SDI', 'SDI+ADI', 'ADI+SDI', 'Tsaa']

expected = [[-3.96614620673174e-08, 9.813240333503754e-08, 6.920690625734128e-08, -3.7924737076858164e-08],
[2.1744099321366555e-08, -1.9568214295495464e-07, -3.1063405372801503e-07, 8.690272190365003e-08],
[-6.743135285332267e-08, -3.835617222377436e-07, 6.258907828194748e-07, -3.315712845816095e-08],
[-4.6081253414983635e-08, -1.0142240257765332e-07, -6.027023520146822e-07, -1.1293200783270142e-08]]
[-4.6081253414983635e-08, -1.0142240257765332e-07, -6.027023520146822e-07, -1.1293200783270142e-08],
[-5.217859691120134e-07, -1.286673780273927e-06, -2.2755802755461952e-07, -4.698175472464411e-07]]

shape_expc = [(2, 6, 30, 30),
(2, 6, 30, 30),
(2, 2, 6, 30, 30),
(2, 2, 6, 30, 30)]
(2, 2, 6, 30, 30),
(2, 30, 30)]

# change sience to sience_prep after available
for i, p_type in enumerate(processing_types):
Expand Down

0 comments on commit c0c78b6

Please sign in to comment.