|
| 1 | +#include <cmath> |
| 2 | +#include <chrono> |
| 3 | +#include <iomanip> |
| 4 | +#include <iostream> |
| 5 | +#include <numeric> |
| 6 | +#include <random> |
| 7 | +#include <vector> |
| 8 | + |
| 9 | +#include "Array.h" |
| 10 | +#include "Source_functions.h" |
| 11 | + |
| 12 | +struct ColumnResult { |
| 13 | + Array<Float,1> lwp; |
| 14 | + Array<Float,1> iwp; |
| 15 | + Array<Float,1> rel; |
| 16 | + Array<Float,1> dei; |
| 17 | +}; |
| 18 | + |
| 19 | +struct ijk |
| 20 | +{ |
| 21 | + int i; |
| 22 | + int j; |
| 23 | + int k; |
| 24 | +}; |
| 25 | + |
| 26 | +inline int sign(Float value) |
| 27 | +{ |
| 28 | + return (Float(0.) < value) - (value < Float(0.)); |
| 29 | +} |
| 30 | + |
| 31 | +void tilted_path(std::vector<Float>& xh, std::vector<Float>& yh, |
| 32 | + std::vector<Float>& zh, std::vector<Float>& z, |
| 33 | + Float sza, Float azi, |
| 34 | + Float x_start, Float y_start, |
| 35 | + std::vector<ijk>& tilted_path, |
| 36 | + std::vector<Float>& zh_tilted); |
| 37 | + |
| 38 | +void post_process_output(const std::vector<ColumnResult>& col_results, |
| 39 | + const int n_col_x, const int n_col_y, |
| 40 | + const int n_z, const int n_zh, |
| 41 | + Array<Float,2>* lwp_out, |
| 42 | + Array<Float,2>* iwp_out, |
| 43 | + Array<Float,2>* rel_out, |
| 44 | + Array<Float,2>* dei_out, |
| 45 | + const bool switch_liq_cloud_optics, |
| 46 | + const bool switch_ice_cloud_optics); |
| 47 | + |
| 48 | +bool prepare_netcdf(Netcdf_handle& input_nc, std::string file_name, int n_lay, int n_lev, int n_col_x, int n_col_y, |
| 49 | + int n_zh, int n_z, |
| 50 | + Float sza, std::vector<Float> zh, std::vector<Float> z, |
| 51 | + Array<Float,2> p_lay, Array<Float,2> t_lay, Array<Float,2> p_lev, Array<Float,2> t_lev, |
| 52 | + Array<Float,2> lwp, Array<Float,2> iwp, Array<Float,2> rel, Array<Float,2> dei, |
| 53 | + Gas_concs& gas_concs, std::vector<std::string> gas_names, |
| 54 | + bool switch_cloud_optics, bool switch_liq_cloud_optics, bool switch_ice_cloud_optics); |
| 55 | + |
| 56 | +void restore_bkg_profile(const int n_x, const int n_y, |
| 57 | + const int n_full, |
| 58 | + const int n_tilt, |
| 59 | + const int bkg_start, |
| 60 | + std::vector<Float>& var, |
| 61 | + std::vector<Float>& var_w_bkg); |
| 62 | + |
| 63 | +void restore_bkg_profile_bundle(const int n_col_x, const int n_col_y, |
| 64 | + const int n_lay, const int n_lev, |
| 65 | + const int n_lay_tot, const int n_lev_tot, |
| 66 | + const int n_z_in, const int n_zh_in, |
| 67 | + const int bkg_start_z, const int bkg_start_zh, |
| 68 | + Array<Float,2>* p_lay_copy, Array<Float,2>* t_lay_copy, Array<Float,2>* p_lev_copy, Array<Float,2>* t_lev_copy, |
| 69 | + Array<Float,2>* lwp_copy, Array<Float,2>* iwp_copy, Array<Float,2>* rel_copy, Array<Float,2>* dei_copy, Array<Float,2>* rh_copy, |
| 70 | + Gas_concs& gas_concs_copy, Aerosol_concs& aerosol_concs_copy, |
| 71 | + Array<Float,2>* p_lay, Array<Float,2>* t_lay, Array<Float,2>* p_lev, Array<Float,2>* t_lev, |
| 72 | + Array<Float,2>* lwp, Array<Float,2>* iwp, Array<Float,2>* rel, Array<Float,2>* dei, Array<Float,2>* rh, |
| 73 | + Gas_concs& gas_concs, Aerosol_concs& aerosol_concs, |
| 74 | + std::vector<std::string> gas_names, std::vector<std::string> aerosol_names, |
| 75 | + bool switch_liq_cloud_optics, bool switch_ice_cloud_optics, bool switch_aerosol_optics |
| 76 | + ); |
| 77 | + |
| 78 | +void compress_columns_weighted_avg(const int n_x, const int n_y, |
| 79 | + const int n_out, |
| 80 | + const int n_tilt, |
| 81 | + const int compress_lay_start_idx, |
| 82 | + std::vector<Float>& var, std::vector<Float>& var_weighting); |
| 83 | + |
| 84 | +void compress_columns_p_or_t(const int n_x, const int n_y, |
| 85 | + const int n_out_lay, const int n_tilt, |
| 86 | + const int compress_lay_start_idx, |
| 87 | + std::vector<Float>& var_lev, std::vector<Float>& var_lay); |
| 88 | + |
| 89 | +void tilt_fields(const int n_z_in, const int n_zh_in, const int n_col_x, const int n_col_y, |
| 90 | + const int n_z_tilt, const int n_zh_tilt, const int n_col, |
| 91 | + const Array<Float,1> zh, const Array<Float,1> z, |
| 92 | + const Array<Float,1> zh_tilt, const Array<ijk,1> path, |
| 93 | + Array<Float,2>* p_lay_copy, Array<Float,2>* t_lay_copy, Array<Float,2>* p_lev_copy, Array<Float,2>* t_lev_copy, |
| 94 | + Array<Float,2>* rh_copy, |
| 95 | + Gas_concs& gas_concs_copy, const std::vector<std::string> gas_names, |
| 96 | + Aerosol_concs& aerosol_concs_copy, const std::vector<std::string> aerosol_names, const bool switch_aerosol_optics |
| 97 | + ); |
| 98 | + |
| 99 | +void compress_fields(const int compress_lay_start_idx, const int n_col_x, const int n_col_y, |
| 100 | + const int n_z_in, const int n_zh_in, const int n_z_tilt, |
| 101 | + Array<Float,2>* p_lay_copy, Array<Float,2>* t_lay_copy, Array<Float,2>* p_lev_copy, Array<Float,2>* t_lev_copy, |
| 102 | + Array<Float,2>* rh_copy, |
| 103 | + Gas_concs& gas_concs_copy, std::vector<std::string> gas_names, |
| 104 | + Aerosol_concs& aerosol_concs_copy, std::vector<std::string> aerosol_names, const bool switch_aerosol_optics); |
| 105 | + |
| 106 | +void create_tilted_columns(const int n_x, const int n_y, const int n_lay_in, const int n_lev_in, |
| 107 | + const std::vector<Float>& zh_tilted, const std::vector<ijk>& tilted_path, |
| 108 | + std::vector<Float>& var); |
| 109 | + |
| 110 | +void interpolate(const int n_x, const int n_y, const int n_lay_in, const int n_lev_in, |
| 111 | + const std::vector<Float>& zh_in, const std::vector<Float>& zf_in, |
| 112 | + const std::vector<Float>& play_in, const std::vector<Float>& plev_in, |
| 113 | + const Float zp, const ijk offset, |
| 114 | + Float* p_out); |
| 115 | + |
| 116 | +void create_tilted_columns_levlay(const int n_x, const int n_y, const int n_lay_in, const int n_lev_in, |
| 117 | + const std::vector<Float>& zh_in, const std::vector<Float>& z_in, |
| 118 | + const std::vector<Float>& zh_tilted, const std::vector<ijk>& tilted_path, |
| 119 | + std::vector<Float>& var_lay, std::vector<Float>& var_lev); |
| 120 | + |
| 121 | +void tica_tilt(const Float sza, const Float azi, |
| 122 | + const int n_col_x, const int n_col_y, const int n_col, |
| 123 | + const int n_lay, const int n_lev, const int n_z_in, const int n_zh_in , |
| 124 | + Array<Float,1> xh, Array<Float,1> yh, Array<Float,1> zh, Array<Float,1> z, |
| 125 | + Array<Float,2> p_lay, Array<Float,2> t_lay, Array<Float,2> p_lev, Array<Float,2> t_lev, |
| 126 | + Array<Float,2> lwp, Array<Float,2> iwp, Array<Float,2> rel, Array<Float,2> dei, Array<Float,2> rh, |
| 127 | + Gas_concs gas_concs, Aerosol_concs aerosol_concs, |
| 128 | + Array<Float,2>& p_lay_out, Array<Float,2>& t_lay_out, Array<Float,2>& p_lev_out, Array<Float,2>& t_lev_out, |
| 129 | + Array<Float,2>& lwp_out, Array<Float,2>& iwp_out, Array<Float,2>& rel_out, Array<Float,2>& dei_out, Array<Float,2>& rh_out, |
| 130 | + Gas_concs& gas_concs_out, Aerosol_concs aerosol_concs_out, |
| 131 | + std::vector<std::string> gas_names, std::vector<std::string> aerosol_names, |
| 132 | + bool switch_cloud_optics, bool switch_liq_cloud_optics, bool switch_ice_cloud_optics, bool switch_aerosol_optics); |
0 commit comments