Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from May Huntsman commissioning run #535

Merged
merged 9 commits into from
Jul 13, 2018
Merged

Conversation

AnthonyHorton
Copy link
Collaborator

A new Huntsman commissioning run (and a bunch of frenzied coding) is imminent, so I'd like to merge the assorted minor changes from the previous run. These are a few bug fixes, plus some more substantial changes to the autofocus routine and the Bisque dome control.

@codecov
Copy link

codecov bot commented Jul 10, 2018

Codecov Report

Merging #535 into develop will decrease coverage by 0.74%.
The diff coverage is 61.11%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #535      +/-   ##
===========================================
- Coverage    70.54%   69.79%   -0.75%     
===========================================
  Files           64       65       +1     
  Lines         5470     5841     +371     
  Branches       760      841      +81     
===========================================
+ Hits          3859     4077     +218     
- Misses        1403     1547     +144     
- Partials       208      217       +9
Impacted Files Coverage Δ
pocs/core.py 77.16% <ø> (ø) ⬆️
pocs/camera/camera.py 90.81% <100%> (+0.2%) ⬆️
pocs/utils/images/__init__.py 74.34% <100%> (-2.73%) ⬇️
pocs/observatory.py 81.59% <100%> (-0.28%) ⬇️
pocs/focuser/focuser.py 82.58% <50%> (+5.91%) ⬆️
pocs/focuser/focuslynx.py 18.47% <0%> (ø)
pocs/state/machine.py 89.26% <0%> (+0.3%) ⬆️
pocs/serial_handlers/protocol_arduinosimulator.py 77.3% <0%> (+0.38%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5d5eef...bdad372. Read the comment docs.

@wtgee
Copy link
Member

wtgee commented Jul 10, 2018

Thanks @AnthonyHorton. A lot of these changes are in #511. I'll do an actual review in a bit as this PR might be better than that one since it is fresher.

Copy link
Member

@wtgee wtgee left a comment

Choose a reason for hiding this comment

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

Sorry, is a bit different from #511, which I'll do separately. Most of this looks good, but a few things to remove and a question about some of the focus logic.

@@ -14,7 +14,8 @@ environment:
weather:
station: mongo
aag_cloud:
serial_port: '/dev/ttyUSB1'
# serial_port: '/dev/ttyUSB1'
serial_port: '/dev/tty.USA19H2P1.1'
Copy link
Member

Choose a reason for hiding this comment

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

We should probably just comment this out and force the use of peas_local.yaml. I've been thinking of doing that system wide to make it obvious to new installers what needs to be changed in the config. Should be okay for here, just mostly thinking out loud.

pocs/core.py Outdated
@@ -181,6 +182,13 @@ def say(self, msg):
self.logger.info('Unit says: {}', msg)
self.send_message(msg, channel='PANCHAT')

if 'slack_webhook_url' in self.config:
Copy link
Member

Choose a reason for hiding this comment

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

Some of the slack and twitter stuff got officially pulled into POCS, so let's strip all this from here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, removed.

# Fit data around the maximum value to determine best focus position.
# Initialise models
shift = models.Shift(offset=-focus_positions[imax])
poly = models.Polynomial1D(degree=4, c0=1, c1=0, c2=-1e-2, c3=0, c4=-1e-4,
Copy link
Member

Choose a reason for hiding this comment

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

Any chance you'll want to change the degree of this, i.e. pull from config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's possible, but unlikely I think. As well as changing the degree of the polynomial you'd need to change the number of points around the maximum used for the fitting, so it isn't an under or over constrained fitting problem.

@@ -485,6 +486,9 @@ def autofocus_cameras(self, camera_list=None, coarse=False):

autofocus_events = dict()

if coarse is None:
coarse = not self._coarse_focus_done
Copy link
Member

Choose a reason for hiding this comment

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

Seems like either this variable name is wrong or the default logic is wrong. Doesn't this end up doing a coarse focus every time but the first time? Also see setter below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's doing something fairly sensible. self._coarse_focus_done is set to False in the constructor, so unless coarse has been set in the call to autofocus_cameras then coarse will get set to True here, and so it will do a coarse focus the first time autofocus_cameras is called.

Not clear to me that we actually want it to do this, though. Coarse focus is only needed in a pretty limited set of circumstances already, and will only be needed less with time.

Copy link
Member

Choose a reason for hiding this comment

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

Sadly I think I wrote this code so I would hopefully understand it. Actually, I missed the not in the logic. Thanks.

@@ -507,6 +511,8 @@ def autofocus_cameras(self, camera_list=None, coarse=False):
else:
autofocus_events[cam_name] = autofocus_event

self._coarse_focus_done = True
Copy link
Member

Choose a reason for hiding this comment

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

Along with above, seems like this should check if a coarse focus was done and if so set variable. It is currently always set to True as far as I can tell.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is all a bit odd. It sets self._coarse_focus_done to True after any call to autofocus_cameras, regardless of whether a coarse focus was actually performed.

I wondering whether we should just remove all of this. We hardly every want to actually do a coarse focus, and I feel like any logic for deciding whether to do it or not belongs more in the state machine than here.

Copy link
Member

Choose a reason for hiding this comment

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

That's okay with me so I leave the decision up to you. We could feasibly build a coarse-focus state that we could transition to at various points.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. Will remove it for now and see how we go during the next Huntsman run, and reinstate if needed.

@@ -56,6 +56,7 @@ def read(self, timeout=5):

try:
response = self.socket.recv(4096).decode()
self.logger.debug('Response from reading TSX socket: {}'.format(response))
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed. I was using it for debug and it generated way too much output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@wtgee
Copy link
Member

wtgee commented Jul 11, 2018

@AnthonyHorton , if you see this in time could you actually split this into separate PRs? After the removal of the items commented on above there is essentially:

  • camera focus (can include small exp_time fix and warnings import)
  • dome parking
  • colorbar on pretty image from FITS.

These are all separate things, so that will keep it a little cleaner. I'm guilty of the same thing on #511 but @jamessynge was good and called me out on it. ;)

Copy link
Member

@wtgee wtgee left a comment

Choose a reason for hiding this comment

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

I'm going to approve and leave the decision about the coarse code removal to you.

pocs/core.py Outdated
@@ -5,6 +5,7 @@
import warnings
import multiprocessing
import zmq
import requests
Copy link
Member

Choose a reason for hiding this comment

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

Not needed, was part of the slack stuff. Will pull through with a merge from upstream/develop anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, removing for now.

@AnthonyHorton AnthonyHorton merged commit c952500 into develop Jul 13, 2018
@wtgee wtgee deleted the may-run branch October 13, 2019 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants