|
| 1 | +import os |
| 2 | + |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import numpy as np |
| 5 | +import pyarts3 as pyarts |
| 6 | + |
| 7 | +# Download catalogs |
| 8 | +pyarts.data.download() |
| 9 | + |
| 10 | +ws = pyarts.workspace.Workspace() |
| 11 | + |
| 12 | +# %% Sampled frequency range |
| 13 | +line_f0 = 118750348044.712 |
| 14 | +ws.freq_grid = np.linspace(-50e6, 50e6, 1001) + line_f0 |
| 15 | + |
| 16 | +# %% Species and line absorption |
| 17 | +ws.abs_speciesSet(species=["O2-66"]) |
| 18 | +ws.ReadCatalogData() |
| 19 | +ws.abs_bandsSelectFrequencyByLine(fmin=40e9, fmax=120e9) |
| 20 | +ws.abs_bandsSetZeeman(species="O2-66", fmin=118e9, fmax=119e9) |
| 21 | +ws.WignerInit() |
| 22 | + |
| 23 | +# %% Use the automatic agenda setter for propagation matrix calculations |
| 24 | +ws.spectral_propmat_agendaAuto() |
| 25 | + |
| 26 | +# %% Grids and planet |
| 27 | +ws.surf_fieldPlanet(option="Earth") |
| 28 | +ws.surf_field[pyarts.arts.SurfaceKey("t")] = 295.0 |
| 29 | +ws.atm_fieldRead( |
| 30 | + toa=100e3, basename="planets/Earth/afgl/tropical/", missing_is_zero=1 |
| 31 | +) |
| 32 | +ws.atm_fieldSchmidthFieldFromIGRF(time="2000-03-11 14:39:37") |
| 33 | + |
| 34 | +# %% Checks and settings |
| 35 | +ws.spectral_rad_transform_operatorSet(option="Tb") |
| 36 | + |
| 37 | +# %% Core calculations |
| 38 | +pos = [100e3, 0, 0] |
| 39 | +los = [180.0, 0.0] |
| 40 | +ws.ray_pathGeometric(pos=pos, los=los, max_stepsize=1000.0) |
| 41 | +ws.spectral_radClearskyLinearInTauAndPropEmission() |
| 42 | +ws.spectral_radApplyUnitFromSpectralRadiance() |
| 43 | + |
| 44 | +# %% Show results |
| 45 | +fig, ax = pyarts.plot(ws.spectral_rad, freqs=( |
| 46 | + ws.freq_grid - line_f0) / 1e6) |
| 47 | +[a.set_xlabel("Frequency offset [MHz]") for a in ax.flatten()] |
| 48 | +[a.set_ylabel("Spectral radiance [K]") for a in ax.flatten()] |
| 49 | +fig.suptitle(f"Zeeman effect of {round(line_f0 / 1e6)} MHz O$_2$ line") |
| 50 | + |
| 51 | +if "ARTS_HEADLESS" not in os.environ: |
| 52 | + plt.show() |
| 53 | + |
| 54 | +# %% Test |
| 55 | + |
| 56 | +assert np.allclose( |
| 57 | + ws.spectral_rad[::100], |
| 58 | + np.array( |
| 59 | + [[ 2.27830141e+02, 4.25489128e-04, 1.02599187e-04, 5.68881918e-02], |
| 60 | + [ 2.30907190e+02, 6.59070807e-04, 1.59097448e-04, 7.03735321e-02], |
| 61 | + [ 2.34847968e+02, 1.16702319e-03, 2.82212718e-04, 9.33486760e-02], |
| 62 | + [ 2.40400744e+02, 2.61388422e-03, 6.34254900e-04, 1.40005198e-01], |
| 63 | + [ 2.49821088e+02, 9.73795166e-03, 2.38733210e-03, 2.69700244e-01], |
| 64 | + [ 2.08949873e+02, 2.37747404e+01, 1.64966784e+00, 5.47066239e-06], |
| 65 | + [ 2.49820521e+02, 9.74149272e-03, 2.38822964e-03, -2.69777785e-01], |
| 66 | + [ 2.40399650e+02, 2.61568960e-03, 6.34700330e-04, -1.40081856e-01], |
| 67 | + [ 2.34846390e+02, 1.16822346e-03, 2.82506203e-04, -9.34247505e-02], |
| 68 | + [ 2.30905136e+02, 6.59975316e-04, 1.59317615e-04, -7.04496271e-02], |
| 69 | + [ 2.27827622e+02, 4.26220137e-04, 1.02776641e-04, -5.69642694e-02]] |
| 70 | + ), |
| 71 | +), "Values have drifted from expected results in spectral radiance" |
0 commit comments