Coverage for src/susi/atlantes/atlas.py: 89%

19 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2025-06-13 14:15 +0000

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3""" 

4Base class for an atlas implementation 

5 

6@author: hoelken 

7""" 

8import numpy as np 

9 

10 

11class Atlas: 

12 """ 

13 Base class for an atlas implementation 

14 """ 

15 

16 def __init__(self, start: float, stop: float): 

17 #: Wavelength to start to read from 

18 self.start = start 

19 #: Wavelength to read to 

20 self.stop = stop 

21 # Containers for the loaded atlas 

22 #: Wavelength 

23 self.wl = [] 

24 #: Intensity 

25 self.intensity = [] 

26 

27 def load(self): 

28 """Read the content of the atlas to mem""" 

29 raise NotImplementedError('Derived class does not implement this method.') 

30 pass 

31 

32 def convert_wl(self, factor) -> None: 

33 """ 

34 Convert the WL by the given factor. 

35 Default is Angstrom, use `factor=1/10` to convert to [nm]. 

36 """ 

37 self.wl = np.array(self.wl) 

38 self.wl = self.wl * factor 

39 

40 def normalized_intensity(self): 

41 self.intensity = np.array(self.intensity) 

42 return self.intensity / self.intensity.mean() 

43 

44 def __len__(self) -> int: 

45 return len(self.wl)