Package: xeofs
VersionsBuild & TestingCode QualityDocumentationCitation & LicensingUser EngagementOverviewxeofsis a dedicated Python package for dimensionality reduction in the realm of climate science, offering methods like PCA, known as EOF analysis within the field, and related variants. Seamlessly integrated withxarrayandDask, it's tailored for easy handling and scalable computation on large, multi-dimensional datasets, making advanced climate data analysis both accessible and efficient.Multi-Dimensional: Designed forxarrayobjects, it applies dimensionality reduction to multi-dimensional data while maintaining data labels.Dask-Integrated: Supports large datasets viaDaskxarray objectsExtensive Methods: Offers various dimensionality reduction techniquesAdaptable Output: Provides output corresponding to the type of input, whether single or list ofxr.DataArrayorxr.DatasetMissing Values: HandlesNaNvalues within the dataBootstrapping: Comes with a user-friendly interface for model evaluation using bootstrappingEfficient: Ensures computational efficiency, particularly with large datasets through randomized SVDModular: Allows users to implement and incorporate new dimensionality reduction methodsInstallationTo install the package, use either of the following commands:condainstall-cconda-forgexeofsorpipinstallxeofsQuickstartIn order to get started withxeofs, follow these simple steps:Import the package>>>importxarrayasxr# for example data only>>>importxeofsasxeLoad example data>>>t2m=xr.tutorial.open_dataset("air_temperature")>>>t2m_west=t2m.isel(lon=slice(None,20))>>>t2m_east=t2m.isel(lon=slice(21,None))EOF analysisInitiate and fit the EOF/PCA model to the data>>>eof=xe.models.EOF(n_modes=10)>>>eof.fit(t2m,dim="time")# doctest: +ELLIPSIS<xeofs.models.eof.EOFobjectat...>Now, you can access the model's EOF components and PC scores:>>>comps=eof.components()# EOFs (spatial patterns)>>>scores=eof.scores()# PCs (temporal patterns)Varimax-rotated EOF analysisInitiate and fit anEOFRotatorclass to the model to obtain a varimax-rotated EOF analysis>>>rotator=xe.models.EOFRotator(n_modes=3)>>>rotator.fit(eof)# doctest: +ELLIPSIS<xeofs.models.eof_rotator.EOFRotatorobjectat...>>>>rot_comps=rotator.components()# Rotated EOFs (spatial patterns)>>>rot_scores=rotator.scores()# Rotated PCs (temporal patterns)Maximum Covariance Analysis (MCA)>>>mca=xe.models.MCA(n_modes=10)>>>mca.fit(t2m_west,t2m_east,dim="time")# doctest: +ELLIPSIS<xeofs.models.mca.MCAobjectat...>>>>comps1,comps2=mca.components()# Singular vectors (spatial patterns)>>>scores1,scores2=mca.scores()# Expansion coefficients (temporal patterns)Varimax-rotated MCA>>>rotator=xe.models.MCARotator(n_modes=10)>>>rotator.fit(mca)# doctest: +ELLIPSIS<xeofs.models.mca_rotator.MCARotatorobjectat...>>>>rot_comps=rotator.components()# Rotated singular vectors (spatial patterns)>>>rot_scores=rotator.scores()# Rotated expansion coefficients (temporal patterns)To further explore the capabilities ofxeofs, check out theavailable documentationandexamples.
For a full list of currently available methods, see theReference API.DocumentationFor a more comprehensive overview and usage examples, visit thedocumentation.ContributingContributions are highly welcomed and appreciated. If you're interested in improvingxeofsor fixing issues, please read ourContributing Guide.LicenseThis project is licensed under the terms of theMIT license.ContactFor questions or support, please open aGithub issue.CreditsRandomized PCA:scikit-learnEOF analysis: Python packageeofsby Andrew DawsonMCA: Python packagexMCAby YefeeCCA: Python packageCCA-Zooby James ChapmanROCK-PCA: Matlab implementation byDiego BuesoHow to cite?When usingxeofs, kindly remember to cite the original references of the methods employed in your work. Additionally, ifxeofsis proving useful in your research, we'd appreciate if you could acknowledge its use with the following citation:@article{rieger_xeofs_2024,author={Rieger, Niclas and Levang, Samuel J.},doi={10.21105/joss.06060},journal={Journal of Open Source Software},month=jan,number={93},pages={6060},title={{xeofs: Comprehensive EOF analysis in Python with xarray}},url={https://joss.theoj.org/papers/10.21105/joss.06060},volume={9},year={2024}}Contributors