From 035d7e00715fd5ef2de02a3d48044e0c957e5dc9 Mon Sep 17 00:00:00 2001 From: rstiskalek Date: Sun, 2 Apr 2023 22:23:50 +0100 Subject: [PATCH] add crossfiles reader --- csiborgtools/read/summaries.py | 20 +++++++++++++++++ meetings/220403_knn.ipynb | 39 +++++++++++++++++----------------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/csiborgtools/read/summaries.py b/csiborgtools/read/summaries.py index b2163ee..6222b4f 100644 --- a/csiborgtools/read/summaries.py +++ b/csiborgtools/read/summaries.py @@ -18,6 +18,7 @@ Tools for summarising various results. import numpy import joblib from os.path import (join, isfile) +from glob import glob from tqdm import tqdm @@ -283,6 +284,25 @@ class kNNCDFReader: cdf = cdf[0, ...] if nknns == 1 else cdf # Reshape if necessary return cdf + @staticmethod + def cross_files(ic, folder): + """ + Return the file paths corresponding to the cross-correlation of a given + IC. + + Parameters + ---------- + ic : int + The desired IC. + folder : str + The folder containing the cross-correlation files. + + Returns + ------- + filepath : list of str + """ + return [file for file in glob(join(folder, "*")) if str(ic) in file] + class PairOverlap: r""" diff --git a/meetings/220403_knn.ipynb b/meetings/220403_knn.ipynb index da4822f..b5d2d9d 100644 --- a/meetings/220403_knn.ipynb +++ b/meetings/220403_knn.ipynb @@ -6,8 +6,8 @@ "id": "5a38ed25", "metadata": { "ExecuteTime": { - "end_time": "2023-04-02T19:21:33.573666Z", - "start_time": "2023-04-02T19:21:30.143966Z" + "end_time": "2023-04-02T21:16:58.830606Z", + "start_time": "2023-04-02T21:16:55.025438Z" }, "scrolled": true }, @@ -42,12 +42,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 13, "id": "6083fcbe", "metadata": { "ExecuteTime": { - "end_time": "2023-04-02T19:23:31.324449Z", - "start_time": "2023-04-02T19:23:29.114870Z" + "end_time": "2023-04-02T21:20:09.950356Z", + "start_time": "2023-04-02T21:20:06.317948Z" } }, "outputs": [ @@ -55,7 +55,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 101/101 [00:01<00:00, 73.91it/s]\n" + "100%|██████████| 101/101 [00:02<00:00, 38.07it/s]\n" ] } ], @@ -69,12 +69,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "id": "6ec8e4a5", "metadata": { "ExecuteTime": { - "end_time": "2023-04-02T19:23:33.894435Z", - "start_time": "2023-04-02T19:23:32.073212Z" + "end_time": "2023-04-02T21:20:11.664874Z", + "start_time": "2023-04-02T21:20:09.952179Z" }, "scrolled": false }, @@ -1047,7 +1047,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1086,12 +1086,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "id": "1f9898f6", "metadata": { "ExecuteTime": { - "end_time": "2023-04-02T19:23:40.416015Z", - "start_time": "2023-04-02T19:23:39.223369Z" + "end_time": "2023-04-02T21:21:19.279253Z", + "start_time": "2023-04-02T21:21:16.309685Z" } }, "outputs": [ @@ -1099,7 +1099,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 35/35 [00:01<00:00, 32.52it/s]\n" + "100%|██████████| 100/100 [00:02<00:00, 42.21it/s]\n" ] } ], @@ -1107,7 +1107,8 @@ "knnreader = csiborgtools.read.kNNCDFReader()\n", "\n", "cross_files = glob(\"/mnt/extraspace/rstiskalek/csiborg/knn/cross/knncdf_9004*\")\n", - "len(cross_files)\n", + "\n", + "cross_files = knnreader.cross_files(7444, \"/mnt/extraspace/rstiskalek/csiborg/knn/cross/\")\n", "\n", "ks = [0, 3, 7]\n", "rs, corr, mass_thresholds = knnreader.read(cross_files, ks, rmin=1)" @@ -1115,12 +1116,12 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 17, "id": "e0fcf77b", "metadata": { "ExecuteTime": { - "end_time": "2023-04-02T19:24:34.981711Z", - "start_time": "2023-04-02T19:24:31.703199Z" + "end_time": "2023-04-02T21:21:22.690776Z", + "start_time": "2023-04-02T21:21:19.980499Z" } }, "outputs": [ @@ -2092,7 +2093,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ ""