Skip to content

Commit

Permalink
Fixed a lowercase name match bug in loading standard stars.
Browse files Browse the repository at this point in the history
  • Loading branch information
cylammarco committed Jan 19, 2023
1 parent 924a80b commit 5935425
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/conda-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: publish_conda

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: publish-to-conda
uses: amauryval/publish_conda_package_action@1.2.0
with:
# CondaDir: locate the directory containing your meta.yml, conda_build_config.yaml (...) files
CondaDir: 'conda'
# Channels: You can add more channel with a space separator
Channels: 'conda-forge'
# Platforms: remove one or more of these platforms
Platforms: 'osx-64 linux-64 win-64 noarch'
CondaUsername: ${{ secrets.CONDA_USERNAME }}
CondaPassword: ${{ secrets.CONDA_PASSWORD }}
2 changes: 2 additions & 0 deletions conda/bld.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
1 change: 1 addition & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip install .
32 changes: 32 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# get version from setup.py
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}

package:
name: aspired
version: {{ data.get('version') }}

source:
path: ../

build:
noarch: python

requirements:
build:
- python>=3.7
- setuptools
run:
{% for req in data.get('install_requires', []) %}
- {{ req }}
{% endfor %}

test:
imports:
- aspired

about:
home: https://github.com/cylammarco/ASPIRED
license: GPL-3.0
license_file: license
description: The Automated SpectroPhotometric REDuction (ASPIRED) toolkit is aimed to be as general as possible with high flexibility such that it can work with different instruments. It offers a flexible set of functions for users to refine and tailor-make automated pipelines for different instruments. ASPIRED is entirely Python-based and is independent of iraf.
summary: Automated SpectroPhotometric Image REDuction (ASPIRED)
6 changes: 3 additions & 3 deletions src/aspired/image_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ def load_data(self):
)
self.dark_filename.append(self.dark_list[i].split("/")[-1])

# combine the arc frames
# combine the dark frames
self.dark_main = self.combine_dark()

# Get the flats if available
Expand All @@ -2080,7 +2080,7 @@ def load_data(self):
)
self.flat_filename.append(self.flat_list[i].split("/")[-1])

# combine the arc frames
# combine the flat frames
self.flat_main = self.combine_flat()

# Get the biases if available
Expand All @@ -2105,7 +2105,7 @@ def load_data(self):
)
self.bias_filename.append(self.bias_list[i].split("/")[-1])

# combine the arc frames
# combine the bias frames
self.bias_main = self.combine_bias()

def add_light(self, light, header, exposure_time):
Expand Down
20 changes: 16 additions & 4 deletions src/aspired/onedspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5091,7 +5091,7 @@ def set_atmospheric_extinction(
else:

filename = pkg_resources.resource_filename(
"aspired", "extinction/{}_atm_extinct.txt".format(location)
"aspired", "extinction/{}_atm_extinct.txt".format(location.lower())
)
extinction_table = np.loadtxt(filename, delimiter=",")
self.extinction_func = interp1d(
Expand Down Expand Up @@ -5175,7 +5175,7 @@ def apply_atmospheric_extinction_correction(

standard_am = standard_airmass
self.logger.info(
"Airmass is set to be {}.".format(standard_am)
"Standard airmass is set to be {}.".format(standard_am)
)

if isinstance(standard_airmass, str):
Expand All @@ -5195,7 +5195,7 @@ def apply_atmospheric_extinction_correction(
"Keyword for airmass: {} cannot be found "
"in header.".format(standard_airmass)
)
self.logger.warning("Airmass is set to be 1.0")
self.logger.warning("Standard airmass is set to be 1.0")

else:

Expand All @@ -5212,7 +5212,7 @@ def apply_atmospheric_extinction_correction(
"Keyword for airmass: AIRMASS cannot be found "
"in header."
)
self.logger.warning("Airmass is set to be 1.0")
self.logger.warning("Standard airmass is set to be 1.0")

if spec_id is not None:

Expand Down Expand Up @@ -5243,6 +5243,9 @@ def apply_atmospheric_extinction_correction(
if isinstance(science_airmass, (int, float)):

science_am = science_airmass
self.logger.info(
"Science airmass is set to be {}.".format(standard_am)
)

if isinstance(science_airmass, str):

Expand All @@ -5256,6 +5259,9 @@ def apply_atmospheric_extinction_correction(

self.logger.warning(str(e))
science_am = 1.0
self.logger.info(
"Science airmass is set to be 1.0."
)

else:

Expand All @@ -5264,11 +5270,17 @@ def apply_atmospheric_extinction_correction(
try:

science_am = science_spec.spectrum_header["AIRMASS"]
self.logger.info(
f"Science airmass is set to be {science_am}."
)

except Exception as e:

self.logger.warning(str(e))
science_am = 1.0
self.logger.info(
"Science airmass is set to be 1.0."
)

if science_am is None:

Expand Down
39 changes: 23 additions & 16 deletions src/aspired/twodspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ def add_data(self, data, header=None):
)

# If it is a fits.hdu.image.PrimaryHDU object
elif isinstance(data, fits.hdu.image.PrimaryHDU) or isinstance(
data, fits.hdu.image.ImageHDU
elif (
isinstance(data, fits.hdu.image.PrimaryHDU)
or isinstance(data, fits.hdu.image.ImageHDU)
):

self.img = data.data
Expand Down Expand Up @@ -281,6 +282,8 @@ def add_data(self, data, header=None):
else:
self.set_header(header)

self.logger.info("An ImageReduction is loaded as data.")

if data.arc_main is not None:

self.arc = data.arc_main
Expand Down Expand Up @@ -1239,8 +1242,9 @@ def add_bad_mask(self, bad_mask=None):
)

# If it is a fits.hdu.image.PrimaryHDU object
elif isinstance(bad_mask, fits.hdu.image.PrimaryHDU) or isinstance(
bad_mask, fits.hdu.image.ImageHDU
elif (
isinstance(bad_mask, fits.hdu.image.PrimaryHDU)
or isinstance(bad_mask, fits.hdu.image.ImageHDU)
):
self.bad_mask = bad_mask.data

Expand Down Expand Up @@ -1349,8 +1353,9 @@ def add_arc(self, arc, header=None):
)

# If it is a fits.hdu.image.PrimaryHDU object
elif isinstance(arc, fits.hdu.image.PrimaryHDU) or isinstance(
arc, fits.hdu.image.ImageHDU
elif (
isinstance(arc, fits.hdu.image.PrimaryHDU)
or isinstance(arc, fits.hdu.image.ImageHDU)
):

self.arc = arc.data
Expand Down Expand Up @@ -1917,25 +1922,27 @@ def set_header(self, header):

self.logger.info('The "header" provided is None. Doing nothing.')

if self.exptime_is_default_value:
if self.header is not None:

self.set_exptime()
if self.exptime_is_default_value:

if self.airmass_is_default_value:
self.set_exptime()

self.set_airmass()
if self.airmass_is_default_value:

if self.seeing_is_default_value:
self.set_airmass()

self.set_seeing()
if self.seeing_is_default_value:

if self.readnoise_is_default_value:
self.set_seeing()

self.set_readnoise()
if self.readnoise_is_default_value:

if self.gain_is_default_value:
self.set_readnoise()

self.set_gain()
if self.gain_is_default_value:

self.set_gain()

def _gaus(self, x, a, b, x0, sigma):
"""
Expand Down

0 comments on commit 5935425

Please sign in to comment.