Giter Club home page Giter Club logo

wss_tools's Introduction

WSS Tools

Powered by Astropy Badge

Github Actions CI Status

Documentation Status

This package contains Python tools for JWST Wavefront Sensing Software (WSS). In particular, it provides Quicklook and Image Preprocessor (QUIP) for WEx.

wss_tools's People

Contributors

astrofrog avatar azure-pipelines[bot] avatar bsipocz avatar cdeil avatar crawfordsm avatar dependabot-preview[bot] avatar embray avatar eteq avatar hamogu avatar kbarbary avatar keflavich avatar kulpster85 avatar larrybradley avatar mdboom avatar mperrin avatar mwcraig avatar nflagey-stsci avatar pllim avatar rendinam avatar wkerzendorf avatar zblz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wss_tools's Issues

Infrastructure updates notice from Astropy Project

Hello from Astropy Project!

The following updates to your package might be necessary to ensure compatibility with the latest stable version of Astropy:

  • MPLBACKEND is now set to Agg in ci-helpers, packages expecting interactive plotting should override it in .travis.yml
  • Astropy 3.1 is not compatible with Numpy <1.13 versions. If you want to keep testing these older Numpy versions, please use ASTROPY_VERSION=3.0 or ASTROPY_VERSION=LTS in your Travis CI matrix.
  • Add sphinx-astropy as a package dependency if you are using astropy-helpers 3.1 or later. Otherwise, your documentation build (e.g., on ReadTheDocs) might fail.
  • If you are using six that is bundled with Astropy, please consider using the standalone six package instead.

If these are no longer applicable to you, please close the issue.

This is an automated issue for packages that opted in for automated astropy-helpers update. If this is opened in error, please let @pllim know.

xref astropy/astropy-tools#108

possible feature request - background subtraction of a 2D background image

Also mentioned by Knight, but it's TBD if this is sufficiently a concern to implement.

Right now the background subtraction just works to subtract a constant background level, and that is expected to be sufficient for WFS analyses purposes. As a contingency capability, if there is more spatially variable background than we expect, it might be desired to have some capability to subtract a 2D background image. I.e. load an image A, then select some other image B (via a file selection dialog?) and subtract image B from image A.

Class TKxxxx is implemented in both

Similar problem to the one reported here. Charles has the same problem with QUIP using his root (Python 2.7) Anaconda environment.

NOTE: Explicitly setting backend to Qt4 instead of GTK on ~/.ginga/general.cfg didn't work for him. Asked him to set the backend to Qt4Agg in ~/.config/matplotlib/matplotlibrc but that didn't work either.

SOLUTION: Need to set export MPLBACKEND="Qt4Agg" in the bash shell that calls QUIP.

SaveQUIP crash with ValueError (rare bug?)

I encountered it once while testing but unable to reproduce it. I modified some images in different ways and then tried to save them out. One of them crashed with an error that can be reproduced in Astropy like this:

In [1]: from astropy.io import fits

In [2]: prihdu = fits.PrimaryHDU()

In [3]: prihdu.header.add_history('\n')
...
.../astropy/io/fits/card.py in value(self, value)
    321                     'FITS header values must contain standard printable ASCII '
    322                     'characters; {!r} contains characters not representable in '
--> 323                     'ASCII or non-printable characters.'.format(value))
    324         elif isinstance(value, bytes):
    325             # Allow str, but only if they can be decoded to ASCII text; note

ValueError: FITS header values must contain standard printable ASCII characters; '\n' contains characters not representable in ASCII or non-printable characters.

So, somehow a \n character sneaked into the change history in Ginga and crashed the process of writing modified FITS back out. If this happens to you, please report your story here so I can track it somemore.

Cannot import stginga from AstroConda

If using the instructions to conda install stginga from AstroConda channel results in "cannot find module named stginga" error message, try this within the same conda environment you have set up for QUIP:

conda uninstall stginga
pip install git+https://github.com/spacetelescope/[email protected]

When stginga is fixed in AstroConda, switch back to that build by doing this:

pip uninstall stginga
conda install stginga

NOTE: Also see astroconda/astroconda-contrib#35

test....

