Skip to content

Commit

Permalink
Type checks added to read_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed May 3, 2020
1 parent ed30996 commit c5fec94
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions species/read/read_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import os
import configparser

from typing import Tuple

import h5py
import numpy as np

from scipy.interpolate import interp1d, InterpolatedUnivariateSpline
from typeguard import typechecked
from scipy.interpolate import interp1d, InterpolatedUnivariateSpline, interpolate

from species.data import database

Expand All @@ -18,8 +21,9 @@ class ReadFilter:
Class for reading a filter profile from the database.
"""

@typechecked
def __init__(self,
filter_name):
filter_name: str) -> None:
"""
Parameters
----------
Expand All @@ -42,7 +46,8 @@ def __init__(self,

self.database = config['species']['database']

def get_filter(self):
@typechecked
def get_filter(self) -> np.ndarray:
"""
Function for selecting a filter profile from the database.
Expand All @@ -69,7 +74,8 @@ def get_filter(self):

return data

def interpolate_filter(self):
@typechecked
def interpolate_filter(self) -> interpolate.interp1d:
"""
Function for linearly interpolating a filter profile.
Expand All @@ -87,7 +93,8 @@ def interpolate_filter(self):
bounds_error=False,
fill_value=float('nan'))

def wavelength_range(self):
@typechecked
def wavelength_range(self) -> Tuple[float, float]:
"""
Extract the wavelength range of the filter profile.
Expand All @@ -103,7 +110,8 @@ def wavelength_range(self):

return np.amin(data[0, ]), np.amax(data[0, ])

def mean_wavelength(self):
@typechecked
def mean_wavelength(self) -> float:
"""
Calculate the weighted mean wavelength of the filter profile.
Expand All @@ -117,7 +125,8 @@ def mean_wavelength(self):

return np.trapz(data[0, ]*data[1, ], data[0, ]) / np.trapz(data[1, ], data[0, ])

def filter_fwhm(self):
@typechecked
def filter_fwhm(self) -> float:
"""
Calculate the full width at half maximum (FWHM) of the filter profile.
Expand Down

0 comments on commit c5fec94

Please sign in to comment.