Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Guides/SkyFit.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Next, a dialog asking you to input an approximate azimuth and altitude of the ca

Use arrow keys **<-- Left** and **Right -->** to cycle through images. Find an image which has clearly visible stars and has no clouds. **Green circles** are stars detected on the image using an automatic algorithm, but there might be some which were not automatically detected. You will also notice **red plusses** on the image, those are projected positions of catalog stars, and the projection is done by using the current astrometric parameters. The size of the catalog star marker is proportional to the brightness of the star, which can help you with identifying which star is which. You will notice that the stars on the image and the catalog stars do not match at all. Our goal is to tweak the astrometric parameters until they do match.

If the image is dark, **use U and J keys to change the image gamma.** You can press **CTRL + A** to automatically adjust the image levels.
If the image is dark, **use U and J keys to change the image gamma.** Automatic adjustment of the image levels is enabled by default - press **CTRL + A** to toggle it off and on, or simply drag the histogram region on the Levels tab to switch to manual levels (starting from the auto-determined values).

First, cycle through images and see if the catalog stars follow the general direction of the movement of the image stars. For example, if your camera is rotated in any way, the movement of catalog stars will not match the movement of the image stars. This can be corrected for by changing the ***rotation*** using keys **Q** and **E**. Rotate the catalog stars until the stars start moving in approximately the same direction. If the stars are going in the opposite direction, the position angle should be 180 degrees.

Expand Down
17 changes: 15 additions & 2 deletions RMS/Routines/CustomPyqtgraphClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ def mousePressEvent(self, event):
modifier = QtWidgets.QApplication.keyboardModifiers()
pos = self.vb.mapSceneToView(event.pos())
if self.item.region.movable and modifier == QtCore.Qt.ControlModifier:
self.item.exitAutoLevels()
if event.button() == QtCore.Qt.LeftButton:
self.setLevels(pos.y(), self.getLevels()[1])
elif event.button() == QtCore.Qt.RightButton:
Expand Down Expand Up @@ -1248,14 +1249,26 @@ def toggleAutoLevels(self):
else:
self.setLevels(*self.saved_manual_levels)
self.auto_levels = not self.auto_levels
self.region.setMovable(not self.auto_levels)

def exitAutoLevels(self):
"""
Drop out of auto levels mode, keeping the auto-determined levels as the manual levels
"""
if self.auto_levels:
self.auto_levels = False
self.saved_manual_levels = self.getLevels()

def paint(self, p, *args):
# tbh this is an improvement
pass

def regionChanging(self):
pass # doesn't update when moving it
# Doesn't update the image when moving the region, only on release

# A user drag on the region while auto levels are on drops to manual mode, keeping the
# auto-determined levels as the starting point
if self.auto_levels and (self.region.moving or any(l.moving for l in self.region.lines)):
self.exitAutoLevels()

def imageChanged(self, autoLevel=False, autoRange=False):
if not self.auto_levels:
Expand Down
21 changes: 19 additions & 2 deletions Utils/SkyFit2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3310,6 +3310,10 @@ def setupUI(self, loaded_file=False):
else:
self.tab.hist.setLevels(0, 255)

# Turn on auto levels by default (Ctrl + A toggles back to manual)
if not self.tab.hist.auto_levels:
self.tab.hist.toggleAutoLevels()

self.tab.settings.updateInvertColours()
self.tab.settings.updateImageGamma()
self.tab.star_detection.setCatalogLM(self.cat_lim_mag)
Expand Down Expand Up @@ -3636,7 +3640,13 @@ def changeStation(self, dir_path=None, config_override=None):
# Update ImageItems with new handle before loading platepar (which triggers drawing)
self.img.changeHandle(self.img_handle)
self.img_zoom.changeHandle(self.img_handle)
self.tab.hist.setLevels(0, 2**(8*self.img.data.itemsize) - 1)
if not self.tab.hist.auto_levels:
self.tab.hist.setLevels(0, 2**(8*self.img.data.itemsize) - 1)
Comment on lines +3643 to +3644

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the zoom image synced after auto-level reloads

When auto levels are enabled and a station is changed, self.img.changeHandle() recalculates the histogram levels and emits them to img_zoom before self.img_zoom.changeHandle() reloads the zoom image. That reload calls setImage() without levels, so pyqtgraph assigns independent min/max levels to the zoom item; because this guard skips the following hist.setLevels(...), nothing resynchronizes the zoom window. The same ordering exists in the running-state load path, so after switching stations/loading state in default auto mode the zoom view can be stretched differently from the main image.

Useful? React with 👍 / 👎.


# Sync both image items to the histogram levels (setImage assigns each item independent
# min/max levels, and an unchanged histogram won't re-emit them)
self.img.setLevels(self.tab.hist.getLevels())
self.img_zoom.setLevels(self.tab.hist.getLevels())

# Now that the new image dimensions are available, load this station's mask (or clear a
# previous station's mask if this one has none), then render the overlay
Expand Down Expand Up @@ -9580,7 +9590,14 @@ def loadState(self, dir_path, state_name, beginning_time=None, mask=None):
self.img.changeHandle(self.img_handle)
self.img_zoom.changeHandle(self.img_handle)

self.tab.hist.setLevels(0, 2**(8*self.img.data.itemsize) - 1)
if not self.tab.hist.auto_levels:
self.tab.hist.setLevels(0, 2**(8*self.img.data.itemsize) - 1)

# Sync both image items to the histogram levels (setImage assigns each item independent
# min/max levels, and an unchanged histogram won't re-emit them)
self.img.setLevels(self.tab.hist.getLevels())
self.img_zoom.setLevels(self.tab.hist.getLevels())

self.img_frame.autoRange(padding=0)

self.updateCalstars()
Expand Down