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

Adapt display_firefly to new Firefly API and make py3-compatible DM-7321 #1

Merged
merged 10 commits into from Nov 22, 2016

Conversation

stargaser
Copy link
Contributor

The Firefly backend for afwDisplay requires the {{firefly_client}} module, installable via {{pip install firefly_client}}. A Firefly server must be accessible.

  • Applied autopep8 and futurize per Python 3 porting guide
  • Implement masks display
  • Update Python API calls to new firefly_client
  • Implement erase, scale, zoom pan



print("RHL", event)
lsst.log.debug("RHL {}".format(event))

Choose a reason for hiding this comment

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

We probably don't want RHL in the debug messages.

lsst.log.debug('*************area select')
pParams = {'URL': 'http://web.ipac.caltech.edu/staff/roby/demo/wise-m51-band2.fits',
'ColorTable': '9'}
plot_id = 3

Choose a reason for hiding this comment

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

I was unable to test the interact stuff. Looking at this hardwired URL to Trey's M51 image I wonder if it works yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not get interact() working for this ticket. It will be addressed in DM-8173.

_fireflyClient.addListener(self.__handleCallbacks)
_fireflyClient = firefly_client.FireflyClient("%s:%d" % (host, port), name)
_fireflyClient.launch_browser()
_fireflyClient.add_listener(self.__handleCallbacks)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a white-space only change; is it necessary? There are others, but I haven't commented on all of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the new LSST Python style guide hews closely to PEP8, we changed the Firefly API to use PEP8-style names (e.g. no camelCase for function names). Other whitespace changes were introduced by autopep8 as part of the Python 3 porting procedure. It was probably a rookie mistake on my part to include the Python 3 porting together with the more substantial changes in DM-7321.


self._scale('Linear', 1, 99, 'Percent')
#self._scale('linear', 1, 99, 'percent')

Choose a reason for hiding this comment

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

Please remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this, will do.

exp = afwImage.ExposureF(mskimg, wcs)
else:
raise RuntimeError("Unknown image type")

Choose a reason for hiding this comment

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

You're allocating a lot of memory just to simplify the code (at the worst case, a mask image, a variance image, and misc. small things like a Wcs). I don't think we want to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this is not efficient. I can try backing this out. In the stack, putting the wcs back together with the image requires building up an Exposure. I see now why you made your own displayLib.writeFitsImage to make the FITS file for Firefly.

There was a bug (since fixed) in the Firefly server in which masks in separate files didn't quite work right. I will try using displayLib.writeFitsImage to write (image + wcs) and mask as separate FITS files and will upload those to Firefly.

@@ -183,23 +222,25 @@ def _drawLines(self, points, ctype):
def _erase(self):
"""Erase the specified DS9 frame"""

Choose a reason for hiding this comment

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

Update the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this, will do.

elif min == "zscale":
pass
elif min == 'zscale':
interval_type = 'zscale'

Choose a reason for hiding this comment

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

You need an else clause to set interval_type = None (otherwise display.scale("log", 0, 100) generates an exception)

if unit == 'absolute' and interval_type is None:
interval_type = 'absolute'
if unit == 'percent':
interval_type = 'percent'

Choose a reason for hiding this comment

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

Can you use elif here? It'd be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do. These are all mutually exclusive.

@stargaser stargaser merged commit f5ddfa2 into master Nov 22, 2016
@stargaser
Copy link
Contributor Author

Post-review fixes:

  • Output informative message when browser tab is not reopened to correct Firefly URL
  • Write image+wcs and mask to separate FITS files to upload to Firefly, instead of recreating the Exposure object
  • Minor code fixes per the pull request

@ktlim ktlim deleted the tickets/DM-7321 branch August 25, 2018 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants