pyradtran.interface.PyRadtranAccessor#
- class pyradtran.interface.PyRadtranAccessor(xarray_obj)[source]#
Bases:
objectxarray accessor for running libRadtran simulations.
Registered as
ds.pyradtran. The primary method isrun(), which parallelisesuvspecover every point in the dataset.Examples
>>> result = ds.pyradtran.run( ... config_path="config/my_config.yaml", ... era5_atmosphere=era5_ds, ... params={"albedo": 0.85}, ... )
See also
execute_simulation_batchThe underlying parallel driver.
- explain(point: Dict[str, Any] | None = None, params: Dict[str, Any] | None = None, config_path: str | Path | None = None, config: SimulationConfig | None = None, time_var: str = 'time', lat_var: str = 'latitude', lon_var: str = 'longitude') str[source]#
Preview the annotated uvspec input file for one point.
No simulation is run. Each line is tagged with the layer that produced it (
config/params-literal/dataset-var/unvalidated).- Parameters:
- Return type:
str
- inspect_cloud_file(selector: Dict[str, Any] | None = None, params: Dict[str, Any] | None = None, parameter_overrides: Dict[str, Any] | None = None, cloud_wc_var: str | None = None, cloud_ic_var: str | None = None, cloud_reff_var: str | None = None, cloud_ic_reff_var: str | None = None, cloud_top_var: str | None = None, cloud_bottom_var: str | None = None) str[source]#
Preview the cloud-profile file that would be generated.
- Parameters:
selector (dict, optional) – Passed to
Dataset.sel()to pick a single point. Defaults to the first element along every dimension.params (dict, optional) – Unified parameter mapping (same as
run());Varentries resolve from the selected point.parameter_overrides (dict, optional) – Deprecated — use
paramsinstead.cloud_wc_var (str, optional)
cloud_ic_var (str, optional)
cloud_reff_var (str, optional)
cloud_ic_reff_var (str, optional)
cloud_top_var (str, optional)
cloud_bottom_var (str, optional)
- Returns:
Column-formatted cloud profile, or an explanatory message when no cloud can be constructed.
- Return type:
str
- jacobian(param: str, delta: float, params: Dict[str, Any] | None = None, config_path: str | Path | None = None, config: SimulationConfig | None = None, **run_kwargs) Dataset[source]#
Finite-difference sensitivity kernel for one scalar parameter.
Runs the batch twice (base and
param + delta) and returns(perturbed - base) / deltawith the same dimensions.- Parameters:
param (str) – Registry parameter to perturb (must resolve to a scalar: a
paramsliteral or a config default — not aVar).delta (float) – Perturbation size in the parameter’s units.
params (dict, optional) – Base parameter mapping (same as
run()).config_path – Configuration source, same as
run().config – Configuration source, same as
run().**run_kwargs – Forwarded to
run()(e.g.show_progress=False).
- Returns:
Kernel dataset; attrs
jacobian_param,jacobian_delta.- Return type:
xarray.Dataset
- Raises:
ValidationError – If param is a
Varreference or no base value exists.
- run(config_path: str | Path | None = None, config: SimulationConfig | None = None, params: Dict[str, Any] | None = None, parameter_overrides: Dict[str, Any] | None = None, time_var: str = 'time', lat_var: str = 'latitude', lon_var: str = 'longitude', albedo_var: str | None = None, surface_temperature_var: str | None = None, surface_type_var: str | None = None, era5_atmosphere: Dataset | None = None, era5_clouds: bool | Dict[str, Any] = False, return_dataset: bool = True, save_to_file: bool = True, output_path: str | Path | None = None, progress_callback: callable | None = None, cloud_wc_var: str | None = None, cloud_ic_var: str | None = None, cloud_reff_var: str | None = None, cloud_ic_reff_var: str | None = None, cloud_top_var: str | None = None, cloud_bottom_var: str | None = None, show_progress: bool = True, channels: DataArray | None = None, keep_spectral: bool = False) Dataset | Path[source]#
Run
uvspecfor every point in the dataset.- Parameters:
config_path (str or pathlib.Path, optional) – YAML configuration file.
config (SimulationConfig, optional) – Pre-built config (overrides config_path).
params (dict, optional) – Unified parameter mapping: registry keys / raw uvspec keywords / dotted config paths to literal values or
Varper-point dataset references. Preferred over the deprecated*_varandparameter_overrideskwargs below.parameter_overrides (dict, optional) – Deprecated — use
paramsinstead.time_var (str) – Coordinate variable names.
lat_var (str) – Coordinate variable names.
lon_var (str) – Coordinate variable names.
albedo_var (str, optional) – Deprecated — use
params={"albedo": Var(...)}.surface_temperature_var (str, optional) – Deprecated — use
params={"sur_temperature": Var(...)}.surface_type_var (str, optional) – Deprecated — use
params={"brdf_rpv_type": Var(...)}.era5_atmosphere (xarray.Dataset, optional) – ERA5 dataset for custom atmosphere profiles. Raw CDS or ARCO-ERA5 naming is accepted and normalised automatically; an
o3field adds an ozone profile to the radiosonde file (and disables the configozone_duscaling).era5_clouds (bool or dict, default
False) – Also derive per-point cloud profiles (wc_file/ic_file) from the ERA5clwc/ciwcfields. A dict is forwarded topyradtran.era5.cloud_profiles()(e.g.{"reff_water_um": 8.0}). Explicit cloud settings viaparamsorcloud_*_varwin over ERA5 clouds.return_dataset (bool, default
True) – Return results as an xarray Dataset.save_to_file (bool, default
True) – Write results to NetCDF.output_path (str or pathlib.Path, optional) – Destination file (auto-generated when None).
progress_callback (callable, optional) –
callback(current, total).show_progress (bool, default
True) – Show atqdmprogress bar. PassFalseto suppress it (useful when the output will be rendered as HTML).cloud_wc_var (str, optional) – LWC / IWC dataset variables.
cloud_ic_var (str, optional) – LWC / IWC dataset variables.
cloud_reff_var (str, optional) – Effective-radius variables.
cloud_ic_reff_var (str, optional) – Effective-radius variables.
cloud_top_var (str, optional) – Cloud geometry variables (km).
cloud_bottom_var (str, optional) – Cloud geometry variables (km).
channels (xarray.DataArray, optional) – Instrument spectral response functions, dims
(channel, wavelength). When given and the result is spectral, every spectral variable is SRF-averaged onto achanneldimension viaconvolve_channels(); the returned (and saved) dataset is channel-space.keep_spectral (bool, default
False) – With channels, also keep the original spectral variables under<name>_spectral.
- Returns:
Results dataset when return_dataset is True, otherwise the output file path.
- Return type:
xarray.Dataset or pathlib.Path
- Raises:
PyRadtranError – If no valid results are produced.
- run_uvspec(config_path: str | Path | None = None, config: SimulationConfig | None = None, params: Dict[str, Any] | None = None, parameter_overrides: Dict[str, Any] | None = None, time_var: str = 'time', lat_var: str = 'latitude', lon_var: str = 'longitude', albedo_var: str | None = None, surface_temperature_var: str | None = None, surface_type_var: str | None = None, era5_atmosphere: Dataset | None = None, era5_clouds: bool | Dict[str, Any] = False, return_dataset: bool = True, save_to_file: bool = True, output_path: str | Path | None = None, progress_callback: callable | None = None, cloud_wc_var: str | None = None, cloud_ic_var: str | None = None, cloud_reff_var: str | None = None, cloud_ic_reff_var: str | None = None, cloud_top_var: str | None = None, cloud_bottom_var: str | None = None, show_progress: bool = True, channels: DataArray | None = None, keep_spectral: bool = False) Dataset | Path#
Alias for
run()— kept for backwards compatibility with older notebooks that callds.pyradtran.run_uvspec(...).