From 24a0c493e9504f9875cb4f44ea066f5462886120 Mon Sep 17 00:00:00 2001
From: Julian Linke <jlinke-tug@aim-gpu6.spsc.tugraz.at>
Date: Tue, 1 Aug 2023 11:32:43 +0200
Subject: [PATCH] no .eps and argument ERROR

---
 local/plot_pca_similarities.py | 18 ++++++------------
 run.sh                         |  6 +++---
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/local/plot_pca_similarities.py b/local/plot_pca_similarities.py
index 431e072..d087f29 100644
--- a/local/plot_pca_similarities.py
+++ b/local/plot_pca_similarities.py
@@ -35,7 +35,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
     A = np.load(pcaA_path)
     b = np.load(pcab_path)
     print('\nspkIDs:\n{}'.format(spks))
-    print('\ninput matrix:\n{}'.format(X))
+    print('\ninput matrix X:\n{}'.format(X))
 
     labels = list(spks)
     fig, ax = plt.subplots(figsize=(15,15))
@@ -45,7 +45,7 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
     plt.yticks(range(len(labels)), labels);
     fig.colorbar(cax, ticks=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, .8, .9, 1])
     fig_path = os.path.join(out_path,'{}.png'.format(X_path.split('/')[-1].replace('.npy','')))
-    print('\nsave fig {}'.format(fig_path))
+    print('\nsave similarity matrix to {}'.format(fig_path))
     plt.savefig(fig_path)
 
     colordict = {}
@@ -56,10 +56,9 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
         spks_tmp = corpora[corpus]
         for spk in spks_tmp:
             colordict[corpus].append(colors[idx])
-    print(colordict)
     col = sum([lst for lst in colordict.values()], [])
 
-    print("\nProject with PCA (3 dimensions)...")
+    print("\nProject with PCA (3 dimensions) ...")
     X_proj = np.dot(X, A) + b # [styles x 320^2] * [320^2 x 2] or [styles x corpora] + [corpora x 2]
     print(f"\nshape(X_proj) = {np.shape(X_proj)}")
     print('mean(X_proj,0): {}'.format(np.mean(X_proj,0)))
@@ -82,14 +81,12 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
     ax.legend(loc='center left', bbox_to_anchor=(1.175, .5))
     # Save the plot
     fig_path = os.path.join(out_path,'scatter3D_{}.png'.format(X_path.split('/')[-1].replace('.npy','')))
-    print('\nsave fig {}'.format(fig_path))
+    print('\nsave 3D scatter plot {}'.format(fig_path))
     plt.savefig(fig_path)
-    fig_path = os.path.join(out_path,'scatter3D_{}.eps'.format(X_path.split('/')[-1].replace('.npy','')))
-    print('save fig {}'.format(fig_path))
-    plt.savefig(fig_path, format='eps')
     
     plt.rcParams.update({'font.size': 50})
     for proj in [(0, 1), (0, 2), (1, 2)]:
+        print(f"\nProject on dimensions {proj}")
         x, y = X_proj[:,proj[0]], X_proj[:,proj[1]]
         fig, ax = plt.subplots(figsize=(18,16))
 
@@ -109,11 +106,8 @@ def main(X_path, y_path, pcaA_path, pcab_path, out_path, json_path):
         plt.grid()
         plt.tight_layout()
         fig_path = os.path.join(out_path,'scatter_proj{}_{}.png'.format(''.join([str(proj[0]),str(proj[1])]), X_path.split('/')[-1].replace('.npy','')))
-        print('\nsave fig {}'.format(fig_path))
+        print('save 2D scatter plot {}'.format(fig_path))
         plt.savefig(fig_path)
-        fig_path = os.path.join(out_path,'scatter_proj{}_{}.eps'.format(''.join([str(proj[0]),str(proj[1])]), X_path.split('/')[-1].replace('.npy','')))
-        print('save fig {}'.format(fig_path))
-        plt.savefig(fig_path, format='eps')
 
 if __name__ == "__main__":
     ############################# FEATURES PATH ###########################
diff --git a/run.sh b/run.sh
index 47b0e31..ec094cc 100755
--- a/run.sh
+++ b/run.sh
@@ -8,8 +8,8 @@ set -e -o pipefail
 . path.sh
 . conda.sh
 
-if [[ $# -eq 0 ]] ; then
-    echo 'ERROR: this run-script requires an argument: stage=?'
+if [[ $# -eq 1 ]] ; then
+    echo 'ERROR: this run-script requires two arguments: DATA=? stage=?'
     exit 1
 fi
 
@@ -82,7 +82,7 @@ if [ $stage == 4 ] || [ $stage == 0 ]; then
         $exp_dir/numpy/similarity_matrix.npy \
         --output $exp_dir/numpy/pca \
         --dim 3
-    printf "\n... PLOT ...\n"
+    printf "\n... PLOT similarity in PCA space (Analysis) ...\n"
     python3 local/plot_pca_similarities.py \
         $exp_dir/numpy/similarity_matrix.npy \
         $exp_dir/numpy/splits_labels.npy \
-- 
GitLab