Skip to content

Commit 4c06df6

Browse files
committed
Clean up the script stuff
modified: README.rst modified: doc/scripts/write_script_help.py modified: obstools/__init__.py modified: obstools/deveny_collfocus.py modified: obstools/deveny_grangle.py modified: obstools/dfocus.py modified: obstools/fix_ldt_header.py modified: obstools/lmi_etc.py modified: obstools/neocp_ephem.py modified: obstools/scrub_deveny_pickup.py modified: obstools/utils.py
1 parent fcb5bf0 commit 4c06df6

File tree

11 files changed

+19
-80
lines changed

11 files changed

+19
-80
lines changed

README.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ simply be a matter of executing:
157157
Optional Dependencies
158158
^^^^^^^^^^^^^^^^^^^^^
159159

160-
There are no optional dependencies at this time.
160+
.. There are no optional dependencies at this time.
161161
162-
.. Some of the instrument-specific routines in this package require additional dependencies
163-
.. that are not otherwise needed by the majority of the routines herein.
162+
Some of the instrument-specific routines in this package require additional dependencies
163+
that are not otherwise needed by the majority of the routines herein.
164164

165-
.. - If you are using the ``deveny_pickup_cleaner`` routine, you will need the
166-
.. spectroscopic data reduction pipeline PypeIt for the iterative cleaning of
167-
.. the pickup noise. It can be installed by including it in the optional
168-
.. dependencies, `e.g.`:
165+
- If you are using the ``scrub_deveny_pickup`` tool, you will need the
166+
spectroscopic data reduction pipeline `PypeIt <https://pypeit.readthedocs.io/en/release/>`_
167+
for the iterative cleaning of the pickup noise. It can be installed by
168+
including it in the optional dependencies, *e.g.*:
169169

170-
.. .. code-block:: console
170+
.. code-block:: console
171171
172-
.. pip install "obstools[pypeit] @ git+https://github.com/LowellObservatory/LDTObserverTools"
172+
pip install "obstools[pypeit] @ git+https://github.com/LowellObservatory/LDTObserverTools"

doc/scripts/write_script_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def write_help(script_cls: utils.ScriptBase, opath: pathlib.Path, width: int = 8
3535
width : :obj:`int`, optional
3636
The width of the help text before wrapping (Default: 80)
3737
"""
38-
exe = script_cls.name()
38+
exe = script_cls.name
3939
ofile = os.path.join(opath, f"{exe}.rst")
4040
lines = [".. code-block:: console", ""]
4141
lines += [f" $ {exe} -h"]

obstools/__init__.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
from obstools import neocp_ephem
3030
from obstools import scrub_deveny_pickup
3131
except ImportError as err:
32-
print(f"Had an import error! {err}")
32+
pass
33+
3334

3435
def short_warning(message, category, filename, lineno, file=None, line=None):
3536
"""
@@ -58,17 +59,10 @@ def script_classes() -> dict:
5859
from obstools import utils
5960

6061
# Recursively collect all subclasses
61-
# Since we use PypeIt's ScriptBase, remove all classes from that package
62-
scr_class = np.array(
63-
[
64-
cls
65-
for cls in list(utils.all_subclasses(utils.ScriptBase))
66-
if "pypeit" not in cls.name()
67-
]
68-
)
62+
scr_class = np.array(list(utils.all_subclasses(utils.ScriptBase)))
6963
print(scr_class)
7064

71-
scr_name = np.array([c.name() for c in scr_class])
65+
scr_name = np.array([c.name for c in scr_class])
7266
# Construct a dictionary with the script name and class
7367
srt = np.argsort(scr_name)
7468
return dict(zip(scr_name[srt], scr_class[srt]))

obstools/deveny_collfocus.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,6 @@ class DevenyCollfocus(utils.ScriptBase):
310310
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
311311
"""
312312

313-
@classmethod
314-
def name(cls):
315-
"""
316-
Provide the name of the script. By default, this is the name of the
317-
module.
318-
"""
319-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
320-
321313
@classmethod
322314
def get_parser(cls, width=None):
323315
"""Construct the command-line argument parser.

obstools/deveny_grangle.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,6 @@ class DevenyGrangle(utils.ScriptBase):
379379
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
380380
"""
381381

382-
@classmethod
383-
def name(cls):
384-
"""
385-
Provide the name of the script. By default, this is the name of the
386-
module.
387-
"""
388-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
389-
390382
@classmethod
391383
def get_parser(cls, width=None):
392384
"""Construct the command-line argument parser.

obstools/dfocus.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -856,14 +856,6 @@ class DFocus(utils.ScriptBase):
856856
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
857857
"""
858858

859-
@classmethod
860-
def name(cls):
861-
"""
862-
Provide the name of the script. By default, this is the name of the
863-
module.
864-
"""
865-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
866-
867859
@classmethod
868860
def get_parser(cls, width=None):
869861
"""Construct the command-line argument parser.

obstools/fix_ldt_header.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ class FixLdtHeader(utils.ScriptBase):
7171
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
7272
"""
7373

74-
@classmethod
75-
def name(cls):
76-
"""
77-
Provide the name of the script. By default, this is the name of the
78-
module.
79-
"""
80-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
81-
8274
@classmethod
8375
def get_parser(cls, width=None):
8476
"""Construct the command-line argument parser.

obstools/lmi_etc.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,6 @@ class LmiEtc(utils.ScriptBase):
535535
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
536536
"""
537537

538-
@classmethod
539-
def name(cls):
540-
"""
541-
Provide the name of the script. By default, this is the name of the
542-
module.
543-
"""
544-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
545-
546538
@classmethod
547539
def get_parser(cls, width=None):
548540
"""Construct the command-line argument parser.

obstools/neocp_ephem.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,6 @@ class NeocpEphem(utils.ScriptBase):
190190
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
191191
"""
192192

193-
@classmethod
194-
def name(cls):
195-
"""
196-
Provide the name of the script. By default, this is the name of the
197-
module.
198-
"""
199-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
200-
201193
@classmethod
202194
def get_parser(cls, width=None):
203195
"""Construct the command-line argument parser.

obstools/scrub_deveny_pickup.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,14 +1614,6 @@ class ScrubDevenyPickup(utils.ScriptBase):
16141614
Script structure borrowed from :class:`pypeit.scripts.scriptbase.ScriptBase`.
16151615
"""
16161616

1617-
@classmethod
1618-
def name(cls):
1619-
"""
1620-
Provide the name of the script. By default, this is the name of the
1621-
module.
1622-
"""
1623-
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
1624-
16251617
@classmethod
16261618
def get_parser(cls, width=None):
16271619
"""Construct the command-line argument parser.

obstools/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ def warn_and_return_zeros(return_full: bool, x, xx, yy, order, raise_warn=False)
505505
"""
506506

507507

508-
509508
class SmartFormatter(argparse.HelpFormatter):
510509
r"""
511510
Enable a combination of both fixed-format and wrappable lines to be
@@ -617,9 +616,9 @@ def entry_point(cls):
617616
def name(cls):
618617
"""
619618
Provide the name of the script. By default, this is the name of the
620-
module with "pypeit" prepended.
619+
module.
621620
"""
622-
return f"pypeit_{cls.__module__.split('.')[-1]}"
621+
return f"{cls.__module__.rsplit('.', maxsplit=1)[-1]}"
623622

624623
@classmethod
625624
def parse_args(cls, options=None):
@@ -629,7 +628,9 @@ def parse_args(cls, options=None):
629628
parser = cls.get_parser()
630629
ScriptBase._fill_parser_cwd(parser)
631630
# Add "--version" to bottom of all scripts
632-
parser.add_argument("--version", action="store_true", help="Print version and exit")
631+
parser.add_argument(
632+
"--version", action="store_true", help="Print version and exit"
633+
)
633634
return parser.parse_args() if options is None else parser.parse_args(options)
634635

635636
@staticmethod

0 commit comments

Comments
 (0)