Skip to content

Commit

Permalink
fix constrain g bug
Browse files Browse the repository at this point in the history
  • Loading branch information
scottprahl committed May 15, 2024
1 parent 239302e commit c7a1fdc
Show file tree
Hide file tree
Showing 9 changed files with 1,882 additions and 2,086 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

v3.16.3 (15 May 2024)
---------------------
* fixed bug that discarded info from "g" input column

v3.16.2 (23 Apr 2024)
---------------------
* fixed bug in mc_lost affecting lost light estimation
Expand Down
2 changes: 1 addition & 1 deletion src/iad_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void Fill_AB_Grid(struct measure_type m, struct invert_type r)
double max_log_b = +8;

if (Debug(DEBUG_GRID))
fprintf(stderr, "GRID: Filling AB grid\n");
fprintf(stderr, "GRID: Filling AB grid (g=%.5f)\n", RR.slab.g);

if (The_Grid == NULL)
Allocate_Grid(r.search);
Expand Down
2 changes: 1 addition & 1 deletion src/iad_calc.w
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void Fill_AB_Grid(struct measure_type m, struct invert_type r)
double max_log_b = +8; /* exp(+8) is greatest thickness */

if (Debug(DEBUG_GRID))
fprintf(stderr, "GRID: Filling AB grid\n");
fprintf(stderr, "GRID: Filling AB grid (g=%.5f)\n", RR.slab.g);

if (The_Grid==NULL) Allocate_Grid(r.search);
@<Zero \\{GG}@>@;
Expand Down
16 changes: 11 additions & 5 deletions src/iad_find.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,13 @@ void U_Find_AG(struct measure_type m, struct invert_type *r)

if (Debug(DEBUG_SEARCH)) {
fprintf(stderr, "SEARCH: Using U_Find_AG()");
fprintf(stderr, " (mu=%6.4f)", r->slab.cos_angle);
if (r->default_b != UNINITIALIZED)
fprintf(stderr, " default_b = %8.5f", r->default_b);
fprintf(stderr, " mu=%4.2f, ", r->slab.cos_angle);
if (m.num_measures == 3)
fprintf(stderr, " b= %6.3f (M_U)", What_Is_B(r->slab, m.m_u));
else if (r->default_b != UNINITIALIZED)
fprintf(stderr, " b = %6.3f (constrained)", r->default_b);
else
fprintf(stderr, " b = %6.3f (default)", 1.0);
fprintf(stderr, "\n");
}

Expand Down Expand Up @@ -395,9 +399,11 @@ void U_Find_AB(struct measure_type m, struct invert_type *r)

if (Debug(DEBUG_SEARCH)) {
fprintf(stderr, "SEARCH: Using U_Find_AB()");
fprintf(stderr, " (mu=%6.4f)", r->slab.cos_angle);
fprintf(stderr, " mu=%4.2f, g=", r->slab.cos_angle);
if (r->default_g != UNINITIALIZED)
fprintf(stderr, " default_g = %8.5f", r->default_g);
fprintf(stderr, " %7.3f (constrained g)", r->default_g);
else
fprintf(stderr, " %7.3f (default)", 0.0);
fprintf(stderr, "\n");
}

Expand Down
16 changes: 11 additions & 5 deletions src/iad_find.w
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ This is the most common case.

if (Debug(DEBUG_SEARCH)) {
fprintf(stderr,"SEARCH: Using U_Find_AB()");
fprintf(stderr," (mu=%6.4f)",r->slab.cos_angle);
fprintf(stderr," mu=%4.2f, g=",r->slab.cos_angle);
if (r->default_g != UNINITIALIZED)
fprintf(stderr," default_g = %8.5f", r->default_g);
fprintf(stderr," %7.3f (constrained g)", r->default_g);
else
fprintf(stderr," %7.3f (default)", 0.0);
fprintf(stderr,"\n");
}

Expand Down Expand Up @@ -510,9 +512,13 @@ away.

if (Debug(DEBUG_SEARCH)) {
fprintf(stderr,"SEARCH: Using U_Find_AG()");
fprintf(stderr," (mu=%6.4f)",r->slab.cos_angle);
if (r->default_b != UNINITIALIZED)
fprintf(stderr," default_b = %8.5f", r->default_b);
fprintf(stderr," mu=%4.2f, ",r->slab.cos_angle);
if (m.num_measures==3)
fprintf(stderr," b= %6.3f (M_U)", What_Is_B(r->slab, m.m_u));
else if (r->default_b != UNINITIALIZED)
fprintf(stderr," b = %6.3f (constrained)", r->default_b);
else
fprintf(stderr," b = %6.3f (default)", 1.0);
fprintf(stderr,"\n");
}

