Skip to content

Commit

Permalink
Create co-added images (phase 2) (#6)
Browse files Browse the repository at this point in the history
* Rename refine to reprocess

* Lots of refactor of camera WCS reprocessing

* Calculate ZP for each frame

* Add PA to frame data

* Sigma-clip, fit, and calculate PA drift

* Support processing spec frames

* Add initial plotting

* Add zero point plot

* Allow to force using time range to select frames

* Use UTC and getmtime

* Fix cases when the reference WCS is empty

* Move extract_sources out of Cameras and add MF pixels

* Add placeholder columns to sources during extraction

* Add CameraSolution and GuiderSolution classes

* Missing colon

* Add data model file

* Use model to update PROC and SOURCES extensions

* Major, major refactor

* Move some code around

* Remove GAIA_CACHE

* Add MF WCS (!) and some header keywords

* Allow to load FITS file into dataclass

* Bump version to 0.3.0a0

* Change some types in SOURCES data model

* Fix update_fits()

* Add DIRNAME

* Change header comment

* Typing

* post_init -> __post_init__

* Fix a few bugs

* Fix merge issues

* Update deps

* Deal with empty dataframe when converting to Table

* Some fixes

* Some fixes

* Remove table_from_dataframe

* Use MF pixels for global solution

* Use parquet for sources files

* Close HDU list

* Reset detections index to ensure Gaia match

* Fix call to update_fits

* Various fixes to guiding. Decrease guide tolerance

* Guide in PA

* Write PACORR to header

* Minimum version to load dataclasses -> 0.4.0a0

* Prevent multiple rotation corrections

* Disable rotation correction for now

* Comment unused lines

* Pretty complete rewrite of co-add functions using dataclasses

* Rename master frame to full frame

* Deal with spec telescope

* Add camera name to log message

* Typo in get_dark_subtrcted_data

* Support dark subtraction in old files without DIRNAME

* Support reprocessing old files. Fix some bugs.

* Plots for FWHM, ZP, and PA

* Add comments and remove redundant code

* Add guider offsets plots

* Various fixes to the datamodel and type casting

* Fix corner case in populating the ap. phot DF

* Fix dtypes that were not serializable

* Save PA offset to guider solution and FITS

* Improve logic to guide in PA

* Fix repetitive message during acquisition

* Set umask so that new files inherit the parent folder permissions

* Tweaks to plotting
  • Loading branch information
albireox authored Sep 4, 2023
1 parent 0e32e1f commit 56c3434
Show file tree
Hide file tree
Showing 16 changed files with 2,293 additions and 1,315 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ RUN pip3 install -U pip setuptools wheel
RUN cd lvmguider && pip3 install .
RUN rm -Rf lvmguider

# Set umask so that new files inherit the parent folder permissions.
RUN echo "umask 0002" >> /etc/bash.bashrc

ENTRYPOINT lvmguider actor start --debug
3 changes: 2 additions & 1 deletion docs/sphinx/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os

from pkg_resources import parse_version
from trurl import __version__

from lvmguider import __version__


# Are we building in RTD?
Expand Down
5 changes: 0 additions & 5 deletions src/lvmguider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import pathlib
import warnings

from astropy.wcs import FITSFixedWarning

from sdsstools import Configuration, get_logger, get_package_version


warnings.simplefilter("ignore", category=FITSFixedWarning)


NAME = "lvmguider"


Expand Down
2 changes: 1 addition & 1 deletion src/lvmguider/actor/commands/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def is_stopping(command: GuiderCommand):
@click.option(
"--reference-pixel",
type=click.Tuple((float, float)),
help="The pixel of the master frame to use as pointing reference.",
help="The pixel of the full frame to use as pointing reference.",
)
@click.option(
"--guide-tolerance",
Expand Down
4 changes: 2 additions & 2 deletions src/lvmguider/actor/commands/set_pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@click.argument("PIXEL-X", type=float)
@click.argument("PIXEL-Z", type=float)
async def set_pixel(command: GuiderCommand, pixel_x: float, pixel_z: float):
"""Sets the master frame pixel coordinates on which to guide.
"""Sets the full frame pixel coordinates on which to guide.
This command can be issued during active guiding to change the pointing
of the telescope.
Expand All @@ -43,7 +43,7 @@ async def set_pixel(command: GuiderCommand, pixel_x: float, pixel_z: float):

@lvmguider_parser.command()
async def reset_pixel(command: GuiderCommand):
"""Resets the master frame pixel on which to guide to the central pixel..
"""Resets the full frame pixel on which to guide to the central pixel..
This command can be issued during active guiding to change the pointing
of the telescope.
Expand Down
15 changes: 10 additions & 5 deletions src/lvmguider/astrometrynet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import pandas
from astropy.io import fits
from astropy.table import Table
from astropy.wcs import WCS
from astropy.units import UnitsWarning
from astropy.wcs import WCS, FITSFixedWarning


PathLike = TypeVar("PathLike", pathlib.Path, str)
Expand Down Expand Up @@ -478,16 +479,20 @@ def astrometrynet_quick(
else:
return solution

warnings.simplefilter("ignore")
wcs = WCS(open(wcs_output).read(), relax=True)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FITSFixedWarning)
wcs = WCS(open(wcs_output).read(), relax=True)

solution.wcs = wcs
solution.stdout = open(stdout).read()
solution.stderr = open(stderr).read()

if os.path.exists(corr_file):
stars = Table.read(corr_file).to_pandas()
solution.stars = stars
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UnitsWarning)

stars = Table.read(corr_file).to_pandas()
solution.stars = stars

return solution

Expand Down
2 changes: 1 addition & 1 deletion src/lvmguider/cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def expose(
if len(sources) > 0:
all_sources = pandas.concat(sources)
valid = all_sources.loc[all_sources.valid == 1]
fwhm = numpy.median(valid["fwhm"]) if len(valid) > 0 else None
fwhm = float(numpy.median(valid["fwhm"])) if len(valid) > 0 else None
else:
valid = []
fwhm = None
Expand Down
Loading

0 comments on commit 56c3434

Please sign in to comment.