Skip to content

Feature/plot labels #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
.pytest_cache

# Virtual environments

venv/
.venv/
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Introduction
# LcAnalyzer
![Continuous Integration build in GitHub Actions](https://github.com/<your_github_username>/light-curve-analysis/workflows/CI/badge.svg?branch=main)
LcAnalyzer is a package written in Python that allows you to inspect light curves.

This is a template software project repository used by the [Intermediate Python for Astronomical Software Development](https://shrra.github.io/python-intermediate-development/index.html).
## Main features
Here are some key features of LcAnalyzer:

## Purpose
- Reading CSV and Pickle files;
- Giving the list of unique objects present in the data;
- Selecting observations of a given star in a given bands;
...

This repository is intended to be used as a code template which is copied by learners at [Intermediate Python for Astronomical Software Development](https://shrra.github.io/python-intermediate-development/index.html) course.
This can be done using the `Fork` button towards the top right of this repo's GitHub page.
## Prerequisites
LcAnalyzer requires the following Python packages:

This software project is not finished, is currently failing to run and contains some code style issues. It is used as a starting point for the course - issues will be fixed and code will be added in a number of places during the course by learners in their own copies of the repository, as course topics are introduced.
- [Pandas](https://pandas.pydata.org/) - makes use of Pandas's data types and statistical functions
- [Matplotlib](https://matplotlib.org/stable/index.html) - uses Matplotlib to generate statistical plots

## Tests
The following optional packages are required to run LcAnalyzer's unit tests:

- [pytest](https://docs.pytest.org/en/stable/) - LcAnalyzer's unit tests are written using pytest
- [pytest-cov](https://pypi.org/project/pytest-cov/) - Adds test coverage stats to unit testing

Several tests have been implemented already, some of which are currently failing.
These failing tests set out the requirements for the additional code to be implemented during the workshop.
11,178 changes: 11,178 additions & 0 deletions data/lsst_RRLyr.csv

Large diffs are not rendered by default.

Binary file added data/lsst_RRLyr_protocol_4.pkl
Binary file not shown.
23 changes: 17 additions & 6 deletions lcanalyzer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@
def load_dataset(filename):
"""Load a table from CSV file.

:param filename: The name of the .csv file to load
: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"""
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"""
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):
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.
Expand Down
3 changes: 2 additions & 1 deletion lcanalyzer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def plotUnfolded(data,mag_col,time_col,color,marker):
)
ax.minorticks_on()
ax.set_xlabel("MJD (days)")
ax.set_ylabel('Mag')
ax.set_ylabel('Mag' + mag_col)
ax.set_title('Light curve')
fig.tight_layout()
plt.show()

Loading