Skip to content

Commit 5fb3348

Browse files
committed
tica column compression, weight by layer depth (delta p_lev) instead of layer pressure (p_lay)
1 parent 04229a3 commit 5fb3348

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

src_test/Radiation_solver_bw.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ void Radiation_solver_longwave::solve_gpu(
630630
*/
631631
}
632632

633+
// color matchin functions from https://jcgt.org/published/0002/02/01/paper.pdf
634+
633635

634636
Float get_x(const Float wv)
635637
{

src_test/test_rte_rrtmgp_rt.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ void solve_radiation(int argc, char** argv)
300300
switch_independent_column = true;
301301
}
302302

303-
if (switch_tica && switch_aerosol_optics) {
304-
std::string error = "Aerosol optics are not supported in TICA mode"; // NOTE: Aersol optics with TICA has significant errors at high SZA.
305-
throw std::runtime_error(error);
306-
}
303+
//if (switch_tica && switch_aerosol_optics) {
304+
// std::string error = "Aerosol optics are not supported in TICA mode"; // NOTE: Aersol optics with TICA has significant errors at high SZA.
305+
// throw std::runtime_error(error);
306+
//}
307307

308308
// Print the options to the screen.
309309
print_command_line_options(command_line_switches, command_line_ints);

src_tilt/tilt_utils.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ void post_process_output(const std::vector<ColumnResult>& col_results,
356356
}
357357
}
358358

359-
void compress_columns_weighted_avg(const int n_x, const int n_y,
360-
const int n_out,
359+
void compress_columns_weighted_avg(const int n_x, const int n_y,
360+
const int n_out,
361361
const int n_tilt,
362362
const int compress_lay_start_idx,
363-
std::vector<Float>& var, std::vector<Float>& var_weighting)
363+
std::vector<Float>& var, std::vector<Float>& p_lev)
364364
{
365365
std::vector<Float> var_tmp(n_out * n_x * n_y);
366366

@@ -400,15 +400,18 @@ void compress_columns_weighted_avg(const int n_x, const int n_y,
400400
for (int k = 0; k < num_inputs; ++k)
401401
{
402402
int in_idx = ix + iy * n_x + (i_lay_in + k) * n_x * n_y;
403-
t_sum += var[in_idx] * var_weighting[in_idx];
404-
w_sum += var_weighting[in_idx];
403+
int in_idx_top = ix + iy * n_x + (i_lay_in + k + 1) * n_x * n_y;
404+
405+
const Float dp_local = abs(p_lev[in_idx] - p_lev[in_idx_top]);
406+
t_sum += var[in_idx] * dp_local;
407+
w_sum += dp_local;
405408
}
406409

407410
if (w_sum > 1e-6)
408411
{
409412
var_tmp[out_idx] = t_sum / w_sum;
410-
}
411-
else
413+
}
414+
else
412415
{
413416
Float avg = 0.0;
414417
for (int k = 0; k < num_inputs; ++k)
@@ -592,8 +595,8 @@ void tilt_fields(const int n_z_in, const int n_zh_in, const int n_col_x, const i
592595

593596
void compress_fields(const int compress_lay_start_idx, const int n_col_x, const int n_col_y,
594597
const int n_z_in, const int n_zh_in, const int n_z_tilt,
595-
Array<Float,2>* p_lay_copy, Array<Float,2>* t_lay_copy, Array<Float,2>* p_lev_copy, Array<Float,2>* t_lev_copy,
596-
Array<Float,2>* rh_copy,
598+
Array<Float,2>* p_lay_copy, Array<Float,2>* t_lay_copy, Array<Float,2>* p_lev_copy, Array<Float,2>* t_lev_copy,
599+
Array<Float,2>* rh_copy,
597600
Gas_concs& gas_concs_copy, std::vector<std::string> gas_names,
598601
Aerosol_concs& aerosol_concs_copy, std::vector<std::string> aerosol_names, const bool switch_aerosol_optics)
599602
{
@@ -608,22 +611,23 @@ void compress_fields(const int compress_lay_start_idx, const int n_col_x, const
608611
Array<Float,2> gas_tmp(gas);
609612
compress_columns_weighted_avg(n_col_x, n_col_y,
610613
n_z_in, n_z_tilt,
611-
compress_lay_start_idx,
612-
gas_tmp.v(),
613-
p_lay_copy->v());
614+
compress_lay_start_idx,
615+
gas_tmp.v(),
616+
p_lev_copy->v());
614617
gas_tmp.expand_dims({n_col, n_z_in});
615618
gas_concs_copy.set_vmr(gas_name, gas_tmp);
616619
}
617620
}
618621

619622
if (switch_aerosol_optics)
620623
{
621-
std::vector<Float> ones(p_lay_copy->v().size(), 1.0);
624+
// should we just recompute relative humidity after tilting water vapour and temperature?
622625
compress_columns_weighted_avg(n_col_x, n_col_y,
623626
n_z_in, n_z_tilt,
624-
compress_lay_start_idx,
625-
rh_copy->v(),
626-
ones);
627+
compress_lay_start_idx,
628+
rh_copy->v(),
629+
p_lev_copy->v());
630+
627631
rh_copy->expand_dims({n_col, n_z_in});
628632

629633
for (const auto& aerosol_name : aerosol_names) {
@@ -635,9 +639,9 @@ void compress_fields(const int compress_lay_start_idx, const int n_col_x, const
635639
Array<Float,2> gas_tmp(gas);
636640
compress_columns_weighted_avg(n_col_x, n_col_y,
637641
n_z_in, n_z_tilt,
638-
compress_lay_start_idx,
639-
gas_tmp.v(),
640-
p_lay_copy->v());
642+
compress_lay_start_idx,
643+
gas_tmp.v(),
644+
p_lev_copy->v());
641645
gas_tmp.expand_dims({n_col, n_z_in});
642646
aerosol_concs_copy.set_vmr(aerosol_name, gas_tmp);
643647
}

0 commit comments

Comments
 (0)