why did the other one disappear?

Recenter images if needed for wavefront maintenance

Description

Need functionality in QUIP to center the image at the desired WAS location when not doing LOS Jitter at the begging of the Routine Fine Phasing observations. The "autoQuip" mode would also need to create the QUIP Out file for WEx to process then send those updated images to WAS Automatic mode instead of ones from DMS. So this is a feature request for “auto-quip” (which is just a pre-processing routine that didn’t use quip (ginga) at all) to center the target at the WAS-expected point before invoking the WAS.

Additional context

SegIDHelper interface does not work for everyone

This is a follow up of #47 .

  • Font size is hardcoded, resulting in misalignment on my machine (screenshot below). To fix this, adding an interface for me to set font size would be desirable. Or whatever setting that needs to be customizable to make it work, not necessarily font size alone.
  • While we're adding configuration, option to change text colors would be nice too, in case you need to display the image in a different colormap.
  • Not sure why the dialog for this plugin is on the left, and not right like everything else. Can we move it to the right?
  • When I close the plugin, I cannot make the text overlay disappear.
  • How do I hide the text while plugin is still active? This overlay can be confusing if I decide to load another image that is not the "segment ID" format.
  • Could use module docstring and a Help button to display usage info for users.

Screenshot from 2019-03-12 16-39-46

Ginga cannot load AboutQUIP and MosaicAuto

Using:

  • wss-tools 0.3.7
  • stginga 0.1.3
  • and ginga 2.6.3
  • python 3.5.3

Log:

2017-05-31 12:55:41,837 | E | ModuleManager.py:90 (load_module) | Failed to load module 'AboutQUIP': No module named 'AboutQUIP'
2017-05-31 12:55:41,838 | E | Control.py:314 (add_global_plugin) | Unable to load global plugin 'AboutQUIP': No module named 'AboutQUIP'

2017-05-31 12:55:42,333 | E | ModuleManager.py:90 (load_module) | Failed to load module 'MosaicAuto': No module named 'MosaicAuto'
2017-05-31 12:55:42,333 | E | Control.py:287 (add_local_plugin) | Unable to load local plugin 'MosaicAuto': No module named 'MosaicAuto'

2017-05-31 12:55:42,400 | E | PluginManager.py:74 (load_plugin) | Traceback:
  File ".../ginga/gw/PluginManager.py", line 43, in load_plugin
    module = self.mm.get_module(spec.module)

  File ".../ginga/misc/ModuleManager.py", line 95, in get_module
    return self.module[module_name]

Similar problem as spacetelescope/stginga#126 although it theoretically should have been fixed in the Ginga release being used...

c/c @ejeschke @Skyhawk172

Does mosaic for THUMBNAIL have WCS?

Answer: Yes, but no distortion, which should not matter for the purpose of QUIP.

Below is the resultant WCS from nircam_test mosaic generated using MosaicAuto and saved out using SaveImage:

>>> from astropy.io import fits
>>> from astropy.wcs import WCS
>>> with fits.open('mosaic0_quip.fits') as pf:
...     data = pf[0].data
...     hdr = pf[0].header
>>> WCS(hdr)
WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'  
CRVAL : 5.6305680000000002  0.42412888888889  
CRPIX : 484.0  276.0  
PC1_1 PC1_2  : 1.0  0.0  
PC2_1 PC2_2  : -0.0  1.0  
CDELT : 0.0001818624  0.0001818624  
NAXIS    : 758 550

No method found matching xxxx

QUIP (or rather, Ginga) gives the following terminal messages on start-up, which are misinterpreted as errors by WEx. Need to find a way to make these messages go away.

No method found matching 'ms_draw'
No method found matching 'kp_poly_del'
No method found matching 'ms_none'
No method found matching 'gs_swipe'
No method found matching 'kp_poly_add'
No method found matching 'ms_wheel'
No method found matching 'gs_tap'
No method found matching 'kp_edit_del'
No method found matching 'ms_cursor'

Opened an issue for Ginga to address this at ejeschke/ginga#357

request: SNRCalc tool should calculate and display background mean

