Commit 52b90ca0 authored by Vigeesh Gangadharan's avatar Vigeesh Gangadharan
Browse files

add auto select line

parent f83d1e47
Pipeline #3964 passed with stage
in 3 minutes and 15 seconds
......@@ -166,6 +166,7 @@ def vfisv(
line: Optional[float] = 15662.017,
width: Optional[float] = 1.8,
numproc: Optional[int] = 2,
auto = False,
weights = None
):
"""
......@@ -211,7 +212,7 @@ def vfisv(
"""
vfisv_data = VFISVpackage(path, id, line, width)
vfisv_data = VFISVpackage(path, id, line, width, auto)
# If weights not given, set to 0 for default vfisv weights
if not weights:
......@@ -1631,7 +1632,7 @@ class VFISVpackage:
Package the VFISV parameters for transmission
"""
def __init__(self, path, id, line, width):
def __init__(self, path, id, line, width, auto):
"""
Initialize
......@@ -1656,6 +1657,7 @@ class VFISVpackage:
self.width = width # spectral width in angstrom
self.noise = 0.001 # noise
self.filenames = None # list containing filenames
self.auto = auto
# Populate all parameters
# Get the list of filenames
......@@ -1841,6 +1843,14 @@ class VFISVpackage:
# get the wavelength using the WCS and convert to Angstrom
wave_array = self.get_wavelength_array(convert=Unit.Angstrom)
# set spectral lines automatically based on the spectral region
if auto:
if wave_array[0] <= 15662.017 <= wave_array[-1]:
self.line = 15662.017
elif wave_array[0] <= 10838.970 <= wave_array[-1]:
self.line = 10838.970
# Check if the line is in limit
if wave_array[0] <= self.line <= wave_array[-1]:
# Get wavelength relative to the spectral line
......@@ -2164,9 +2174,10 @@ class VFISVpackage:
@click.option("--errors", type=str, help="Filename to save the uncertainties")
@click.option("--diagnose", type=str, help="Filename to write the inversion fits")
@click.option("--log", type=str, help="Filename to write the log file")
@click.option('--auto', '-a', is_flag=True, help="Automatically select the spectral line/width")
@click.version_option(get_version())
def main(path, id, out, numproc, line, width, weights, preview, errors, diagnose, log):
def main(path, id, out, numproc, line, width, weights, preview, errors, diagnose, log, auto):
"""SDC:GRIS Inversion Pipeline code """
# Get the MPI Communicator
......@@ -2195,7 +2206,7 @@ def main(path, id, out, numproc, line, width, weights, preview, errors, diagnose
sys.exit()
# Run VFISV
data, stokes, header = vfisv(path, id, line, width,numproc,weights=weights)
data, stokes, header = vfisv(path, id, line, width, numproc, auto, weights=weights)
# Get the MPI timer
total_time = MPI.Wtime() - start_time
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment