File: stokesimager.cpp

package info (click to toggle)
aoflagger 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,232 kB
  • sloc: cpp: 61,805; python: 60; sh: 23; makefile: 8
file content (77 lines) | stat: -rw-r--r-- 2,377 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "stokesimager.h"

Image2DPtr StokesImager::CreateStokesIAmplitude(Image2DCPtr realXX, Image2DCPtr imaginaryXX, Image2DCPtr realYY, Image2DCPtr imaginaryYY)
{
	Image2D *stokesI = Image2D::CreateUnsetImage(realXX->Width(), realXX->Height());

	for(unsigned long y = 0; y < realXX->Height(); ++y) {
		for(unsigned long x = 0; x < realXX->Width(); ++x) {
			double xx_a = sqrt(realXX->Value(x, y)*realXX->Value(x, y) + imaginaryXX->Value(x, y)*imaginaryXX->Value(x, y));
			double yy_a = sqrt(realYY->Value(x, y)*realYY->Value(x, y) + imaginaryYY->Value(x, y)*imaginaryYY->Value(x, y));
		
			stokesI->SetValue(x, y, xx_a + yy_a);
		}
	}
	return Image2DPtr(stokesI);
}

Image2DPtr StokesImager::CreateSum(Image2DCPtr left, Image2DCPtr right)
{
	Image2D *sum = Image2D::CreateUnsetImage(left->Width(), right->Height());

	for(unsigned long y = 0; y < left->Height(); ++y) {
		for(unsigned long x = 0; x < right->Width(); ++x) {
			num_t left_a = left->Value(x, y);
			num_t right_a = right->Value(x, y);
		
			sum->SetValue(x, y, left_a + right_a);
		}
	}
	return Image2DPtr(sum);
}

Image2DPtr StokesImager::CreateNegatedSum(Image2DCPtr left, Image2DCPtr right)
{
	Image2D *sum = Image2D::CreateUnsetImage(left->Width(), right->Height());

	for(unsigned long y = 0; y < left->Height(); ++y) {
		for(unsigned long x = 0; x < right->Width(); ++x) {
			num_t left_a = left->Value(x, y);
			num_t right_a = right->Value(x, y);
		
			sum->SetValue(x, y, -(left_a + right_a));
		}
	}
	return Image2DPtr(sum);
}

Image2DPtr StokesImager::CreateDifference(Image2DCPtr left, Image2DCPtr right)
{
	Image2D *difference = Image2D::CreateUnsetImage(left->Width(), right->Height());

	for(unsigned long y = 0; y < left->Height(); ++y) {
		for(unsigned long x = 0; x < right->Width(); ++x) {
			num_t left_a = left->Value(x, y);
			num_t right_a = right->Value(x, y);
		
			difference->SetValue(x, y, left_a - right_a);
		}
	}
	return Image2DPtr(difference);
}

Image2DPtr StokesImager::CreateAvgPhase(Image2DCPtr xx, Image2DCPtr yy)
{
	Image2D *avgPhase = Image2D::CreateUnsetImage(xx->Width(), xx->Height());

	for(unsigned long y = 0; y < xx->Height(); ++y) {
		for(unsigned long x = 0; x < xx->Width(); ++x) {
			double xx_a = xx->Value(x, y);
			double yy_a = yy->Value(x, y);
		
			avgPhase->SetValue(x, y, fmodn(xx_a + yy_a, 2.0L*M_PIn) );
		}
	}
	return Image2DPtr(avgPhase);
}