htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit db50d7467f11d45a20c61cc8473c4dc1ab9dc277
parent fec112abc16950412ad6386b8be9fe78bdaac916
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 12 Mar 2021 15:25:14 +0100

Update the unit of the pdf returned by htrdr_ran_wlen_sample

Diffstat:
Msrc/atmosphere/htrdr_atmosphere_draw_map.c | 4+++-
Msrc/core/htrdr_ran_wlen.c | 5+++--
Msrc/core/htrdr_ran_wlen.h | 2+-
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/atmosphere/htrdr_atmosphere_draw_map.c b/src/atmosphere/htrdr_atmosphere_draw_map.c @@ -165,6 +165,7 @@ draw_pixel_image case 2: wlen = htrdr_cie_xyz_sample_Z(cmd->cie, r0, r1, &pdf); break; default: FATAL("Unreachable code.\n"); break; } + pdf *= 1.e9; /* Transform the pdf from nm^-1 to m^-1 */ iband = htsky_find_spectral_band(cmd->sky, wlen); iquad = htsky_spectral_band_sample_quadrature(cmd->sky, r2, iband); @@ -174,7 +175,6 @@ draw_pixel_image ATMOSPHERE_RADIANCE_ALL, ray_org, ray_dir, wlen, iband, iquad); ASSERT(weight >= 0); - pdf *= 1.e9; /* Transform the pdf from nm^-1 to m^-1 */ weight /= pdf; /* In W/m^2/sr */ /* End the registration of the per realisation time */ @@ -250,6 +250,7 @@ draw_pixel_flux /* Sample a wavelength */ wlen = htrdr_ran_wlen_sample(cmd->ran_wlen, r0, r1, &band_pdf); + band_pdf *= 1.e9; /* Transform the pdf from nm^-1 to m^-1 */ /* Select the associated band and sample a quadrature point */ iband = htsky_find_spectral_band(cmd->sky, wlen); @@ -370,6 +371,7 @@ draw_pixel_xwave /* Sample a wavelength */ wlen = htrdr_ran_wlen_sample(cmd->ran_wlen, r0, r1, &band_pdf); + band_pdf *= 1.e9; /* Transform the pdf from nm^-1 to m^-1 */ /* Select the associated band and sample a quadrature point */ iband = htsky_find_spectral_band(cmd->sky, wlen); diff --git a/src/core/htrdr_ran_wlen.c b/src/core/htrdr_ran_wlen.c @@ -201,9 +201,10 @@ wlen_ran_sample_continue const double B_lambda = htrdr_planck(lambda_m, lambda_m, Tref); const double B_mean = htrdr_planck(range_m[0], range_m[1], Tref); *pdf = B_lambda / (B_mean * (range_m[1]-range_m[0])); + *pdf = 1.e-9; /* Transform from m^-1 to nm^-1 */ } - return lambda_m * 1.0e9; /* Convert in nanometers */ + return lambda_m * 1.e9; /* Convert in nanometers */ } static double @@ -249,7 +250,7 @@ wlen_ran_sample_discrete /* Uniformly sample a wavelength in the sampled band */ lambda = band_range[0] + (band_range[1] - band_range[0]) * r1; - pdf_continue = 1.0 / ((band_range[1] - band_range[0])*1.e-9); + pdf_continue = 1.0 / (band_range[1] - band_range[0]); if(pdf) { *pdf = pdf_band * pdf_continue; diff --git a/src/core/htrdr_ran_wlen.h b/src/core/htrdr_ran_wlen.h @@ -53,7 +53,7 @@ htrdr_ran_wlen_sample (const struct htrdr_ran_wlen* wlen_ran, const double r0, /* Canonical number in [0, 1[ */ const double r1, /* Canonical number in [0, 1[ */ - double* pdf); /* May be NULL */ + double* pdf); /* In nm^-1. May be NULL */ END_DECLS