-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathmodels.py
More file actions
50 lines (39 loc) · 1.81 KB
/
Copy pathmodels.py
File metadata and controls
50 lines (39 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Module containing models representing lightcurves.
The Model layer is responsible for the 'business logic' part of the software.
The lightcurves are saved in a table (2D array) where each row corresponds to a single observation.
Depending on the dataset (LSST or Kepler), a table can contain observations of a single or several objects,
in a single or different bands.
"""
import pandas as pd
import numpy as np
from astropy.timeseries import LombScargle
def load_dataset(filename):
"""Load a table from CSV file.
:param filename: The name of the .csv file to load.
:raises Eror: when the file is not CSV/
no file was given as an inut/
the file or directory was not found
:returns: pd.DataFrame with the data from the file.
"""
return pd.read_csv(filename)
def mean_mag(data, mag_col):
"""Calculate the mean magnitude of a lightcurve
:param data: pd.DataFrame with observed magnitudes for a single source
:param mag_col: a string with the name of the column for calculating the min value.
:returns: the mean for the mag_col coming from the data table
"""
return data[mag_col].mean()
def max_mag(data, mag_col):
"""Calculate the max magnitude of a lightcurve
:param data: pd.DataFrame with observed magnitudes for a single source
:param: a string with the name of the column for calculating the max value.
:returns: the max for the mag_col coming from the data table
"""
return data[mag_col].max()
def min_mag(data, mag_col):
"""Calculate the min magnitude of a lightcurve
:param data: pd.DataFrame with observed magnitudes for a single source.
:param mag_col: a string with the name of the column for calculating the min value.
:returns: The min value of the column.
"""
return data[mag_col].min()