From edbd6ed11c52eb30c84189f8541c7fd48e9a1ad1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Riette?= <sebastien.riette@meteo.fr>
Date: Fri, 24 Nov 2023 09:29:57 +0100
Subject: [PATCH] S. Riette 24 Nov 2023: better handling of python dependencies

---
 README.md        | 4 ++++
 tools/compare.py | 9 +++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 7653682d8..ae51720fe 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,10 @@ Several presentations were done, the materials can be found on the [wiki](https:
 Prerequisites:
   - an internet connexion (with access to the github servers) is needed only for the installation
   - python > 3.7 (but only tested with version 3.10)
+  - some python packages:
+    - numpy and pandas for the testprogs
+    - epygram and matplotlib for AROME
+    - xarray for Meso-NH
   - a C compiler (tested with cc 11.4.0)
   - a FORTRAN compiler (tested with ifort and gfortran, but automatic installation only works with gfortran >= 10)
   - some classical unix tools: wget, tar, make and git
diff --git a/tools/compare.py b/tools/compare.py
index a6f241ec5..215039faf 100755
--- a/tools/compare.py
+++ b/tools/compare.py
@@ -1,13 +1,9 @@
 #!/usr/bin/env python3
 
-import matplotlib
-matplotlib.use('Agg')
 import os
 os.environ['NUMEXPR_MAX_THREADS'] = '1'
 import shutil
 import numpy
-import matplotlib.pyplot as plt
-import xarray as xr
 import sys
 import subprocess
 import difflib
@@ -31,6 +27,7 @@ avail_groups=['Stations/sta1',
               'Budgets/RG','Budgets/RS','Budgets/RH','Budgets/TK']
 
 def compareBACKUPFiles(file_user, file_ref):
+  import xarray as xr
   status = 0
   da = xr.open_dataset(file_user)
   da2 = xr.open_dataset(file_ref)
@@ -71,6 +68,7 @@ def compareBACKUPFiles(file_user, file_ref):
   return status
 
 def compareTSERIESFiles(file_user, file_ref, tol_ad=1E-12):
+  import xarray as xr
   status = 0
   da = xr.open_dataset(file_user)
   da2 = xr.open_dataset(file_ref)
@@ -120,6 +118,9 @@ def compareTSERIESFiles(file_user, file_ref, tol_ad=1E-12):
   return status
 
 def comp_DDH(filename1, filename2, output_fig, tol_ad=3E-7, tol_rd=1.E-6, verbose=False):
+    import matplotlib
+    matplotlib.use('Agg')
+    import matplotlib.pyplot as plt
     import epygram
     epygram.init_env()
 
-- 
GitLab