{"id":113524,"name":"Sacpy","description":"An effecient Statistical Analysis tool (e.g. regression, EOF, MCA) for Climate and Meteorology data.","url":"https://github.com/zilum/sacpy","last_synced_at":"2026-05-12T07:30:32.926Z","repository":{"id":48192515,"uuid":"516767282","full_name":"ZiluM/sacpy","owner":"ZiluM","description":"A Python Package for Statistical Analysis of Climate","archived":false,"fork":false,"pushed_at":"2026-02-02T22:45:01.000Z","size":105966,"stargazers_count":64,"open_issues_count":3,"forks_count":16,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-15T12:53:37.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZiluM.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-22T13:48:34.000Z","updated_at":"2026-02-02T22:45:05.000Z","dependencies_parsed_at":"2023-10-15T03:16:26.788Z","dependency_job_id":"b9edfdc6-e13d-4688-9c1b-da7da96a5baf","html_url":"https://github.com/ZiluM/sacpy","commit_stats":{"total_commits":48,"total_committers":3,"mean_commits":16.0,"dds":"0.14583333333333337","last_synced_commit":"8230ad68cc380fe4c496f41d6fe04247fce09c86"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ZiluM/sacpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM","download_url":"https://codeload.github.com/ZiluM/sacpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30691529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-19T04:38:48.377Z","status":"ssl_error","status_checked_at":"2026-03-19T04:38:19.675Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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"}},"owner":{"login":"ZiluM","name":"ZiluMeng","uuid":"59824654","kind":"user","description":"Major in Meteorology.","email":"","website":null,"location":"Nanjing","twitter":null,"company":"NUIST","icon_url":"https://avatars.githubusercontent.com/u/59824654?v=4","repositories_count":5,"last_synced_at":"2023-07-23T10:21:59.037Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/ZiluM","funding_links":[],"total_stars":null,"followers":null,"following":null,"created_at":"2023-07-23T10:21:59.109Z","updated_at":"2023-07-23T10:21:59.109Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM/repositories"},"packages":[{"id":4610890,"name":"sacpy","ecosystem":"pypi","description":"A repaid Statistical Analysis tool for Climate or Meteorology data.","homepage":"https://github.com/ZiluM/sacpy","licenses":"MIT","normalized_licenses":["MIT"],"repository_url":"https://github.com/ZiluM/sacpy","keywords_array":["meteorology","data","statistic","climate"],"namespace":null,"versions_count":17,"first_release_published_at":"2022-07-22T13:53:55.000Z","latest_release_published_at":"2024-02-23T03:28:23.000Z","latest_release_number":"0.0.24","last_synced_at":"2026-03-13T02:01:35.050Z","created_at":"2022-07-22T14:01:56.724Z","updated_at":"2026-03-13T02:01:35.050Z","registry_url":"https://pypi.org/project/sacpy/","install_command":"pip install sacpy --index-url https://pypi.org/simple","documentation_url":"https://sacpy.readthedocs.io/","metadata":{"funding":null,"documentation":null,"classifiers":[],"normalized_name":"sacpy","project_status":null},"repo_metadata":{"id":48192515,"uuid":"516767282","full_name":"ZiluM/sacpy","owner":"ZiluM","description":"A Python Package for Statistical Analysis of Climate","archived":false,"fork":false,"pushed_at":"2024-08-05T19:48:22.000Z","size":105955,"stargazers_count":56,"open_issues_count":3,"forks_count":14,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T20:33:40.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZiluM.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-22T13:48:34.000Z","updated_at":"2024-10-05T02:14:31.000Z","dependencies_parsed_at":"2023-10-15T03:16:26.788Z","dependency_job_id":"b9edfdc6-e13d-4688-9c1b-da7da96a5baf","html_url":"https://github.com/ZiluM/sacpy","commit_stats":{"total_commits":48,"total_committers":3,"mean_commits":16.0,"dds":"0.14583333333333337","last_synced_commit":"8230ad68cc380fe4c496f41d6fe04247fce09c86"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM","download_url":"https://codeload.github.com/ZiluM/sacpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222130465,"owners_count":16936299,"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","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"},"owner_record":{"login":"ZiluM","name":"ZiluMeng","uuid":"59824654","kind":"user","description":"Major in Meteorology.","email":"","website":null,"location":"Nanjing","twitter":null,"company":"NUIST","icon_url":"https://avatars.githubusercontent.com/u/59824654?v=4","repositories_count":5,"last_synced_at":"2023-07-23T10:21:59.037Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/ZiluM","funding_links":[],"total_stars":null,"followers":null,"following":null,"created_at":"2023-07-23T10:21:59.109Z","updated_at":"2023-07-23T10:21:59.109Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZiluM/repositories"},"tags":[{"name":"sappy_0.20.0","sha":"8230ad68cc380fe4c496f41d6fe04247fce09c86","kind":"commit","published_at":"2024-03-22T05:52:22.000Z","download_url":"https://codeload.github.com/ZiluM/sacpy/tar.gz/sappy_0.20.0","html_url":"https://github.com/ZiluM/sacpy/releases/tag/sappy_0.20.0","dependencies_parsed_at":null,"dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sappy_0.20.0","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sappy_0.20.0/manifests"},{"name":"sacpy_0.0.13","sha":"7c9117a2ccb9266c3f16cc5258da0462fcabdfce","kind":"commit","published_at":"2022-08-01T14:06:01.000Z","download_url":"https://codeload.github.com/ZiluM/sacpy/tar.gz/sacpy_0.0.13","html_url":"https://github.com/ZiluM/sacpy/releases/tag/sacpy_0.0.13","dependencies_parsed_at":null,"dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sacpy_0.0.13","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sacpy_0.0.13/manifests"},{"name":"sacpy_0.0.9","sha":"df18573b6b8732041194de369f04b62237414854","kind":"commit","published_at":"2022-07-24T13:36:31.000Z","download_url":"https://codeload.github.com/ZiluM/sacpy/tar.gz/sacpy_0.0.9","html_url":"https://github.com/ZiluM/sacpy/releases/tag/sacpy_0.0.9","dependencies_parsed_at":null,"dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sacpy_0.0.9","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/tags/sacpy_0.0.9/manifests"}]},"repo_metadata_updated_at":"2024-10-29T23:10:07.577Z","dependent_packages_count":0,"downloads":764,"downloads_period":"last-month","dependent_repos_count":0,"rankings":{"downloads":9.554468699189647,"dependent_repos_count":30.61104109666564,"dependent_packages_count":6.633233862033089,"stargazers_count":13.896597733273259,"forks_count":13.56444630182248,"average":14.851957538596825},"purl":"pkg:pypi/sacpy","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/pypi/sacpy","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/pypi/sacpy","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/pypi/sacpy/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":{"last_synced_at":"2024-10-29T19:31:37.094Z","issues_count":5,"pull_requests_count":4,"avg_time_to_close_issue":105372.0,"avg_time_to_close_pull_request":599318.75,"issues_closed_count":2,"pull_requests_closed_count":4,"pull_request_authors_count":1,"issue_authors_count":4,"avg_comments_per_issue":2.0,"avg_comments_per_pull_request":0.0,"merged_pull_requests_count":4,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":1,"past_year_pull_requests_count":4,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":599318.75,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":4,"past_year_pull_request_authors_count":1,"past_year_issue_authors_count":1,"past_year_avg_comments_per_issue":0.0,"past_year_avg_comments_per_pull_request":0.0,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":4,"issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/issues","maintainers":[],"active_maintainers":[]},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/sacpy/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/sacpy/version_numbers","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/sacpy/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/sacpy/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages/sacpy/codemeta","maintainers":[{"uuid":"Vector_M","login":"Vector_M","name":null,"email":null,"url":null,"packages_count":2,"html_url":"https://pypi.org/user/Vector_M/","role":null,"created_at":"2023-02-26T00:30:05.752Z","updated_at":"2023-02-26T00:30:05.752Z","packages_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/maintainers/Vector_M/packages"}],"registry":{"name":"pypi.org","url":"https://pypi.org","ecosystem":"pypi","default":true,"packages_count":814978,"maintainers_count":346923,"namespaces_count":0,"keywords_count":0,"github":"pypi","metadata":{"funded_packages_count":52831},"icon_url":"https://github.com/pypi.png","created_at":"2022-04-04T15:19:23.364Z","updated_at":"2026-03-14T07:29:55.205Z","packages_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/packages","maintainers_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/maintainers","namespaces_url":"https://packages.ecosyste.ms/api/v1/registries/pypi.org/namespaces"}}],"commits":{"id":684591,"full_name":"ZiluM/sacpy","default_branch":"main","total_commits":50,"total_committers":3,"total_bot_commits":0,"total_bot_committers":0,"mean_commits":16.666666666666668,"dds":0.14,"past_year_total_commits":2,"past_year_total_committers":1,"past_year_total_bot_commits":0,"past_year_total_bot_committers":0,"past_year_mean_commits":2.0,"past_year_dds":0.0,"last_synced_at":"2026-03-13T02:01:37.637Z","last_synced_commit":"12ad836dab8a8413dacc412327a76396f1011820","created_at":"2023-03-09T11:04:48.752Z","updated_at":"2026-03-13T02:01:24.101Z","committers":[{"name":"ZiluM","email":"mzll1202@163.com","login":"ZiluM","count":43},{"name":"HaoyuZhuang","email":"zhuanghaoyurichard@gmail.com","login":"Z-Richard","count":4},{"name":"孟子路","email":"zilumeng@mengziludeMacBook-Pro.local","login":null,"count":3}],"past_year_committers":[{"name":"Zilu Meng","email":"59824654+ZiluM","login":"ZiluM","count":2}],"commits_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/commits","host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-03-15T00:00:35.572Z","repositories_count":6204408,"commits_count":934652001,"contributors_count":36190185,"owners_count":1149752,"icon_url":"https://github.com/github.png","host_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories"}},"issues_stats":{"full_name":"ZiluM/sacpy","html_url":"https://github.com/ZiluM/sacpy","last_synced_at":"2026-03-02T21:03:08.902Z","status":"error","issues_count":5,"pull_requests_count":3,"avg_time_to_close_issue":105372.0,"avg_time_to_close_pull_request":795680.0,"issues_closed_count":2,"pull_requests_closed_count":3,"pull_request_authors_count":1,"issue_authors_count":4,"avg_comments_per_issue":2.0,"avg_comments_per_pull_request":0.0,"merged_pull_requests_count":3,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":0,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0,"created_at":"2023-05-15T04:17:36.244Z","updated_at":"2026-03-02T21:03:08.902Z","repository_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy","issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZiluM%2Fsacpy/issues","issue_labels_count":{},"pull_request_labels_count":{},"issue_author_associations_count":{"NONE":5},"pull_request_author_associations_count":{"CONTRIBUTOR":5,"NONE":1},"issue_authors":{"gkb999":2,"plyu3":1,"jesieleo":1,"Pan-Yuxian":1},"pull_request_authors":{"Z-Richard":6},"host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-03-15T00:00:34.780Z","repositories_count":13732348,"issues_count":34681363,"pull_requests_count":113159181,"authors_count":11203031,"icon_url":"https://github.com/github.png","host_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories","owners_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/owners","authors_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors"},"past_year_issue_labels_count":{},"past_year_pull_request_labels_count":{},"past_year_issue_author_associations_count":{},"past_year_pull_request_author_associations_count":{},"past_year_issue_authors":{},"past_year_pull_request_authors":{},"maintainers":[],"active_maintainers":[]},"events":{"total":{"ForkEvent":1,"WatchEvent":6,"PushEvent":1},"last_year":{"WatchEvent":1,"PushEvent":1}},"keywords":[],"dependencies":[{"ecosystem":"pypi","filepath":"setup.py","sha":null,"kind":"manifest","created_at":"2023-10-15T03:16:26.426Z","updated_at":"2023-10-15T03:16:26.426Z","repository_link":"https://github.com/ZiluM/sacpy/blob/main/setup.py","dependencies":[{"id":14209800285,"package_name":"numpy","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false}]}],"score":11.94318074188561,"created_at":"2023-10-10T00:05:13.047Z","updated_at":"2026-05-12T07:30:32.937Z","avatar_url":"https://github.com/ZiluM.png","language":"Python","category":"Climate Change","sub_category":"Climate Data Processing and Analysis","monthly_downloads":764,"total_dependent_repos":0,"total_dependent_packages":0,"readme":"# SACPY -- A Python Package for Statistical Analysis of Climate\n\n**Sacpy**, an effecient Statistical Analysis tool for Climate and Meteorology data.\n\nAuthor : Zilu Meng \n\ne-mail : zilumeng@uw.edu\n\ngithub : https://github.com/ZiluM/sacpy\n\npypi : https://pypi.org/project/sacpy/\n\nDocument: https://zilum.github.io/sacpy/\n\nversion : 0.0.20\n\n## Cite our work ##\n\n```\n@inproceedings{meng2023sacpy,\n  title={Sacpy-A Python Package for Statistical Analysis of Climate},\n  author={Meng, Zilu and Zhu, Feng and Hakim, Gregory J},\n  booktitle={Agu fall meeting abstracts},\n  volume={2023},\n  number={1252},\n  pages={PP13D--1252},\n  year={2023}\n}\n\n```\n\n## Why choose Sacpy?\n\n### Fast!\n\nFor example, Sacpy is more than 60 times faster than the traditional regression analysis with Python (see **speed test**). The following is the time spent performing the same task. Sacpy is fastest.\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/speed_test_00.png)\n\n### Turn to climate data customization!\n\nCompatible with commonly used meteorological calculation libraries such as numpy and xarray.\n\n### Concise code\n\nYou can finish drawing a following figure with just seven lines of code. see **examples of concise**.\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/one_test.png)\n\nYou can use SVD/MCA to get the image below easily.\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/SVD.png)\n\n## Install and update\n\nYou can use pip to install.\n\n    pip install sacpy\n\nOr you can visit https://gitee.com/zilum/sacpy/tree/main/dist to download **.whl file**, then\n\n    pip install .whl_file\n\nupdate:\n\n    pip install --upgrade sacpy\n\nor you can download **.whl** file and then install use ` pip install .whl_file`.\n\n## Speed\n\nAs a comparison, we use the  **corr**  function in the xarray library, **corrcoef** function in numpy library, cdist in scipy, apply_func in xarray  and **for-loop**. The time required to calculate the correlation coefficient between SSTA and nino3.4 for 50 times is shown in the figure below.\n\nIt can be seen that we are four times faster than scipy cdist, five times faster than xarray.corr, 60 times faster than forloop, 110 times faster than xr.apply_func and 200 times faster than numpy.corrcoef.\n\nMoreover, xarray and numpy can not return the **p value**. We can simply check the pvalue attribute of sacpy to get the p value.\n\nAll in all, if we want to get p-value and correlation or slope, we only to choose **Sacpy is 60 times faster than before**.\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/speed_test_00.png)\n\n## Example\n\n### example1\n\nCalculate the correlation between SST and nino3.4 index\n\n```Python\nimport numpy as np\nimport scapy as scp\nimport matplotlib.pyplot as plt\nimport sacpy.Map # need cartopy or you can just not import\nimport cartopy.crs as ccrs\n\n# load sst\nsst = scp.load_sst()['sst']\n# get ssta (method=1, Remove linear trend;method=0, Minus multi-year average)\nssta = scp.get_anom(sst,method=1)\n# calculate Nino3.4\nNino34 = ssta.loc[:,-5:5,190:240].mean(axis=(1,2))\n# regression\nlinreg = scp.LinReg(Nino34,ssta)\n# plot\nfig = plt.figure(figsize=[7, 3])\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nlon ,lat = ssta.lon , ssta.lat\n# shading\nm = ax.scontourf(lon,lat,linreg.corr)\n# significant plot\nn = ax.sig_plot(lon,lat,linreg.p_value,color=\"k\",marker=\"..\")\n# initialize map\nax.init_map(stepx=50, ysmall=2.5)\n# colorbar\nplt.colorbar(m)\n# save\nplt.savefig(\"../pic/nino34.png\",dpi=200)\n\n```\n\nResult(For a detailed drawing process, see **example**):\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/nino34.png)\n\n### example2\n\nmultiple linear regression on Nino3.4 IOD Index and ssta pattern\n\n```Python\nimport numpy as np\nimport scapy as scp\nimport matplotlib.pyplot as plt\n\n\n# load sst\nsst = scp.load_sst()['sst']\n# get ssta (method=1, Remove linear trend;method=0, Minus multi-year average)\nssta = scp.get_anom(sst,method=1)\n# calculate Nino3.4\nNino34 = ssta.loc[:,-5:5,190:240].mean(axis=(1,2))\n# calculate IODIdex\nIODW = ssta.loc[:,-10:10,50:70].mean(axis=(1,2))\nIODE = ssta.loc[:,-10:0,90:110].mean(axis=(1,2))\nIODI = +IODW - IODE\n# get x\nX = np.vstack([np.array(Nino34),np.array(IODI)]).T\n# multiple linear regression\nMLR = scp.MultLinReg(X,ssta)\n\n# plot IOD's effect\nimport sacpy.Map\nimport cartopy.crs as ccrs\n\n\nfig = plt.figure(figsize=[7, 3])\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nlon ,lat = ssta.lon , ssta.lat\nm = ax.scontourf(lon,lat,MLR.slope[1])\n# significant plot\nn = ax.sig_plot(lon,lat,MLR.pv_i[1],color=\"k\",marker=\"..\")\n# initialize map\nax.init_map(stepx=50, ysmall=2.5)\nplt.colorbar(m)\nplt.savefig(\"../pic/MLR.png\",dpi=200)\n```\n\nResult(For a detailed drawing process, see **example**):\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/MLR.png)\n\n### example3\n\nWhat effect will ENSO have on the sea surface temperature in the next summer?\n\n```Python\nimport numpy as np\nimport sacpy as scp\nimport matplotlib.pyplot as plt\nimport xarray as xr\n\n# load sst\nsst = scp.load_sst()['sst']\nssta = scp.get_anom(sst)\n\n# calculate Nino3.4\nNino34 = ssta.loc[:,-5:5,190:240].mean(axis=(1,2))\n\n# get DJF mean Nino3.4\nDJF_nino34 = scp.XrTools.spec_moth_yrmean(Nino34,[12,1,2])\n\n# get JJA mean ssta\nJJA_ssta = scp.XrTools.spec_moth_yrmean(ssta, [6,7,8])\n\n# regression\nreg = scp.LinReg(DJF_nino34[:-1], JJA_ssta)\n# plot\nimport cartopy.crs as ccrs\nimport sacpy.Map\n\n\nfig = plt.figure(figsize=[7, 3])\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nlon ,lat = np.array(ssta.lon) , np.array(ssta.lat)\nm = ax.scontourf(lon,lat,reg.slope)\nn = ax.sig_plot(lon,lat,reg.p_value,color=\"k\",marker=\"///\")\nax.init_map(stepx=50, ysmall=2.5)\nplt.colorbar(m)\nplt.savefig(\"../pic/ENSO_Next_year_JJA.png\",dpi=300)\n\n```\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/ENSO_Next_year_JJA.png)\n\nSame as **Indian Ocean Capacitor Effect on Indo–Western Pacific Climate during the Summer following El Niño** (Xie et al.), the El Nino will lead to Indian ocean warming in next year JJA.\n\n### example4\n\nEOF analysis\n\n```Python\nimport sacpy as scp\nimport numpy as np\nimport matplotlib.pyplot as plt\n# get data\nsst = scp.load_sst()[\"sst\"].loc[:, -20:30, 150:275]\nssta = scp.get_anom(sst)\n# EOF\neof = scp.EOF(np.array(ssta))\neof.solve()\n# get spartial pattern and pc\npc = eof.get_pc(npt=2)\npt = eof.get_pt(npt=2)\n# plot\nimport cartopy.crs as ccrs\nimport sacpy.Map\nlon , lat = np.array(ssta.lon) , np.array(ssta.lat)\nfig = plt.figure(figsize=[15,10])\nax = fig.add_subplot(221,projection=ccrs.PlateCarree(central_longitude=180))\nm1 = ax.scontourf(lon,lat,pt[0,:,:],cmap='RdBu_r',levels=np.linspace(-0.75,0.75,15),extend=\"both\")\nax.scontour(m1,colors=\"black\")\nax.init_map(ysmall=2.5)\n# plt.colorbar(m1)\nax2 = fig.add_subplot(222)\nax2.plot(sst.time,pc[0])\nax3 = fig.add_subplot(223,projection=ccrs.PlateCarree(central_longitude=180))\nm2 = ax3.scontourf(lon,lat,pt[1,:,:],cmap='RdBu_r',levels=np.linspace(-0.75,0.75,15),extend=\"both\")\nax3.scontour(m2,colors=\"black\")\nax3.init_map(ysmall=2.5)\nax4 = fig.add_subplot(224)\nax4.plot(sst.time,pc[1])\ncb_ax = fig.add_axes([0.1,0.06,0.4,0.02])\nfig.colorbar(m1,cax=cb_ax,orientation=\"horizontal\")\nplt.savefig(\"../pic/eof_ana.png\",dpi=300)\n```\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/eof_ana.png)\n\n## example5\n\nMean value (Composite Analysis) t-test for super El Nino (DJF Nino3.4 \u003e 1)\n\n```Python\n\nimport sacpy as scp\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nsst = scp.load_sst()[\"sst\"]\nssta = scp.get_anom(sst, method=0)\n# get Dec Jan Feb SSTA\nssta_djf = scp.XrTools.spec_moth_yrmean(ssta,[12,1,2])\nNino34 = ssta_djf.loc[:, -5:5, 190:240].mean(axis=(1, 2))\n# select year of Super El Nino\nselect = Nino34 \u003e= 1\nssta_sl = ssta_djf[select]\nmean, pv = scp.one_mean_test(ssta_sl)\n# plot\nimport sacpy.Map\nimport cartopy.crs as ccrs\nfig = plt.figure(figsize=[7, 3])\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nlon ,lat = np.array(ssta.lon) , np.array(ssta.lat)\nm = ax.scontourf(lon,lat,mean)\nn = ax.sig_plot(lon,lat,pv,color=\"k\",marker=\"..\")\nax.init_map(stepx=50, ysmall=2.5)\nplt.colorbar(m)\nplt.savefig(\"../pic/one_test.png\")\n```\n\nResult:\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/one_test.png)\n\n## example6\n\nSVD(MCA) analysis.\n\n```Python\nimport sacpy as scp\nimport xarray as xr\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom xmca import array\nimport sacpy.Map\nimport cartopy.crs as ccrs\n\n# load data\nsst = scp.load_sst()['sst'].loc[\"1991\":\"2021\", -20:30, 150:275]\nssta = scp.get_anom(sst)\nu = scp.load_10mwind()['u']\nv = scp.load_10mwind()['v']\n\nuua = scp.get_anom(u)\nvua = scp.get_anom(v)\nuv = np.concatenate([np.array(uua)[...,np.newaxis],np.array(vua)[...,np.newaxis]],axis=-1)\n# calculation\nsvd = scp.SVD(ssta,uv,complex=False)\nsvd.solve()\nptl, ptr = svd.get_pt(3)\npcl,pcr = svd.get_pc(3)\nupt ,vpt = ptr[...,0] , ptr[...,1]\nsst_pt = ptl\n# plot progress, see example/SVD.ipynb\n```\n\nresult:\n\n![](https://raw.githubusercontent.com/ZiluM/sacpy/main/pic/SVD.png)\n\n## examples of concise\n\nIf you want to plot example1's figure , you need write:\n\n```Python\nfrom cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter\nfrom matplotlib.ticker import MultipleLocator\nimport cartopy.crs as ccrs\nplt.rc('font', family='Times New Roman', size=12)\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nm = ax.contourf(ssta.lon,ssta.lat,linreg.corr,\n                cmap=\"RdBu_r\",\n                levels=np.linspace(-1, 1, 15),\n                extend=\"both\",\n                transform=ccrs.PlateCarree())\nn = plt.contourf(ssta.lon,ssta.lat,linreg.p_value,\n                 levels=[0, 0.05, 1],\n                 zorder=1,\n                 hatches=['..', None],\n                 colors=\"None\",\n                 transform=ccrs.PlateCarree())\nxtk = np.arange(-180,181,60)\nax.set_xticks(xtk)\n# ax.set_xticks(xtk,crs=ccrs.PlateCarree())\nax.set_yticks(np.arange(-50,51,20),crs=ccrs.PlateCarree())\nax.yaxis.set_major_formatter(LatitudeFormatter())\nax.xaxis.set_major_formatter(LongitudeFormatter(zero_direction_label=True))\nax.xaxis.set_minor_locator(MultipleLocator(10))\nax.yaxis.set_minor_locator(MultipleLocator(5))\nax.coastlines()\nax.set_aspect(\"auto\")\nplt.colorbar(m)\n\n```\n\n**So troublesome!!!**\n\nBut if you `import sacpy.Map`, you can easily write:\n\n```Python\nimport sacpy.Map\nimport cartopy.crs as ccrs\nfig = plt.figure(figsize=[7, 3])\nax = plt.axes(projection=ccrs.PlateCarree(central_longitude=180))\nlon ,lat = ssta.lon , ssta.lat\nm = ax.scontourf(lon,lat,rvalue)\nn = ax.sig_plot(lon,lat,p,color=\"k\",marker=\"..\")\nax.init_map(stepx=50, ysmall=2.5)\nplt.colorbar(m)\n```\n\nHow wonderful, how concise !\n\n## Acknowledgements\n\nThank Prof. Feng Zhu (NUIST,https://fzhu2e.github.io/) for his guidance of this project.\n\nThank for Prof. Tim Li (University of Hawaii at Mānoa, http://iprc.soest.hawaii.edu/people/li.php) ,Prof. Lin Chen (NUIST, https://faculty.nuist.edu.cn/chenlin12/zh_CN/index.htm) and Dr. Ming Sun (NUIST) 's help.\n\nSepcial thanks: Lifei Lin (Sun Yat-sen University) 's `repr_html.py` to visualize class in jupyter!\n","funding_links":[],"readme_doi_urls":[],"works":{},"citation_counts":{},"total_citations":0,"keywords_from_contributors":[],"project_url":"https://ost.ecosyste.ms/api/v1/projects/113524","html_url":"https://ost.ecosyste.ms/projects/113524"}