From aa5e153f9f2f3eddfe80a7c3ce1f4faafc9a5df8 Mon Sep 17 00:00:00 2001 From: Konstantinos Papadakis Date: Wed, 27 Nov 2024 13:24:40 +0200 Subject: [PATCH 1/3] Bool method to test whether a cell id has a vdf or not --- pyVlsv/vlsvreader.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index bacb74d4..f8a06009 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -2375,6 +2375,16 @@ def get_cellid_with_vdf(self, coords, pop = 'proton'): return output else: return output[0] + + def cellid_has_vdf(self, cid, pop = 'proton')->bool: + ''' Returns whether the cid in question has a vdf or not + :param coords: the cellid to test for + :returns: bool + ''' + if not pop in self.__cells_with_blocks: + return False + cid_w_vdf = self.__cells_with_blocks[pop] + return cid in cid_w_vdf def get_vertex_indices(self, coordinates): ''' Get dual grid vertex indices for all coordinates. From 612a10e5b1a7f0fea6ab469a1b2ef396af17a74d Mon Sep 17 00:00:00 2001 From: Konstantinos Papadakis Date: Wed, 27 Nov 2024 13:29:23 +0200 Subject: [PATCH 2/3] Fix --- pyVlsv/vlsvreader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index f8a06009..da30f736 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -1,4 +1,4 @@ -# +#s # This file is part of Analysator. # Copyright 2013-2016 Finnish Meteorological Institute # Copyright 2017-2024 University of Helsinki @@ -2382,7 +2382,7 @@ def cellid_has_vdf(self, cid, pop = 'proton')->bool: :returns: bool ''' if not pop in self.__cells_with_blocks: - return False + self.__set_cell_offset_and_blocks_nodict(pop) cid_w_vdf = self.__cells_with_blocks[pop] return cid in cid_w_vdf From a9a8e32d396ae0b5bb71820aa1701e11b06ea26b Mon Sep 17 00:00:00 2001 From: Konstantinos Papadakis Date: Wed, 27 Nov 2024 13:36:31 +0200 Subject: [PATCH 3/3] And another one --- pyVlsv/vlsvreader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index da30f736..2918e1e8 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -2381,8 +2381,7 @@ def cellid_has_vdf(self, cid, pop = 'proton')->bool: :param coords: the cellid to test for :returns: bool ''' - if not pop in self.__cells_with_blocks: - self.__set_cell_offset_and_blocks_nodict(pop) + self.__set_cell_offset_and_blocks_nodict(pop) cid_w_vdf = self.__cells_with_blocks[pop] return cid in cid_w_vdf