diff --git a/.buildinfo b/.buildinfo new file mode 100644 index 00000000..f6b6d96f --- /dev/null +++ b/.buildinfo @@ -0,0 +1,4 @@ +# Sphinx build info version 1 +# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. +config: 1a0f82af78fd96a174357eedad693495 +tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/_images/00e7391285ad0a23d217120f9c20d6926001d3de4f8f5ab35f43e51a94dfeb51.png b/_images/00e7391285ad0a23d217120f9c20d6926001d3de4f8f5ab35f43e51a94dfeb51.png new file mode 100644 index 00000000..d79b5788 Binary files /dev/null and b/_images/00e7391285ad0a23d217120f9c20d6926001d3de4f8f5ab35f43e51a94dfeb51.png differ diff --git a/_images/076e00af7001644d67284ed2d84bfb106d3e30ca9637c23adc8db0fca2c5b9d7.png b/_images/076e00af7001644d67284ed2d84bfb106d3e30ca9637c23adc8db0fca2c5b9d7.png new file mode 100644 index 00000000..88f87c5b Binary files /dev/null and b/_images/076e00af7001644d67284ed2d84bfb106d3e30ca9637c23adc8db0fca2c5b9d7.png differ diff --git a/_images/1102d5acf830210369344c64345b23987b401afa2521cc8f6a1e39a3adc0a194.png b/_images/1102d5acf830210369344c64345b23987b401afa2521cc8f6a1e39a3adc0a194.png new file mode 100644 index 00000000..8357ec57 Binary files /dev/null and b/_images/1102d5acf830210369344c64345b23987b401afa2521cc8f6a1e39a3adc0a194.png differ diff --git a/_images/178bd07351dab10c117e96bd31c12ebdcb55ec04e301d21bd870aec2c006e739.png b/_images/178bd07351dab10c117e96bd31c12ebdcb55ec04e301d21bd870aec2c006e739.png new file mode 100644 index 00000000..981781a6 Binary files /dev/null and b/_images/178bd07351dab10c117e96bd31c12ebdcb55ec04e301d21bd870aec2c006e739.png differ diff --git a/_images/1cc96366fcab69b189d48e20b148a3dfc0adad2b2cdfe0007d37cbcf4842cbe7.png b/_images/1cc96366fcab69b189d48e20b148a3dfc0adad2b2cdfe0007d37cbcf4842cbe7.png new file mode 100644 index 00000000..83dccbde Binary files /dev/null and b/_images/1cc96366fcab69b189d48e20b148a3dfc0adad2b2cdfe0007d37cbcf4842cbe7.png differ diff --git a/_images/1eb0f54dce16aa787039d2a78fb9cdaa94e90ab054835fdfd055234bb0506296.png b/_images/1eb0f54dce16aa787039d2a78fb9cdaa94e90ab054835fdfd055234bb0506296.png new file mode 100644 index 00000000..7b212a1f Binary files /dev/null and b/_images/1eb0f54dce16aa787039d2a78fb9cdaa94e90ab054835fdfd055234bb0506296.png differ diff --git a/_images/24dc1f2ac24f427dfbe135ee1f7a80db8d7a37d4e0b7194e2c4e41e1028ade16.png b/_images/24dc1f2ac24f427dfbe135ee1f7a80db8d7a37d4e0b7194e2c4e41e1028ade16.png new file mode 100644 index 00000000..b188d986 Binary files /dev/null and b/_images/24dc1f2ac24f427dfbe135ee1f7a80db8d7a37d4e0b7194e2c4e41e1028ade16.png differ diff --git a/_images/2c2c8ee16bbfcc6327079590834ae77ee505d64debb3e76564cf1e9e79036519.png b/_images/2c2c8ee16bbfcc6327079590834ae77ee505d64debb3e76564cf1e9e79036519.png new file mode 100644 index 00000000..d1cd2d55 Binary files /dev/null and b/_images/2c2c8ee16bbfcc6327079590834ae77ee505d64debb3e76564cf1e9e79036519.png differ diff --git a/_images/3c68f765a2940f6a54a6c8c7f1d5ba02731462a6b740cf1fdc559402003babb7.png b/_images/3c68f765a2940f6a54a6c8c7f1d5ba02731462a6b740cf1fdc559402003babb7.png new file mode 100644 index 00000000..d6e99bed Binary files /dev/null and b/_images/3c68f765a2940f6a54a6c8c7f1d5ba02731462a6b740cf1fdc559402003babb7.png differ diff --git a/_images/488ae9d16d7a67a5299c9339dd99bfac3ae118110f0de025bbcab0a268b99036.png b/_images/488ae9d16d7a67a5299c9339dd99bfac3ae118110f0de025bbcab0a268b99036.png new file mode 100644 index 00000000..f270746d Binary files /dev/null and b/_images/488ae9d16d7a67a5299c9339dd99bfac3ae118110f0de025bbcab0a268b99036.png differ diff --git a/_images/4af075153c0c37778b7d6eb6ba678cf64909a1a89089d2b520ccfab3b3a44931.png b/_images/4af075153c0c37778b7d6eb6ba678cf64909a1a89089d2b520ccfab3b3a44931.png new file mode 100644 index 00000000..cbfc9aa4 Binary files /dev/null and b/_images/4af075153c0c37778b7d6eb6ba678cf64909a1a89089d2b520ccfab3b3a44931.png differ diff --git a/_images/4bc19ff34148935d8dfa16c86d3b8009f15dfe4d47334fd88dd5ed18c2d60c43.png b/_images/4bc19ff34148935d8dfa16c86d3b8009f15dfe4d47334fd88dd5ed18c2d60c43.png new file mode 100644 index 00000000..f8f2f535 Binary files /dev/null and b/_images/4bc19ff34148935d8dfa16c86d3b8009f15dfe4d47334fd88dd5ed18c2d60c43.png differ diff --git a/_images/4ea045a3a63de9128e016f22cc479595544073cefa39337d1b6f4deca3b55c94.png b/_images/4ea045a3a63de9128e016f22cc479595544073cefa39337d1b6f4deca3b55c94.png new file mode 100644 index 00000000..71bbf2b8 Binary files /dev/null and b/_images/4ea045a3a63de9128e016f22cc479595544073cefa39337d1b6f4deca3b55c94.png differ diff --git a/_images/4ed8679ebd728d3ce67c6d3f73b4811a21d5daf456c82f1766f947d065bbe9a6.png b/_images/4ed8679ebd728d3ce67c6d3f73b4811a21d5daf456c82f1766f947d065bbe9a6.png new file mode 100644 index 00000000..1b47aa45 Binary files /dev/null and b/_images/4ed8679ebd728d3ce67c6d3f73b4811a21d5daf456c82f1766f947d065bbe9a6.png differ diff --git a/_images/509795073e05838cebf6c8d793f8a1c4ce34f6c50d0a2f6c91c1d6f0a646357f.png b/_images/509795073e05838cebf6c8d793f8a1c4ce34f6c50d0a2f6c91c1d6f0a646357f.png new file mode 100644 index 00000000..612df441 Binary files /dev/null and b/_images/509795073e05838cebf6c8d793f8a1c4ce34f6c50d0a2f6c91c1d6f0a646357f.png differ diff --git a/_images/51e09db13ce7191895d405687afb40d85c9cd55b12f34b072bc6a8cdcead41c7.png b/_images/51e09db13ce7191895d405687afb40d85c9cd55b12f34b072bc6a8cdcead41c7.png new file mode 100644 index 00000000..c90a2b2b Binary files /dev/null and b/_images/51e09db13ce7191895d405687afb40d85c9cd55b12f34b072bc6a8cdcead41c7.png differ diff --git a/_images/522e4b7ec7dc871201c328a5ee2606310e78fb959220e1a2a9b11c2860659791.png b/_images/522e4b7ec7dc871201c328a5ee2606310e78fb959220e1a2a9b11c2860659791.png new file mode 100644 index 00000000..eac17a95 Binary files /dev/null and b/_images/522e4b7ec7dc871201c328a5ee2606310e78fb959220e1a2a9b11c2860659791.png differ diff --git a/_images/571b9c0473337cb87e975564853ab154297f228dcd399e21408c5a5d646db2d0.png b/_images/571b9c0473337cb87e975564853ab154297f228dcd399e21408c5a5d646db2d0.png new file mode 100644 index 00000000..d27efcff Binary files /dev/null and b/_images/571b9c0473337cb87e975564853ab154297f228dcd399e21408c5a5d646db2d0.png differ diff --git a/_images/5a1b9c5ce24cf77cd4270719c96568b4e3108bf4daf3c230934915564ed79778.png b/_images/5a1b9c5ce24cf77cd4270719c96568b4e3108bf4daf3c230934915564ed79778.png new file mode 100644 index 00000000..eb8c80c1 Binary files /dev/null and b/_images/5a1b9c5ce24cf77cd4270719c96568b4e3108bf4daf3c230934915564ed79778.png differ diff --git a/_images/6318dca69a7fbaa564cc6c6309ad8dde2fb0a9a542828a8fb905d4a684bd7305.png b/_images/6318dca69a7fbaa564cc6c6309ad8dde2fb0a9a542828a8fb905d4a684bd7305.png new file mode 100644 index 00000000..da754b31 Binary files /dev/null and b/_images/6318dca69a7fbaa564cc6c6309ad8dde2fb0a9a542828a8fb905d4a684bd7305.png differ diff --git a/_images/633eb6dce0859a9b8298cb085d99a6a4d47d66be4846a5431d66b055089f226f.png b/_images/633eb6dce0859a9b8298cb085d99a6a4d47d66be4846a5431d66b055089f226f.png new file mode 100644 index 00000000..99a3dd88 Binary files /dev/null and b/_images/633eb6dce0859a9b8298cb085d99a6a4d47d66be4846a5431d66b055089f226f.png differ diff --git a/_images/66d2f5ddb8c6b4c88ce7b8cd657b839abd722880fcdc9b7afe6aad22b901dd88.png b/_images/66d2f5ddb8c6b4c88ce7b8cd657b839abd722880fcdc9b7afe6aad22b901dd88.png new file mode 100644 index 00000000..571927cf Binary files /dev/null and b/_images/66d2f5ddb8c6b4c88ce7b8cd657b839abd722880fcdc9b7afe6aad22b901dd88.png differ diff --git a/_images/69155f2d6771a4e04a41e8895f57ec7eff76ff407340f19b947c9d2d64603883.png b/_images/69155f2d6771a4e04a41e8895f57ec7eff76ff407340f19b947c9d2d64603883.png new file mode 100644 index 00000000..1384a760 Binary files /dev/null and b/_images/69155f2d6771a4e04a41e8895f57ec7eff76ff407340f19b947c9d2d64603883.png differ diff --git a/_images/69d9ac2bc475aab34768f0f8ccacb79dc6424d401fbd3b0129cdb7016b9cff7b.png b/_images/69d9ac2bc475aab34768f0f8ccacb79dc6424d401fbd3b0129cdb7016b9cff7b.png new file mode 100644 index 00000000..b5984aea Binary files /dev/null and b/_images/69d9ac2bc475aab34768f0f8ccacb79dc6424d401fbd3b0129cdb7016b9cff7b.png differ diff --git a/_images/74407a92cd9c13e7e4ff0789405abbdcf75c9e26963d31986c0ccacfa9dff556.png b/_images/74407a92cd9c13e7e4ff0789405abbdcf75c9e26963d31986c0ccacfa9dff556.png new file mode 100644 index 00000000..aeb1ea11 Binary files /dev/null and b/_images/74407a92cd9c13e7e4ff0789405abbdcf75c9e26963d31986c0ccacfa9dff556.png differ diff --git a/_images/758de58cada0eddb31da248a36ce2a3fc4fadfe065d7c3e0d980af4c4f2b882c.png b/_images/758de58cada0eddb31da248a36ce2a3fc4fadfe065d7c3e0d980af4c4f2b882c.png new file mode 100644 index 00000000..31a14876 Binary files /dev/null and b/_images/758de58cada0eddb31da248a36ce2a3fc4fadfe065d7c3e0d980af4c4f2b882c.png differ diff --git a/_images/80a3533503df36866685a054f0e8a6ea8fc5844e211b1b5ee3de8466a084bdcd.png b/_images/80a3533503df36866685a054f0e8a6ea8fc5844e211b1b5ee3de8466a084bdcd.png new file mode 100644 index 00000000..56ac2522 Binary files /dev/null and b/_images/80a3533503df36866685a054f0e8a6ea8fc5844e211b1b5ee3de8466a084bdcd.png differ diff --git a/_images/849f7ec3940d295224493cfa01e608da92e53123a9503ba3f3b8dd312a9e0693.png b/_images/849f7ec3940d295224493cfa01e608da92e53123a9503ba3f3b8dd312a9e0693.png new file mode 100644 index 00000000..bf5f900b Binary files /dev/null and b/_images/849f7ec3940d295224493cfa01e608da92e53123a9503ba3f3b8dd312a9e0693.png differ diff --git a/_images/85b6a9b19e2e86b56cf2104458ba9f787a54896fcd452fe1fd789ef70590280e.png b/_images/85b6a9b19e2e86b56cf2104458ba9f787a54896fcd452fe1fd789ef70590280e.png new file mode 100644 index 00000000..49e10f5e Binary files /dev/null and b/_images/85b6a9b19e2e86b56cf2104458ba9f787a54896fcd452fe1fd789ef70590280e.png differ diff --git a/_images/97635637c92862857de9ca5957ab760a23ea9da7e42e23827b898be170aac9e1.png b/_images/97635637c92862857de9ca5957ab760a23ea9da7e42e23827b898be170aac9e1.png new file mode 100644 index 00000000..96a9f40b Binary files /dev/null and b/_images/97635637c92862857de9ca5957ab760a23ea9da7e42e23827b898be170aac9e1.png differ diff --git a/_images/9f3f4f597ff02b15f6aa76fa7aea1f36648133beeae8f006a80c2f9e158d841b.png b/_images/9f3f4f597ff02b15f6aa76fa7aea1f36648133beeae8f006a80c2f9e158d841b.png new file mode 100644 index 00000000..5b4ee11a Binary files /dev/null and b/_images/9f3f4f597ff02b15f6aa76fa7aea1f36648133beeae8f006a80c2f9e158d841b.png differ diff --git a/_images/b65a737d863cf5630de0b9750604b95e15eb4b5952e184c48c50e88cb19d5792.png b/_images/b65a737d863cf5630de0b9750604b95e15eb4b5952e184c48c50e88cb19d5792.png new file mode 100644 index 00000000..1463c661 Binary files /dev/null and b/_images/b65a737d863cf5630de0b9750604b95e15eb4b5952e184c48c50e88cb19d5792.png differ diff --git a/_images/b7a59c635e7c612edcc8359da18e8f65c53e75b7f1490fb69b4d692eee452c36.png b/_images/b7a59c635e7c612edcc8359da18e8f65c53e75b7f1490fb69b4d692eee452c36.png new file mode 100644 index 00000000..f7cb15db Binary files /dev/null and b/_images/b7a59c635e7c612edcc8359da18e8f65c53e75b7f1490fb69b4d692eee452c36.png differ diff --git a/_images/be8faac5487cbb19137388cc8c7d4dbc3d588e8261049c1e9bfa3e3eadf561e3.png b/_images/be8faac5487cbb19137388cc8c7d4dbc3d588e8261049c1e9bfa3e3eadf561e3.png new file mode 100644 index 00000000..bd667214 Binary files /dev/null and b/_images/be8faac5487cbb19137388cc8c7d4dbc3d588e8261049c1e9bfa3e3eadf561e3.png differ diff --git a/_images/c29dbd4f7f0c5166fa175351f3030a04b98a190064ae7ffe316cd46fab78f3e0.png b/_images/c29dbd4f7f0c5166fa175351f3030a04b98a190064ae7ffe316cd46fab78f3e0.png new file mode 100644 index 00000000..1a9c7779 Binary files /dev/null and b/_images/c29dbd4f7f0c5166fa175351f3030a04b98a190064ae7ffe316cd46fab78f3e0.png differ diff --git a/_images/convnp_arch.png b/_images/convnp_arch.png new file mode 100644 index 00000000..e1776f0e Binary files /dev/null and b/_images/convnp_arch.png differ diff --git a/_images/deepsensor_application_examples.png b/_images/deepsensor_application_examples.png new file mode 100644 index 00000000..d34ef4ef Binary files /dev/null and b/_images/deepsensor_application_examples.png differ diff --git a/_images/deepsensor_design.png b/_images/deepsensor_design.png new file mode 100644 index 00000000..2f71d940 Binary files /dev/null and b/_images/deepsensor_design.png differ diff --git a/_images/e3893525400c6f9ee54bcf805009ab9021207b8b1362478cd929eeea8dd5731d.png b/_images/e3893525400c6f9ee54bcf805009ab9021207b8b1362478cd929eeea8dd5731d.png new file mode 100644 index 00000000..e2407996 Binary files /dev/null and b/_images/e3893525400c6f9ee54bcf805009ab9021207b8b1362478cd929eeea8dd5731d.png differ diff --git a/_images/e86ea5a44aa3d5c7e6ddbcd55571c2fb08b847ac901c9f041e0e98ca17c078c3.png b/_images/e86ea5a44aa3d5c7e6ddbcd55571c2fb08b847ac901c9f041e0e98ca17c078c3.png new file mode 100644 index 00000000..6a474c42 Binary files /dev/null and b/_images/e86ea5a44aa3d5c7e6ddbcd55571c2fb08b847ac901c9f041e0e98ca17c078c3.png differ diff --git a/_images/e960e363e424d7894ad6f13e6c5637e8995991709ddc5afc65a664f81dfc8487.png b/_images/e960e363e424d7894ad6f13e6c5637e8995991709ddc5afc65a664f81dfc8487.png new file mode 100644 index 00000000..d07c54ba Binary files /dev/null and b/_images/e960e363e424d7894ad6f13e6c5637e8995991709ddc5afc65a664f81dfc8487.png differ diff --git a/_images/f50db2d4af9adf756b379f55bab153c1c600cc9c7ba7f22acd354e7494585c3e.png b/_images/f50db2d4af9adf756b379f55bab153c1c600cc9c7ba7f22acd354e7494585c3e.png new file mode 100644 index 00000000..faf918cc Binary files /dev/null and b/_images/f50db2d4af9adf756b379f55bab153c1c600cc9c7ba7f22acd354e7494585c3e.png differ diff --git a/_images/f5be28482b9f49c4d04fdb59b6502f56c0f8ee636541aacf73452bad89035642.png b/_images/f5be28482b9f49c4d04fdb59b6502f56c0f8ee636541aacf73452bad89035642.png new file mode 100644 index 00000000..e8a211d0 Binary files /dev/null and b/_images/f5be28482b9f49c4d04fdb59b6502f56c0f8ee636541aacf73452bad89035642.png differ diff --git a/_images/f708fa3993b7fa909597e8666480a2e0e5667f0a2c51277a76a90fafa6097115.png b/_images/f708fa3993b7fa909597e8666480a2e0e5667f0a2c51277a76a90fafa6097115.png new file mode 100644 index 00000000..c6896f63 Binary files /dev/null and b/_images/f708fa3993b7fa909597e8666480a2e0e5667f0a2c51277a76a90fafa6097115.png differ diff --git a/_images/index_api.svg b/_images/index_api.svg new file mode 100644 index 00000000..87013d24 --- /dev/null +++ b/_images/index_api.svg @@ -0,0 +1,97 @@ + + + + diff --git a/_images/index_community2.png b/_images/index_community2.png new file mode 100644 index 00000000..962e3912 Binary files /dev/null and b/_images/index_community2.png differ diff --git a/_images/index_getting_started.svg b/_images/index_getting_started.svg new file mode 100644 index 00000000..d1c7b08a --- /dev/null +++ b/_images/index_getting_started.svg @@ -0,0 +1,66 @@ + + + + diff --git a/_images/index_user_guide.svg b/_images/index_user_guide.svg new file mode 100644 index 00000000..bff24824 --- /dev/null +++ b/_images/index_user_guide.svg @@ -0,0 +1,67 @@ + + + + diff --git a/_sources/community/code_of_conduct.md b/_sources/community/code_of_conduct.md new file mode 100644 index 00000000..cc6912b9 --- /dev/null +++ b/_sources/community/code_of_conduct.md @@ -0,0 +1,2 @@ +```{include} ../../CODE_OF_CONDUCT.md +``` diff --git a/_sources/community/contributing.md b/_sources/community/contributing.md new file mode 100644 index 00000000..ef6daa82 --- /dev/null +++ b/_sources/community/contributing.md @@ -0,0 +1,2 @@ +```{include} ../../CONTRIBUTING.md +``` diff --git a/_sources/community/faq.md b/_sources/community/faq.md new file mode 100644 index 00000000..7396b20b --- /dev/null +++ b/_sources/community/faq.md @@ -0,0 +1,97 @@ +# Community FAQ + +This FAQ aims to answer common questions about the DeepSensor library. It is our way to streamline the onboarding process and clarify expectations. + +```{note} +If you have a question you'd like to see answered here, make a request in a issue or in the [Slack channel](https://ai4environment.slack.com/archives/C05NQ76L87R). +``` + +## Questions + +**Q: Why doesn't the package name `DeepSensor` mention NPs if it's all about neural processes?** + +**Answer:** +DeepSensor aims to be extensible to models that are not necessarily NPs. +We also wanted to keep the name short and easy to remember. +The name `DeepSensor` is a reference to the fact that the library is about deep learning and sensor data. + +--- + +**Q: How can I contribute?** + +**Answer:** +There are many ways to contribute, from writing code and fixing bugs to improving documentation or translating content. +Check our [](./contributing.md) guide. + +--- + +**Q: Do I need to sign a Contributor License Agreement (CLA)?** + +**Answer:** At the current time, we do not require a CLA from our contributors. + +--- + +**Q: How do I report a bug?** + +**Answer:** Please submit an issue in our GitHub repository. Make sure to provide detailed information, including steps to reproduce the bug and the expected outcome. + +--- + +**Q: How do I request a new feature?** + +**Answer:** Open a new issue on our GitHub repository and label it as a feature request. Describe the feature in detail and its potential benefits. + +--- + +**Q: How can I get in touch with other contributors or maintainers?** + +**Answer:** +Request to join our Slack channel to stay in touch with other contributors and maintainers. You can join by [signing up for the Turing Environment & Sustainability stakeholder community](https://forms.office.com/pages/responsepage.aspx?id=p_SVQ1XklU-Knx-672OE-ZmEJNLHTHVFkqQ97AaCfn9UMTZKT1IwTVhJRE82UjUzMVE2MThSOU5RMC4u). The form includes a question on signing up for the Slack team, where you can find DeepSensor's channel. + +We also have a regular community Zoom call (join the Slack channel or get in touch to find out more). + +--- + +**Q: How do I set up the development environment?** + +**Answer:** Follow the instructions in our developer documentation. If you run into issues, ask in our [community chat](https://ai4environment.slack.com/archives/C05NQ76L87R) (on Slack). + +--- + +**Q: Do you have a code of conduct?** + +**Answer:** +Yes, we value a respectful and inclusive community. +Please read our [](./code_of_conduct.md) before contributing. + +--- + +**Q: Can I contribute even if I'm not a coder?** + +**Answer:** Absolutely! Contributions can be made in the form of documentation, design, testing, and more. Everyone's skills are valuable. Join our Slack discussion to learn more. + +--- + +**Q: How do I claim an issue to work on?** + +**Answer:** Comment on the issue expressing your interest to help out. If the issue is unassigned, a maintainer will likely assign it to you. + +--- + +**Q: What's the process for proposing a significant change?** + +**Answer:** For significant changes, it's a good practice to first open a discussion or issue to gather feedback. Once there's a consensus, you can proceed with a pull request. + +--- + +**Q: How can I get my pull request (PR) merged?** + +**Answer:** Ensure your PR follows the contribution guidelines, passes all tests, and has been reviewed by at least one maintainer. Address any feedback provided. + +--- + +**Q: How is credit given to contributors?** + +**Answer:** +Contributors are acknowledged via an `all-contributors` system, which records contributions (code or non-code) at the end of the project's README. +Code contributions are acknowledged in our release notes. diff --git a/_sources/community/index.md b/_sources/community/index.md new file mode 100644 index 00000000..dad2568e --- /dev/null +++ b/_sources/community/index.md @@ -0,0 +1,7 @@ +# Community + +The DeepSensor community is a group of users and contributors who are interested in the development of DeepSensor. The community is open to anyone who is interested in DeepSensor. The community is a place to ask questions, discuss ideas, and share your work. + +If you are interested in joining the community, please request to join our Slack channel. You can join by [signing up for the Turing Environment & Sustainability stakeholder community](https://forms.office.com/pages/responsepage.aspx?id=p_SVQ1XklU-Knx-672OE-ZmEJNLHTHVFkqQ97AaCfn9UMTZKT1IwTVhJRE82UjUzMVE2MThSOU5RMC4u). The form includes a question on signing up for the Slack team, where you can find DeepSensor's channel. + +We welcome contributions from the community. If you are interested in contributing to DeepSensor, please read the [Contributing Guide](./contributing.md). diff --git a/_sources/community/roadmap.md b/_sources/community/roadmap.md new file mode 100644 index 00000000..75d0d385 --- /dev/null +++ b/_sources/community/roadmap.md @@ -0,0 +1,24 @@ +# DeepSensor Roadmap + +This page contains a list of new features that we would like to add to DeepSensor in the future. +Some of these have been raised as issues on the [GitHub issue tracker](https://github.com/alan-turing-institute/deepsensor/issues) +with further details. + +```{note} +We will soon create a GitHub project board to track progress on these items, which will provide a more up-to-date view of the roadmap. +``` + +```{note} +We are unable to provide a timetable for the roadmap due to maintainer time constraints. +If you are interested in contributing to the project, check out our [](./contributing.md) page. +``` + +* Patch-wise training and inference +* Saving a ``TaskLoader`` when instantiated with raw xarray/pandas objects +* Spatial-only modelling +* Continuous time measurements (i.e. not just discrete, uniformly sampled data on the same time grid) +* Test the framework with other models (e.g. GPs) +* Add simple baselines models (e.g. linear interpolation, GPs) +* Test and extend support for using ``dask`` in the ``DataProcessor`` and ``TaskLoader`` +* Infer linked context-target sets from the ``TaskLoader`` entries, don't require user to explicitly specify ``links`` kwarg +* Improve unit test suite, increase coverage, test more edge cases, etc diff --git a/_sources/contact.md b/_sources/contact.md new file mode 100644 index 00000000..8d09384a --- /dev/null +++ b/_sources/contact.md @@ -0,0 +1,6 @@ +# Contact the core team + +If you would like to contact us directly, please loop in everyone on the core team: + +* Lead developer: tomandersson3@gmail.com +* Product manager: kwesterling@turing.ac.uk diff --git a/_sources/getting-started/data_requirements.ipynb b/_sources/getting-started/data_requirements.ipynb new file mode 100644 index 00000000..b9003716 --- /dev/null +++ b/_sources/getting-started/data_requirements.ipynb @@ -0,0 +1,448 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Data Requirements" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Before getting started with DeepSensor, it's important to understand the package's data requirements.\n", + "Further details on what DeepSensor supports and does not support are provided below.\n", + "\n", + "DeepSensor **does** support:\n", + "* Arbitrary numbers of context sets (or data streams), each with arbitrary numbers of variables (i.e. data channels)\n", + "* Spatiotemporal data and static auxiliary data\n", + "* Gridded and off-the-grid data\n", + "* Moving sensors\n", + "* Missing data\n", + "\n", + "DeepSensor **does not** support:\n", + "* Data with irregular temporal sampling (i.e. continuous time)\n", + "\n", + "DeepSensor has the following **data requirements**:\n", + "* Data formats:\n", + " * Pandas Series/DataFrame (i.e. tabular CSV data)\n", + " * Xarray DataArray/Dataset (i.e. gridded NetCDF data)\n", + "* Regular temporal sampling (i.e. hourly, daily, monthly, etc.), which is the same for all variables\n", + "* Consistent spatiotemporal dimension names across variables (but arbitrary names are permitted, e.g. `time`, `lat`, `lon`, or `date`, `y`, `x`)\n", + "* Each variable has a unique ID, which is used to identify the variable in the model\n", + "* Missing data represented by NaNs (i.e., not arbitrary values such as -9999)\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Data Sources\n", + "\n", + "DeepSensor provides several functions in `deepsensor.data.sources` for fetching environmental data in the format expected by the package.\n", + "These are not intended as definitive data sources for DeepSensor applications, but rather as a means of demoing and getting started with the package.\n", + "\n", + "The following data sources are currently supported:\n", + "* [GHCND](https://www.ncei.noaa.gov/products/land-based-station/global-historical-climatology-network-daily): Global Historical Climatology Network Daily (GHCND) station data\n", + "* [ERA5](https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=overview): ERA5 reanalysis data\n", + "* [EarthEnv](https://www.earthenv.org/): EarthEnv elevation and Topographic Position Index (TPI) data at various resolutions (1 km, 5 km, 10 km, 50 km, 100 km)\n", + "* [GLDAS](https://ldas.gsfc.nasa.gov/gldas/): Global Land Data Assimilation System (GLDAS) 0.25 degree resolution binary land mask\n", + "\n", + "For more details on the data sources, see the API reference for the [data.sources module](../reference/data/sources.rst).\n", + "\n", + "`````{note}\n", + "Some of the data downloader functions used here require additional dependencies.\n", + "To run this yourself you will need to run:\n", + "```\n", + "pip install rioxarray\n", + "```\n", + "to install the [`rioxarray`](https://corteva.github.io/rioxarray/stable/) package and\n", + "```\n", + "pip install git+https://github.com/scott-hosking/get-station-data.git\n", + "```\n", + "to install the [`get_station_data`](https://github.com/scotthosking/get-station-data) package.\n", + "`````\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 2, + "outputs": [], + "source": [ + "import logging\n", + "logging.captureWarnings(True)\n", + "\n", + "import xarray as xr\n", + "import cartopy.crs as ccrs\n", + "import cartopy.feature as cfeature\n", + "import matplotlib.pyplot as plt\n", + "\n", + "# Cache the data in root of docs/ folder, so that other notebook don't need to download it again\n", + "cache_dir = \"../../.datacache\"" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-10-29T19:00:27.269168395Z", + "start_time": "2023-10-29T19:00:27.226884650Z" + } + } + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "ExecuteTime": { + "end_time": "2023-10-27T11:36:37.929530655Z", + "start_time": "2023-10-27T11:36:33.793092748Z" + } + }, + "outputs": [], + "source": [ + "from deepsensor.data.sources import get_ghcnd_station_data, get_era5_reanalysis_data, \\\n", + " get_earthenv_auxiliary_data, get_gldas_land_mask" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "ExecuteTime": { + "end_time": "2023-10-27T11:36:37.948287959Z", + "start_time": "2023-10-27T11:36:37.940134911Z" + } + }, + "outputs": [], + "source": [ + "data_range = (\"2015-06-25\", \"2015-06-30\")\n", + "extent = \"europe\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Off-the-grid station data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Off-the-grid station data is data that is not on a regular grid, such as in-situ observations from weather stations.\n", + "In DeepSensor, Pandas DataFrames are used to represent off-the-grid station data.\n", + "* The variable ID is the column name\n", + "* If the DataFrame has multiple columns, each column is treated as a separate variable\n", + "* The indexes must be (time, x1, x2), where time is a datetime, and x1 and x2 are the spatial dimensions\n", + "* There may be an arbitrary number of additional indexes after these first three indexes. This can be useful for tracking station IDs, for example." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "ExecuteTime": { + "end_time": "2023-10-27T11:36:38.212135690Z", + "start_time": "2023-10-27T11:36:37.952196514Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": " PRCP TAVG\ntime lat lon station \n2015-06-25 35.017 -1.450 AGM00060531 0.0 23.0\n 35.100 -1.850 AGE00147716 0.0 23.4\n 35.117 36.750 SYM00040030 NaN 25.4\n 35.167 2.317 AGM00060514 0.0 25.9\n 35.200 -0.617 AGM00060520 0.0 24.9\n... ... ...\n2015-06-30 45.933 7.700 ITM00016052 NaN 5.7\n 38.367 -0.500 SPM00008359 0.0 27.6\n 55.383 36.700 RSM00027611 0.0 17.2\n 59.080 17.860 SWE00138750 0.0 NaN\n 63.760 12.430 SWE00140158 0.6 NaN\n\n[16922 rows x 2 columns]", + "text/html": "
\n | \n | \n | \n | PRCP | \nTAVG | \n
---|---|---|---|---|---|
time | \nlat | \nlon | \nstation | \n\n | \n |
2015-06-25 | \n35.017 | \n-1.450 | \nAGM00060531 | \n0.0 | \n23.0 | \n
35.100 | \n-1.850 | \nAGE00147716 | \n0.0 | \n23.4 | \n|
35.117 | \n36.750 | \nSYM00040030 | \nNaN | \n25.4 | \n|
35.167 | \n2.317 | \nAGM00060514 | \n0.0 | \n25.9 | \n|
35.200 | \n-0.617 | \nAGM00060520 | \n0.0 | \n24.9 | \n|
... | \n... | \n... | \n... | \n... | \n... | \n
2015-06-30 | \n45.933 | \n7.700 | \nITM00016052 | \nNaN | \n5.7 | \n
38.367 | \n-0.500 | \nSPM00008359 | \n0.0 | \n27.6 | \n|
55.383 | \n36.700 | \nRSM00027611 | \n0.0 | \n17.2 | \n|
59.080 | \n17.860 | \nSWE00138750 | \n0.0 | \nNaN | \n|
63.760 | \n12.430 | \nSWE00140158 | \n0.6 | \nNaN | \n
16922 rows × 2 columns
\n<xarray.Dataset>\nDimensions: (time: 6, lat: 141, lon: 221)\nCoordinates:\n * lat (lat) float32 70.0 69.75 69.5 ... 35.5 35.25 35.0\n * lon (lon) float32 -15.0 -14.75 -14.5 ... 39.75 40.0\n * time (time) datetime64[ns] 2015-06-25 ... 2015-06-30\nData variables:\n 2m_temperature (time, lat, lon) float32 274.7 274.8 ... 300.5\n 10m_u_component_of_wind (time, lat, lon) float32 5.999 5.951 ... 4.999\n 10m_v_component_of_wind (time, lat, lon) float32 2.87 2.746 ... -3.017
<xarray.Dataset>\nDimensions: (lon: 6600, lat: 4200)\nCoordinates:\n * lon (lon) float64 -15.0 -14.99 -14.98 -14.97 ... 39.98 39.99 40.0\n * lat (lat) float64 70.0 69.99 69.98 69.97 ... 35.03 35.02 35.01 35.0\nData variables:\n elevation (lat, lon) float32 0.0 0.0 0.0 0.0 ... 260.8 261.6 261.5 260.6\n tpi (lat, lon) float32 0.0 0.0 0.0 0.0 ... 0.03906 0.07812 0.1641
<xarray.DataArray 'GLDAS_mask' (lat: 140, lon: 220)>\narray([[0., 0., 0., ..., 0., 0., 0.],\n [0., 0., 0., ..., 0., 0., 0.],\n [0., 0., 0., ..., 0., 0., 0.],\n ...,\n [0., 0., 0., ..., 1., 1., 1.],\n [0., 0., 0., ..., 1., 1., 1.],\n [0., 0., 0., ..., 1., 1., 1.]], dtype=float32)\nCoordinates:\n * lon (lon) float32 -14.88 -14.62 -14.38 -14.12 ... 39.38 39.62 39.88\n * lat (lat) float32 69.88 69.62 69.38 69.12 ... 35.88 35.62 35.38 35.12
\n | x1 | \nx2 | \n
---|---|---|
iteration | \n\n | \n |
0 | \n68.50 | \n-118.75 | \n
1 | \n70.25 | \n-159.75 | \n
2 | \n69.00 | \n-131.25 | \n
<xarray.Dataset>\nDimensions: (time: 6, x1: 141, x2: 221)\nCoordinates:\n * time (time) datetime64[ns] 2015-06-25 ... 2015-06-30\n * x1 (x1) float32 0.6364 0.6318 0.6273 ... 0.004545 0.0\n * x2 (x2) float32 0.0 0.004545 0.009091 ... 0.9955 1.0\nData variables:\n 2m_temperature (time, x1, x2) float32 -2.652 -2.635 ... 2.322\n 10m_u_component_of_wind (time, x1, x2) float32 1.987 1.985 ... 1.572 1.529\n 10m_v_component_of_wind (time, x1, x2) float32 1.054 1.018 ... -0.724
\n | \n | \n | \n | PRCP | \nTAVG | \n
---|---|---|---|---|---|
time | \nx1 | \nx2 | \nstation | \n\n | \n |
2015-06-25 | \n0.000309 | \n0.246364 | \nAGM00060531 | \n-0.278121 | \n0.759107 | \n
0.001818 | \n0.239091 | \nAGE00147716 | \n-0.278121 | \n0.836200 | \n|
0.002127 | \n0.940909 | \nSYM00040030 | \nNaN | \n1.221668 | \n|
0.003036 | \n0.314855 | \nAGM00060514 | \n-0.278121 | \n1.318035 | \n|
0.003636 | \n0.261509 | \nAGM00060520 | \n-0.278121 | \n1.125301 | \n|
... | \n... | \n... | \n... | \n... | \n... | \n
2015-06-30 | \n0.198782 | \n0.412727 | \nITM00016052 | \nNaN | \n-2.575188 | \n
0.061218 | \n0.263636 | \nSPM00008359 | \n-0.278121 | \n1.645682 | \n|
0.370600 | \n0.940000 | \nRSM00027611 | \n-0.278121 | \n-0.358749 | \n|
0.437818 | \n0.597455 | \nSWE00138750 | \n-0.278121 | \nNaN | \n|
0.522909 | \n0.498727 | \nSWE00140158 | \n-0.134323 | \nNaN | \n
16922 rows × 2 columns
\n<xarray.Dataset>\nDimensions: (x1: 4200, x2: 6600)\nCoordinates:\n * x1 (x1) float64 0.6363 0.6361 0.636 ... 0.0002273 7.576e-05\n * x2 (x2) float64 7.576e-05 0.0002273 0.0003788 ... 0.9998 0.9999\nData variables:\n elevation (x1, x2) float32 -0.921 -0.921 -0.921 ... -0.8095 -0.8095 -0.8099\n tpi (x1, x2) float32 -0.09401 -0.09401 -0.09401 ... -0.09305 -0.09199
<xarray.Dataset>\nDimensions: (time: 6, lat: 141, lon: 221)\nCoordinates:\n * time (time) datetime64[ns] 2015-06-25 ... 2015-06-30\n * lat (lat) float32 70.0 69.75 69.5 ... 35.5 35.25 35.0\n * lon (lon) float32 -15.0 -14.75 -14.5 ... 39.75 40.0\nData variables:\n 2m_temperature (time, lat, lon) float32 274.7 274.8 ... 302.3\n 10m_u_component_of_wind (time, lat, lon) float32 6.309 6.305 ... 5.004\n 10m_v_component_of_wind (time, lat, lon) float32 3.221 3.105 ... -2.549
\n | \n | \n | \n | PRCP | \nTAVG | \n
---|---|---|---|---|---|
time | \nlat | \nlon | \nstation | \n\n | \n |
2015-06-25 | \n35.017 | \n-1.450 | \nAGM00060531 | \n0.0 | \n23.0 | \n
35.100 | \n-1.850 | \nAGE00147716 | \n0.0 | \n23.4 | \n|
35.117 | \n36.750 | \nSYM00040030 | \nNaN | \n25.4 | \n|
35.167 | \n2.317 | \nAGM00060514 | \n0.0 | \n25.9 | \n|
35.200 | \n-0.617 | \nAGM00060520 | \n0.0 | \n24.9 | \n|
... | \n... | \n... | \n... | \n... | \n... | \n
2015-06-30 | \n45.933 | \n7.700 | \nITM00016052 | \nNaN | \n5.7 | \n
38.367 | \n-0.500 | \nSPM00008359 | \n0.0 | \n27.6 | \n|
55.383 | \n36.700 | \nRSM00027611 | \n0.0 | \n17.2 | \n|
59.080 | \n17.860 | \nSWE00138750 | \n0.0 | \nNaN | \n|
63.760 | \n12.430 | \nSWE00140158 | \n0.6 | \nNaN | \n
16922 rows × 2 columns
\n<xarray.Dataset>\n", + "Dimensions: (time: 1, lat: 25, lon: 53)\n", + "Coordinates:\n", + " * lat (lat) float32 75.0 72.5 70.0 67.5 65.0 ... 25.0 22.5 20.0 17.5 15.0\n", + " * lon (lon) float32 200.0 202.5 205.0 207.5 ... 322.5 325.0 327.5 330.0\n", + " * time (time) datetime64[ns] 2014-01-01\n", + "Data variables:\n", + " mean (time, lat, lon) float32 275.1 275.1 275.1 ... 275.1 275.1 275.1\n", + " std (time, lat, lon) float32 1.631 1.631 1.631 ... 1.631 1.631 1.631
<xarray.Dataset>\nDimensions: (time: 1, lat: 482, lon: 802)\nCoordinates:\n * lat (lat) float64 75.0 74.88 74.75 74.63 ... 15.37 15.25 15.12 15.0\n * lon (lon) float64 -160.0 -159.9 -159.8 -159.6 ... -60.25 -60.12 -60.0\n * time (time) datetime64[ns] 2019-06-25\nData variables:\n mean (time, lat, lon) float32 275.0 275.2 275.1 ... 300.9 300.9 301.1\n std (time, lat, lon) float32 1.811 1.665 1.554 ... 0.6224 0.629 0.6557
\n | \n | \n | mean | \nstd | \n
---|---|---|---|---|
time | \nlat | \nlon | \n\n | \n |
2019-06-01 | \n50 | \n-80 | \n280.406281 | \n1.834735 | \n
40 | \n-110 | \n290.741547 | \n2.129284 | \n|
2019-06-02 | \n50 | \n-80 | \n282.370087 | \n1.753442 | \n
40 | \n-110 | \n292.015839 | \n1.990584 | \n|
2019-06-03 | \n50 | \n-80 | \n281.934479 | \n1.701114 | \n
... | \n... | \n... | \n... | \n... | \n
2019-12-29 | \n40 | \n-110 | \n261.715698 | \n3.435812 | \n
2019-12-30 | \n50 | \n-80 | \n263.644775 | \n2.347633 | \n
40 | \n-110 | \n261.7883 | \n3.48374 | \n|
2019-12-31 | \n50 | \n-80 | \n267.722748 | \n1.995918 | \n
40 | \n-110 | \n262.06546 | \n3.490994 | \n
428 rows × 2 columns
\n<xarray.Dataset>\nDimensions: (time: 1, lat: 241, lon: 401)\nCoordinates:\n * lat (lat) float32 75.0 74.75 74.5 74.25 74.0 ... 15.75 15.5 15.25 15.0\n * lon (lon) float32 -160.0 -159.8 -159.5 -159.2 ... -60.5 -60.25 -60.0\n * time (time) datetime64[ns] 2019-06-25\nData variables:\n mean (time, lat, lon) float32 275.0 275.1 274.4 ... 301.0 300.9 301.1\n std (time, lat, lon) float32 1.811 1.553 1.384 ... 0.6224 0.6557\n sample_0 (time, lat, lon) float32 275.8 274.9 273.8 ... 302.4 302.7 303.6\n sample_1 (time, lat, lon) float32 274.5 273.8 272.9 ... 302.5 302.8 303.7\n sample_2 (time, lat, lon) float32 276.8 275.8 274.5 ... 302.5 302.7 303.7
Short
+ */ + .o-tooltip--left { + position: relative; + } + + .o-tooltip--left:after { + opacity: 0; + visibility: hidden; + position: absolute; + content: attr(data-tooltip); + padding: .2em; + font-size: .8em; + left: -.2em; + background: grey; + color: white; + white-space: nowrap; + z-index: 2; + border-radius: 2px; + transform: translateX(-102%) translateY(0); + transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1), transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1); +} + +.o-tooltip--left:hover:after { + display: block; + opacity: 1; + visibility: visible; + transform: translateX(-100%) translateY(0); + transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1), transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1); + transition-delay: .5s; +} + +/* By default the copy button shouldn't show up when printing a page */ +@media print { + button.copybtn { + display: none; + } +} diff --git a/_static/copybutton.js b/_static/copybutton.js new file mode 100644 index 00000000..10485a9d --- /dev/null +++ b/_static/copybutton.js @@ -0,0 +1,248 @@ +// Localization support +const messages = { + 'en': { + 'copy': 'Copy', + 'copy_to_clipboard': 'Copy to clipboard', + 'copy_success': 'Copied!', + 'copy_failure': 'Failed to copy', + }, + 'es' : { + 'copy': 'Copiar', + 'copy_to_clipboard': 'Copiar al portapapeles', + 'copy_success': '¡Copiado!', + 'copy_failure': 'Error al copiar', + }, + 'de' : { + 'copy': 'Kopieren', + 'copy_to_clipboard': 'In die Zwischenablage kopieren', + 'copy_success': 'Kopiert!', + 'copy_failure': 'Fehler beim Kopieren', + }, + 'fr' : { + 'copy': 'Copier', + 'copy_to_clipboard': 'Copier dans le presse-papier', + 'copy_success': 'Copié !', + 'copy_failure': 'Échec de la copie', + }, + 'ru': { + 'copy': 'Скопировать', + 'copy_to_clipboard': 'Скопировать в буфер', + 'copy_success': 'Скопировано!', + 'copy_failure': 'Не удалось скопировать', + }, + 'zh-CN': { + 'copy': '复制', + 'copy_to_clipboard': '复制到剪贴板', + 'copy_success': '复制成功!', + 'copy_failure': '复制失败', + }, + 'it' : { + 'copy': 'Copiare', + 'copy_to_clipboard': 'Copiato negli appunti', + 'copy_success': 'Copiato!', + 'copy_failure': 'Errore durante la copia', + } +} + +let locale = 'en' +if( document.documentElement.lang !== undefined + && messages[document.documentElement.lang] !== undefined ) { + locale = document.documentElement.lang +} + +let doc_url_root = DOCUMENTATION_OPTIONS.URL_ROOT; +if (doc_url_root == '#') { + doc_url_root = ''; +} + +/** + * SVG files for our copy buttons + */ +let iconCheck = `` + +// If the user specified their own SVG use that, otherwise use the default +let iconCopy = ``; +if (!iconCopy) { + iconCopy = `` +} + +/** + * Set up copy/paste for code blocks + */ + +const runWhenDOMLoaded = cb => { + if (document.readyState != 'loading') { + cb() + } else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', cb) + } else { + document.attachEvent('onreadystatechange', function() { + if (document.readyState == 'complete') cb() + }) + } +} + +const codeCellId = index => `codecell${index}` + +// Clears selected text since ClipboardJS will select the text when copying +const clearSelection = () => { + if (window.getSelection) { + window.getSelection().removeAllRanges() + } else if (document.selection) { + document.selection.empty() + } +} + +// Changes tooltip text for a moment, then changes it back +// We want the timeout of our `success` class to be a bit shorter than the +// tooltip and icon change, so that we can hide the icon before changing back. +var timeoutIcon = 2000; +var timeoutSuccessClass = 1500; + +const temporarilyChangeTooltip = (el, oldText, newText) => { + el.setAttribute('data-tooltip', newText) + el.classList.add('success') + // Remove success a little bit sooner than we change the tooltip + // So that we can use CSS to hide the copybutton first + setTimeout(() => el.classList.remove('success'), timeoutSuccessClass) + setTimeout(() => el.setAttribute('data-tooltip', oldText), timeoutIcon) +} + +// Changes the copy button icon for two seconds, then changes it back +const temporarilyChangeIcon = (el) => { + el.innerHTML = iconCheck; + setTimeout(() => {el.innerHTML = iconCopy}, timeoutIcon) +} + +const addCopyButtonToCodeCells = () => { + // If ClipboardJS hasn't loaded, wait a bit and try again. This + // happens because we load ClipboardJS asynchronously. + if (window.ClipboardJS === undefined) { + setTimeout(addCopyButtonToCodeCells, 250) + return + } + + // Add copybuttons to all of our code cells + const COPYBUTTON_SELECTOR = 'div.highlight pre'; + const codeCells = document.querySelectorAll(COPYBUTTON_SELECTOR) + codeCells.forEach((codeCell, index) => { + const id = codeCellId(index) + codeCell.setAttribute('id', id) + + const clipboardButton = id => + `` + codeCell.insertAdjacentHTML('afterend', clipboardButton(id)) + }) + +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string +} + +/** + * Removes excluded text from a Node. + * + * @param {Node} target Node to filter. + * @param {string} exclude CSS selector of nodes to exclude. + * @returns {DOMString} Text from `target` with text removed. + */ +function filterText(target, exclude) { + const clone = target.cloneNode(true); // clone as to not modify the live DOM + if (exclude) { + // remove excluded nodes + clone.querySelectorAll(exclude).forEach(node => node.remove()); + } + return clone.innerText; +} + +// Callback when a copy button is clicked. Will be passed the node that was clicked +// should then grab the text and replace pieces of text that shouldn't be used in output +function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onlyCopyPromptLines = true, removePrompts = true, copyEmptyLines = true, lineContinuationChar = "", hereDocDelim = "") { + var regexp; + var match; + + // Do we check for line continuation characters and "HERE-documents"? + var useLineCont = !!lineContinuationChar + var useHereDoc = !!hereDocDelim + + // create regexp to capture prompt and remaining line + if (isRegexp) { + regexp = new RegExp('^(' + copybuttonPromptText + ')(.*)') + } else { + regexp = new RegExp('^(' + escapeRegExp(copybuttonPromptText) + ')(.*)') + } + + const outputLines = []; + var promptFound = false; + var gotLineCont = false; + var gotHereDoc = false; + const lineGotPrompt = []; + for (const line of textContent.split('\n')) { + match = line.match(regexp) + if (match || gotLineCont || gotHereDoc) { + promptFound = regexp.test(line) + lineGotPrompt.push(promptFound) + if (removePrompts && promptFound) { + outputLines.push(match[2]) + } else { + outputLines.push(line) + } + gotLineCont = line.endsWith(lineContinuationChar) & useLineCont + if (line.includes(hereDocDelim) & useHereDoc) + gotHereDoc = !gotHereDoc + } else if (!onlyCopyPromptLines) { + outputLines.push(line) + } else if (copyEmptyLines && line.trim() === '') { + outputLines.push(line) + } + } + + // If no lines with the prompt were found then just use original lines + if (lineGotPrompt.some(v => v === true)) { + textContent = outputLines.join('\n'); + } + + // Remove a trailing newline to avoid auto-running when pasting + if (textContent.endsWith("\n")) { + textContent = textContent.slice(0, -1) + } + return textContent +} + + +var copyTargetText = (trigger) => { + var target = document.querySelector(trigger.attributes['data-clipboard-target'].value); + + // get filtered text + let exclude = '.linenos'; + + let text = filterText(target, exclude); + return formatCopyText(text, '$', false, true, true, true, '', '') +} + + // Initialize with a callback so we can modify the text before copy + const clipboard = new ClipboardJS('.copybtn', {text: copyTargetText}) + + // Update UI with error/success messages + clipboard.on('success', event => { + clearSelection() + temporarilyChangeTooltip(event.trigger, messages[locale]['copy'], messages[locale]['copy_success']) + temporarilyChangeIcon(event.trigger) + }) + + clipboard.on('error', event => { + temporarilyChangeTooltip(event.trigger, messages[locale]['copy'], messages[locale]['copy_failure']) + }) +} + +runWhenDOMLoaded(addCopyButtonToCodeCells) \ No newline at end of file diff --git a/_static/copybutton_funcs.js b/_static/copybutton_funcs.js new file mode 100644 index 00000000..dbe1aaad --- /dev/null +++ b/_static/copybutton_funcs.js @@ -0,0 +1,73 @@ +function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string +} + +/** + * Removes excluded text from a Node. + * + * @param {Node} target Node to filter. + * @param {string} exclude CSS selector of nodes to exclude. + * @returns {DOMString} Text from `target` with text removed. + */ +export function filterText(target, exclude) { + const clone = target.cloneNode(true); // clone as to not modify the live DOM + if (exclude) { + // remove excluded nodes + clone.querySelectorAll(exclude).forEach(node => node.remove()); + } + return clone.innerText; +} + +// Callback when a copy button is clicked. Will be passed the node that was clicked +// should then grab the text and replace pieces of text that shouldn't be used in output +export function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onlyCopyPromptLines = true, removePrompts = true, copyEmptyLines = true, lineContinuationChar = "", hereDocDelim = "") { + var regexp; + var match; + + // Do we check for line continuation characters and "HERE-documents"? + var useLineCont = !!lineContinuationChar + var useHereDoc = !!hereDocDelim + + // create regexp to capture prompt and remaining line + if (isRegexp) { + regexp = new RegExp('^(' + copybuttonPromptText + ')(.*)') + } else { + regexp = new RegExp('^(' + escapeRegExp(copybuttonPromptText) + ')(.*)') + } + + const outputLines = []; + var promptFound = false; + var gotLineCont = false; + var gotHereDoc = false; + const lineGotPrompt = []; + for (const line of textContent.split('\n')) { + match = line.match(regexp) + if (match || gotLineCont || gotHereDoc) { + promptFound = regexp.test(line) + lineGotPrompt.push(promptFound) + if (removePrompts && promptFound) { + outputLines.push(match[2]) + } else { + outputLines.push(line) + } + gotLineCont = line.endsWith(lineContinuationChar) & useLineCont + if (line.includes(hereDocDelim) & useHereDoc) + gotHereDoc = !gotHereDoc + } else if (!onlyCopyPromptLines) { + outputLines.push(line) + } else if (copyEmptyLines && line.trim() === '') { + outputLines.push(line) + } + } + + // If no lines with the prompt were found then just use original lines + if (lineGotPrompt.some(v => v === true)) { + textContent = outputLines.join('\n'); + } + + // Remove a trailing newline to avoid auto-running when pasting + if (textContent.endsWith("\n")) { + textContent = textContent.slice(0, -1) + } + return textContent +} diff --git a/_static/design-tabs.js b/_static/design-tabs.js new file mode 100644 index 00000000..b25bd6a4 --- /dev/null +++ b/_static/design-tabs.js @@ -0,0 +1,101 @@ +// @ts-check + +// Extra JS capability for selected tabs to be synced +// The selection is stored in local storage so that it persists across page loads. + +/** + * @type {Record