{"id":13698662,"url":"https://github.com/materialsproject/pyrho","last_synced_at":"2025-09-21T07:05:28.345Z","repository":{"id":37939613,"uuid":"266894456","full_name":"materialsproject/pyrho","owner":"materialsproject","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-01T00:23:24.000Z","size":50070,"stargazers_count":40,"open_issues_count":5,"forks_count":9,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-09-04T23:52:51.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://materialsproject.github.io/pyrho/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/materialsproject.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-25T22:44:02.000Z","updated_at":"2025-03-16T10:58:04.000Z","dependencies_parsed_at":"2023-12-28T02:07:09.187Z","dependency_job_id":"5cffc6cf-1f03-4d1b-ab9e-c217255ea391","html_url":"https://github.com/materialsproject/pyrho","commit_stats":{"total_commits":244,"total_committers":9,"mean_commits":27.11111111111111,"dds":"0.21311475409836067","last_synced_commit":"43351ff2b53d3c9c5346bd1dd33c4cc527fe54b8"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/materialsproject/pyrho","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materialsproject%2Fpyrho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materialsproject%2Fpyrho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materialsproject%2Fpyrho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materialsproject%2Fpyrho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/materialsproject","download_url":"https://codeload.github.com/materialsproject/pyrho/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materialsproject%2Fpyrho/sbom","scorecard":{"id":623783,"data":{"date":"2025-08-11","repo":{"name":"github.com/materialsproject/pyrho","commit":"43351ff2b53d3c9c5346bd1dd33c4cc527fe54b8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/python-publish.yml:16","Warn: no topLevel permission defined: .github/workflows/testing.yml:1","Warn: no topLevel permission defined: .github/workflows/update-precommit.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/python-publish.yml:19"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/python-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/python-publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-publish.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/python-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:75: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/testing.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testing.yml:44: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/testing.yml:60: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/testing.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-precommit.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/update-precommit.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-precommit.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/update-precommit.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-precommit.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/materialsproject/pyrho/update-precommit.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:32","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:53","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:54","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:81","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:82","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:24","Warn: pipCommand not pinned by hash: .github/workflows/testing.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/update-precommit.yml:21","Info:   0 out of  11 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned","Info:   0 out of   9 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T05:51:06.501Z","repository_id":37939613,"created_at":"2025-08-21T05:51:06.501Z","updated_at":"2025-08-21T05:51:06.501Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274176660,"owners_count":25235757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T19:00:51.634Z","updated_at":"2025-09-21T07:05:28.285Z","avatar_url":"https://github.com/materialsproject.png","language":"Python","funding_links":[],"categories":["Data Structures"],"sub_categories":[],"readme":"# mp-pyrho\n📄 [Full Documentation](https://materialsproject.github.io/pyrho)\n\n# Installation\n\n```\npip install mp-pyrho\n```\n\nTools for re-griding volumetric quantum chemistry data for machine-learning purposes.\n\n[![.github/workflows/testing.yml](https://github.com/materialsproject/pyrho/actions/workflows/testing.yml/badge.svg)](https://github.com/materialsproject/pyrho/actions/workflows/testing.yml)\n[![codecov](https://codecov.io/gh/materialsproject/pyrho/branch/main/graph/badge.svg?token=YoFMXzpeKI)](https://codecov.io/gh/materialsproject/pyrho)\n[![DOI](https://zenodo.org/badge/266894456.svg)](https://zenodo.org/badge/latestdoi/266894456)\n\n\nIf you use this package in your research, please cite the following:\n\n```\nShen, J.-X., Munro, J. M., Horton, M. K., Huck, P., Dwaraknath, S., \u0026 Persson, K. A. (2022). \nA representation-independent electronic charge density database for crystalline materials. \nSci Data, 9(661), 1–7. doi: 10.1038/s41597-022-01746-z\n```\n\n# Regridding data using PyRho\n\n\n\n## The PGrid Class\n\nThe `PGrid` object is defined by an N-dimensional numpy array `grid_data` and a N lattice vector given as a matrix `lattice`. The input array is a scalar field that is defined on a regularly spaced set of grid points starting at the origin. For example, you can construct a periodic field as follows:\n\n\n```python\nimport numpy as np\nfrom pyrho.pgrid import PGrid\nfrom pyrho.vis.scatter import get_scatter_plot\n\n\ndef func(X, Y):\n    return np.sin(X) * np.cos(2 * Y)\n\n\na = np.linspace(0, np.pi, 27, endpoint=False)\nb = np.linspace(0, np.pi, 28, endpoint=False)\nX, Y = np.meshgrid(a, b, indexing=\"ij\")\ndata = func(X, Y)\npg2d = PGrid(grid_data=data, lattice=[[np.pi, 0], [0, np.pi]])\n```\n\nThe data can be examined using the helper plotting function which supports up to 3-D.\n\n\n```python\nimport matplotlib as mpl\n\nmpl.rc(\"image\", cmap=\"viridis\")\nget_scatter_plot(pg2d.grid_data, pg2d.lattice, marker_size=40)\n```\n\n![](https://github.com/materialsproject/pyrho/blob/main/docs/source/_static/img/output_3_0.png?raw=true)\n\n\n\nThe period data in the PGrid object must be fixed-scaled so if you half the number of points in the domain, the range of the data will stay the same. This is different from how the charge density is stored in codes like VASP where the values at each point change based on the number of grid points used to store the data.\n\nThe regridding capabilities allow the user to obtain the data in any arbitrary representation. For example, if we want to shift to the middle of the unit-cell and create a ((1,1), (1,-1)) super-cell, with a 30 by 32 grid, we can run:\n\n\n```python\npg_2x = pg2d.get_transformed([[1, 1], [1, -1]], origin=[0.5, 0.5], grid_out=[30, 32])\nget_scatter_plot(pg_2x.grid_data, pg_2x.lattice, skips=1, opacity=1, marker_size=10)\n```\n\n\n\n![png](https://github.com/materialsproject/pyrho/blob/main/docs/source/_static/img/output_5_0.png?raw=true)\n\n\n\n# Up-sampling with Fourier interpolation\n\nThe up-sampling capabilities allow the user to exploit the periodicity of the data to obtain a higher-resolution grid.\nAs an example, we can take a sparsely sampled periodic data in 1-D:\n\n\n```python\ndef func1(X):\n    return np.sin(6 * X)\n\n\na = np.linspace(0, np.pi, 10, endpoint=False)\ndata = func1(a)\n\npg1d = PGrid(grid_data=data, lattice=[[np.pi]])\nget_scatter_plot(pg1d.grid_data, pg1d.lattice, marker_size=50)\n```\n\n\n\n![png](https://github.com/materialsproject/pyrho/blob/main/docs/source/_static/img/output_7_0.png?raw=true)\n\n\n\nThis does not really resemble the `np.sin(6*X)` function we used to generate the data.\nHowever, if we use an up-sample factor of 8, we can obtain a more dense representation:\n\n\n```python\npg1d_fine = pg1d.get_transformed(\n    sc_mat=[[2]],\n    grid_out=[\n        200,\n    ],\n    up_sample=8,\n)\nget_scatter_plot(pg1d_fine.grid_data, pg1d_fine.lattice, marker_size=10)\n```\n\n\n\n![png](https://github.com/materialsproject/pyrho/blob/main/docs/source/_static/img/output_9_0.png?raw=true)\n\n\n\n## The ChargeDensity class\n\nThe `ChargeDensity` object can use the `from_file` construction method from `pymatgen.io.vasp.outputs.Chgcar` as shown below.\n\n\n```python\nfrom pymatgen.io.vasp import Chgcar\nfrom pyrho.charge_density import ChargeDensity\n\ncden_uc = ChargeDensity.from_file(\n    \"../test_files/CHGCAR.uc.vasp\"\n)\ncden_sc = ChargeDensity.from_file(\n    \"../test_files/CHGCAR.sc1.vasp\"\n)\nchgcar_sc = Chgcar.from_file(\n    \"../test_files/CHGCAR.sc1.vasp\"\n)\ncden_transformed = cden_uc.get_transformed(\n    [[1, 1, 0], [1, -1, 0], [0, 0, 1]],\n    grid_out=cden_sc.grid_shape,\n    up_sample=2,\n)\n\n\n```\n\nThe `normalized_data` property contains a dictionary keyed with the same keys as `Chgcar.data` (typically \"total\" and \"diff\" for spin charge densities).\nThis quantity is the fixed scalar field that should remain fixed after the transformation.\n\n\n```python\ndata = cden_uc.normalized_data[\"total\"]\nprint(\n    f\"The normalized charge density data is has a range of {data.min():0.3f} --\u003e {data.max():0.3f} e-/Ang^3\"\n)\n\n```\n\n    The normalized charge density data is has a range of -0.188 --\u003e 0.572 e-/Ang^3\n\n\nNote that the PAW transformation sometimes results in negative charge densities.\n\n\n```python\ntrans_data = cden_transformed.normalized_data[\"total\"]\nprint(\n    f\"The transformed normalized charge density data is has a range of {trans_data.min():0.3f} --\u003e {trans_data.max():0.3f} e-/Ang^3\"\n)\n\n```\n\n    The transformed normalized charge density data is has a range of -0.188 --\u003e 0.572 e-/Ang^3\n\n\n\n```python\nsc_data = cden_sc.normalized_data[\"total\"]\nprint(\n    f\"The reference normalized charge density data is has a range of {sc_data.min():0.3f} --\u003e {sc_data.max():0.3f} e-/Ang^3\"\n)\n\n```\n\n    The reference normalized charge density data is has a range of -0.188 --\u003e 0.570 e-/Ang^3\n\n\n## Credits\n\nJimmy-Xuan Shen: Project lead\n\nWennie Wang: For naming the package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterialsproject%2Fpyrho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaterialsproject%2Fpyrho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterialsproject%2Fpyrho/lists"}