11import argparse
22import requests
33import torch
4- from .parse_config import galfit_config , basic_config
5- from . import models , image , plots , utils , fit , param , AP_config
4+ from . import config , models , plots , utils , fit
5+ from .param import forward , Param , Module
6+
7+ from .image import (
8+ Image ,
9+ ImageList ,
10+ TargetImage ,
11+ TargetImageList ,
12+ SIPTargetImage ,
13+ JacobianImage ,
14+ JacobianImageList ,
15+ PSFImage ,
16+ ModelImage ,
17+ ModelImageList ,
18+ Window ,
19+ WindowList ,
20+ )
21+ from .models import Model
622
723try :
824 from ._version import version as VERSION # noqa
2137
2238def run_from_terminal () -> None :
2339 """
24- Execute AstroPhot from the command line with various options.
25-
26- This function uses the `argparse` module to parse command line arguments and execute the appropriate functionality.
27- It accepts the following arguments:
28-
29- - `filename`: the path to the configuration file. Or just 'tutorial' to download tutorials.
30- - `--config`: the type of configuration file being provided. One of: astrophot, galfit.
31- - `-v`, `--version`: print the current AstroPhot version to screen.
32- - `--log`: set the log file name for AstroPhot. Use 'none' to suppress the log file.
33- - `-q`: quiet flag to stop command line output, only print to log file.
34- - `--dtype`: set the float point precision. Must be one of: float64, float32.
35- - `--device`: set the device for AstroPhot to use for computations. Must be one of: cpu, gpu.
36-
37- If the `filename` argument is not provided, it raises a `RuntimeError`.
38- If the `filename` argument is `tutorial` or `tutorials`,
39- it downloads tutorials from various URLs and saves them locally.
40-
41- This function logs messages using the `AP_config` module,
42- which sets the logging output based on the `--log` and `-q` arguments.
43- The `dtype` and `device` of AstroPhot can also be set using the `--dtype` and `--device` arguments, respectively.
44-
45- Returns:
46- None
40+ Running from terminal no longer supported. This is only used for convenience to download the tutorials.
4741
4842 """
49- AP_config . ap_logger .debug ("running from the terminal, not sure if it will catch me." )
43+ config . logger .debug ("running from the terminal, not sure if it will catch me." )
5044 parser = argparse .ArgumentParser (
5145 prog = "astrophot" ,
5246 description = "Fast and flexible astronomical image photometry package. For the documentation go to: https://astrophot.readthedocs.io" ,
@@ -58,60 +52,60 @@ def run_from_terminal() -> None:
5852 metavar = "configfile" ,
5953 help = "the path to the configuration file. Or just 'tutorial' to download tutorials." ,
6054 )
61- parser .add_argument (
62- "--config" ,
63- type = str ,
64- default = "astrophot" ,
65- choices = ["astrophot" , "galfit" ],
66- metavar = "format" ,
67- help = "The type of configuration file being being provided. One of: astrophot, galfit." ,
68- )
55+ # parser.add_argument(
56+ # "--config",
57+ # type=str,
58+ # default="astrophot",
59+ # choices=["astrophot", "galfit"],
60+ # metavar="format",
61+ # help="The type of configuration file being being provided. One of: astrophot, galfit.",
62+ # )
6963 parser .add_argument (
7064 "-v" ,
7165 "--version" ,
7266 action = "version" ,
7367 version = f"%(prog)s { __version__ } " ,
7468 help = "print the current AstroPhot version to screen" ,
7569 )
76- parser .add_argument (
77- "--log" ,
78- type = str ,
79- metavar = "logfile.log" ,
80- help = "set the log file name for AstroPhot. use 'none' to suppress the log file." ,
81- )
82- parser .add_argument (
83- "-q" ,
84- action = "store_true" ,
85- help = "quiet flag to stop command line output, only print to log file" ,
86- )
87- parser .add_argument (
88- "--dtype" ,
89- type = str ,
90- choices = ["float64" , "float32" ],
91- metavar = "datatype" ,
92- help = "set the float point precision. Must be one of: float64, float32" ,
93- )
94- parser .add_argument (
95- "--device" ,
96- type = str ,
97- choices = ["cpu" , "gpu" ],
98- metavar = "device" ,
99- help = "set the device for AstroPhot to use for computations. Must be one of: cpu, gpu" ,
100- )
70+ # parser.add_argument(
71+ # "--log",
72+ # type=str,
73+ # metavar="logfile.log",
74+ # help="set the log file name for AstroPhot. use 'none' to suppress the log file.",
75+ # )
76+ # parser.add_argument(
77+ # "-q",
78+ # action="store_true",
79+ # help="quiet flag to stop command line output, only print to log file",
80+ # )
81+ # parser.add_argument(
82+ # "--dtype",
83+ # type=str,
84+ # choices=["float64", "float32"],
85+ # metavar="datatype",
86+ # help="set the float point precision. Must be one of: float64, float32",
87+ # )
88+ # parser.add_argument(
89+ # "--device",
90+ # type=str,
91+ # choices=["cpu", "gpu"],
92+ # metavar="device",
93+ # help="set the device for AstroPhot to use for computations. Must be one of: cpu, gpu",
94+ # )
10195
10296 args = parser .parse_args ()
10397
10498 if args .log is not None :
105- AP_config .set_logging_output (
99+ config .set_logging_output (
106100 stdout = not args .q , filename = None if args .log == "none" else args .log
107101 )
108102 elif args .q :
109- AP_config .set_logging_output (stdout = not args .q , filename = "AstroPhot.log" )
103+ config .set_logging_output (stdout = not args .q , filename = "AstroPhot.log" )
110104
111105 if args .dtype is not None :
112- AP_config . dtype = torch .float64 if args .dtype == "float64" else torch .float32
106+ config . DTYPE = torch .float64 if args .dtype == "float64" else torch .float32
113107 if args .device is not None :
114- AP_config . device = "cpu" if args .device == "cpu" else "cuda:0"
108+ config . DEVICE = "cpu" if args .device == "cpu" else "cuda:0"
115109
116110 if args .filename is None :
117111 raise RuntimeError (
@@ -128,7 +122,6 @@ def run_from_terminal() -> None:
128122 "https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/BasicPSFModels.ipynb" ,
129123 "https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/AdvancedPSFModels.ipynb" ,
130124 "https://raw.github.com/Autostronomy/AstroPhot/main/docs/source/tutorials/ConstrainedModels.ipynb" ,
131- "https://raw.github.com/Autostronomy/AstroPhot-tutorials/main/docs/tutorials/simple_config.py" ,
132125 ]
133126 for url in tutorials :
134127 try :
@@ -140,12 +133,35 @@ def run_from_terminal() -> None:
140133 f"WARNING: couldn't find tutorial: { url [url .rfind ('/' )+ 1 :]} check internet connection"
141134 )
142135
143- AP_config .ap_logger .info ("collected the tutorials" )
144- elif args .config == "astrophot" :
145- basic_config (args .filename )
146- elif args .config == "galfit" :
147- galfit_config (args .filename )
136+ config .logger .info ("collected the tutorials" )
148137 else :
149- raise ValueError (
150- f"Unrecognized configuration file format { args .config } . Should be one of: astrophot, galfit"
151- )
138+ raise ValueError (f"Unrecognized request" )
139+
140+
141+ __all__ = (
142+ "models" ,
143+ "Model" ,
144+ "Image" ,
145+ "ImageList" ,
146+ "TargetImage" ,
147+ "TargetImageList" ,
148+ "SIPTargetImage" ,
149+ "JacobianImage" ,
150+ "JacobianImageList" ,
151+ "PSFImage" ,
152+ "ModelImage" ,
153+ "ModelImageList" ,
154+ "Window" ,
155+ "WindowList" ,
156+ "plots" ,
157+ "utils" ,
158+ "fit" ,
159+ "forward" ,
160+ "Param" ,
161+ "Module" ,
162+ "config" ,
163+ "run_from_terminal" ,
164+ "__version__" ,
165+ "__author__" ,
166+ "__email__" ,
167+ )
0 commit comments