-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a way to turn a netcdf file in array: data-array format into an atmosphere. There are also some other changes to make the process smoother.
- Loading branch information
Showing
81 changed files
with
2,506 additions
and
1,927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
examples/getting-started/3-disort/3.clearsky-flux-from-dataset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import pyarts | ||
import numpy as np | ||
import xarray as xa | ||
from dataclasses import dataclass | ||
import matplotlib.pyplot as plt | ||
|
||
if not pyarts.arts.globals.data.is_lgpl: | ||
NQuad = 16 | ||
max_level_step = 1e3 | ||
atm_latitude = 0.0 | ||
atm_longitude = 0.0 | ||
solar_latitude = 0.0 | ||
solar_longitude = 0.0 | ||
surface_temperature = 293.0 | ||
surface_reflectivity = 0.05 | ||
cutoff = ["ByLine", 750e9] | ||
remove_lines_percentile = 70 | ||
sunfile = "star/Sun/solar_spectrum_QUIET.xml" | ||
planet = "Earth" | ||
|
||
xarr = pyarts.data.xarray_open_dataset("atm.nc") | ||
|
||
ws = pyarts.Workspace() | ||
|
||
ws.frequency_grid = pyarts.arts.convert.kaycm2freq(np.linspace(500, 2500, 1001)) | ||
ws.atmospheric_field = pyarts.data.to_atmospheric_field(xarr) | ||
|
||
v = pyarts.data.to_absorption_species(ws.atmospheric_field) | ||
|
||
ws.absorption_species = v | ||
ws.ReadCatalogData(ignore_missing=True) | ||
ws.propagation_matrix_agendaAuto(T_extrapolfac=1e9) | ||
|
||
for band in ws.absorption_bands: | ||
ws.absorption_bands[band].cutoff = cutoff[0] | ||
ws.absorption_bands[band].cutoff_value = cutoff[1] | ||
|
||
ws.absorption_bands.keep_hitran_s(remove_lines_percentile) | ||
|
||
ws.surface_fieldSetPlanetEllipsoid(option=planet) | ||
|
||
sun = pyarts.arts.GriddedField2.fromxml(sunfile) | ||
|
||
ws.surface_field["t"] = surface_temperature | ||
|
||
ws.sunFromGrid( | ||
sun_spectrum_raw=sun, | ||
latitude=solar_latitude, | ||
longitude=solar_longitude, | ||
) | ||
|
||
ws.disort_quadrature_dimension = NQuad | ||
ws.disort_fourier_mode_dimension = 1 | ||
ws.disort_legendre_polynomial_dimension = 1 | ||
|
||
ws.ray_pathGeometricDownlooking( | ||
latitude=atm_latitude, | ||
longitude=atm_longitude, | ||
max_step=max_level_step, | ||
) | ||
ws.ray_path_atmospheric_pointFromPath() | ||
|
||
ws.ray_path_frequency_gridFromPath() | ||
ws.ray_path_propagation_matrixFromPath() | ||
ws.disort_settingsInit() | ||
ws.disort_settingsOpticalThicknessFromPath() | ||
ws.disort_settingsLayerThermalEmissionLinearInTau() | ||
ws.disort_settingsSurfaceEmissionByTemperature(ray_path_point=ws.ray_path[0]) | ||
ws.disort_settingsCosmicMicrowaveBackgroundRadiation() | ||
ws.disort_settingsSurfaceLambertian(value=surface_reflectivity) | ||
ws.disort_settingsNoSingleScatteringAlbedo() | ||
ws.disort_settingsNoFractionalScattering() | ||
ws.disort_settingsNoLegendre() | ||
ws.disort_settingsSetSun(ray_path_point=ws.ray_path[-1]) | ||
ws.disort_spectral_flux_fieldCalc() | ||
|
||
plt.semilogy(pyarts.arts.convert.freq2kaycm(ws.frequency_grid), | ||
ws.disort_spectral_flux_field[:, 1]) | ||
|
||
f, s = pyarts.plots.AtmField.plot(ws.atmospheric_field, | ||
alts=np.linspace(0, ws.atmospheric_field.top_of_atmosphere)) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
def plot( | ||
atm_field, | ||
*, | ||
fig=None, | ||
alts=np.linspace(0, 1e5), | ||
lats=0, | ||
lons=0, | ||
ygrid=None, | ||
keep_basic=True, | ||
keep_specs=True, | ||
keep_isots=False, | ||
keep_nlte=False, | ||
keep_ssprops=True, | ||
): | ||
"""Plot the atmospheric field parameters in a default manner. | ||
Args: | ||
atm_field (pyarts.arts.AtmField): An atmospheric field | ||
fig (optional): The matplotlib figure to draw on. Defaults to None for new figure. | ||
alts (optional): A grid to plot on - must after broadcast with lats and lons be 1D. Defaults to np.linspace(0, 1e5). | ||
lats (optional): A grid to plot on - must after broadcast with alts and lons be 1D. Defaults to 0. | ||
lons (optional): A grid to plot on - must after broadcast with alts and lats be 1D. Defaults to 0. | ||
ygrid (optional): Choice of y-grid for plotting. Uses broadcasted alts if None. Defaults to None. | ||
keep_basic (bool, optional): Forwarded to pyarts.arts.AtmPoint::keys. Defaults to True. | ||
keep_specs (bool, optional): Forwarded to pyarts.arts.AtmPoint::keys. Defaults to True. | ||
keep_isots (bool, optional): Forwarded to pyarts.arts.AtmPoint::keys. Defaults to False. | ||
keep_nlte (bool, optional): Forwarded to pyarts.arts.AtmPoint::keys. Defaults to False. | ||
keep_ssprops (bool, optional): Forwarded to pyarts.arts.AtmPoint::keys. Defaults to True. | ||
Returns: | ||
fig: as input or a new figure | ||
subs: list of subplots | ||
""" | ||
alts, lats, lons = np.broadcast_arrays(alts, lats, lons) | ||
v = atm_field.at(alts, lats, lons) | ||
|
||
keys = v[0].keys( | ||
keep_basic=keep_basic, | ||
keep_specs=keep_specs, | ||
keep_isots=keep_isots, | ||
keep_nlte=keep_nlte, | ||
keep_ssprops=keep_ssprops, | ||
) | ||
N = len(keys) | ||
n = int(np.ceil(np.sqrt(N))) + 1 | ||
|
||
if fig is None: | ||
fig = plt.figure(figsize=(5 * n, 5 * n)) | ||
|
||
subs = [] | ||
for i in range(N): | ||
subs.append(fig.add_subplot(n, n, i + 1)) | ||
subs[-1].plot( | ||
[x[keys[i]] for x in v], | ||
alts if ygrid is None else ygrid, | ||
label=keys[i], | ||
) | ||
subs[-1].legend() | ||
return fig, subs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.