Skip to content

Commit 9de04e8

Browse files
authored
Finalize Helios CK (#133)
- reads correctly - requires extra band info - still needs test to integrate into RT
1 parent 911bd47 commit 9de04e8

File tree

21 files changed

+259
-227
lines changed

21 files changed

+259
-227
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ jobs:
351351
working-directory: ${{github.workspace}}/build-netcdf/bin
352352
# Execute tests defined by the CMake configuration.
353353
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
354-
run: python ./run_ktable_simple.py
354+
run: python ./run_ktable_earth.py
355355

356356
straka-2d:
357357
if: github.event.pull_request.draft == false

cmake/hjupiter.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ set(NETCDF OFF)
1414
set(PNETCDF ON)
1515
set(MPI ON)
1616
set(DISORT ON)
17-
set(PYTHON_BINDINGS OFF)
17+
set(PYTHON_BINDINGS ON)
1818
set_if_empty(RSOLVER hllc_transform)
19-
#set(GLOG ON)
19+
# set(GLOG ON)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ==========================
2+
# Examples published in XXXX
3+
# ==========================
4+
5+
string(TOLOWER ${CMAKE_BUILD_TYPE} buildl)
6+
string(TOUPPER ${CMAKE_BUILD_TYPE} buildu)
7+
8+
# 2. Copy input file to run directory
9+
file(GLOB inputs *.py *.yaml *.inp)
10+
foreach(input ${inputs})
11+
# softlink inp files
12+
execute_process(COMMAND ln -sf ${input} ${CMAKE_BINARY_DIR}/bin/${inp})
13+
endforeach()
File renamed without changes.

tools/example_earth.yaml renamed to examples/2024-CLi-earth-rt/example_earth.yaml

File renamed without changes.

tools/run_disort_rt.py renamed to examples/2024-CLi-earth-rt/run_disort_earth.py

File renamed without changes.

tools/run_disort_flux.py renamed to examples/2024-CLi-earth-rt/run_disort_earth_flux.py

File renamed without changes.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#! /usr/bin/env python3
2+
import sys, os
3+
4+
sys.path.append("../python")
5+
sys.path.append(".")
6+
7+
from pyharp import radiation_band
8+
from utilities import load_configure, find_resource
9+
from numpy import *
10+
from rfmlib import *
11+
12+
13+
# create atmosphere dictionary
14+
def create_rfm_atmosphere(nlyr: int) -> dict:
15+
atm = {}
16+
ps_mbar = 1.0e3
17+
Ts_K = 300.0
18+
grav_ms2 = 9.8
19+
mu_kgmol = 29.0e-3
20+
Rgas_JKmol = 8.314
21+
Rgas_Jkg = Rgas_JKmol / mu_kgmol
22+
Hscale_km = Rgas_Jkg * Ts_K / grav_ms2 * 1.0e-3
23+
24+
# km
25+
atm["HGT"] = linspace(0, 20, nlyr, endpoint=False)
26+
atm["PRE"] = ps_mbar * exp(-atm["HGT"] / Hscale_km)
27+
atm["TEM"] = Ts_K * ones(nlyr)
28+
# ppmv
29+
atm["CO2"] = 400.0 * ones(nlyr)
30+
# ppmv
31+
atm["H2O"] = 4000.0 * exp(-atm["HGT"] / (Hscale_km / 5.0))
32+
atm["O2"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.21
33+
atm["N2"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.78
34+
atm["Ar"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.01
35+
36+
return atm
37+
38+
39+
if __name__ == "__main__":
40+
hitran_file = find_resource("HITRAN2020.par")
41+
42+
info = load_configure("example_earth.yaml")
43+
opacity = info["opacity-sources"]
44+
band_name = str(info["bands"][0])
45+
46+
band = radiation_band(band_name, info)
47+
48+
nspec = band.get_num_spec_grids()
49+
wmin, wmax = band.get_range()
50+
wres = (wmax - wmin) / (nspec - 1)
51+
52+
num_absorbers = band.get_num_absorbers()
53+
absorbers = []
54+
for i in range(num_absorbers):
55+
absorbers.append(band.get_absorber(i).get_name())
56+
57+
# create atmosphere dictionary
58+
num_layers = 100
59+
wav_grid = (wmin, wmax, wres)
60+
tem_grid = (5, -20, 20)
61+
62+
atm = create_rfm_atmosphere(num_layers)
63+
driver = create_rfm_driver(wav_grid, tem_grid, absorbers, hitran_file)
64+
65+
# write rfm atmosphere file to file
66+
write_rfm_atm(atm)
67+
write_rfm_drv(driver)
68+
69+
# run rfm and write kcoeff file
70+
run_rfm()
71+
write_ktable(f"kcoeff-{band_name}.nc", absorbers, atm, wav_grid, tem_grid)

examples/2024-XZhang-cloud-rt/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endif()
88
setup_problem(hjupiter)
99

1010
# 2. Copy input files to run directory
11-
file(GLOB inputs *.inp *.yaml)
11+
file(GLOB inputs *.py *.inp *.yaml)
1212
foreach(input ${inputs})
13-
file(COPY ${input} DESTINATION ${CMAKE_BINARY_DIR}/bin)
13+
execute_process(COMMAND ln -sf ${input} ${CMAKE_BINARY_DIR}/bin/${inp})
1414
endforeach()

0 commit comments

Comments
 (0)