From b10c6171cf27feefe33e5bebe02b81ba1d56fad8 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 13:42:32 -0400 Subject: [PATCH 01/14] added map --- docs/source/_static/map.html | 273 +++++++++++++++++++++++++ docs/source/festim_map.ipynb | 380 +++++++++++++++++++++++++++++++++++ docs/source/index.rst | 4 + 3 files changed, 657 insertions(+) create mode 100644 docs/source/_static/map.html create mode 100644 docs/source/festim_map.ipynb diff --git a/docs/source/_static/map.html b/docs/source/_static/map.html new file mode 100644 index 000000000..0d1dc6aec --- /dev/null +++ b/docs/source/_static/map.html @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/docs/source/festim_map.ipynb b/docs/source/festim_map.ipynb new file mode 100644 index 000000000..706b7c8e2 --- /dev/null +++ b/docs/source/festim_map.ipynb @@ -0,0 +1,380 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import json\n", + "from folium.plugins import MarkerCluster\n", + "import folium\n", + "\n", + "import requests\n", + "from PIL import Image\n", + "from io import BytesIO\n", + "\n", + "LOGO_HEIGHT = 80\n", + "\n", + "# Function to get the dimensions of an image from URL\n", + "def get_image_dimensions_from_url(image_url):\n", + " try:\n", + " response = requests.get(image_url)\n", + " response.raise_for_status() # Raise an exception for HTTP errors\n", + " img = Image.open(BytesIO(response.content))\n", + " return img.size\n", + " except Exception as e:\n", + " print(f\"Error fetching or processing image: {e}\")\n", + " return None\n", + "\n", + "\n", + "# Load GeoJSON data\n", + "with open('map.json') as f:\n", + " data = json.load(f)\n", + "\n", + "# Create a map centered on a specific location\n", + "m = folium.Map(location=[42, -71], zoom_start=5, tiles='cartodbpositron')\n", + "marker_cluster = MarkerCluster().add_to(m)\n", + "# Iterate over features in the GeoJSON data\n", + "for feature in data['features']:\n", + " name = feature['properties']['name']\n", + " url = feature['properties']['url']\n", + " if url == \"URL_PLACEHOLDER\":\n", + " url = \"https://upload.wikimedia.org/wikipedia/commons/9/92/LOGO_CEA_ORIGINAL.svg\"\n", + " coordinates = feature['geometry']['coordinates']\n", + " \n", + " # Get the dimensions of the image from URL\n", + " image_dimensions = get_image_dimensions_from_url(url)\n", + " if image_dimensions:\n", + " height_to_width_ratio = image_dimensions[1] / image_dimensions[0]\n", + " image_dimensions = (int(LOGO_HEIGHT / height_to_width_ratio), LOGO_HEIGHT)\n", + " else:\n", + " image_dimensions = (LOGO_HEIGHT, LOGO_HEIGHT)\n", + " # Create a marker with a custom icon and popup\n", + " if coordinates != [0, 0]:\n", + " icon = folium.CustomIcon(url, icon_size=image_dimensions)\n", + " folium.Marker(\n", + " location=[coordinates[1], coordinates[0]],\n", + " icon=icon,\n", + " ).add_to(marker_cluster)\n", + " else:\n", + " print(\"no coordinates for\", name)\n", + "m.save('map.html')\n", + "m" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "map-env", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/source/index.rst b/docs/source/index.rst index a9dde2011..1026c75f7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -23,6 +23,10 @@ For more information, feel free to ask questions on the `FESTIM Discourse Page < "`FESTIM: An open-source code for hydrogen transport simulations. International Journal of Hydrogen Energy 63 (2024): 786-802. `_", + +.. raw:: html + :file: _static/map.html + -------- Contents -------- From 36bb648f474ae5c5d8c299a1a65a5921e35c4dad Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 13:43:45 -0400 Subject: [PATCH 02/14] add geojson file --- docs/source/map.json | 271 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 docs/source/map.json diff --git a/docs/source/map.json b/docs/source/map.json new file mode 100644 index 000000000..a033c4cb7 --- /dev/null +++ b/docs/source/map.json @@ -0,0 +1,271 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 5.7843, + 43.7254 + ] + }, + "properties": { + "name": "IRFM cadarache France", + "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/LOGO_CEA_ORIGINAL.svg/768px-LOGO_CEA_ORIGINAL.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 2.3458, + 48.9583 + ] + }, + "properties": { + "name": "LSPM Villetaneuse France", + "url": "https://upload.wikimedia.org/wikipedia/en/thumb/2/2c/CNRS.svg/316px-CNRS.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -71.0921, + 42.3601 + ] + }, + "properties": { + "name": "MIT Cambridge, MA USA", + "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/MIT_logo.svg/321px-MIT_logo.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -74.6596903, + 40.35006468849364 + ] + }, + "properties": { + "name": "Thea Energy USA", + "url": "https://media.licdn.com/dms/image/sync/D4E27AQEtSPdhh29Xiw/articleshare-shrink_800/0/1711995007077?e=1714071600&v=beta&t=l2mnifsctT8XWseYQSfPIyzRpwsAYVgq5j-FOWejeyY" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -71.6152, + 42.5406 + ] + }, + "properties": { + "name": "Commonwealth Fusion Systems Devens, MA USA", + "url": "https://api-kla-prod.2ambh.com/v1/images/10348/thumb/w950" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -89.4012, + 43.0761 + ] + }, + "properties": { + "name": "University Wisconsin Madison USA", + "url": "https://brand.wisc.edu/content/uploads/2023/09/vert-w-crest-logo-web-digital-color.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -122.41135340346865, + 37.77479335835942 + ] + }, + "properties": { + "name": "Marathon Fusion USA", + "url": "https://media.licdn.com/dms/image/D560BAQFyuUtXrkDBGg/company-logo_200_200/0/1707489994810/marathon_fusion_logo?e=1721865600&v=beta&t=HoM15_eB3GxED9wJ_21j057IVLQaFfU--iGjbBOpK4U" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -117.1611, + 32.7157 + ] + }, + "properties": { + "name": "University San Diego", + "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Seal_of_the_University_of_California%2C_San_Diego.svg/1920px-Seal_of_the_University_of_California%2C_San_Diego.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 37.5314, + 55.8260 + ] + }, + "properties": { + "name": "MEPhI moscow Russia", + "url": "https://cdn.freelogovectors.net/wp-content/uploads/2021/04/national-research-nuclear-university-logo-freelogovectors.net_.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 5.0266, + 43.5455 + ] + }, + "properties": { + "name": "ITER organization France", + "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/ITER_Logo_NoonYellow.svg/500px-ITER_Logo_NoonYellow.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -1.229138717146069, + 51.65868576158049 + ] + }, + "properties": { + "name": "UKAEA UK", + "url": "https://upload.wikimedia.org/wikipedia/en/thumb/9/95/UK_Atomic_Energy_Authority_logo.svg/1920px-UK_Atomic_Energy_Authority_logo.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -3.530686738097156, + 50.719235968686455 + ] + }, + "properties": { + "name": "digiLab UK", + "url": "https://creativedestructionlab.com/wp-content/uploads/2023/05/digilab-logo.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -0.4269, + 52.0720 + ] + }, + "properties": { + "name": "cranfield University UK", + "url": "https://resiliencefirst.org/sites/default/files/2022-02/cranfield-university-vector-logo-small.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 7.6818, + 45.0703 + ] + }, + "properties": { + "name": "Politecnico di Torino", + "url": "https://upload.wikimedia.org/wikipedia/it/thumb/4/47/Logo_PoliTo_dal_2021_blu.png/2880px-Logo_PoliTo_dal_2021_blu.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 116.3056, + 39.9923 + ] + }, + "properties": { + "name": "University of Beijing", + "url": "https://upload.wikimedia.org/wikipedia/en/thumb/f/f4/Beihang_University_logo.svg/1920px-Beihang_University_logo.svg.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 117.2703, + 31.8669 + ] + }, + "properties": { + "name": "University of Hefei China", + "url": "https://media.licdn.com/dms/image/C510BAQFbUnIQqa62aA/company-logo_200_200/0/1630599485875/caships_logo?e=1721865600&v=beta&t=wKPCqctsafbewtZpD0Mk1snTab681zYrQaRoSTSZzBI" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 14.487728061376515, + 46.043586411058726 + ] + }, + "properties": { + "name": "Institut Jožef Stefan", + "url": "https://www.concordia-h2020.eu/wp-content/uploads/2019/02/IJS_logo.jpg" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 139.76446527724698, + 35.68673663876397 + ] + }, + "properties": { + "name": "Kyoto Fusioneering", + "url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSEBUXW9DSGrDVhY80Fr6--hOywnBUnAwsb4ZTc9_2liw&s" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.455144726473035, + 41.818823289415484 + ] + }, + "properties": { + "name": "ENI", + "url": "https://upload.wikimedia.org/wikipedia/en/thumb/b/b2/Eni_new_logo.svg/320px-Eni_new_logo.svg.png" + } + } + ] +} \ No newline at end of file From 6aa73f21462996c1b0d25d842d75f030e74bd548 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 13:51:13 -0400 Subject: [PATCH 03/14] changed syntax --- docs/source/index.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 1026c75f7..c00d62c57 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,7 +25,9 @@ For more information, feel free to ask questions on the `FESTIM Discourse Page < .. raw:: html - :file: _static/map.html + + + -------- Contents From 0f63b39316973f09e2a8eb394482e18734852761 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:17:06 -0400 Subject: [PATCH 04/14] generate map on the fly --- docs/environment.yml | 2 + docs/source/_static/map.html | 273 ------------------------- docs/source/conf.py | 14 ++ docs/source/festim_map.ipynb | 380 ----------------------------------- docs/source/map.py | 64 ++++++ 5 files changed, 80 insertions(+), 653 deletions(-) delete mode 100644 docs/source/_static/map.html delete mode 100644 docs/source/festim_map.ipynb create mode 100644 docs/source/map.py diff --git a/docs/environment.yml b/docs/environment.yml index e5128ed39..42892d354 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -7,9 +7,11 @@ dependencies: - matplotlib==3.7.1 - pip>=20.1 - sphinx==7 + - folium - pip: - sympy - sphinx_book_theme==1.1.0rc1 - sphinx-design==0.5.0 - sphinxcontrib-bibtex - sphinx-copybutton + - pillow diff --git a/docs/source/_static/map.html b/docs/source/_static/map.html deleted file mode 100644 index 0d1dc6aec..000000000 --- a/docs/source/_static/map.html +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 04deba793..4a1660385 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -88,3 +88,17 @@ } html_title = "FESTIM Documentation" + + +# Generate the map + +import os +import sys + +# Add the directory containing your Python script to the Python path +sys.path.insert(0, os.path.abspath(".")) + +import map + +m = map.generate_map() +m.save("_static/map.html") diff --git a/docs/source/festim_map.ipynb b/docs/source/festim_map.ipynb deleted file mode 100644 index 706b7c8e2..000000000 --- a/docs/source/festim_map.ipynb +++ /dev/null @@ -1,380 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
Make this Notebook Trusted to load map: File -> Trust Notebook
" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import json\n", - "from folium.plugins import MarkerCluster\n", - "import folium\n", - "\n", - "import requests\n", - "from PIL import Image\n", - "from io import BytesIO\n", - "\n", - "LOGO_HEIGHT = 80\n", - "\n", - "# Function to get the dimensions of an image from URL\n", - "def get_image_dimensions_from_url(image_url):\n", - " try:\n", - " response = requests.get(image_url)\n", - " response.raise_for_status() # Raise an exception for HTTP errors\n", - " img = Image.open(BytesIO(response.content))\n", - " return img.size\n", - " except Exception as e:\n", - " print(f\"Error fetching or processing image: {e}\")\n", - " return None\n", - "\n", - "\n", - "# Load GeoJSON data\n", - "with open('map.json') as f:\n", - " data = json.load(f)\n", - "\n", - "# Create a map centered on a specific location\n", - "m = folium.Map(location=[42, -71], zoom_start=5, tiles='cartodbpositron')\n", - "marker_cluster = MarkerCluster().add_to(m)\n", - "# Iterate over features in the GeoJSON data\n", - "for feature in data['features']:\n", - " name = feature['properties']['name']\n", - " url = feature['properties']['url']\n", - " if url == \"URL_PLACEHOLDER\":\n", - " url = \"https://upload.wikimedia.org/wikipedia/commons/9/92/LOGO_CEA_ORIGINAL.svg\"\n", - " coordinates = feature['geometry']['coordinates']\n", - " \n", - " # Get the dimensions of the image from URL\n", - " image_dimensions = get_image_dimensions_from_url(url)\n", - " if image_dimensions:\n", - " height_to_width_ratio = image_dimensions[1] / image_dimensions[0]\n", - " image_dimensions = (int(LOGO_HEIGHT / height_to_width_ratio), LOGO_HEIGHT)\n", - " else:\n", - " image_dimensions = (LOGO_HEIGHT, LOGO_HEIGHT)\n", - " # Create a marker with a custom icon and popup\n", - " if coordinates != [0, 0]:\n", - " icon = folium.CustomIcon(url, icon_size=image_dimensions)\n", - " folium.Marker(\n", - " location=[coordinates[1], coordinates[0]],\n", - " icon=icon,\n", - " ).add_to(marker_cluster)\n", - " else:\n", - " print(\"no coordinates for\", name)\n", - "m.save('map.html')\n", - "m" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "map-env", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/source/map.py b/docs/source/map.py new file mode 100644 index 000000000..aedcb1bf6 --- /dev/null +++ b/docs/source/map.py @@ -0,0 +1,64 @@ +import json +from folium.plugins import MarkerCluster +import folium + +import requests +from PIL import Image +from io import BytesIO + +LOGO_HEIGHT = 80 + + +def get_image_dimensions_from_url(image_url): + """Function to get the dimensions of an image from URL + + + Args: + image_url (str): the url + + Returns: + tuple: the dimensions of the image + """ + try: + response = requests.get(image_url) + response.raise_for_status() # Raise an exception for HTTP errors + img = Image.open(BytesIO(response.content)) + return img.size + except Exception as e: + print(f"Error fetching or processing image: {e}") + return None + + +def generate_map(): + # Load GeoJSON data + with open("map.json") as f: + data = json.load(f) + + # Create a map centered on a specific location + m = folium.Map(location=[42, -71], zoom_start=5, tiles="cartodbpositron") + marker_cluster = MarkerCluster().add_to(m) + # Iterate over features in the GeoJSON data + for feature in data["features"]: + name = feature["properties"]["name"] + url = feature["properties"]["url"] + if url == "URL_PLACEHOLDER": + url = "https://upload.wikimedia.org/wikipedia/commons/9/92/LOGO_CEA_ORIGINAL.svg" + coordinates = feature["geometry"]["coordinates"] + + # Get the dimensions of the image from URL + image_dimensions = get_image_dimensions_from_url(url) + if image_dimensions: + height_to_width_ratio = image_dimensions[1] / image_dimensions[0] + image_dimensions = (int(LOGO_HEIGHT / height_to_width_ratio), LOGO_HEIGHT) + else: + image_dimensions = (LOGO_HEIGHT, LOGO_HEIGHT) + # Create a marker with a custom icon and popup + if coordinates != [0, 0]: + icon = folium.CustomIcon(url, icon_size=image_dimensions) + folium.Marker( + location=[coordinates[1], coordinates[0]], + icon=icon, + ).add_to(marker_cluster) + else: + print("no coordinates for", name) + return m From 93bc2e8ec12f489ed716b51e9bfea12c966a2c7c Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:22:55 -0400 Subject: [PATCH 05/14] correct path --- docs/source/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4a1660385..bde3590f2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -101,4 +101,5 @@ import map m = map.generate_map() -m.save("_static/map.html") +current_dir = os.path.dirname(__file__) +m.save(os.path.join(current_dir, "_static", "map.html")) From aeee7cd0d809a759ee27fac43a2e102e5b3801a4 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:23:06 -0400 Subject: [PATCH 06/14] correct location for MEPHI --- docs/source/map.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/map.json b/docs/source/map.json index a033c4cb7..f307987d0 100644 --- a/docs/source/map.json +++ b/docs/source/map.json @@ -118,8 +118,8 @@ "geometry": { "type": "Point", "coordinates": [ - 37.5314, - 55.8260 + 37.6649462235042, + 55.66362336404334 ] }, "properties": { From 152a4f6782e10e6492e276c11665d6150391cab1 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:34:26 -0400 Subject: [PATCH 07/14] added headers to request --- docs/source/map.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/map.py b/docs/source/map.py index aedcb1bf6..49b4fffd7 100644 --- a/docs/source/map.py +++ b/docs/source/map.py @@ -19,8 +19,12 @@ def get_image_dimensions_from_url(image_url): Returns: tuple: the dimensions of the image """ + headers = { + "User-Agent": "FESTIM (https://github.com/festim-dev/festim; remidm@mit.edu)" + } + try: - response = requests.get(image_url) + response = requests.get(image_url, headers=headers) response.raise_for_status() # Raise an exception for HTTP errors img = Image.open(BytesIO(response.content)) return img.size From f3c7d397f9e0e8082d3a4da9b6871bda118c58d6 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:35:57 -0400 Subject: [PATCH 08/14] print path --- docs/source/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index bde3590f2..19a866a92 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -102,4 +102,6 @@ m = map.generate_map() current_dir = os.path.dirname(__file__) -m.save(os.path.join(current_dir, "_static", "map.html")) +html_path = os.path.join(current_dir, "_static", "map.html") +print(html_path) +m.save(html_path) From 682b275b507d707c0b6534fa618b3b9ba9247e93 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:45:39 -0400 Subject: [PATCH 09/14] create directory if it doesn't exist --- docs/source/conf.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 19a866a92..e60d3ac36 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,24 @@ sys.path.insert(0, os.path.abspath("../..")) + +# Generate the map + +# Add the directory containing your Python script to the Python path +sys.path.insert(0, os.path.abspath(".")) + +import map + +m = map.generate_map() +current_dir = os.path.dirname(__file__) +html_path = os.path.join(current_dir, "_static", "map.html") + +# create _static directory if it doesn't exist +if not os.path.exists(os.path.dirname(html_path)): + os.makedirs(os.path.dirname(html_path)) + +m.save(html_path) + # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -88,20 +106,3 @@ } html_title = "FESTIM Documentation" - - -# Generate the map - -import os -import sys - -# Add the directory containing your Python script to the Python path -sys.path.insert(0, os.path.abspath(".")) - -import map - -m = map.generate_map() -current_dir = os.path.dirname(__file__) -html_path = os.path.join(current_dir, "_static", "map.html") -print(html_path) -m.save(html_path) From c3fc53a83585ac71b2519c0e66a493d488b5fb3e Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:46:29 -0400 Subject: [PATCH 10/14] exist_ok --- docs/source/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index e60d3ac36..bee1b3009 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,8 +27,7 @@ html_path = os.path.join(current_dir, "_static", "map.html") # create _static directory if it doesn't exist -if not os.path.exists(os.path.dirname(html_path)): - os.makedirs(os.path.dirname(html_path)) +os.makedirs(os.path.dirname(html_path), exist_ok=True) m.save(html_path) From 8004559beb7239b4f5fe7260b42097803d375324 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 15:51:13 -0400 Subject: [PATCH 11/14] added ENEA --- docs/source/map.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/source/map.json b/docs/source/map.json index f307987d0..c21491597 100644 --- a/docs/source/map.json +++ b/docs/source/map.json @@ -266,6 +266,20 @@ "name": "ENI", "url": "https://upload.wikimedia.org/wikipedia/en/thumb/b/b2/Eni_new_logo.svg/320px-Eni_new_logo.svg.png" } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.670768074076161, + 41.83511773016589 + ] + }, + "properties": { + "name": "ENEA", + "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/ENEA_logo.svg/358px-ENEA_logo.svg.png" + } } ] } \ No newline at end of file From 5e026f12359be3fc4f20995c7b26ec164d37a78b Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 16:04:15 -0400 Subject: [PATCH 12/14] centre of map --- docs/source/map.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/map.py b/docs/source/map.py index 49b4fffd7..791137390 100644 --- a/docs/source/map.py +++ b/docs/source/map.py @@ -39,7 +39,12 @@ def generate_map(): data = json.load(f) # Create a map centered on a specific location - m = folium.Map(location=[42, -71], zoom_start=5, tiles="cartodbpositron") + m = folium.Map( + location=[42.256349987281666, -37.61204625889672], + zoom_start=3, + tiles="cartodbpositron", + ) + marker_cluster = MarkerCluster().add_to(m) # Iterate over features in the GeoJSON data for feature in data["features"]: From a718eb4c82c45b3f6dfdbc1911d8564cdd82fb9b Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 16:04:22 -0400 Subject: [PATCH 13/14] added note + title --- docs/source/index.rst | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index c00d62c57..bf5a01d8f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -23,24 +23,14 @@ For more information, feel free to ask questions on the `FESTIM Discourse Page < "`FESTIM: An open-source code for hydrogen transport simulations. International Journal of Hydrogen Energy 63 (2024): 786-802. `_", +Map of FESTIM users +------------------- .. raw:: html --------- -Contents --------- - -.. toctree:: - :maxdepth: 1 - - installation - examples - theory - userguide/index - devguide/index - api/festim - publications +.. admonition:: Add your institution + If you would like your institution to be added to this map, please `open an issue `_. \ No newline at end of file From 07350e9ebe89f2daf67c476afcdfb5d51800a7b4 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 19 Apr 2024 16:53:29 -0400 Subject: [PATCH 14/14] we need the toctree --- docs/source/index.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index bf5a01d8f..423e5240a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -33,4 +33,20 @@ Map of FESTIM users .. admonition:: Add your institution - If you would like your institution to be added to this map, please `open an issue `_. \ No newline at end of file + If you would like your institution to be added to this map, please `open an issue `_. + + +-------- +Contents +-------- + +.. toctree:: + :maxdepth: 1 + + installation + examples + theory + userguide/index + devguide/index + api/festim + publications \ No newline at end of file