From 4890e47042c181223c9bb34bcf7ffe205ef1dd9f Mon Sep 17 00:00:00 2001 From: mac/cli Date: Mon, 26 Jan 2026 22:56:42 -0500 Subject: [PATCH 1/3] wip --- src/integrator/integrator.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/integrator/integrator.hpp b/src/integrator/integrator.hpp index c9a0ee4..2f45d3f 100644 --- a/src/integrator/integrator.hpp +++ b/src/integrator/integrator.hpp @@ -37,6 +37,9 @@ struct IntegratorOptionsImpl { static std::shared_ptr from_yaml( YAML::Node const& node, bool verbose = false); + std::shared_ptr clone() const { + return std::make_shared(*this); + } void report(std::ostream& os) const { os << "* type = " << type() << "\n" << "* cfl = " << cfl() << "\n" From aaf95fbd21181da38ff1c247f3c07d6c0978ecc9 Mon Sep 17 00:00:00 2001 From: mac/cli Date: Tue, 27 Jan 2026 08:15:10 -0500 Subject: [PATCH 2/3] wip --- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 2 +- pyproject.toml | 4 ++-- src/opacity/opacity_options.hpp | 3 +++ src/radiation/radiation.hpp | 7 +++++++ src/radiation/radiation_band.hpp | 33 +++++++++++++++++++++++--------- src/rtsolver/toon_mckay89.hpp | 3 +++ 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e81583d..02a4c0e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -81,7 +81,7 @@ jobs: CIBW_BUILD: cp${{ env.PY_VERSION }}* CIBW_ARCHS: ${{ env.MACOS_ARCH }} CIBW_BEFORE_BUILD: | - pip install numpy 'cmake<=3.30' 'pydisort>=1.4.1' 'torch==2.7.1' + pip install numpy 'cmake<=3.30' 'pydisort>=1.4.5' 'torch==2.7.1' brew update brew install netcdf TORCH_CMAKE_PREFIX_PATH=$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)') @@ -148,7 +148,7 @@ jobs: CIBW_SKIP: "*musllinux*" CIBW_BEFORE_BUILD: | yum install -y epel-release && yum install -y netcdf-devel - pip install numpy 'cmake<=3.30' 'pydisort>=1.4.1' 'torch==2.7.1' + pip install numpy 'cmake<=3.30' 'pydisort>=1.4.5' 'torch==2.7.1' TORCH_CMAKE_PREFIX_PATH=$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)') export LD_LIBRARY_PATH=$(python -c "import torch; print(torch.__path__[0] + '/lib')"):$(pwd)/build/lib:$LD_LIBRARY_PATH $LD_LIBRARY_PATH diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 273ae04..ef15f7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: - name: Install Python dependencies run: | - pip install numpy 'pydisort>=1.4.1' 'torch==2.7.1' + pip install numpy 'pydisort>=1.4.5' 'torch==2.7.1' - name: Install NetCDF run: | diff --git a/pyproject.toml b/pyproject.toml index b80fff5..c22aaad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = [ "wheel", "build", "ninja", - "pydisort>=1.4.1", + "pydisort>=1.4.5", "cmake>=3.20", "torch<=2.7.1,>=2.7.0", ] @@ -22,7 +22,7 @@ readme = "README.md" requires-python = ">=3.9" dependencies = [ "numpy", - "pydisort>=1.4.1", + "pydisort>=1.4.5", ] classifiers = [ "Development Status :: 4 - Beta", diff --git a/src/opacity/opacity_options.hpp b/src/opacity/opacity_options.hpp index 836754e..881ca35 100644 --- a/src/opacity/opacity_options.hpp +++ b/src/opacity/opacity_options.hpp @@ -14,6 +14,9 @@ struct OpacityOptionsImpl { std::string const& filename, std::string const& op_name, std::string bd_name = ""); + std::shared_ptr clone() const { + return std::make_shared(*this); + } void report(std::ostream& os) const { os << "* type = " << type() << "\n"; os << "* bname = " << bname() << "\n"; diff --git a/src/radiation/radiation.hpp b/src/radiation/radiation.hpp index f0e6d08..6969469 100644 --- a/src/radiation/radiation.hpp +++ b/src/radiation/radiation.hpp @@ -51,6 +51,13 @@ struct RadiationOptionsImpl { static std::shared_ptr from_yaml( std::string const& filename); + std::shared_ptr clone() const { + auto op = std::make_shared(*this); + for (auto& b : op->bands()) { + b = b->clone(); + } + return op; + } void report(std::ostream& os) const { os << "* outdirs = " << outdirs() << "\n"; os << "* [ bands:\n"; diff --git a/src/radiation/radiation_band.hpp b/src/radiation/radiation_band.hpp index e219174..fb05e03 100644 --- a/src/radiation/radiation_band.hpp +++ b/src/radiation/radiation_band.hpp @@ -10,6 +10,7 @@ #include // harp +#include #include #include @@ -66,6 +67,16 @@ struct RadiationBandOptionsImpl { static std::shared_ptr from_yaml( std::string const& filename, std::string const& bd_name); + std::shared_ptr clone() const { + auto op = std::make_shared(*this); + if (op->disort() != nullptr) { + op->disort() = op->disort()->clone(); + } + if (op->toon() != nullptr) { + op->toon() = op->toon()->clone(); + } + return op; + } void report(std::ostream& os) const { os << "* name = " << name() << "\n"; os << "* outdirs = " << outdirs() << "\n"; @@ -75,20 +86,24 @@ struct RadiationBandOptionsImpl { os << "* ncol = " << ncol() << "\n"; os << "* nlyr = " << nlyr() << "\n"; os << "* nstr = " << nstr() << "\n"; - os << "* [ opacities:\n"; + + os << "* opacities: [\n"; for (auto const& [k, v] : opacities()) { os << " - " << k << ":\n"; v->report(os); } os << " ]\n"; - os << "* disort:\n"; - disort()->report(os); - os << "* wavenumber = ["; - for (auto const& w : wavenumber()) os << w << ", "; - os << "]\n"; - os << "* weight = [ "; - for (auto const& w : weight()) os << w << ", "; - os << "]\n"; + + if (solver_name() == "disort") { + os << "* disort:\n"; + disort()->report(os); + } else if (solver_name() == "toon") { + os << "* toon:\n"; + toon()->report(os); + } + + os << "* wavenumber = " << fmt::format("{}", wavenumber()) << "\n"; + os << "* weight = " << fmt::format("{}", weight()) << "\n"; os << "* verbose = " << (verbose() ? "true" : "false") << "\n"; } diff --git a/src/rtsolver/toon_mckay89.hpp b/src/rtsolver/toon_mckay89.hpp index e128b5b..cc75617 100644 --- a/src/rtsolver/toon_mckay89.hpp +++ b/src/rtsolver/toon_mckay89.hpp @@ -18,6 +18,9 @@ struct ToonMcKay89OptionsImpl { return std::make_shared(); } + std::shared_ptr clone() const { + return std::make_shared(*this); + } void report(std::ostream& os) const { os << "* zenith_correction = " << zenith_correction() << "\n"; From 1894a188bb1a9bfd57a4e4caef050e779c37aff4 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:10:42 -0500 Subject: [PATCH 3/3] Implement deep cloning for opacities map in RadiationBandOptionsImpl (#82) * Initial plan * Add deep cloning for opacities map in clone method Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com> * Final update: deep cloning implementation complete Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com> * Remove CodeQL artifact file Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com> * Update src/radiation/radiation_band.hpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chengcli <69489965+chengcli@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/radiation/radiation_band.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/radiation/radiation_band.hpp b/src/radiation/radiation_band.hpp index fb05e03..142bde0 100644 --- a/src/radiation/radiation_band.hpp +++ b/src/radiation/radiation_band.hpp @@ -75,6 +75,11 @@ struct RadiationBandOptionsImpl { if (op->toon() != nullptr) { op->toon() = op->toon()->clone(); } + auto& opacities_ref = op->opacities(); + opacities_ref.clear(); + for (auto const& [k, v] : opacities()) { + opacities_ref[k] = v->clone(); + } return op; } void report(std::ostream& os) const {