Request from Scott Knight. In the SNRCalc tool display, where it outputs Background STDEV, it could also display the Background Mean. This would help inform the user if the background is substantially nonzero in which case the user may wish to use the Background Subtraction feature.

Does mosaic for THUMBNAIL have WCS?

Answer: Yes.

Below is the resultant WCS from using nircam_test input images. Obviously, it ignores distortion but shouldn't matter for the purpose of QUIP. The mosaic was generated using MosaicAuto and saved out using SaveImage.

>>> from astropy.io import fits
>>> from astropy.wcs import WCS
>>> with fits.open('mosaic0_quip.fits') as pf:
...     data = pf[0].data
...     hdr = pf[0].header
>>> WCS(hdr)
WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'  
CRVAL : 5.6305680000000002  0.42412888888889  
CRPIX : 484.0  276.0  
PC1_1 PC1_2  : 1.0  0.0  
PC2_1 PC2_2  : -0.0  1.0  
CDELT : 0.0001818624  0.0001818624  
NAXIS    : 758 550

Cannot install Ginga and stginga from AstroConda on Windows

As reported by @Skyhawk172, the instructions to install dependencies from AstroConda do not work on Windows. Instead this error is given, "Could not find URL http://ssb.stsci.edu/astroconda/win-64"

Temporary workaround is to use pip install instead. The following installs the latest dev commit of Ginga (at the time of this post) and latest release of stginga:

pip install git+https://github.com/ejeschke/ginga.git@100296e
pip install git+https://github.com/spacetelescope/[email protected]

The workaround can be used until astroconda/astroconda#17 is resolved, if possible. If not, then the installation instructions will have to be updated to reflect this limitation permanently.

Bad recentering of the WL images due to field with “relatively bright stars”

Description

Encountered an issue with the recenter function during routine wavefront sensing. The Center of mass was off due to other bright stars in the field. This is an update to force the center of mass to not be biased by nearby stars.

Expected behavior

Recenter the brightest star in the field.

Actual behavior

The center of mass was offset which caused the center of the PSF to be miscalculated, resulting in NaN(s).

Steps to Reproduce

Run QUIP with an Operation File with Operation WAVEFRONT_MAINTENANCE with the following input images: (which can be obtained from MAST)
jw02726-o097_t020_nircam_f212n-wlm8-nrca3_wfscmb-04.fits
jw02726-o097_t020_nircam_f212n-wlp8-nrca3_wfscmb-05.fits

  1. Download the images from MAST: https://mast.stsci.edu/portal/Mashup/Clients/Mast/Portal.html?searchQuery=%7B%22service%22%3A%22JWSTFILTERED%22%2C%22inputText%22%3A%5B%7B%22paramName%22%3A%22filter%22%2C%22niceName%22%3A%22filter%22%2C%22values%22%3A%5B%22F212N%22%5D%2C%22valString%22%3A%22F212N%22%2C%22isDate%22%3Afalse%2C%22facetType%22%3A%22discrete%22%2C%22displayString%22%3A%22F212N%22%7D%2C%7B%22paramName%22%3A%22observtn%22%2C%22niceName%22%3A%22observtn%22%2C%22values%22%3A%5B%5D%2C%22valString%22%3A%22097%22%2C%22isDate%22%3Afalse%2C%22freeText%22%3A%22097%22%2C%22displayString%22%3A%22097%22%7D%2C%7B%22paramName%22%3A%22program%22%2C%22niceName%22%3A%22program%22%2C%22values%22%3A%5B%5D%2C%22valString%22%3A%2202726%22%2C%22isDate%22%3Afalse%2C%22freeText%22%3A%2202726%22%2C%22displayString%22%3A%2202726%22%7D%2C%7B%22paramName%22%3A%22act_id%22%2C%22niceName%22%3A%22act_id%22%2C%22values%22%3A%5B%2205%22%2C%2204%22%5D%2C%22valString%22%3A%2205%2C%2004%22%2C%22isDate%22%3Afalse%2C%22facetType%22%3A%22discrete%22%2C%22displayString%22%3A%2205%2C%2004%22%7D%2C%7B%22paramName%22%3A%22detector%22%2C%22niceName%22%3A%22detector%22%2C%22values%22%3A%5B%22NRCA3%22%5D%2C%22valString%22%3A%22NRCA3%22%2C%22isDate%22%3Afalse%2C%22facetType%22%3A%22discrete%22%2C%22displayString%22%3A%22NRCA3%22%7D%2C%7B%22paramName%22%3A%22productLevel%22%2C%22niceName%22%3A%22productLevel%22%2C%22values%22%3A%5B%223%22%5D%2C%22valString%22%3A%223%22%2C%22isDate%22%3Afalse%2C%22facetType%22%3A%22discrete%22%2C%22displayString%22%3A%223%22%7D%5D%2C%22position%22%3A%22undefined%2C%20undefined%2C%20undefined%22%2C%22paramsService%22%3A%22Mast.Jwst.Filtered.Nircam%22%2C%22title%22%3A%22JWST%3A%20%20Advanced%20Search%201%22%2C%22tooltip%22%3A%22F212N%3B%20097%3B%2002726%3B%2005%2C%2004%3B%20NRCA3%3B%203%3B%20%22%2C%22columns%22%3A%22*%22%7D
  2. Create a Operation File that provides the downloaded images: see example: https://github.com/spacetelescope/wss_tools/blob/master/wss_tools/tests/data/operation_file_001.xml
  3. quip <operation_file>
  4. Verify the error is thrown at recenter.py, line 90
