Skip to content
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

feature/repo initialisation #1

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 25 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include versioneer.py
include src/pykoala/_version.py
include src/pykoala/plotting/pykoala.mplstyle

include *.toml
include LICENSE
include tox.ini
recursive-include src *.dat
recursive-include src *.txt
recursive-include src *.fits
recursive-include src *.ctio

recursive-include docs *.bat
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include tests *.py
include *.txt
recursive-include * .empty

recursive-exclude .circleci *
exclude .circleci
exclude codecov.yml
recursive-exclude ci *
exclude azure-pipelines.yml
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[build-system]
requires = ["setuptools >= 70.0", "versioneer[toml]"]
build-backend = "setuptools.build_meta"

[project]
name = "koala_drpipe"
dynamic = ["version"]
authors = [
{ name="Pablo Corcho-Caballero", email="[email protected]" },
{ name="Ángel R. López-Sánchez", email="[email protected]" },
{ name="Yago Ascasibar", email="[email protected]" }
]
description = "Data reduction tools for the KOALA IFU."
readme = "README.md"
keywords = ["astronomy", "IFS", "data reduction"]
license = {text = "BSD-3-Clause"}
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Topic :: Scientific/Engineering',
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
dependencies = [
"astropy>=5.3.4",
"matplotlib>=3.7.2",
"numpy>=1.24.0",
"scipy>=1.2.3",
"synphot",
'future',
]
requires-python = ">=3.7"

[project.urls]
Homepage = "https://github.com/pykoala/koala-ifu-drpipe"
Issues = "https://github.com/pykoala/koala-ifu-drpipe/issues"
18 changes: 18 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[flake8]
max-complexity = 15
ignore=E226,N802,N803,N806,E402

[versioneer]
VCS = git
style = pep440
versionfile_source = src/koala_drpipe/_version.py
versionfile_build = koala_drpipe/_version.py
tag_prefix = v
#parentdir_prefix =

[check-manifest]
ignore =
tasks.py
.travis.yml
.gitchangelog.rc
DESCRIPTION.rst
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
import setuptools

import versioneer

#DESCRIPTION_FILES = ["pypi-intro.rst"]
#
#long_description = []
#import codecs
#for filename in DESCRIPTION_FILES:
# with codecs.open(filename, 'r', 'utf-8') as f:
# long_description.append(f.read())
#long_description = "\n".join(long_description)


setuptools.setup(
version = versioneer.get_version(),
)
Empty file added src/koala_drpipe/__init__.py
Empty file.
110 changes: 110 additions & 0 deletions src/koala_drpipe/instrument_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

from pykoala import vprint
from astropy.io import fits

def print_aaomega_gratings():
print("Blue arm gratings: ", "\n".join(["580V" , "1500V" ,"1700B" , "3200B" , "2500V"]))
print("Red arm gratings: ", "\n".join(["385R","1000R","2000R", "1000I", "1700D","1700I"]))

AAOMEGA_GRATINGS = {
"blue_arm": ["580V" , "1500V" ,"1700B" , "3200B" , "2500V"],
"red_arm": ["385R","1000R","2000R", "1000I", "1700D","1700I"]}


class AAOMegaConfig(object):
def __init__(self, arm, grating, dichroic, exptime, *args, **kwargs):
self.arm = arm
self.grating = grating
self.dichroic = dichroic
self.exptime = exptime

@classmethod
def from_header(cls, header):
"""Build a configuration using the information provided in the header."""
arm = header["SPECTID"]
grating = header["GRATID"]
dichroic = header["DICHROIC"]
exptime = header["EXPOSED"]

return cls(arm, grating, dichroic, exptime)

@classmethod
def from_fits(cls, path, extension=0):
header = fits.getheader(path, extension)
return cls.from_header(header)

def show_config(self):
vprint(f"AAOMega configuration:\n - Arm: {self.arm}"
+ f"\n - Grating: {self.grating}\n - Dichroic: {self.dichroic}"
+ f"\n - Exp. Time: {self.exptime}")


class KOALAConfig(object):
def __init__(self, mode, rotator_pa=0.0, *args, **kwargs):
self.mode = mode
self.rotator_pa = rotator_pa

@classmethod
def from_header(cls, header):
"""Build a configuration using the information provided in the header."""
rotator_pa = header["TEL_PA"]
mode = header.get("FOV", "N/A")
return cls(mode, rotator_pa)

@classmethod
def from_fits(cls, path, extension=0):
header = fits.getheader(path, extension)
return cls.from_header(header)

def show_config(self):
vprint(f"KOALA configuration:\n - Mode: {self.mode}"
+ f"\n - Rotator PA: {self.rotator_pa}")


class ObservationConfig(object):
def __init__(self, aaomega_config, koala_config, mean_ra, mean_dec, utdate, **kwargs):
self.aaomega_config = aaomega_config
self.koala_config = koala_config
self.mean_ra, self.mean_dec = mean_ra, mean_dec
self.utdate = utdate
# Convert to python datetime
self.utstart = kwargs.get("utstart")
self.utend = kwargs.get("utend")
self.utmjd = kwargs.get("utmjd")
self.zenital_distance = kwargs.get("zdstart")
self.ver_2dfdr = kwargs.get("ver_2dfdr")
self.is_raw = kwargs.get("is_raw")

@classmethod
def from_header(cls, header):
aaomega_config = AAOMegaConfig.from_header(header)
koala_config = KOALAConfig.from_header(header)

obs_args = {"mean_ra": header["MEANRA"], "mean_dec": header["MEANDEC"],
"utdate": header["UTDATE"], "utmjd": header["UTMJD"],
"utstart": header["UTSTART"], "utend": header["UTEND"],
"is_raw": False}
obs_args["ver_2dfdr"] = header.get('2DFDRVER', None)
if obs_args["ver_2dfdr"] is None:
obs_args["is_raw"] = True

return cls(aaomega_config, koala_config, **obs_args)

@classmethod
def from_fits(cls, path, extension=0):
header = fits.getheader(path, extension)
return cls.from_header(header)

def show_config(self):
vprint(f"Observation configuration:\n - Mean Ra/Dec: {self.mean_ra}/{self.mean_dec}"
+ f"\n - UT date: {self.utdate}"
+ f"\n - UT start: {self.utstart}"
+ f"\n - Is raw file: {self.is_raw}"
+ f"\n - 2dfdr version: {self.ver_2dfdr}")
self.aaomega_config.show_config()
self.koala_config.show_config()


def group_observations(list_of_obs_config, criteria):
pass

Loading