微波輻射傳輸PAMTRA1.0安裝

參考PAMTRA官方文檔:Installation — Pamtra 1.0.doc documentation

1. 本機(jī)配置

環(huán)境:Win 11 子系統(tǒng)WSL2(Ubuntu 22.04)
python: miniconda3 python3.8。由于采用conda安裝的python3.8,故直接跳過官方文檔的python安裝

2. 編譯pamtra

在pamtra文件目錄,輸入

$ make F2PY=f2py3

3. 安裝pamtra

由于python采用conda環(huán)境,需修改python路徑,編輯Makefile,替換

PYINSTDIR := lib/python

PYINSTDIR := /home/zoom/miniconda3/lib/python3.8/site-packages/

在命令行輸入如下命令,進(jìn)行安裝

$ make pyinstall F2PY=f2py3 

4. 測試

import numpy as np 
import netCDF4
import matplotlib
import matplotlib.pyplot as plt
from IPython import embed
from glob import glob
import pyPamtra  # import pyPamtra
import warnings
warnings.filterwarnings("ignore")
matplotlib.rcParams['axes.unicode_minus'] = False
font = {'font.family': 'Times New Roman',
        'mathtext.fontset': 'stix',
        'font.size': 12}
matplotlib.rcParams.update(font)

pam = pyPamtra.pyPamtra()
descriptorFile = np.array([
        #['hydro_name' 'as_ratio' 'liq_ice' 'rho_ms' 'a_ms' 'b_ms' 'alpha_as' 'beta_as' 'moment_in' 'nbin' 'dist_name' 'p_1' 'p_2' 'p_3' 'p_4' 'd_1' 'd_2' 'scat_name' 'vel_size_mod' 'canting']
        ('cwc_q', -99.0,  1, -99.0,   -99.0, -99.0,  -99.0, -99.0, 3, 1, 'mono', -99.0, -99.0,   2.0,    1.0,   2.0e-6,   8.0e-5, 'disabled', 'khvorostyanov01_drops', -99.0),
        ('iwc_q', 1.0, -1, 700.0, -99.0,  -99.0,  -99.0,   -99.0, 3, 1, 'mono', -99.0, -99.0, 1.564, 0.8547, 1.744e-5, 9.369e-3, 'disabled',   'heymsfield10_particles',  -99.0),
        ('rwc_q', -99.0, 1, -99.0, -99.0, -99.0,  -99.0, -99.0, 3, 50, 'exp', 0.22, 2.2,   -99.0,    -99.0,  0.00012,   0.006, 'disabled', 'khvorostyanov01_drops',  -99.0),
        ('swc_q', 1.0, -1, -99.0, 0.069, 2.0, 0.3971,  1.88, 3, 50, 'exp', 2.0e06, 0.,  -99.0, -99.0, 2.0e-04,  0.02, 'disabled',   'heymsfield10_particles', -99.0),
        ('gwc_q', -99.,-1, -99.0, 169.6, 3.1, -99.0, -99.0, 3, 50, 'exp', -99.0, -99.0, 4.0e6, -99.0, 1.0e-10, 1.0e-2, 'disabled', 'khvorostyanov01_spheres', -99.0)],
        dtype=[('hydro_name', 'S15'), ('as_ratio', '<f8'), ('liq_ice', '<i8'), ('rho_ms', '<f8'), ('a_ms', '<f8'), ('b_ms', '<f8'), ('alpha_as', '<f8'), ('beta_as', '<f8'), ('moment_in', '<i8'), ('nbin', '<i8'), ('dist_name', 'S15'), ('p_1', '<f8'), ('p_2', '<f8'), ('p_3', '<f8'), ('p_4', '<f8'), ('d_1', '<f8'), ('d_2', '<f8'), ('scat_name', 'S20'), ('vel_size_mod', 'S30'), ('canting', '<f8')] 
        )
for hyd in descriptorFile: pam.df.addHydrometeor(hyd)
pam.readPamtraProfile('/home/zoom/pamtra/profile/example_input.lay')

# 廓線數(shù)據(jù)展示
fig = plt.figure(figsize=[12,4])
fig.add_axes([0.1,0.1,0.25,0.8])
plt.plot(pam.p['press'][0,0,:]/100.,pam.p['hgt'][0,0,:])
plt.ylabel('height [m]')
plt.xlabel('pressure [hPa]')
fig.add_axes([0.425,0.1,0.25,0.8])
plt.plot(pam.p['temp'][0,0,:],pam.p['hgt'][0,0,:])
plt.xlabel('temperature [K]')
fig.add_axes([0.75,0.1,0.25,0.8])
plt.plot(pam.p['relhum'][0,0,:],pam.p['hgt'][0,0,:])
plt.xlabel('rel. humidity [%]')
plt.show()

# 模擬10到200Ghz的天頂和地基微波輻射(被動(dòng))
freqs = np.arange(10.,200.,1.)
pam.nmlSet['active'] = False
pam.runParallelPamtra(freqs, pp_deltaX=1, pp_deltaY=1, pp_deltaF=10, pp_local_workers="auto")
print(pam.dimensions['tb'])

plt.figure()
plt.plot(freqs,pam.r["tb"][0,0,0,7,:,0],label='upwelling 52$^{\circ}$ V_pol')
plt.plot(freqs,pam.r["tb"][0,0,0,7,:,1],label='upwelling 52$^{\circ}$ H_pol')
plt.plot(freqs,pam.r["tb"][0,0,1,31,:].mean(axis=-1),label='downwelling zenith')
plt.xlabel('frequency [GHz]')
plt.ylabel('brightness temperature [K]')
plt.legend(loc=4)
plt.show()
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容