Skip to content

Commit

Permalink
fixed broken imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cylammarco committed Apr 9, 2023
1 parent 26f7862 commit cb55004
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 74 deletions.
2 changes: 2 additions & 0 deletions src/aspired/__init__.py
Expand Up @@ -27,4 +27,6 @@
"spectral_reduction",
"standard_list",
"util",
"flux_calibration",
"wavelength_calibration",
]
4 changes: 2 additions & 2 deletions src/aspired/flux_calibration.py
Expand Up @@ -498,7 +498,7 @@ def load_standard(
def inspect_standard(
self,
display: bool = True,
rendererLstr="default",
renderer: str = "default",
width: int = 1280,
height: int = 720,
return_jsonstring: bool = False,
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def get_sensitivity(
sens_deg: int = 7,
use_continuum: bool = False,
recompute_continuum: bool = False,
*args,
*args: str,
):
"""
The sensitivity curve is computed by dividing the true values by the
Expand Down
4 changes: 2 additions & 2 deletions src/aspired/image_reduction.py
Expand Up @@ -20,7 +20,7 @@

from .util import bfixpix, create_bad_pixel_mask, create_cutoff_mask

__all__ = ["ImageReduction", "Reducer"]
__all__ = ["ImageReduction", "ImageReducer"]


class ImageReducer:
Expand Down Expand Up @@ -2960,7 +2960,7 @@ def list_files(self):
print(i)


class ImageReducer(Reducer):
class ImageReduction(ImageReducer):
"""
Wrapper class of ImageReduction that will be deprecated in the next
release.
Expand Down
33 changes: 17 additions & 16 deletions src/aspired/spectrum_oneD.py
Expand Up @@ -4,9 +4,10 @@
import os
from typing import Callable, Union

import astropy
import numpy as np
from astropy.io import fits
from rascal import Calibrator
from rascal.calibrator import Calibrator
from scipy import interpolate as itp

__all__ = ["SpectrumOneD"]
Expand Down Expand Up @@ -94,10 +95,8 @@ def __init__(
self.handler = logging.StreamHandler()
else:
if log_file_name == "default":
log_file_name = "{}_{}.log".format(
logger_name,
datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S"),
)
t_str = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
log_file_name = "{logger_name}_{t_str}.log"
# Save log to file
if log_file_folder == "default":
log_file_folder = ""
Expand All @@ -114,7 +113,7 @@ def __init__(
# spectrum ID
if spec_id is None:
self.spec_id = 0
elif type(spec_id) == int:
elif isinstance(spec_id, int):
self.spec_id = spec_id
else:
error_msg = (
Expand Down Expand Up @@ -481,7 +480,7 @@ def __init__(
for d1, d2 in zip(self.hdu_name.values(), number_of_hdus.values()):
self.n_hdu[d1] = d2

def merge(self, spectrum_oned: SpectrumOneD, overwrite: bool = False):
def merge(self, spectrum_oned, overwrite: bool = False):
"""
This function copies all the info from the supplied spectrum_oned to
this one, including the spec_id.
Expand Down Expand Up @@ -525,10 +524,10 @@ def add_spectrum_header(
"""

if header is not None:
if type(header) == fits.Header:
if isinstance(header, fits.Header):
self.spectrum_header = header
self.logger.info("spectrum_header is stored.")
elif type(header[0]) == fits.Header:
elif isinstance(header[0], fits.Header):
self.spectrum_header = header[0]
self.logger.info("spectrum_header is stored.")
else:
Expand Down Expand Up @@ -564,10 +563,10 @@ def add_standard_header(
"""

if header is not None:
if type(header) == fits.Header:
if isinstance(header, fits.Header):
self.standard_header = header
self.logger.info("standard_header is stored.")
elif type(header[0]) == fits.Header:
elif isinstance(header[0], fits.Header):
self.standard_header = header[0]
self.logger.info("standard_header is stored.")
else:
Expand Down Expand Up @@ -857,14 +856,14 @@ def remove_variances(self):
self.var = None

def add_line_spread_profile_upsampled(
self, line_spread_profile_upsampled: astropy.model
self, line_spread_profile_upsampled: astropy.modeling.Fittable1DModel
):
"""
Add the empirical line spread profile as measured from the upsampled image.
Parameters
----------
profile_func: a fitted astropy.model
profile_func: a fitted astropy.modeling.Fittable1DModel
The fitted trace profile.
"""

Expand All @@ -877,13 +876,15 @@ def remove_line_spread_profile_upsampled(self):

self.line_spread_profile_upsampled = None

def add_line_spread_profile(self, line_spread_profile: astropy.model):
def add_line_spread_profile(
self, line_spread_profile: astropy.modeling.Fittable1DModel
):
"""
Add the empirical line spread profile as measured.
Parameters
----------
profile_func: a fitted astropy.model
profile_func: a fitted astropy.modeling.Fittable1DModel
The fitted trace profile.
"""

Expand All @@ -902,7 +903,7 @@ def add_profile_func(self, profile_func: Callable):
Parameters
----------
profile_func: a fitted astropy.model
profile_func: a fitted astropy.modeling.Fittable1DModel
The fitted trace profile.
"""

Expand Down
26 changes: 13 additions & 13 deletions src/aspired/twodspec.py
Expand Up @@ -32,7 +32,7 @@
optimal_extraction_marsh89,
tophat_extraction,
)
from .image_reduction import ImageReduction, Reducer
from .image_reduction import ImageReducer, ImageReduction
from .line_spread_function import (
build_line_spread_profile,
get_line_spread_function,
Expand All @@ -56,7 +56,7 @@ def __init__(
fits.hdu.hdulist.HDUList,
fits.hdu.hdulist.PrimaryHDU,
fits.hdu.hdulist.ImageHDU,
Reducer,
ImageReducer,
ImageReduction,
] = None,
header: fits.Header = None,
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(
"SEEDIMM",
"DSEEING",
]
# AEPOSURE is the average exposure time computed in Reducer
# AEPOSURE is the average exposure time computed in ImageReducer
# it is the effective exposure time suitable for computing
# the sensitivity curve.
self.exptime_keyword = [
Expand Down Expand Up @@ -262,14 +262,14 @@ def add_data(
fits.hdu.hdulist.PrimaryHDU,
fits.hdu.hdulist.ImageHDU,
CCDData,
Reducer,
ImageReducer,
ImageReduction,
],
header: fits.Header = None,
):
"""
Adding the 2D image data to be processed. The data can be a 2D numpy
array, an AstroPy ImageHDU/Primary HDU object or an Reducer
array, an AstroPy ImageHDU/Primary HDU object or an ImageReducer
object.
parameters
Expand Down Expand Up @@ -324,10 +324,10 @@ def add_data(
self.bad_mask = create_bad_pixel_mask(self.img)[0]
self.logger.info("A CCDData is loaded as data.")

# If it is an Reducer object
elif isinstance(data, (Reducer, ImageReduction)):
# If it is an ImageReducer object
elif isinstance(data, (ImageReducer, ImageReduction)):
# If the data is not reduced, reduce it here. Error handling is
# done by the Reducer class
# done by the ImageReducer class
if data.image_fits is None:
data.create_image_fits()

Expand All @@ -343,7 +343,7 @@ def add_data(

else:
self.logger.warning(
"Arc frame is not in the Reducer "
"Arc frame is not in the ImageReducer "
"object, please supplied manually if you wish to perform "
"wavelength calibration."
)
Expand Down Expand Up @@ -380,7 +380,7 @@ def add_data(
error_msg = (
"Please provide a numpy array, an "
+ "astropy.io.fits.hdu.image.PrimaryHDU object "
+ "or an Reducer object."
+ "or an ImageReducer object."
)
self.logger.critical(error_msg)
raise TypeError(error_msg)
Expand Down Expand Up @@ -1142,7 +1142,7 @@ def add_bad_mask(
Parameters
----------
bad_mask: numpy.ndarray, PrimaryHDU/ImageHDU, Reducer, str
bad_mask: numpy.ndarray, PrimaryHDU/ImageHDU, ImageReducer, str
The bad pixel mask of the image, make sure it is of the same size
as the image and the right orientation.
Expand Down Expand Up @@ -1245,7 +1245,7 @@ def add_arc(
Parameters
----------
arc: numpy.ndarray, PrimaryHDU/ImageHDU, Reducer, str
arc: numpy.ndarray, PrimaryHDU/ImageHDU, ImageReducer, str
The image of the arc image.
header: FITS header (deafult: None)
An astropy.io.fits.Header object. This is not used if arc is
Expand Down Expand Up @@ -1345,7 +1345,7 @@ def add_arc(
"astropy.io.fits.hdu.image.PrimaryHDU object, an "
"astropy.io.fits.hdu.image.ImageHDU object, an "
"astropy.io.fits.HDUList object, or an "
"aspired.Reducer object."
"aspired.ImageReducer object."
)
self.logger.critical(error_msg)
raise TypeError(error_msg)
Expand Down
7 changes: 3 additions & 4 deletions src/aspired/wavelength_calibration.py
Expand Up @@ -2,6 +2,7 @@
import datetime
import logging
import os
from typing import Union

import numpy as np
from plotly import graph_objects as go
Expand Down Expand Up @@ -95,10 +96,8 @@ def __init__(
self.handler = logging.StreamHandler()
else:
if log_file_name == "default":
log_file_name = "{}_{}.log".format(
logger_name,
datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S"),
)
t_str = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
log_file_name = f"{logger_name}_{t_str}.log"
# Save log to file
if log_file_folder == "default":
log_file_folder = ""
Expand Down

0 comments on commit cb55004

Please sign in to comment.