Atmosphere
This demonstrates how to set your atmospheric field using netcdf.
An atmospheric field is created using standard workspace method
flow. The atmospheric field is then gridded to a uniform grid
before being written to a netcdf file via the xarray.Dataset
format.
An helper method
1import pyarts
2import numpy as np
3
4# Use defaul
5ws = pyarts.Workspace()
6ws.absorption_speciesSet(species=["O2", "CO2"])
7ws.atmospheric_fieldRead(
8 toa=100e3, basename="planets/Earth/afgl/tropical/", missing_is_zero=1
9)
10
11# The atmospheric field must be uniformly gridded to be saved to a netcdf file
12gridded_atm = ws.atmospheric_field.as_gridded(np.linspace(0, 100e3, 101), [0], [0])
13
14# Save only O2 VMR, temperature and pressure to a netcdf file
15gridded_atm.to_xarray(keys=["O2", 't', 'p']).to_netcdf("atmosphere.nc")
16
17# Use helper method to read the netcdf file (if it is in any path seen by ARTS)
18atmnc = pyarts.data.xarray_open_dataset("atmosphere.nc")
19
20# Convert the xarray dataset to an atmospheric field
21atm = pyarts.data.to_atmospheric_field(atmnc)