Skip to content

Commit

Permalink
Update README.md, AutofocuserBase.save_focus_record
Browse files Browse the repository at this point in the history
- Increment version
- Improve installation instructions and package description
- Imporve logging in AutofocuserBase.save_focus_record

Modify autofocuser save method

Modify autofocuser save method
  • Loading branch information
ddegen committed Dec 11, 2023
1 parent 51dc957 commit 54c7f6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AstrAFocus
`AstrAFocus` is a package designed to automate the autofocus (AF) process for telescopes. It comprises two main components:
AstrAFocus is a package that provides flexible autofocus (AF) procedures for telescopes.
The tasks that this package aims to automate fall into two broad categories.
1. **Locate the focus calibration region**:
- Identify an area around the zenith that is suitable for focus calibration, given the chosen
focus measurement operator.
Expand Down Expand Up @@ -30,6 +31,8 @@ The key components include:
- Focsuing
- `SweepingAutofocuser`: Performs the autofocusing using sweeping through a range of focus positions.
- `AnalyticResponseAutofocuser(SweepingAutofocuser)`: Performs the autofocusing utilising the analytic nature of the focus response curve of a given focus measure.
- `NonParametricResponseAutofocuser(SweepingAutofocuser)`: Performs the autofocusing using an arbitrary focus measure operator and then applying an extremum estimator from to find the position of maximal focus.


For detailed usage and customization, refer to the source code and docstrings in each module.

Expand All @@ -54,13 +57,16 @@ The package supports additional features through optional dependencies.
You can install these dependencies based on your needs. Choose from the following options:
```bash
# To also install visualization tools, including matplotlib, plotly and dash
python3 -m pip install .[visualization]
python3 -m pip install ".[visualization]"

# To install packages for more statistics and machine learning, including scikit-learn.
python3 -m pip install .[extended]
python3 -m pip install ".[extended]"

# To install dash
python3 -m pip install ".[dash]"

# To install alpyca
python3 -m pip install .[alpaca]
python3 -m pip install ".[alpaca]"
```
`Alpyca` is a [Python 3.7+ API library](https://pypi.org/project/alpyca/)
for all Astronomy Common Object Model ([ASCOM](https://ascom-standards.org/))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"sqlite3worker==1.1.7",
"statsmodels",
]
version = '0.0.2'
version = '0.0.3'

[tool.setuptools.packages.find]
where = ["scr"]
Expand Down
27 changes: 16 additions & 11 deletions scr/astrafocus/autofocuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,22 @@ def reset(self):
self.autofocus_device_manager.move_focuser_to_position(self.initial_position)

def save_focus_record(self):
if self.save_path is not None:
try:
if self.save_path.endswith(".csv"):
self.focus_record.to_csv(self.save_path, index=False)
else:
timestr = time.strftime("%Y%m%d-%H%M")
save_path = os.path.join(self.save_path, f"{timestr}_focus_record.csv")
self.focus_record.to_csv(save_path, index=False)
except Exception as e:
logger.exception(e)
logger.warning("Error saving focus record to csv.")
if not isinstance(self.save_path, str):
if self.save_path is not None:
logger.warning("Error saving focus record to csv. Invalid save path.")
return None

try:
if self.save_path.endswith(".csv"):
save_path = self.save_path
else:
timestr = time.strftime('%Y-%m-%dT%H:%M:%S')
save_path = os.path.join(self.save_path, f"{timestr}_focus_record.csv")

self.focus_record.to_csv(save_path, index=False)
except Exception as e:
logger.exception(e)
logger.warning("Error saving focus record to csv.")

def get_focus_record(self):
if self._focus_record.size == 0:
Expand Down

0 comments on commit 54c7f6a

Please sign in to comment.