offsetdata = np.roll(data, (xcntr - int(ycpsf),
                                        ycntr - int(xcpsf)),
                                 axis=(1, 0))
ValueError: cannot convert float NaN to integer 

System Details

Add function to generate operation file

In some cases, users will want to launch QUIP from the command line, which requires the generation of an operation file. Currently, the WSS WEx handles the generation of the file when QUIP is started. A new function shall therefore be created that will allow the user to generate such an operation file.

This discussion was started earlier where Pey-Lian already made some suggestions as to where and how to implement this function. See #49 (review)

As discussed, Pey-Lian will lead the development of this new function.

Support Qt5?

Need to update general.cfg to use 'qt5' if Qt5 becomes the default.

[SOLVED] Cannot mosaic 624 small images together

There are 624 shruken images to be mosaicked, each is 43 KB (totalling to 27 MB). Original image size is 206 KB.

Shrunken image info:

No.    Name         Type      Cards   Dimensions   Format
  0  SCI         PrimaryHDU      26   (100, 100)   float32

Error message from Ginga (on terminal):

2017-06-05 14:10:59,384 | E | Task.py:925 (execute) |
  Task '<ginga.rv.Control.GingaShell object at 0x7f18dfe70dd8>.task630' raised exception:
  Failed to load file 'testnnn.fits': [Errno 24] Too many open files
...
2017-06-05 14:10:59,417 | E | Task.py:364 (execute) | Traceback:
  File ".../ginga/misc/Task.py", line 350, in execute
    res = self.func(*self.args, **self.kwdargs)
  File ".../ginga/rv/plugins/Mosaic.py", line 466, in mosaic_some
    image = image_loader(url)
  File ".../ginga/rv/Control.py", line 516, in load_image
    raise ControlError(errmsg)

Error message from Ginga (in Errors plugins):

Failed to load file 'testnnn.fits': [Errno 24] Too many open files
  File ".../ginga/rv/Control.py", line 503, in load_image
    image = self.fits_opener.load_file(filepath, **kwargs)

  File ".../ginga/util/io_fits.py", line 167, in load_file
    inherit_primary_header=inherit_primary_header)

  File ".../ginga/util/io_fits.py", line 258, in get_hdu
    if not isinstance(hdu.data, numpy.ndarray):

  File ".../astropy/utils/decorators.py", line 736, in __get__

  File ".../astropy/io/fits/hdu/image.py", line 243, in data

  File ".../astropy/io/fits/hdu/image.py", line 700, in _get_scaled_image_data

  File ".../astropy/io/fits/hdu/base.py", line 478, in _get_raw_data

  File ".../astropy/io/fits/file.py", line 264, in readarray

  File ".../numpy/core/memmap.py", line 264, in __new__

