Skip to content

DM-5192 Implement Python API to support Firefly actions. #130

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

Merged
merged 8 commits into from
Aug 8, 2016

Conversation

cwang2016
Copy link
Contributor

  • move 'python' and 'test/python' from fftools to be under firefly and firefly/test.
  • implement functions to dispatch actions for showing fits, showing table, and adding extension, operating the image (zoom, stretch, and pan), creating/deleting region layer, adding/removing region entries.
  • More functions for adding/removing mask and showing XYPlot will be implemented further.

Fixed some region/footprint related issues in Javascript implementation,

  • per DS9 document, the default system is implicitly set to be 'PHYSICAL' if no coordinate system is explicitly specified in the region file or region data.
  • fixed the footprint/marker display in case the target is represented in various world coordinate systems.

@cwang2016
Copy link
Contributor Author

  • some footprint data is updated, please build and deploy firefly first.
    (gradle :firefly:war :firefly:deploy, and gradle :wise:war)

@cwang2016
Copy link
Contributor Author

The test file, firefly/test/python/demo-notebook.ipynb, can be run by setting PYTHONPATH = where firefly/python/display/FireflyClient.py is located.

@robyww
Copy link
Contributor

robyww commented Aug 2, 2016

Clean up firefly/src/fftools/python/display/FireflyClient.pyc needs to be removed from git.

@robyww
Copy link
Contributor

robyww commented Aug 2, 2016

in the test files you should use relative paths to the data. The put come documentation at the top saying which directly to expect to start notebook in.

@robyww
Copy link
Contributor

robyww commented Aug 2, 2016

Review Complete. Code looks good. Good Job.

@stargaser
Copy link
Contributor

Copied from DM-5192 (I couldn't put all of these in comments on code diffs since many are legacy issues):

Here are some style comments on the FireflyClient.py module, drawn in part from the DM Python Style Guide. I'm still thinking about the method signatures in detail and will comment a little later on those.

  • The methods you don't intend users to use should be prefixed with a single underscore (handleEvent, sendURLAsGet, sendURLAsPost, isPageConnected, createRV, makePidParam)
  • Static methods which use other attributes or methods of the class should be class methods instead. See this discussion on Stack Overflow. The methods in this case include createRV, createRangeValuesStandard, createRangeValuesZScale, genItemId, createImageURL.
  • Instead of if type(var) is list , should use if isinstance(var, list)

@stargaser
Copy link
Contributor

This is another comment not on the specific diffs in this pull request:

As far as the API goes: I know that the Javascript API is organized around Actions. Python users will want to get information back from Firefly. So a simple zoom or pan does not indicate by itself whether the user is setting the zoom in Firefly or getting the currently set value back. If a getZoom or getPan is doable with the Javascript API, then I'd want to have setZoom and setPan. Astronomers will also want to be able to use world coordinates (ra, dec) for specifying the panning, in addition to pixel units.

@stargaser
Copy link
Contributor

stargaser commented Aug 3, 2016

I like the naming of showFits, showTable, and showXYPlot as they clearly indicate that something is going to happen in the Firefly window, and they are in keeping with e.g. the APLpy methods.

Similarly, addRegionData, deleteRegion, removeRegionData indicate actions though I would expect deleteRegion to delete a single region marker and not an entire layer. I suggest to change to deleteRegionLayer and overlayRegionLayer to make it clearer.

"source": [
"import os\n",
"\n",
"from FireflyClient import *\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use from FireflyClient import FireflyClient. I also wonder if the module should be named fireflyClient.py -- I couldn't tell for sure from reading the DM Python Style guide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also they may be trying to get away from camel casing. At one time they decided they wanted to do it like they but I remember some discussion. Might be worth asking Tim Jenness

@robyww
Copy link
Contributor

robyww commented Aug 3, 2016

As far as the API goes: I know that the Javascript API is organized around Actions. Python users will want to get information back from Firefly. So a simple zoom or pan does not indicate by itself whether the user is setting the zoom in Firefly or getting the currently set value back. If a getZoom or getPan is doable with the Javascript API, then I'd want to have setZoom and setPan. Astronomers will also want to be able to use world coordinates (ra, dec) for specifying the panning, in addition to pixel units.

I think you are right about the naming. However, the names where made to be similar to the afw.display api. We should probably make better name and be aware they they will be different. Maybe down the road we can improve the afw.display names.

if not retval:
a= algorithm if algorithm.lower() in FireflyClient.stretchAlgorithmDict else 'linear'
retval= FireflyClient.createRV('zscale',1,2,a,25,600,120)
return retval


@staticmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

make this a @classmethod since it references the class

@stargaser
Copy link
Contributor

Another comment on legacy code:

The methods for specifying the stretch of the image look very forbidding to the astronomer, especially createRV, createRangeValuesStandard and createRangeValuesZScale. It would be better to hide a lot of this under the hood in a setStretch method that would allow for either Zscale, MinMax, Percentile, or absolute levels for the stretch.

"outputs": [],
"source": [
"#file= fc.uploadFile('./data/c.fits')\n",
"file= fc.uploadFile('/hydra/cm/firefly/src/firefly/test/python/data/wise-1b-1.fits')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

The user might be using standalone firefly-exec.war so please use a relative path: .data/wise-1b-1.fits

@stargaser
Copy link
Contributor

Review complete. The region functionality is very nice!
Apologies for so many comments that were on legacy code predating this pull request.

@cwang2016 cwang2016 changed the title Implement Python API to support Firefly actions. DM-5192 Implement Python API to support Firefly actions. Aug 3, 2016
@stargaser
Copy link
Contributor

stargaser commented Aug 3, 2016

An extra note. Tim Jenness confirmed that LSST will move towards more Pythonic lowercase_and_underscores instead of camelCase. The DM Python style guide needs updating. So we should rename removeRegionData to remove_region_data, etc. In general, the style guide will follow Python's PEP8 per RFC-162.

@cwang2016 cwang2016 merged commit 1fe1f3f into dev Aug 8, 2016
@cwang2016 cwang2016 deleted the DM-5192-PyAPI branch August 10, 2016 17:43
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.

3 participants