[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master a6b838c 18/19: Match: script to generate debug
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master a6b838c 18/19: Match: script to generate debugging input taken in bin/match/ |
Date: |
Sun, 14 Nov 2021 20:41:01 -0500 (EST) |
branch: master
commit a6b838c4880d2ce63a4a6dc3b3fb55e1b4559205
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Match: script to generate debugging input taken in bin/match/
Until now, to generate inputs to the Match program, we always needed two
catalogs and it was annoying to build them by hand every time. So during
the work on k-d trees, a script was written to either build two catalogs
from scratch, or use an existing one and add noise to its coordinates. But
that script was in a temporary directory we had built while working on
Match.
With this commit, that temporary directory has been deleted, however, since
the input generation script was useful for the future, it has been put in
the 'bin/match/' directory in case it may be useful in the future.
---
.../scripts/gen-inputs.sh => bin/match/debug-1.sh | 25 ++++++++
during-dev-test-data/scripts/benchmark.py | 69 ----------------------
during-dev-test-data/scripts/kdtree-gen.py | 31 ----------
3 files changed, 25 insertions(+), 100 deletions(-)
diff --git a/during-dev-test-data/scripts/gen-inputs.sh b/bin/match/debug-1.sh
similarity index 50%
rename from during-dev-test-data/scripts/gen-inputs.sh
rename to bin/match/debug-1.sh
index 21cd7e1..7bfcc2b 100755
--- a/during-dev-test-data/scripts/gen-inputs.sh
+++ b/bin/match/debug-1.sh
@@ -1,4 +1,29 @@
#!/bin/bash
+# Script to create inputs to debug match. It can either take one catalog,
+# randomly select a sub-set, and add noise to its coordinates to create a
+# second catalog, or just build two catalogs from scratch.
+#
+# Original author:
+# Mohammad Akhlaghi <mohammad@akhlaghi.org>
+# Contributing author(s):
+# Copyright (C) 2021, Free Software Foundation, Inc.
+#
+# Gnuastro is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# Gnuastro is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+
# If you want to use a real catalog as reference (and manually add noise to
# randomly selected rows, give a value to the 'real' variable). If this is
diff --git a/during-dev-test-data/scripts/benchmark.py
b/during-dev-test-data/scripts/benchmark.py
deleted file mode 100755
index 830e642..0000000
--- a/during-dev-test-data/scripts/benchmark.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /usr/bin/env python
-# Do benchmark test and generate resulting graphs.
-# TODO: Use multithreading for faster parallel execution.
-
-import time
-import subprocess
-import matplotlib.pyplot as plt
-
-
-######## Set the variable and execute the script. #########
-script = "/home/sachin/gnuastro_dev/gnuastro/tests/during-dev.sh"
-maximum_executions = 10
-maximun_jump_factor = 10
-graph_name = "KD-tree"
-###########################################################
-
-
-# Wrapper function for calculating runtime.
-def timed_execution(function):
- def wrapper(args):
- start = time.time()
- function(args)
- end = time.time()
- return (end-start)
- return wrapper
-
-
-@timed_execution
-def execute_script(script_):
- subprocess.call([script_], stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
-
-
-# Make the list of number of times the script is to be executed.
-def make_num_execution_list(num, jump_factor):
- num_execution_list = []
- i = 1
- while(i <= num):
- num_execution_list.append(i)
- i *= jump_factor
-
- return num_execution_list
-
-
-# Make the list for the time taken by the script to run for a particular
number of times.
-def make_time_list(num_execution_list):
- time_list = []
- for num in num_execution_list:
- time_taken = 0
- for _ in range(int(num)):
- t = execute_script(script)
- time_taken += t
- time_list.append(time_taken)
-
- return time_list
-
-
-# Make a graph between the number of times the script is executed and the time
taken for it.
-def make_graph(name, time_list, num_execution_list):
- plt.plot(num_execution_list, time_list, marker='o', markerfacecolor='red',
markersize=10)
- plt.xlabel("number of executions")
- plt.ylabel("time required for executions")
- plt.title(name)
- plt.show()
-
-
-# Interface
-if __name__ == "__main__":
- num_execution_list = make_num_execution_list(maximum_execution,
maximum_jump_factor)
- make_graph(graph_name, make_time_list(num_execution_list),
num_execution_list)
diff --git a/during-dev-test-data/scripts/kdtree-gen.py
b/during-dev-test-data/scripts/kdtree-gen.py
deleted file mode 100755
index 8583506..0000000
--- a/during-dev-test-data/scripts/kdtree-gen.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /usr/bin/env python
-# Generate random floating numbers to make a kd-tree.
-# Usage: ./kdtree-gen.py [filename] [number of rows] [number of columns]
-
-import sys
-import random
-
-
-if len(sys.argv) == 1:
- row_num = 10
- col_num = 2
-else:
- row_num = sys.argv[2]
- col_num = sys.argv[3]
-
-
-def format_row(ncols=col_num, seed=10):
- row = ""
- for _ in range(int(ncols)):
- col = random.uniform(seed, seed+5)
- row += f"{col}\t"
- row += "\n"
-
- return row
-
-
-if __name__ == "__main__":
- with open(f"../{sys.argv[1]}", "w+") as input_file:
- for _ in range(int(row_num)):
- input_file.write(format_row())
-
- [gnuastro-commits] master 48d760d 12/19: Library (match.h): k-d tree method discards regions with no overlap, (continued)
- [gnuastro-commits] master 48d760d 12/19: Library (match.h): k-d tree method discards regions with no overlap, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master d0b19b8 10/19: Match: make check script for k-d tree matching now executable, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 095c788 13/19: Match: matched rows aren't permuted, but new column allocated, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 9e258a8 14/19: Library (fits.h): reading table columns now done in parallel, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 29f8b20 16/19: Table and Arithmetic: corrected some memory leaks, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 8b17675 06/19: Corrected segmentation fault, included aperture, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master a7bfa5b 11/19: Match: k-d tree matching UI fixed, to do: finalizing docs and tests, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master f5d7d1a 19/19: Match: added tests, completed docs of new k-d tree based matching, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 6f7ff61 08/19: Library (match.h): Using the old infra-structure for double-matches, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 68823e3 17/19: Library (fits.h): correctly reading columns of 0 width/repeat, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master a6b838c 18/19: Match: script to generate debugging input taken in bin/match/,
Mohammad Akhlaghi <=