{"library":"mp-pyrho","title":"mp-pyrho: Quantum Chemistry Data Regridding","description":"mp-pyrho is a Python library providing tools for re-gridding periodic volumetric quantum chemistry data (e.g., charge densities, COHP, ELFCAR) into a consistent, resolution-agnostic representation suitable for machine learning applications. It is currently at version 0.5.1 and is actively maintained with a regular release cadence.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install mp-pyrho"],"cli":null},"imports":["from mp_pyrho.grid import RhoGrid"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from pymatgen.core import Structure\nfrom mp_pyrho.grid import RhoGrid\nimport numpy as np\n\n# Create a dummy structure (e.g., a simple cubic perovskite)\nstructure = Structure.from_spacegroup(\"Pm-3m\", [3.8], [\"Fe\", \"O\"], [[0, 0, 0], [0.5, 0.5, 0.5]])\n\n# Create dummy 3D volumetric data (e.g., 20x20x20 points)\n# In a real scenario, this would be loaded from a CHGCAR, LOCPOT, or similar file\ndummy_grid_data = np.random.rand(20, 20, 20)\n\n# Initialize RhoGrid object with the structure and volumetric data\nrho_grid = RhoGrid(structure=structure, grid_data=dummy_grid_data)\n\n# Regrid the data to a new target resolution (e.g., 0.1 Å)\n# The output is a 3D NumPy array\nregridded_data = rho_grid.regrid(target_resolution=0.1)\nprint(f\"Original grid shape: {rho_grid.grid_data.shape}\")\nprint(f\"Shape of regridded data: {regridded_data.shape}\")\n\n# Featurize the regridded data\n# For mp-pyrho >= 0.5.0, `vectorize_grid` defaults to True and `center_method` to 'mass'\nfeatures_vectorized = rho_grid.featurize(target_resolution=0.1)\nprint(f\"Shape of features (vectorized): {features_vectorized.shape}\")\n\n# If you need the 3D grid output from featurize, set vectorize_grid=False\nfeatures_3d_grid = rho_grid.featurize(target_resolution=0.1, vectorize_grid=False)\nprint(f\"Shape of features (3D grid): {features_3d_grid.shape}\")","lang":"python","description":"This quickstart demonstrates how to initialize a `RhoGrid` object with a `pymatgen.core.Structure` and dummy 3D volumetric data. It then shows how to use the `regrid` method to standardize the resolution and the `featurize` method to generate a machine-learning-ready representation, either as a 1D vector or a 3D grid.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}