pyphyschemtools 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. pyphyschemtools/Chem3D.py +831 -0
  2. pyphyschemtools/ML.py +42 -0
  3. pyphyschemtools/PeriodicTable.py +289 -0
  4. pyphyschemtools/__init__.py +43 -0
  5. pyphyschemtools/aithermo.py +350 -0
  6. pyphyschemtools/cheminformatics.py +230 -0
  7. pyphyschemtools/core.py +119 -0
  8. pyphyschemtools/icons-logos-banner/Logo_pyPhysChem_border.svg +1109 -0
  9. pyphyschemtools/icons-logos-banner/__init__.py +0 -0
  10. pyphyschemtools/icons-logos-banner/logo.png +0 -0
  11. pyphyschemtools/icons-logos-banner/tools4pyPC_banner.png +0 -0
  12. pyphyschemtools/icons-logos-banner/tools4pyPC_banner.svg +193 -0
  13. pyphyschemtools/kinetics.py +193 -0
  14. pyphyschemtools/resources/css/BrainHalfHalf-120x139.base64 +1 -0
  15. pyphyschemtools/resources/css/BrainHalfHalf-120x139.png +0 -0
  16. pyphyschemtools/resources/css/BrainHalfHalf.base64 +8231 -0
  17. pyphyschemtools/resources/css/BrainHalfHalf.png +0 -0
  18. pyphyschemtools/resources/css/BrainHalfHalf.svg +289 -0
  19. pyphyschemtools/resources/css/visualID.css +325 -0
  20. pyphyschemtools/resources/img/Tranformative_3.webp +0 -0
  21. pyphyschemtools/resources/img/Tranformative_3_banner.png +0 -0
  22. pyphyschemtools/resources/img/pyPhysChem_1.png +0 -0
  23. pyphyschemtools/resources/svg/BrainHalfHalf.png +0 -0
  24. pyphyschemtools/resources/svg/BrainHalfHalf.svg +289 -0
  25. pyphyschemtools/resources/svg/GitHub-Logo-C.png +0 -0
  26. pyphyschemtools/resources/svg/GitHub-Logo.png +0 -0
  27. pyphyschemtools/resources/svg/Logo-Universite-Toulouse-n-2023.png +0 -0
  28. pyphyschemtools/resources/svg/Logo_pyPhysChem_1-translucentBgd-woName.png +0 -0
  29. pyphyschemtools/resources/svg/Logo_pyPhysChem_1-translucentBgd.png +0 -0
  30. pyphyschemtools/resources/svg/Logo_pyPhysChem_1.png +0 -0
  31. pyphyschemtools/resources/svg/Logo_pyPhysChem_1.svg +622 -0
  32. pyphyschemtools/resources/svg/Logo_pyPhysChem_5.png +0 -0
  33. pyphyschemtools/resources/svg/Logo_pyPhysChem_5.svg +48 -0
  34. pyphyschemtools/resources/svg/Logo_pyPhysChem_border.svg +1109 -0
  35. pyphyschemtools/resources/svg/Python-logo-notext.svg +265 -0
  36. pyphyschemtools/resources/svg/Python_logo_and_wordmark.svg.png +0 -0
  37. pyphyschemtools/resources/svg/UT3_logoQ.jpg +0 -0
  38. pyphyschemtools/resources/svg/UT3_logoQ.png +0 -0
  39. pyphyschemtools/resources/svg/Universite-Toulouse-n-2023.svg +141 -0
  40. pyphyschemtools/resources/svg/X.png +0 -0
  41. pyphyschemtools/resources/svg/logoAnaconda.png +0 -0
  42. pyphyschemtools/resources/svg/logoAnaconda.webp +0 -0
  43. pyphyschemtools/resources/svg/logoCNRS.png +0 -0
  44. pyphyschemtools/resources/svg/logoDebut.svg +316 -0
  45. pyphyschemtools/resources/svg/logoEnd.svg +172 -0
  46. pyphyschemtools/resources/svg/logoFin.svg +172 -0
  47. pyphyschemtools/resources/svg/logoPPCL.svg +359 -0
  48. pyphyschemtools/resources/svg/logoPytChem.png +0 -0
  49. pyphyschemtools/resources/svg/logo_lpcno_300_dpi_notexttransparent.png +0 -0
  50. pyphyschemtools/resources/svg/logo_pyPhysChem.png +0 -0
  51. pyphyschemtools/resources/svg/logo_pyPhysChem_0.png +0 -0
  52. pyphyschemtools/resources/svg/logo_pyPhysChem_0.svg +390 -0
  53. pyphyschemtools/resources/svg/logopyPhyschem.png +0 -0
  54. pyphyschemtools/resources/svg/logopyPhyschem_2.webp +0 -0
  55. pyphyschemtools/resources/svg/logopyPhyschem_3.webp +0 -0
  56. pyphyschemtools/resources/svg/logopyPhyschem_4.webp +0 -0
  57. pyphyschemtools/resources/svg/logopyPhyschem_5.png +0 -0
  58. pyphyschemtools/resources/svg/logopyPhyschem_5.webp +0 -0
  59. pyphyschemtools/resources/svg/logopyPhyschem_6.webp +0 -0
  60. pyphyschemtools/resources/svg/logopyPhyschem_7.webp +0 -0
  61. pyphyschemtools/resources/svg/logos-Anaconda-pyPhysChem.png +0 -0
  62. pyphyschemtools/resources/svg/logos-Anaconda-pyPhysChem.svg +58 -0
  63. pyphyschemtools/resources/svg/pyPCBanner.svg +309 -0
  64. pyphyschemtools/resources/svg/pyPhysChem-GitHubSocialMediaTemplate.png +0 -0
  65. pyphyschemtools/resources/svg/pyPhysChem-GitHubSocialMediaTemplate.svg +295 -0
  66. pyphyschemtools/resources/svg/pyPhysChemBanner.png +0 -0
  67. pyphyschemtools/resources/svg/pyPhysChemBanner.svg +639 -0
  68. pyphyschemtools/resources/svg/qrcode-pyPhysChem.png +0 -0
  69. pyphyschemtools/resources/svg/repository-open-graph-template.png +0 -0
  70. pyphyschemtools/spectra.py +451 -0
  71. pyphyschemtools/survey.py +1048 -0
  72. pyphyschemtools/sympyUtilities.py +51 -0
  73. pyphyschemtools/tools4AS.py +960 -0
  74. pyphyschemtools/visualID.py +101 -0
  75. pyphyschemtools/visualID_Eng.py +175 -0
  76. pyphyschemtools-0.1.0.dist-info/METADATA +38 -0
  77. pyphyschemtools-0.1.0.dist-info/RECORD +80 -0
  78. pyphyschemtools-0.1.0.dist-info/WHEEL +5 -0
  79. pyphyschemtools-0.1.0.dist-info/licenses/LICENSE +674 -0
  80. pyphyschemtools-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,119 @@
