Skip to content

Commit

Permalink
Merge branch 'trm-dev'
Browse files Browse the repository at this point in the history
Bringing a bunch of recent changes into the master branch.
  • Loading branch information
trmrsh committed Jun 4, 2021
2 parents 7e0ac9a + a026b11 commit b5dbb6f
Show file tree
Hide file tree
Showing 34 changed files with 2,376 additions and 1,506 deletions.
2 changes: 1 addition & 1 deletion docs/change_log_0.22.0_1.0.0.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. changelog created on Wed 26 May 15:43:37 BST 2021
.. changelog created on Wed 2 Jun 15:19:03 BST 2021
.. include:: globals.rst

Expand Down
6 changes: 5 additions & 1 deletion docs/makingmovies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ raw data, run0005.fits sat.
trim = False
ccd = 2
bias = bias3x3_slow.hcm
dark = none
flat = none
fmap = none
defect = none
log = run0005.log
targ = 1
Expand Down Expand Up @@ -84,7 +86,9 @@ Once you have the stills, you still need to actually make the movie. I use the c
which would find any files of the form 'run0005_0340.png' starting
from 'run0005_0123.png'. 'ffmpeg' has a million-and-one options and
there be ways to tweak it, but this does a reasonable job I find.
You can loop the movie with something like:

``ffmpeg -start_number 3 -i run0011_%04d.png -filter_complex loop=5:362 -c:v libx264 -pix_fmt yuv420p movie.mp4 -y``


which would add 6 loops.

32 changes: 32 additions & 0 deletions docs/reduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,35 @@ no one prescription that works for all cases. Faint targets normally require
different settings from bright ones for the best results (e.g. smaller target
aperture radii). Very faint target may benefit from optimal extraction, while
brighter ones can look worse.

Specific errors
---------------

I hope to list commonly encountered error traces here.

Mis-matching calibration files
..............................

An error message such as this::

