atmos_flux_inversion.wrapper module¶
Wrap the details of an inversion.
Hide most of the implementation details. Take prior and parameters, return posterior.
The interface is still experimental at this point. I am likely to remove functions and parameters as I find better ways to organize things. The code still works fine as an example.
-
atmos_flux_inversion.wrapper.
get_installed_modules
()[source]¶ Get the list of installed modules.
- Returns
List of currently installed packages, using conda if that is available or pip if it is not. List of two-element strings giving name-version pairs.
- Return type
list of list of str
-
atmos_flux_inversion.wrapper.
global_attributes_dict
()[source]¶ Set global attributes required by conventions.
Currently CF-1.6 and ACDD-1.3.
Still needs title, summary, source, creator_institution, product_version, references, cdm_data_type, institution, geospatial_vertical_{min,max,positive,units}, …
Users may want to overwrite the history and creator_name attributes, as these are fancy guesses.
- Returns
global_atts – attribute_name: attribute_value mapping.
- Return type
-
atmos_flux_inversion.wrapper.
invert_uniform
(prior_fluxes, observations, observation_operator, prior_correlation_length, prior_correlation_structure, prior_correlation_time_days, prior_correlation_time_hours, prior_flux_stds, observation_correlation_time, method=<function fold_common>, output_uncertainty_frequency='MS')[source]¶ Perform an inversion.
Assumes error correlations are invariant in time and space and that the error variances are constant in time. Also assumes the observation correlations between towers is zero.
- Parameters
prior_fluxes (xarray.Dataarray[flux_time, y, x]) – The prior or background estimate of the fluxes
observations (xarray.Dataarray[obs_time, site]) – The observed mole fractions
observation_operator (xarray.Dataarray[obs_time, site, flux_time, y, x]) – The linearized operator mapping a flux distribution to observations.
prior_correlation_length (float) – The lengthscale for the spatial correlations in the prior.
prior_correlation_structure (inv_corr.DistanceCorrelationFunction) – The structure of the spatial correlations in the prior.
prior_correlation_time_days (float) – The correlation timescale for fluxes across different days.
prior_correlation_time_hours (float) – The correlation timescale for fluxes within the same day.
prior_flux_stds (xarray.Dataarray[y, x]) – The standard deviations of the prior flux distribution at each point in space.
observation_correlation_time (float) – The correlation timescale for consecutive observations at a single site.
method (function) – The method to use. Must match the signature of
atmos_flux_inversion.optimal_interpolation.simple()
output_uncertainty_frequency (str) – One of the frequencies from http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases or “season”. Often “M”, output_uncertainty_frequency, “Y”, “YS”, or “season” make the most sense. Used to provide lower-temporal-resolution posterior uncertainties.
- Returns
The results of the inversion. Contents:
- prior[flux_time, y, x]
The prior mean for the inversion.
- increment[flux_time, y, x]
The change from the prior to the posterior mean estimates.
- posterior[flux_time, y, x]
The posterior mean for the inversion.
- post_cov[red_flux_time_adj, y_adj, x_adj, red_flux_time, y, x]
The analytic uncertainty for the posterior, expressed as a covariance matrix on a reduced-resolution domain. If the prior and observation likelihood are Gaussian, this will be exact.
- Return type