-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- reads correctly - requires extra band info - still needs test to integrate into RT
- Loading branch information
Showing
21 changed files
with
259 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ========================== | ||
# Examples published in XXXX | ||
# ========================== | ||
|
||
string(TOLOWER ${CMAKE_BUILD_TYPE} buildl) | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} buildu) | ||
|
||
# 2. Copy input file to run directory | ||
file(GLOB inputs *.py *.yaml *.inp) | ||
foreach(input ${inputs}) | ||
# softlink inp files | ||
execute_process(COMMAND ln -sf ${input} ${CMAKE_BINARY_DIR}/bin/${inp}) | ||
endforeach() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#! /usr/bin/env python3 | ||
import sys, os | ||
|
||
sys.path.append("../python") | ||
sys.path.append(".") | ||
|
||
from pyharp import radiation_band | ||
from utilities import load_configure, find_resource | ||
from numpy import * | ||
from rfmlib import * | ||
|
||
|
||
# create atmosphere dictionary | ||
def create_rfm_atmosphere(nlyr: int) -> dict: | ||
atm = {} | ||
ps_mbar = 1.0e3 | ||
Ts_K = 300.0 | ||
grav_ms2 = 9.8 | ||
mu_kgmol = 29.0e-3 | ||
Rgas_JKmol = 8.314 | ||
Rgas_Jkg = Rgas_JKmol / mu_kgmol | ||
Hscale_km = Rgas_Jkg * Ts_K / grav_ms2 * 1.0e-3 | ||
|
||
# km | ||
atm["HGT"] = linspace(0, 20, nlyr, endpoint=False) | ||
atm["PRE"] = ps_mbar * exp(-atm["HGT"] / Hscale_km) | ||
atm["TEM"] = Ts_K * ones(nlyr) | ||
# ppmv | ||
atm["CO2"] = 400.0 * ones(nlyr) | ||
# ppmv | ||
atm["H2O"] = 4000.0 * exp(-atm["HGT"] / (Hscale_km / 5.0)) | ||
atm["O2"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.21 | ||
atm["N2"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.78 | ||
atm["Ar"] = (1e6 - atm["CO2"] - atm["H2O"]) * 0.01 | ||
|
||
return atm | ||
|
||
|
||
if __name__ == "__main__": | ||
hitran_file = find_resource("HITRAN2020.par") | ||
|
||
info = load_configure("example_earth.yaml") | ||
opacity = info["opacity-sources"] | ||
band_name = str(info["bands"][0]) | ||
|
||
band = radiation_band(band_name, info) | ||
|
||
nspec = band.get_num_spec_grids() | ||
wmin, wmax = band.get_range() | ||
wres = (wmax - wmin) / (nspec - 1) | ||
|
||
num_absorbers = band.get_num_absorbers() | ||
absorbers = [] | ||
for i in range(num_absorbers): | ||
absorbers.append(band.get_absorber(i).get_name()) | ||
|
||
# create atmosphere dictionary | ||
num_layers = 100 | ||
wav_grid = (wmin, wmax, wres) | ||
tem_grid = (5, -20, 20) | ||
|
||
atm = create_rfm_atmosphere(num_layers) | ||
driver = create_rfm_driver(wav_grid, tem_grid, absorbers, hitran_file) | ||
|
||
# write rfm atmosphere file to file | ||
write_rfm_atm(atm) | ||
write_rfm_drv(driver) | ||
|
||
# run rfm and write kcoeff file | ||
run_rfm() | ||
write_ktable(f"kcoeff-{band_name}.nc", absorbers, atm, wav_grid, tem_grid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#! /usr/bin/env python3 | ||
import sys, os | ||
|
||
sys.path.append("../python") | ||
sys.path.append(".") | ||
|
||
from pyharp import radiation_band, init_thermo | ||
from utilities import load_configure | ||
from numpy import linspace, ones, exp | ||
from netCDF4 import Dataset | ||
from pylab import * | ||
|
||
|
||
# create atmosphere dictionary | ||
def create_atmosphere(nlyr: int) -> dict: | ||
atm = {} | ||
|
||
data = Dataset("jupiter1d-main.nc", "r") | ||
# km | ||
atm["HGT"] = (data["x1f"][:-1] + data["x1f"][1:]) / (2.0 * 1.0e3) | ||
|
||
# mbar | ||
atm["PRE"] = data["press"][0, :, 0, 0] / 100.0 | ||
|
||
# K | ||
atm["TEM"] = data["temp"][0, :, 0, 0] | ||
|
||
return atm | ||
|
||
|
||
if __name__ == "__main__": | ||
config = load_configure("hjupiter.yaml") | ||
init_thermo(config["thermodynamics"]) | ||
band = radiation_band("ck", config, load_opacity=True) | ||
|
||
ab = band.get_absorber_by_name("premix") | ||
print(ab) | ||
|
||
temp = 300.0 | ||
pres = 10.0e5 | ||
v1 = 0.0 | ||
v2 = 0.0 | ||
v3 = 0.0 | ||
|
||
air = [temp, v1, v2, v3, pres] | ||
print(ab.get_attenuation(1000.0, 1000.0, air)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#! /usr/bin/env python3 | ||
import sys, os | ||
|
||
sys.path.append("../python") | ||
sys.path.append(".") | ||
|
||
from pyharp import radiation_band, subscribe_species | ||
from utilities import load_configure, find_resource | ||
from netCDF4 import Dataset | ||
from numpy import * | ||
from rfmlib import * | ||
|
||
|
||
# create reference atmosphere dictionary | ||
# Edit this function to create your own atmosphere | ||
def create_rfm_atmosphere(nlyr: int) -> dict: | ||
atm = {} | ||
|
||
data = Dataset("hjupiter-main.nc", "r") | ||
# km | ||
atm["HGT"] = (data["x1f"][:-1] + data["x1f"][1:]) / (2.0 * 1.0e3) | ||
|
||
# mbar | ||
atm["PRE"] = data["press"][0, :, 0, 0] / 100.0 | ||
|
||
# K | ||
atm["TEM"] = data["temp"][0, :, 0, 0] | ||
|
||
# ppmv | ||
atm["H2"] = 1.0e6 | ||
|
||
return atm | ||
|
||
|
||
if __name__ == "__main__": | ||
config = load_configure("hjupiter.yaml") | ||
band = radiation_band("B1", config) | ||
|
||
nspec = band.get_num_spec_grids() | ||
wmin, wmax = band.get_range() | ||
wres = (wmax - wmin) / (nspec - 1) | ||
|
||
absorbers = ["H2O", "NH3"] | ||
|
||
# atmospheric properties | ||
num_layers = 100 | ||
wav_grid = (wmin, wmax, wres) | ||
tem_grid = (5, -20, 20) | ||
|
||
atm = create_rfm_atmosphere(num_layers) | ||
driver = create_rfm_driver(wav_grid, tem_grid, absorbers, hitran_file) | ||
|
||
# write rfm atmosphere file to file | ||
write_rfm_atm(atm) | ||
write_rfm_drv(driver) | ||
|
||
# run rfm and write kcoeff file | ||
run_rfm() | ||
|
||
fname = band.get_absorber_by_name("H2O").get_opacity_file() | ||
base_name = os.path.basename(fname) | ||
fname, _ = os.path.splitext(base_name) | ||
write_ktable(fname, absorbers, atm, wav_grid, tem_grid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.