Skip to content

Commit c68be35

Browse files
committed
fixed bug leading to too much background flux in first row and column of detector
1 parent f1b8c7e commit c68be35

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/Detector.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,20 @@ class CDetector
792792
{
793793
Vector3D pos = pp.getPosition();
794794

795-
uint x = uint((pos.X() + 0.5 * sidelength_x - map_shift_x) / sidelength_x * double(bins_x));
795+
double float_x = (pos.X() + 0.5 * sidelength_x - map_shift_x) / sidelength_x * double(bins_x);
796+
if (float_x < 0.) // integer casting leads to zeros from negative and positive side which results in too much flux in the lowest row
797+
return;
798+
uint x = uint(float_x);
796799

797-
if(x < 0 || x >= bins_x)
800+
if(x >= bins_x)
798801
return;
799802

800-
uint y = uint((pos.Y() + 0.5 * sidelength_y - map_shift_y) / sidelength_y * double(bins_y));
803+
double float_y = (pos.Y() + 0.5 * sidelength_y - map_shift_y) / sidelength_y * double(bins_y);
804+
if (float_y < 0.) // integer casting leads to zeros from negative and positive side which results in too much flux in the lowest column
805+
return;
806+
uint y = uint(float_y);
801807

802-
if(y < 0 || y >= bins_y)
808+
if(y >= bins_y)
803809
return;
804810

805811
matrixI[i_spectral].addValue(x, y, st.I());

src/Raytracing.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ class CRaytracingPolar : public CRaytracingBasic
16491649
npix_total += npix_ph[i_r];
16501650
}
16511651

1652-
npix_total++;
1652+
npix_total++; // last pixel is central grid cell
16531653

16541654
if(npix_total > MAX_RT_RAYS)
16551655
{
@@ -1777,9 +1777,11 @@ class CRaytracingPolar : public CRaytracingBasic
17771777
switch(processing_method)
17781778
{
17791779
case 0:
1780+
cout << "HINT: Using 'nearest' method to post process from polar to cartesian detector" << endl;
17801781
return postProcessingUsingNearest();
17811782
break;
17821783
case 1:
1784+
cout << "HINT: Using 'interpolation' method to post process from polar to cartesian detector" << endl;
17831785
return postProcessingUsingInterpolation();
17841786
break;
17851787
default:

src/Source.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,9 @@ StokesVector CSourceBackground::getStokesVector(photon_package * pp)
985985
{
986986
double F, T, I, Q, U, V, pl;
987987
StokesVector res;
988-
Vector3D pos = pp->getPosition();
989988

990989
uint wID = pp->getDustWavelengthID();
991990

992-
uint x = uint((pos.X() + 0.5 * sidelength) / sidelength * double(bins));
993-
uint y = uint((pos.Y() + 0.5 * sidelength) / sidelength * double(bins));
994-
995991
if(constant)
996992
{
997993
if(c_f>=0)
@@ -1018,6 +1014,11 @@ StokesVector CSourceBackground::getStokesVector(photon_package * pp)
10181014
}
10191015
else
10201016
{
1017+
Vector3D pos = pp->getPosition();
1018+
1019+
uint x = uint((pos.X() + 0.5 * sidelength) / sidelength * double(bins));
1020+
uint y = uint((pos.Y() + 0.5 * sidelength) / sidelength * double(bins));
1021+
10211022
F = f(x, y);
10221023
T = temp(x, y);
10231024
Q = q(x, y);

0 commit comments

Comments
 (0)