337.1 / 777.4 nm photometer

Physicist verification companion · source release r4 · mathematical checks and unresolved limits

Review index · Download raw source

reference/analytic/rayleigh.py

1import math,json,pathlib,datetime,hashlib2import numpy as np3b=pathlib.Path('D:/Photometer_research_20261022/revision_20261022_r4/analysis/analytic/rayleigh')4lam_nm=337.1;lam=lam_nm*1e-9;u=lam_nm/10005ratio=(1.0455996-341.29061/u**2-0.90230850*u*u)/(1+0.0027059889/u**2-85.968563*u*u)6sigma_b=ratio*1e-32;tau0_b=0.0021520*ratio7nair0=2.6867811e25;nair288=nair0*273.15/288.158n=1+1e-8*(8060.51+2480990/(132.274-1/u**2)+17455.7/(39.32957-1/u**2))9king=(780840*(1.034+3.17e-4/u**2)+209476*(1.096+1.385e-3/u**2+1.448e-4/u**4)+9340+314*1.15)/1e610sigma_c=24*math.pi**3*((n*n-1)/(n*n+2))**2*king/(lam**4*nair288**2)11R=6356766.;g0=9.80665;Rstar=8314.32;M=28.9644;kb=1.380649e-2312levels=np.array([0.,11000.,20000.,32000.,47000.,51000.,71000.,84852.])13laps=np.array([-.0065,0.,.001,.0028,0.,-.0028,-.002])14Tb=[288.15];Pb=[101325.]15for i,L in enumerate(laps):16 delta=levels[i+1]-levels[i];topT=Tb[-1]+L*delta17 topP=Pb[-1]*(topT/Tb[-1])**(-g0*M/(Rstar*L)) if L else Pb[-1]*math.exp(-g0*M*delta/(Rstar*Tb[-1]))18 Tb.append(topT);Pb.append(topP)19def PT(h):20 h=np.asarray(h);H=R*h/(R+h);i=np.clip(np.searchsorted(levels,H,side='right')-1,0,6);L=laps[i]21 T=np.array(Tb)[i]+L*(H-levels[i]);P=np.zeros(h.shape)22 iso=(L==0)23 P[iso]=np.array(Pb)[i[iso]]*np.exp(-g0*M*(H[iso]-levels[i[iso]])/(Rstar*T[iso]))24 P[~iso]=np.array(Pb)[i[~iso]]*(T[~iso]/np.array(Tb)[i[~iso]])**(-g0*M/(Rstar*L[~iso]))25 return P,T26hmax=R*levels[-1]/(R-levels[-1]);pmax,tmax=PT(np.array([hmax]))27tail=float(pmax[0]/(kb*tmax[0])*(Rstar*tmax[0]/M)/(g0*(R/(R+hmax))**2))28rows=[]29for z in [0,15000,16000,18000,18500]:30 p,T=PT(np.array([z]));p=float(p[0]);T=float(T[0])31 #1m/2m convergence of geometric number column, plus negligible above86km pressure-tail estimate.32 col=[]33 for dz in [2.,1.]:34  hg=np.linspace(z,hmax,int(math.ceil((hmax-z)/dz))+1);pg,tg=PT(hg)35  col.append(float(np.trapezoid(pg/(kb*tg),hg)+tail))36 tau_std=sigma_b*col[-1]37 tau_simple=tau0_b*p/101325.38 tau_frozen=sigma_c*nair0*7200.*math.exp(-z/7200.)39 rows.append({'geometric_altitude_m':z,'geopotential_altitude_m':R*z/(R+z),'pressure_Pa':p,'temperature_K':T,'number_column_m2':col[-1],'number_column_1m_2m_relative_difference':abs(col[1]-col[0])/col[1],'tau_R_standard_density_integral':tau_std,'T_R_standard_direct':math.exp(-tau_std),'tau_R_pressure_ratio_simple':tau_simple,'tau_R_frozen_CloudScat_exp7200':tau_frozen,'T_R_frozen_CloudScat_direct':math.exp(-tau_frozen),'standard_minus_frozen_direct_percentage_points':100*(math.exp(-tau_std)-math.exp(-tau_frozen))})40out={'status':'STAGED_ANALYTIC_AUDIT_NOT_PRODUCTION_RT','calculation_utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'wavelength_nm':lam_nm,'sigma_Bodhaine1999_eq29_fit_m2':sigma_b,'tau_Bodhaine1999_eq30_sea45deg':tau0_b,'sigma_CloudScat_exact_source_m2':sigma_c,'CloudScat_source_nair0_m3':nair0,'CloudScat_source_H_m':7200,'CloudScat_nuray_ground_m1':sigma_c*nair0,'standard_atmosphere_constants':{'g0_m_s2':g0,'Rstar_J_kmol_K':Rstar,'M_kg_kmol':M,'earth_geopotential_radius_m':R,'geopotential_layer_base_m':levels.tolist(),'lapse_K_m':laps.tolist(),'derived_base_pressures_Pa':Pb},'standard_column_method':'Integrate geometric number-density from USSA1976 hydrostatic T/P layers to86km with1m grid; add pressure-column tail estimate above86km (<3e-6 opticaldepth). Tail is a bounded approximation, not a detailed thermosphere model. Composition dryair and gravity/reference radius are standard, not polar weather. Simple p/p0 variant also reported.','sources':[{'url':'https://ntrs.nasa.gov/api/citations/19770009539/downloads/19770009539.pdf','locator':'USSA1976 Part1 and Part4; scanned text poor, formula independently cross-checked in NASA/TM2005-213659 AppendixA pp34-35'},{'url':'https://ntrs.nasa.gov/api/citations/20050207438/downloads/20050207438.pdf','locator':'AppendixA equationsA1-A5; geopotential/temperature/pressure constants'},{'url':'https://doi.org/10.1175/1520-0426(1999)016<1854:ORODC>2.0.CO;2','locator':'Bodhaine etal1999 equations9,29,30; fitted360ppm dryair crosssection'},{'local_read_only':'outputs/CloudScat/source/src/rayleigh.jl and parameters.jl','locator':'frozen actual Ray.sigma uses314ppm composition, STP nair0 and7.2km scale height; comparison reimplements arithmetic only, no simulation/package modification'}],'rows':rows,'interpretation_limits':['Direct/ballistic no-collision transmission only. Rayleigh-scattered photons are not all absorbed or necessarily outside the full instrument response.','Cloud attenuation can multiply this factor for the direct ray e^-tau_cloud only; total diffuse directional fluence requires radiative transfer and cannot be obtained by this exponential alone.','This is a clear dry reference atmosphere; no aerosol, ozone, real polar seasonal weather, source spectrum, or finite-band weighting included.','At/above cloudtop, tau_cloud_above=0 does not remove the delayed contribution of downward photons returning from the cloud below.']}41(b/'Rayleigh_standard_vs_frozen_337_audit.json').write_text(json.dumps(out,indent=2),encoding='utf-8')42print(json.dumps(out,indent=2))43