Expand Down
3,896 changes: 1,836 additions & 2,060 deletions src/iad_main.c

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions src/iad_main.w
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,6 @@ measurements.
rt_total++;
Initialize_Result(m, &r, FALSE);

r.default_a = UNINITIALIZED;
r.default_b = UNINITIALIZED;
r.default_g = UNINITIALIZED;
r.default_mua = UNINITIALIZED;
r.default_mus = UNINITIALIZED;

@<Command-line changes to |r|@>@;
@<Warn and quit for bad options@>@;
@<Write Header @>@;
Expand Down
16 changes: 12 additions & 4 deletions src/iad_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

void Inverse_RT(struct measure_type m, struct invert_type *r)
{
if (m.m_u > 0 && r->default_b == UNINITIALIZED) {
r->default_b = What_Is_B(r->slab, m.m_u);
}

if (r->search == FIND_AUTO) {
r->search = determine_search(m, *r);
}
Expand Down Expand Up @@ -248,6 +244,8 @@ search_type determine_search(struct measure_type m, struct invert_type r)
independent++;
if (m.m_t > 0)
independent++;
if (m.m_u > 0)
independent++;

if (r.default_a != UNINITIALIZED)
constraints++;
Expand All @@ -265,6 +263,16 @@ search_type determine_search(struct measure_type m, struct invert_type r)
if (Debug(DEBUG_SEARCH)) {
fprintf(stderr, "SEARCH: starting with %d measurement(s)\n", independent);
fprintf(stderr, "SEARCH: and with %d constraint(s)\n", constraints);
if (r.default_a != UNINITIALIZED)
fprintf(stderr, " albedo constrained\n");
if (r.default_b != UNINITIALIZED)
fprintf(stderr, " optical thickness constrained\n");
if (r.default_g != UNINITIALIZED)
fprintf(stderr, " anisotropy constrained\n");
if (r.default_mua != UNINITIALIZED)
fprintf(stderr, " mua constrained\n");
if (r.default_mus != UNINITIALIZED)
fprintf(stderr, " mus constrained\n");
fprintf(stderr, "SEARCH: m_r = %8.5f ", m.m_r);
fprintf(stderr, "m_t = %8.5f ", m.m_t);
fprintf(stderr, "m_u = %8.5f\n", m.m_u);
Expand Down
10 changes: 6 additions & 4 deletions src/iad_pub.w
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ that are appropriate for your experiment.
@ @<Definition for |Inverse_RT|@>=
@<Prototype for |Inverse_RT|@>
{
if (m.m_u > 0 && r->default_b == UNINITIALIZED) {
r->default_b = What_Is_B(r->slab, m.m_u);
}

if (r->search == FIND_AUTO) {
r->search = determine_search(m,*r);
}
Expand Down Expand Up @@ -409,6 +405,7 @@ optical properties to determine.

if (m.m_r > 0) independent++;
if (m.m_t > 0) independent++;
if (m.m_u > 0) independent++;

if (r.default_a != UNINITIALIZED) constraints++;
if (r.default_b != UNINITIALIZED) constraints++;
Expand All @@ -421,6 +418,11 @@ optical properties to determine.
if (Debug(DEBUG_SEARCH)) {
fprintf(stderr, "SEARCH: starting with %d measurement(s)\n",independent);
fprintf(stderr, "SEARCH: and with %d constraint(s)\n",constraints);
if (r.default_a != UNINITIALIZED) fprintf(stderr, " albedo constrained\n");
if (r.default_b != UNINITIALIZED) fprintf(stderr, " optical thickness constrained\n");
if (r.default_g != UNINITIALIZED) fprintf(stderr, " anisotropy constrained\n");
if (r.default_mua != UNINITIALIZED) fprintf(stderr, " mua constrained\n");
if (r.default_mus != UNINITIALIZED) fprintf(stderr, " mus constrained\n");
fprintf(stderr, "SEARCH: m_r = %8.5f ",m.m_r);
fprintf(stderr, "m_t = %8.5f ",m.m_t);
fprintf(stderr, "m_u = %8.5f\n",m.m_u);
Expand Down

0 comments on commit c7a1fdc

Please sign in to comment.