nrtplot ../run0012
first - first frame to plot [1]: \
1, utc= 2021-05-10 03:01:12.777 (ok), Traceback (most recent call last):
File "/home/phsaap/.local/bin/nrtplot", line 8, in <module>
sys.exit(nrtplot())
File "/home/phsaap/.local/lib/python3.9/site-packages/hipercam/scripts/nrtplot.py", line 836, in nrtplot
bias = bias.crop(mccd)
File "/home/phsaap/.local/lib/python3.9/site-packages/hipercam/ccd.py", line 795, in crop
tmccd[cnam] = self[cnam].crop(ccd)
File "/home/phsaap/.local/lib/python3.9/site-packages/hipercam/ccd.py", line 552, in crop
raise HipercamError(
hipercam.core.HipercamError: failed to find any enclosing window for window label = E1

is a good sign that you have a problem with a mis-match between a
calibration file and the data. In this case the bias frame selected
was taken with 2x2 binning while the data were unbinned, and so it was
impossible for it to recover. NB The code does attempt to go the other
way, i.e. to bin up 1x1 into 2x2 if need be, although this can only
ever be approximate. The other way for this message to occur is you
try to use windowed calibration data which does not span the windows
of the data.
4 changes: 3 additions & 1 deletion hipercam/ccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,9 @@ def read(cls, fname):
"""
with fits.open(fname) as hdul:
return cls.rhdul(hdul)
mccd = cls.rhdul(hdul)
mccd.head['FILENAME'] = fname
return mccd

@classmethod
def rhdul(cls, hdul):
Expand Down
37 changes: 18 additions & 19 deletions hipercam/cline.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@

# next two lines allow tab completion of file names
import readline

readline.parse_and_bind("tab: complete")

from .core import HipercamError, HipercamWarning
Expand Down Expand Up @@ -764,8 +763,8 @@ def get_value(
if multipleof != None and value % multipleof != 0:
raise ClineError(str(value) + " is not a multiple of " + str(multipleof))

# update appropriate set of defaults. In the case of Fnames, strip the
# extension
# update appropriate set of defaults. In the case of Fnames,
# strip the extension
if self._rpars[param]["g_or_l"] == Cline.GLOBAL:
if isinstance(defval, Fname):
self._gpars[param] = defval.noext(value)
Expand Down Expand Up @@ -842,7 +841,8 @@ def __new__(cls, root, ext="", ftype=OLD, exist=True):
"""

if ftype != Fname.OLD and ftype != Fname.NEW and ftype != Fname.NOCLOBBER:
if ftype != Fname.OLD and ftype != Fname.NEW and \
ftype != Fname.NOCLOBBER:
raise ClineError("ftype must be either OLD, NEW or NOCLOBBER")

# store root with no extension
Expand All @@ -854,9 +854,9 @@ def __new__(cls, root, ext="", ftype=OLD, exist=True):
return fname

def __init__(self, root, ext="", ftype=OLD, exist=True):
"""Initialiser. In the following text items in capitals such as 'OLD' are
static variables so that one should use hipercam.cline.Fname.OLD or
equivalent to refer to them.
"""Initialiser. In the following text items in capitals such as 'OLD'
are static variables so that one should use
hipercam.cline.Fname.OLD or equivalent to refer to them.
Arguments::
Expand All @@ -868,14 +868,14 @@ def __init__(self, root, ext="", ftype=OLD, exist=True):
extension, e.g. '.dat'
ftype : (int)
If exist=True and ftype=OLD, the file :must: exist. If exist=False, the file may or may
not exist already.
If exist=True and ftype=OLD, the file :must: exist. If
exist=False, the file may or may not exist already.
exist : (bool)
If True, the file must exist.
ext, ftype and exist are stored as identically-named attributes. 'root'
is stored as the base string.
ext, ftype and exist are stored as identically-named
attributes. 'root' is stored as the base string.
"""

Expand All @@ -884,16 +884,16 @@ def __init__(self, root, ext="", ftype=OLD, exist=True):
self.exist = exist

def __call__(self, fname):
"""Given a potential file name, this first ensures that it has the correct
extension, and then tests for its existence if need be, depending upon
the values of `ftype` and `exist` defined at instantiation.
"""Given a potential file name, this first ensures that it has the
correct extension, and then tests for its existence if need
be, depending upon the values of `ftype` and `exist` defined
at instantiation.
Arguments::
fname : (string)
file name. The extension associated with the :class:`Fname` will
be added if necessary.
fname : str
file name. The extension associated with the
:class:`Fname` will be added if necessary.
Returns the file name to use. Raises a ClineError exception if there
are problems.
Expand Down Expand Up @@ -926,7 +926,6 @@ def __getnewargs__(self):
"""
return (str(self), self.ext, self.ftype, self.exist)


class ClineError(HipercamError):
"""For throwing exceptions from hipercam.cline"""

Expand Down
2 changes: 1 addition & 1 deletion hipercam/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Version of the reduce file in operation (used by 'reduce' and 'genred')
# Format: YYYYMMDD(.#) where the optional .# part is an integer to allow for
# multiple versions in a day, although that should be rare I hope.
REDUCE_FILE_VERSION = "20210523"
REDUCE_FILE_VERSION = "20210602"

# Standard file extensions
FIELD = ".fld"
Expand Down
7 changes: 5 additions & 2 deletions hipercam/fringe.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,13 @@ def scale(self, ccd, ccdref, nhalf, rmin=None, rmax=None, reset=False, verbose=F
' '.join([f'{rat:.3f}' for rat in np.sort(ratios)])
)

if rmin is not None:
if rmin is not None and rmax is not None:
ratios[(ratios < rmin) & (ratios > rmax)] = np.nan
elif rmin is not None:
ratios[ratios < rmin] = np.nan
if rmax is not None:
elif rmax is not None:
ratios[ratios > rmax] = np.nan

return np.nanmedian(ratios)

class MccdFringePair(Group):
Expand Down
33 changes: 23 additions & 10 deletions hipercam/hcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@ def __init__(self, fname, server=False, full=True):
if "DEC" in hd:
self.thead["DEC"] = hd.get_full("DEC")

if "RADEG" in hd:
self.thead["RADEG"] = hd.get_full("RADEG")

if "DECDEG" in hd:
self.thead["DECDEG"] = hd.get_full("DECDEG")

if "INSTRPA" in hd:
self.thead["INSTRPA"] = hd.get_full("INSTRPA")

Expand All @@ -596,6 +602,12 @@ def __init__(self, fname, server=False, full=True):
if "ESO DET GPS" in hd:
self.thead["GPS"] = hd.get_full("ESO DET GPS")

if "INSTRUME" in hd:
self.thead["INSTRUME"] = hd.get_full("INSTRUME")

if "TELESCOP" in hd:
self.thead["TELESCOP"] = hd.get_full("TELESCOP")

self.thead["XBIN"] = hd.get_full("ESO DET BINX1")
self.thead["YBIN"] = hd.get_full("ESO DET BINY1")
self.thead["SPEED"] = hd.get_full("ESO DET SPEED")
Expand Down Expand Up @@ -1067,7 +1079,7 @@ def __call__(self, nframe=None):
# mode or intermediate junk frames in the case of NSKIP>0
ch["DSTATUS"] = (
(self.nframe > self.ndwins) and (self.nframe % ch["NCYCLE"] == 0),
"Valid data (else junk frame)",
"Valid data or not",
)

# Get time at centre of exposure. Some care here to store a
Expand Down Expand Up @@ -1410,7 +1422,7 @@ def __call__(self, nframe=None):
Arguments::
nframe : int | none
nframe : int | None
frame number to get, starting at 1. 0 for the last (complete)
frame. 'None' indicates that the next frame is wanted.
Expand Down Expand Up @@ -1460,30 +1472,31 @@ def __call__(self, nframe=None):

# update the internal frame counter
self.nframe += 1

# set the reset status to save effort if next time
# we simply want the next frame
self.reset = False

return tbytes

def set(self, nframe=1):
"""Resets the position so that we are just about to read
the timing data of nframe, but does not read them unlike
__call__
__call__. Set the internal "reset" flag if needed.
Arguments::
nframe : int | none
nframe : int | None
frame number to get, starting at 1. 0 for the last (complete)
frame. 'None' indicates that the next frame is wanted.
frame. 'None' indicates just read whatever is the next frame.
Returns:: the timing bytes of the frame
Returns:: the frame number of entry
"""

old_frame = self.nframe

if nframe is None:
# just read whatever frame we are now on
self.reset = False
else:
if nframe is not None:

if nframe == 0:
# go for the last one
nframe = self.ntotal()
Expand Down
Loading

0 comments on commit b5dbb6f

Please sign in to comment.