Coverage for src/hallmd/data/h9/__init__.py: 0%

46 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-07-10 23:12 +0000

1"""Module for H9 datasets.""" 

2 

3from importlib import resources 

4from pathlib import Path 

5 

6from .. import ThrusterDataset 

7 

8 

9class H9(ThrusterDataset): 

10 """Class for handling the H9 datasets.""" 

11 

12 @staticmethod 

13 def datasets_from_names(dataset_names: list[str]) -> list[Path]: 

14 data_list = [] 

15 for dataset in dataset_names: 

16 match dataset: 

17 case "gt2024": 

18 data_list += _gt2024() 

19 case "um2024": 

20 data_list += _um2024() 

21 case _: 

22 raise ValueError(f"Invalid dataset {dataset} selected for the H9 thruster.") 

23 

24 return data_list 

25 

26 @staticmethod 

27 def all_data() -> list[Path]: 

28 return _gt2024() + _um2024() 

29 

30 @staticmethod 

31 def no_data_error(): 

32 return ImportError( 

33 "The H9 data is export-controlled and not stored in this repository." 

34 + "If you have the data, you must manually place it in the src/hallmd/data/h9 directory" 

35 ) 

36 

37 

38def _gt2024() -> list[Path]: 

39 """JANUS FIT-1 test campaign data at Georgia Tech (unpublished).""" 

40 try: 

41 from . import gt2024 

42 except ImportError: 

43 raise H9.no_data_error() 

44 

45 dir = resources.files(gt2024) 

46 datafiles = ["jion_GT_behind_thruster.csv", "thrust_GT_behind_thruster.csv"] 

47 paths = [] 

48 for file in datafiles: 

49 with resources.as_file(dir / file) as path: 

50 paths.append(path) 

51 

52 return paths 

53 

54 

55def _um2024() -> list[Path]: 

56 """JANUS FIT-2 test campaign at the University of Michigan (unpublished).""" 

57 try: 

58 from . import um2024 

59 except ImportError: 

60 raise H9.no_data_error() 

61 

62 dir = resources.files(um2024) 

63 datafiles = ["jion_UMH9.csv", "uion_UMH9.csv", "vcc_UMH9.csv"] 

64 paths = [] 

65 for file in datafiles: 

66 with resources.as_file(dir / file) as path: 

67 paths.append(path) 

68 

69 return paths