2. Clearsky radiance

  1# Import the module
  2import os
  3import pyarts
  4import numpy as np  # This example uses numpy
  5import matplotlib.pyplot as plt
  6
  7
  8# Create a workspace
  9ws = pyarts.Workspace()
 10
 11# Download ARTS catalogs if they are not already present.
 12pyarts.cat.download.retrieve()
 13
 14# The main agenda for computations of the radiative transfer
 15# follows a pure clears sky radiative transfer in this example.
 16# When the path tracing hits the surface, the surface emission
 17# is computed from the lowest atmospheric temperature,
 18# and when the path tracing hits the top of the atmosphere,
 19# the cosmic background is used as emission source.
 20ws.iy_main_agendaSet(option="Emission")
 21ws.iy_surface_agendaSet(option="UseSurfaceRtprop")
 22ws.surface_rtprop_agendaSet(option="Blackbody_SurfTFromt_field")
 23ws.iy_space_agendaSet(option="CosmicBackground")
 24
 25# The path tracing is done step-by-step following a geometric path
 26ws.ppath_agendaSet(option="FollowSensorLosPath")
 27ws.ppath_step_agendaSet(option="GeometricPath")
 28
 29# We might have to compute the Jacobian for the retrieval
 30# of relative humidity, so we need to set the agenda for
 31# that.
 32ws.water_p_eq_agendaSet(option="MK05")
 33
 34# The geometry of our planet, and several other properties, are
 35# set to those of Earth.
 36ws.PlanetSet(option="Earth")
 37
 38# Our output unit is Planc brightness temperature
 39ws.iy_unit = "PlanckBT"
 40
 41# We do not care about polarization in this example
 42ws.stokes_dim = 1
 43
 44# The atmosphere is assumed 1-dimensional
 45ws.atmosphere_dim = 1
 46
 47# We have one sensor position in space, looking down, and one
 48# sensor position at the surface, looking up.
 49ws.sensor_pos = [[300e3], [0]]
 50ws.sensor_los = [[180], [0]]
 51
 52# The dimensions of the problem are defined by a 1-dimensional pressure grid
 53ws.p_grid = np.logspace(5.01, -1)
 54ws.lat_grid = []
 55ws.lon_grid = []
 56
 57# The surface is at 0-meters altitude
 58ws.z_surface = [[0.0]]
 59
 60# Our sensor sees 10 frequency bins between 40 and 120 GHz
 61NF = 10
 62ws.f_grid = np.linspace(40e9, 120e9, NF)
 63
 64# The atmosphere consists of water, oxygen and nitrogen.
 65# We set these to be computed using predefined absorption
 66# models.
 67ws.abs_speciesSet(species=["H2O-PWR98", "O2-PWR98", "N2-SelfContStandardType"])
 68
 69# We have no line-by-line calculations, so we mark the LBL catalog as empty
 70ws.abs_lines_per_speciesSetEmpty()
 71
 72# We now have all the information required to compute the absorption agenda.
 73ws.propmat_clearsky_agendaAuto()
 74
 75# We need an atmosphere.  This is taken from the arts-xml-data in
 76# raw format before being turned into the atmospheric fields that
 77# ARTS uses internally.
 78ws.AtmRawRead(basename="planets/Earth/Fascod/tropical/tropical")
 79ws.AtmFieldsCalc()
 80
 81# These calculations do no partial derivatives, so we can turn it off
 82ws.jacobianOff()
 83
 84# There is no scattering in this example, so we can turn it off
 85ws.cloudboxOff()
 86
 87# The concept of a sensor does not apply to this example, so we can turn it off
 88ws.sensorOff()
 89
 90# We check the atmospheric geometry, the atmospheric fields, the cloud box,
 91# and the sensor.
 92ws.atmgeom_checkedCalc()
 93ws.atmfields_checkedCalc()
 94ws.cloudbox_checkedCalc()
 95ws.sensor_checkedCalc()
 96
 97# We perform the calculations
 98ws.yCalc()
 99
100# Create a simple plot to look at the simulations.  Try increasing NF
101# above to see more details
102plt.plot(ws.f_grid.value/1e9, ws.y.value.value.reshape(2, NF).T)
103plt.xlabel("Frequency [GHz]")
104plt.ylabel("Brightness temperature [K]")
105plt.legend(["Looking down", "Looking up"])
106plt.title("Low resolution O$_2$ millimeter absorption band")
107
108# WE SHOW THE PLOT ONLY IF THIS SCRIPT IS RUN OUTSIDE OUR TEST ENVIRONMENT.
109if os.environ.get("ARTS_HEADLESS") is None:
110    plt.show()
111
112# TESTING
113# AS THIS FILE IS RUN TO TEST ARTS, WE NEED TO CHECK THAT
114# THE CONTENT OF THE VARIABLES ARE GOOD.
115assert np.allclose(
116    ws.y.value,
117    np.array([296.61207605, 292.04188873, 210.01486215, 271.44447592,
118              293.06468686, 294.18513535, 293.97640914, 293.24271601,
119              291.01085103, 252.58148054,  44.8272092 ,  88.45315869,
120              292.69787616, 229.39778329, 104.89723532, 107.59101072,
121              120.4062287 , 136.72275807, 160.08765173, 264.38696518])
122    )
123# END TESTING