def golowtran(c1: Dict[str, Any]) -> xarray.Dataset: """directly run Fortran code""" # %% default parameters if 'time' not in c1: c1['time'] = None defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: if p not in c1: c1[p] = 0 if 'wmol' not in c1: c1['wmol'] = [0] * 12 # %% input check assert len( c1['wmol']) == 12, 'see Lowtran user manual for 12 values of WMOL' assert np.isfinite( c1['h1'] ), 'per Lowtran user manual Table 14, H1 must always be defined' # %% setup wavelength if 'wlstep' not in c1: c1['wlstep'] = 20 if c1['wlstep'] < 5: logging.critical( 'minimum resolution 5 cm^-1, specified resolution 20 cm^-1') wlshort, wllong, nwl = nm2lt7(c1['wlshort'], c1['wllong'], c1['wlstep']) if not 0 < wlshort and wllong <= 50000: logging.critical( 'specified model range 0 <= wavelength [cm^-1] <= 50000') # %% invoke lowtran """ Note we invoke case "3a" from table 14, only observer altitude and apparent angle are specified """ Tx, V, Alam, trace, unif, suma, irrad, sumvv = lowtran7.lwtrn7( True, nwl, wllong, wlshort, c1['wlstep'], c1['model'], c1['itype'], c1['iemsct'], c1['im'], c1['iseasn'], c1['ird1'], c1['zmdl'], c1['p'], c1['t'], c1['wmol'], c1['h1'], c1['h2'], c1['angle'], c1['range_km']) dims = ('time', 'wavelength_nm', 'angle_deg') TR = xarray.Dataset( { 'transmission': (dims, Tx[:, 9][None, :, None]), 'radiance': (dims, sumvv[None, :, None]), 'irradiance': (dims, irrad[:, 0][None, :, None]), 'pathscatter': (dims, irrad[:, 2][None, :, None]) }, coords={ 'time': [c1['time']], 'wavelength_nm': Alam * 1e3, 'angle_deg': [c1['angle']] }) return TR
def golowtran(obsalt_km,zenang_deg, wlnm,c1):# -> DataArray: #%% default parameters defp = ('im','iseasn','ird1','range_km','zmdl','p','t') for p in defp: if p not in c1: c1[p] = 0 if 'wmol' not in c1: c1['wmol']=[0]*12 assert len(c1['wmol']) == 12,'see Lowtran user manual for 12 values of WMOL' #%% altitude obsalt_km = np.atleast_1d(obsalt_km) if obsalt_km.size>1: obsalt_km = obsalt_km[0] logging.error(f'for now I only handle single altitudes. Using first value of {obsalt_km} [km]') #%% zenith angle zenang_deg = np.atleast_1d(zenang_deg) #%% input check if not (np.isfinite(obsalt_km).all() and np.isfinite(zenang_deg).all() and np.isfinite(wlnm).all()): logging.critical('NaN or Inf detected in input, skipping LOWTRAN') return #%% setup wavelength wlcminv,wlcminvstep,nwl = nm2lt7(wlnm) if wlcminvstep<5: logging.critical('minimum resolution 5 cm^-1, specified resolution 20 cm^-1') if not ((0<=wlcminv) & (wlcminv<=50000)).all(): logging.critical('specified model range 0 <= wlcminv <= 50000') #%% invoke lowtran """ Note we invoke case "3a" from table 14, only observer altitude and apparent angle are specified """ Tx,V,Alam,trace,unif,suma,irrad,sumvv = lowtran7.lwtrn7( True, nwl, wlcminv[1], wlcminv[0], wlcminvstep, c1['model'], c1['itype'], c1['iemsct'], c1['im'], c1['iseasn'], c1['ird1'], c1['zmdl'], c1['p'], c1['t'], c1['wmol'], obsalt_km, 0, zenang_deg, c1['range_km']) TR = DataArray(np.column_stack((Tx[:,9],sumvv,irrad[:,0])), coords={'wavelength_nm':Alam*1e3, 'sim':['transmission','radiance','irradiance']}, dims = ['wavelength_nm','sim']) #%% collect results return TR
def golowtran(c1): # %% default parameters defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: if p not in c1: c1[p] = 0 if 'wmol' not in c1: c1['wmol'] = [0] * 12 # %% input check assert len( c1['wmol']) == 12, 'see Lowtran user manual for 12 values of WMOL' assert np.isfinite( c1['h1'] ), 'per Lowtran user manual Table 14, H1 must always be defined' # %% setup wavelength wlcminv, wlcminvstep, nwl = nm2lt7(c1['wlnmlim']) if wlcminvstep < 5: logging.critical( 'minimum resolution 5 cm^-1, specified resolution 20 cm^-1') if not ((0 <= wlcminv) & (wlcminv <= 50000)).all(): logging.critical('specified model range 0 <= wlcminv <= 50000') # %% invoke lowtran """ Note we invoke case "3a" from table 14, only observer altitude and apparent angle are specified """ Tx, V, Alam, trace, unif, suma, irrad, sumvv = lowtran7.lwtrn7( True, nwl, wlcminv[1], wlcminv[0], wlcminvstep, c1['model'], c1['itype'], c1['iemsct'], c1['im'], c1['iseasn'], c1['ird1'], c1['zmdl'], c1['p'], c1['t'], c1['wmol'], c1['h1'], c1['h2'], c1['angle'], c1['range_km']) TR = DataArray( np.column_stack((Tx[:, 9], sumvv, irrad[:, 0], irrad[:, 2])), coords={ 'wavelength_nm': Alam * 1e3, 'sim': ['transmission', 'radiance', 'irradiance', 'pathscatter'] }, dims=['wavelength_nm', 'sim']) return TR
def golowtran(obsalt_km, zenang_deg, wlnm, c1): # -> DataArray: #%% altitude obsalt_km = atleast_1d(obsalt_km) if obsalt_km.size > 1: obsalt_km = obsalt_km[0] logging.error( 'for now I only handle single altitudes. Using first value of {} [km]' .format(obsalt_km)) #%% zenith angle zenang_deg = atleast_1d(zenang_deg) #%% input check if not (isfinite(obsalt_km).all() and isfinite(zenang_deg).all() and isfinite(wlnm).all()): logging.critical('NaN or Inf detected in input, skipping LOWTRAN') return #%% setup wavelength wlcminv, wlcminvstep, nwl = nm2lt7(wlnm) if wlcminvstep < 5: logging.error( 'minimum resolution 5 cm^-1, specified resolution 20 cm^-1') if not ((0 <= wlcminv) & (wlcminv <= 50000)).all(): logging.error('specified model range 0 <= wlcminv <= 50000') #TX,V,ALAM,TRACE,UNIF,SUMA = lt7.lwtrn7(True,nwl) T = DataArray(data=empty((nwl, zenang_deg.size)), dims=['wavelength_nm', 'zenith_angle']) T['zenith_angle'] = zenang_deg #%% invoke lowtran """ Note we invoke case "3a" from table 14, only observer altitude and apparent angle are specified """ for za in zenang_deg: Tx, V, Alam = lt7.lwtrn7(True, nwl, wlcminv[1], wlcminv[0], wlcminvstep, c1['model'], c1['itype'], c1['iemsct'], obsalt_km, 0, za)[:3] T.loc[:, za] = Tx[:, 9] #%% collect results T['wavelength_nm'] = Alam * 1e3 return T