Skip to content

Commit

Permalink
Merge changes into release 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiopasra committed Oct 17, 2014
2 parents 7dd7cd1 + 9307d58 commit 283aceb
Show file tree
Hide file tree
Showing 23 changed files with 1,548 additions and 492 deletions.
7 changes: 7 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.8.1 (17 Oct 2014)
----------------------------
Changes:
* New dither recipe DitheredImageARecipeRequirements
* Recipes use one argument in 'run'
* Added capabilities for FITS validation
* IMprovements in FWHM computation

Version 0.8.0 (02 Apr 2014)
----------------------------
Expand Down
4 changes: 2 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ be able to be installed and work properly:
- scipy (http://www.scipy.org)
- astropy (http://www.astropy.org/)
- numina (http://guaix.fis.ucm.es/hg/numina)
- photutils (https://github.com/sergiopasra/photutils/tree/numpy18)[1]
- photutils (https://github.com/sergiopasra/photutils/tree/numpy18) [1]

EMIR is a wide-field, near-infrared, multi-object spectrograph proposed
for the Nasmyth focus of GTC. It will allow observers to obtain from tens to
Expand All @@ -24,4 +24,4 @@ of the Spanish community at large.
Webpage: https://guaix.fis.ucm.es/projects/emir
Maintainer: sergiopr@fis.ucm.es

_[1] This particular branch of photutils is required due a bug in the main package
[1] This particular branch of photutils is required due a bug in the main package
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# The short X.Y version.
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.8.0'
release = '0.8.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion lib/emir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import logging

__version__ = '0.8.0'
__version__ = '0.8.1'


# Top level NullHandler
Expand Down
92 changes: 91 additions & 1 deletion lib/emir/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,94 @@
# along with PyEmir. If not, see <http://www.gnu.org/licenses/>.
#

from numina.core.reciperesult import RecipeResultAutoQC as RecipeResult
import numpy
from astropy import wcs

from numina.core import DataFrame, ObservationResult
from numina.core.recipeinout import RecipeResultAutoQC as RecipeResult

def gather_info_dframe(dataframe):
with dataframe.open() as hdulist:
info = gather_info_hdu(hdulist)
return info

_meta = {
'readmode': ('READMODE', 'undefined'),
'bunit': ('BUNIT', 'ADU'),
'texp': ('EXPTIME', None),
'filter': ('FILTER', 'undefined'),
'imagetype': ('IMGTYP', 'undefined')
}

def gather_info_hdu(hdulist):


# READMODE is STRING
meta = {}
meta['n_ext'] = len(hdulist)
for key, val in _meta.items():
meta[key] = hdulist[0].header.get(val[0], val[1])

adu_s = False
if meta['bunit'].lower() == 'adu/s':
adu_s = True
meta['adu_s'] = adu_s

return meta

def gather_info_frames(framelist):
iinfo = []
for frame in framelist:
with frame.open() as hdulist:
iinfo.append(gather_info_hdu(hdulist))
return iinfo

def gather_info(recipeinput):
klass = recipeinput.__class__
metadata = {}
for key in klass:
val = getattr(recipeinput, key)
if isinstance(val, DataFrame):
metadata[key] = gather_info_dframe(val)
elif isinstance(val, ObservationResult):
metas = []
for f in val.frames:
metas.append(gather_info_dframe(f))
metadata[key] = metas
else:
pass
return metadata

EMIR_BIAS_MODES = ['simple', 'bias', 'single']

def offsets_from_wcs(frames, pixref):
'''Compute offsets between frames using WCS information.
:parameter frames: sequence of FITS filenames or file descriptors
:parameter pixref: numpy array used as reference pixel
The sky world coordinates are computed on *pixref* using
the WCS of the first frame in the sequence. Then, the
pixel coordinates of the reference sky world-coordinates
are computed for the rest of the frames.
The results is a numpy array with the difference between the
computed pixel value and the reference pixel. The first line
of the array is [0, 0], being the offset from the first image
to itself.
'''

result = numpy.zeros((len(frames), pixref.shape[1]))

with frames[0].open() as hdulist:
wcsh = wcs.WCS(hdulist[0].header)
skyref = wcsh.wcs_pix2sky(pixref, 1)

for idx, frame in enumerate(frames[1:]):
with frame.open() as hdulist:
wcsh = wcs.WCS(hdulist[0].header)
pixval = wcsh.wcs_sky2pix(skyref, 1)
result[idx + 1] = -(pixval[0] - pixref[0])

return result
Loading

0 comments on commit 283aceb

Please sign in to comment.