1
+ ############################################################
2
+ # Text Utilities
3
+ ############################################################
4
+ from .visualID_Eng import fg, bg, hl
5
+
6
+ def centerTitle(content=None):
7
+ '''
8
+ centers and renders as HTML a text in the notebook
9
+ font size = 16px, background color = dark grey, foreground color = white
10
+ '''
11
+ from IPython.display import display, HTML
12
+ display(HTML(f"<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>{content}</div>"))
13
+
14
+
15
+ def centertxt(content=None,font='sans', size=12,weight="normal",bgc="#000000",fgc="#ffffff"):
16
+ '''
17
+ centers and renders as HTML a text in the notebook
18
+ input:
19
+ - content = the text to render (default: None)
20
+ - font = font family (default: 'sans', values allowed = 'sans-serif' | 'serif' | 'monospace' | 'cursive' | 'fantasy' | ...)
21
+ - size = font size (default: 12)
22
+ - weight = font weight (default: 'normal', values allowed = 'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 )
23
+ - bgc = background color (name or hex code, default = '#ffffff')
24
+ - fgc = foreground color (name or hex code, default = '#000000')
25
+ '''
26
+ from IPython.display import display, HTML
27
+ display(HTML(f"<div style='text-align:center; font-family: {font}; font-weight: {weight}; font-size:{size}px;background-color: {bgc};color: {fgc}'>{content}</div>"))
28
+
29
+
30
+ def smart_trim(img):
31
+ """
32
+ Determines the bounding box of the meaningful content in an image.
33
+
34
+ This function automatically detects if the image has transparency (Alpha channel).
35
+ If it does, it calculates the bounding box based on non-transparent pixels.
36
+ If the image is opaque, it assumes a white background and calculates the
37
+ bounding box by detecting differences from a pure white canvas.
38
+
39
+ Args:
40
+ img (PIL.Image.Image): The source image object.
41
+
42
+ Returns:
43
+ tuple: A 4-tuple (left, upper, right, lower) defining the crop box,
44
+ or None if the image is uniform/empty.
45
+ """
46
+ import sys
47
+ from pathlib import Path
48
+ from PIL import Image, ImageOps
49
+
50
+ if img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info):
51
+ return img.getbbox()
52
+ else:
53
+ bg = Image.new("RGB", img.size, (255, 255, 255))
54
+ diff = ImageOps.difference(img.convert("RGB"), bg)
55
+ return diff.getbbox()
56
+
57
+ def crop_images(input_files, process_folder=False):
58
+ """
59
+ Trims whitespace or transparency from image files and saves the results.
60
+
61
+ If process_folder is True, input_files is treated as a directory path,
62
+ and all images within (excluding those ending in -C) are processed.
63
+ Otherwise, input_files is treated as a single file path or a list of paths.
64
+
65
+ The function preserves original image metadata (DPI, ICC profiles).
66
+
67
+ Args:
68
+ input_files (str, Path, or list): File path(s) or a directory path.
69
+ process_folder (bool): If True, treats input_files as a directory to crawl.
70
+
71
+ Returns:
72
+ None: Prints status messages to the console for each file processed.
73
+ """
74
+ import sys
75
+ from pathlib import Path
76
+ from PIL import Image, ImageOps
77
+
78
+ files_to_process = []
79
+
80
+ if process_folder:
81
+ folder_path = Path(input_files)
82
+ if folder_path.is_dir():
83
+ # On récupère png, jpg, jpeg (insensible à la casse)
84
+ # On exclut les fichiers finissant déjà par -C
85
+ extensions = ('*.png', '*.jpg', '*.jpeg', '*.PNG', '*.JPG', '*.JPEG')
86
+ for ext in extensions:
87
+ for f in folder_path.glob(ext):
88
+ if not f.stem.endswith('-C'):
89
+ files_to_process.append(f)
90
+ else:
91
+ print(f"❌ Error: {input_files} is not a valid directory.")
92
+ return
93
+ else:
94
+ # Logique existante pour fichier unique ou liste
95
+ if isinstance(input_files, (str, Path)):
96
+ files_to_process = [Path(input_files)]
97
+ else:
98
+ files_to_process = [Path(f) for f in input_files]
99
+
100
+ for path in files_to_process:
101
+ if not path.exists() or path.is_dir():
102
+ continue
103
+
104
+ output_path = path.with_name(f"{path.stem}-C{path.suffix}")
105
+
106
+ try:
107
+ with Image.open(path) as img:
108
+ info = img.info.copy()
109
+ bbox = smart_trim(img)
110
+
111
+ if bbox:
112
+ img_trimmed = img.crop(bbox)
113
+ img_trimmed.save(output_path, **info)
114
+ print(f"✅ Saved: {output_path.name}")
115
+ else:
116
+ print(f"⚠️ Skipping {path.name}: No content detected.")
117
+
118
+ except Exception as e:
119
+ print(f"❌ Error processing {path.name}: {e}")