Skip to content

Commit

Permalink
Merge branch 'master' into retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed May 5, 2021
2 parents 93ca861 + 2599c20 commit 6efd32d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion species/analysis/emission_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def __init__(self,
@typechecked
def subtract_continuum(self,
poly_degree: int = 3,
plot_filename: str = 'continuum.pdf') -> None:
plot_filename: str = 'continuum.pdf',
spec_filename: Optional[str] = None) -> None:
"""
Method for fitting the continuum with a polynomial function of the following form:
:math:`P = \\sum_{i=0}^{i=n}C_{i} * x^{i}`. The spectrum is first smoothed with a median
Expand All @@ -108,6 +109,9 @@ def subtract_continuum(self,
Degree of the polynomial series.
plot_filename : str
Filename for the plots with the continuum fit and the continuum-subtracted spectrum.
spec_filename : str, None
Output text file for writing the continuum-subtracted spectrum. The file will not be
created if the argument is set to ``None``.
Returns
-------
Expand Down Expand Up @@ -222,6 +226,12 @@ def subtract_continuum(self,

self.continuum_check = True

if spec_filename is not None:
print(f'Writing continuum-subtracted spectrum: {spec_filename}...', end='', flush=True)
header = 'Wavelength (um) - Flux (W m-2 um-1) - Error (W m-2 um-1)'
np.savetxt(spec_filename, self.spectrum, header=header)
print(' [DONE]')

@typechecked
def integrate_flux(self,
wavel_int: Tuple[float, float],
Expand Down

0 comments on commit 6efd32d

Please sign in to comment.