Skip to content

Commit

Permalink
[LBL] Remove warning when SCI_TABLE is not present in template [Issue…
Browse files Browse the repository at this point in the history
  • Loading branch information
njcuk9999 committed Oct 4, 2024
1 parent 96765a7 commit 023b523
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lbl/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# Define variables
# =============================================================================
__NAME__: str = 'base.py'
__version__: str = '0.64.0'
__date__: str = '2024-09-16'
__version__: str = '0.64.001'
__date__: str = '2024-10-04'
__authors__: str = ('Neil Cook, Etienne Artigau, Charles Cadieux, '
'Thomas Vandal, Ryan Cloutier, Pierre Larue')
__package__: str = 'lbl'
Expand Down
14 changes: 12 additions & 2 deletions lbl/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,13 @@ def save_data_to_hdfstore(filename: str, columns: Dict[str, List[np.ndarray]],
# =============================================================================
# Define table functions
# =============================================================================
TableReturn = Union[Table, Tuple[Table, LBLHeader], None, Tuple[None, None]]


def load_table(filename: str, kind: Union[str, None] = None,
fmt: str = 'fits', get_hdr: bool = False,
extname: Optional[str] = None,
) -> Union[Table, Tuple[Table, LBLHeader]]:
extname: Optional[str] = None, required: bool = True
) -> TableReturn:
"""
Standard way to load table
Expand All @@ -1005,6 +1008,13 @@ def load_table(filename: str, kind: Union[str, None] = None,
else:
table = Table.read(filename, format=fmt)
except Exception as e:
if not required:
# deal with an expected table + header return
if get_hdr:
return None, None
# otherwise just return None
else:
return None
emsg = 'Cannot load {0}. Filename: {1} \n\t{2}: {3}'
eargs = [kind, filename, type(e), str(e)]
raise LblException(emsg.format(*eargs))
Expand Down
6 changes: 3 additions & 3 deletions lbl/science/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ def get_systemic_vel_props(inst: InstrumentsType, template_file: str,
props = dict()
# check if there is an extension with the RV for all epochs
# noinspection PyBroadException
try:
props['SCI_TABLE'] = io.load_table(template_file, extname='SCI_TABLE')
except:
props['SCI_TABLE'] = io.load_table(template_file, extname='SCI_TABLE',
required=False)
if props['SCI_TABLE'] is None:
msg = 'No RV table found'
log.general(msg)

Expand Down

0 comments on commit 023b523

Please sign in to comment.