SOLUTION 1

  1. Check "open files" in ulimit -a command line output.
  2. If you have admin privilege, change it to a number higher than approx. 1500 (e.g., 4096). Otherwise, you need to contact ITSD.
  3. Now run QUIP to create the mosaic. It will take up to a few minutes, but no errors or missing inputs this time.

SOLUTION 2

  1. conda update astropy to get 1.3.3 (latest release as of Jun 6, 2017). Make sure you are in the correct conda environment for QUIP.
  2. cd ~/.astropy/config
  3. cp astropy.1.3.3.cfg astropy.cfg
  4. Add the following in the astropy.cfg file under [io.fits] section (about half-way down). Then, save it.
use_memmap = False  # Maybe this does not matter?
lazy_load_hdus = False
  1. Now run QUIP to create the mosaic. It will take up to a few minutes, but no errors or missing inputs this time.
  2. It is recommended that you revert the changes in astropy.cfg for "normal" use afterwards.

pip install sometimes gives errors

When Charles was following the installation step to use pip install to install wss_tools, he ran into errors caused by pip attempting to use Python 2.7 libraries from root environment although he was installing into Python 3.5 wssenv environment. The traceback complains about compat, futures, exc_type, exc_value, traceback, etc. The error appears even when he was only calling pip (not installing wss_tools), so this error has nothing to do with this package, but rather affects its installation.

However, he didn't have that problem when he did pip install in the root environment itself.

If this continues to be a problem, one solution can be to include wss_tools as part of AstroConda distribution. This way, user can use conda install instead.

For now, we just document this and leave it be, as per discussions with Charles.

Why is the global installation on wsslinux2 not working?

ANSWER: Global installation on wsslinux2 in /internal/data2/anaconda has been removed in favor of new distribution method (see "Installation" section in RTD document). The directory is still there because I don't have write permission to remove some of the files, but it does not work anymore. Please do not use.

Does QUIP work on Windows?

Charles will attempt to get it installed and running on the "ITM machine". Theoretically, it should work.

Update the help

Tyler Desjardins mentions that we should consider moving emails from help[at]stsci.edu to point to the web portal where possible and appropriate. For HST (or any non-JWST), it is https://hsthelp.stsci.edu . For JWST, it is https://jwsthelp.stsci.edu . Please update info in setup.py, setup.cfg, documentation, etc as appropriate.

Please close this issue if it is irrelevant to your repository. This is an automated issue. If this is opened in error, please let pllim know!

xref spacetelescope/hstcal#317

Add PyQt to setup.py install_requires

I've run into this problem now a number of times while trying to install wss_tools. I get the following traceback:

> quip quip_wcs_test/ops_file_congrid2048_assignwcs.xml 
Traceback (most recent call last):
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/qtpy/__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/lchambers/miniconda3/envs/mirage/bin/quip", line 10, in <module>
    sys.exit(_main())
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/wss_tools/quip/main.py", line 430, in _main
    main(sys.argv[1:])
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/wss_tools/quip/main.py", line 185, in main
    gmain.reference_viewer(sys_args)
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/ginga/rv/main.py", line 715, in reference_viewer
    viewer.main(options, args)
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/ginga/rv/main.py", line 355, in main
    ginga_toolkit.choose()
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/ginga/toolkit.py", line 75, in choose
    from ginga.qtw import QtHelp  # noqa
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/ginga/qtw/QtHelp.py", line 35, in <module>
    from qtpy import QtCore
  File "/Users/lchambers/miniconda3/envs/mirage/lib/python3.6/site-packages/qtpy/__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

I fix this by installing PyQt, so I think this error could be avoided by adding PyQt5 to the install_requires list in setup.py.

Retire Python 2

Python 2 will not be maintained past Jan 1, 2020 (see https://pythonclock.org/). Please remove all Python 2 compatibility and move this package to Python 3 only.

For conda recipe (including astroconda-contrib), please include the following to prevent packaging it for Python 2 (https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html?preprocessing-selectors#skipping-builds):

build: 
  skip: true  # [py2k] 

Please close this issue if it is irrelevant to your repository. This is an automated issue. If this is opened in error, please let pllim know!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.