Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created June 29, 2015 17:12
Show Gist options
  • Save cdeil/6480edb512002e449317 to your computer and use it in GitHub Desktop.
Save cdeil/6480edb512002e449317 to your computer and use it in GitHub Desktop.
$ make test
export CTAPIPE_EXTRA_DIR=WD/ctapipe-extra
python setup.py test -V
running test
running build
running build_py
Internet access disabled
====================================================== test session starts =======================================================
platform darwin -- Python 3.4.3 -- pytest-2.5.1 -- /opt/local/bin/python
cachedir: /private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/ctapipe-test-76fa4cmx/lib.macosx-10.10-x86_64-3.4/.cache
Running tests with Astropy version 1.1.dev12811.
Running tests in /private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/ctapipe-test-76fa4cmx/lib.macosx-10.10-x86_64-3.4/ctapipe /Users/deil/code/ctapipe2/docs.
Platform: Darwin-14.3.0-x86_64-i386-64bit
Executable: /opt/local/bin/python
Full Python Version:
3.4.3 (default, May 26 2015, 19:25:32)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.9.2
Scipy: 0.15.1
Matplotlib: 1.4.3
h5py: 2.5.0
Running doctests in .rst files is not supported on Python 3.x
plugins: mpl, cache, xdist
collected 3 items
ctapipe/io/camera.py: [doctest] ctapipe.io.camera.get_camera_geometry FAILED
ctapipe/reco/tests/test_hillas.py:9: test_hillas_parameters FAILED
ctapipe/utils/tests/test_datasets.py:8: test_get_datasets_path PASSED
============================================================ FAILURES ============================================================
________________________________________ [doctest] ctapipe.io.camera.get_camera_geometry _________________________________________
040
041 Returns
042 -------
043 a `CameraGeometry` object
044
045
046 Example
047 -------
048
049 >>> geom_ct1 = get_camera_geometry( "hess", 1 )
UNEXPECTED EXCEPTION: FileNotFoundError(2, 'No such file or directory')
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/doctest.py", line 1318, in __run
compileflags, 1), test.globs)
File "<doctest ctapipe.io.camera.get_camera_geometry[0]>", line 1, in <module>
File "/private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/ctapipe-test-76fa4cmx/lib.macosx-10.10-x86_64-3.4/ctapipe/io/camera.py", line 59, in get_camera_geometry
geom = load_camera_geometry_from_file(cam_id, geomfile=geomfile)
File "/private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/ctapipe-test-76fa4cmx/lib.macosx-10.10-x86_64-3.4/ctapipe/io/camera.py", line 90, in load_camera_geometry_from_file
camtable = Table.read(geomfile, hdu="CHERCAM")
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/table/table.py", line 1956, in read
return io_registry.read(cls, *args, **kwargs)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/registry.py", line 323, in read
'read', cls, path, fileobj, args, kwargs)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/registry.py", line 402, in _get_valid_format
valid_formats = identify_format(mode, cls, path, fileobj, args, kwargs)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/registry.py", line 246, in identify_format
origin, path, fileobj, *args, **kwargs):
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/votable/connect.py", line 38, in is_votable
return is_votable(filepath)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/votable/table.py", line 360, in is_votable
with iterparser.get_xml_iterator(source) as iterator:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/utils/xml/iterparser.py", line 175, in get_xml_iterator
with _convert_to_fd_or_read_function(source) as fd:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/utils/xml/iterparser.py", line 66, in _convert_to_fd_or_read_function
with data.get_readable_fileobj(fd, encoding='binary') as new_fd:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/utils/data.py", line 197, in get_readable_fileobj
fileobj = io.FileIO(name_or_obj, 'r')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz'
/private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/ctapipe-test-76fa4cmx/lib.macosx-10.10-x86_64-3.4/ctapipe/io/camera.py:49: UnexpectedException
_____________________________________________________ test_hillas_parameters _____________________________________________________
def test_hillas_parameters():
filename = get_path('hess_camgeom.fits.gz')
# TODO: this test currently doesn't make sense ...
# it's just to show how to access test files
> table = Table.read(filename, format='fits')
ctapipe/reco/tests/test_hillas.py:13:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.table.table.Table'>, args = ('/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz',)
kwargs = {'format': 'fits'}
@classmethod
def read(cls, *args, **kwargs):
"""
Read and parse a data table and return as a Table.
This function provides the Table interface to the astropy unified I/O
layer. This allows easily reading a file in many supported data formats
using syntax such as::
>>> from astropy.table import Table
>>> dat = Table.read('table.dat', format='ascii')
>>> events = Table.read('events.fits', format='fits')
The arguments and keywords (other than ``format``) provided to this function are
passed through to the underlying data reader (e.g. `~astropy.io.ascii.read`).
"""
> return io_registry.read(cls, *args, **kwargs)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/table/table.py:1956:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.table.table.Table'>, args = ('/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz',)
kwargs = {}, format = 'fits', ctx = None, reader = <function read_table_fits at 0x10e8e8e18>
def read(cls, *args, **kwargs):
"""
Read in data
The arguments passed to this method depend on the format
"""
if 'format' in kwargs:
format = kwargs.pop('format')
else:
format = None
ctx = None
try:
if format is None:
path = None
fileobj = None
if len(args):
if isinstance(args[0], six.string_types):
from ..utils.data import get_readable_fileobj
path = args[0]
try:
ctx = get_readable_fileobj(args[0], encoding='binary')
fileobj = ctx.__enter__()
except Exception as e:
fileobj = None
else:
args = [fileobj] + list(args[1:])
elif hasattr(args[0], 'read'):
path = None
fileobj = args[0]
format = _get_valid_format(
'read', cls, path, fileobj, args, kwargs)
reader = get_reader(format, cls)
> data = reader(*args, **kwargs)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/registry.py:326:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', hdu = None
def read_table_fits(input, hdu=None):
"""
Read a Table object from an FITS file
Parameters
----------
input : str or file-like object or compatible `astropy.io.fits` HDU object
If a string, the filename to read the table from. If a file object, or
a compatible HDU object, the object to extract the table from. The
following `astropy.io.fits` HDU objects can be used as input:
- :class:`~astropy.io.fits.hdu.table.TableHDU`
- :class:`~astropy.io.fits.hdu.table.BinTableHDU`
- :class:`~astropy.io.fits.hdu.table.GroupsHDU`
- :class:`~astropy.io.fits.hdu.hdulist.HDUList`
hdu : int or str, optional
The HDU to read the table from.
"""
if isinstance(input, HDUList):
# Parse all table objects
tables = OrderedDict()
for ihdu, hdu_item in enumerate(input):
if isinstance(hdu_item, (TableHDU, BinTableHDU, GroupsHDU)):
tables[ihdu] = hdu_item
if len(tables) > 1:
if hdu is None:
warnings.warn("hdu= was not specified but multiple tables"
" are present, reading in first available"
" table (hdu={0})".format(first(tables)),
AstropyUserWarning)
hdu = first(tables)
# hdu might not be an integer, so we first need to convert it
# to the correct HDU index
hdu = input.index_of(hdu)
if hdu in tables:
table = tables[hdu]
else:
raise ValueError("No table found in hdu={0}".format(hdu))
elif len(tables) == 1:
table = tables[first(tables)]
else:
raise ValueError("No table found")
elif isinstance(input, (TableHDU, BinTableHDU, GroupsHDU)):
table = input
else:
> hdulist = fits_open(input)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/connect.py:137:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'readonly', memmap = None
save_backup = False, cache = True, kwargs = {}, conf = <astropy.io.fits.Conf object at 0x10e62ab00>
def fitsopen(name, mode='readonly', memmap=None, save_backup=False,
cache=True, **kwargs):
"""Factory function to open a FITS file and return an `HDUList` object.
Parameters
----------
name : file path, file object or file-like object
File to be opened.
mode : str, optional
Open mode, 'readonly' (default), 'update', 'append', 'denywrite', or
'ostream'.
If ``name`` is a file object that is already opened, ``mode`` must
match the mode the file was opened with, readonly (rb), update (rb+),
append (ab+), ostream (w), denywrite (rb)).
memmap : bool, optional
Is memory mapping to be used?
save_backup : bool, optional
If the file was opened in update or append mode, this ensures that a
backup of the original file is saved before any changes are flushed.
The backup has the same name as the original file with ".bak" appended.
If "file.bak" already exists then "file.bak.1" is used, and so on.
cache : bool, optional
If the file name is a URL, `~astropy.utils.data.download_file` is used
to open the file. This specifies whether or not to save the file
locally in Astropy's download cache (default: `True`).
kwargs : dict, optional
additional optional keyword arguments, possible values are:
- **uint** : bool
Interpret signed integer data where ``BZERO`` is the
central value and ``BSCALE == 1`` as unsigned integer
data. For example, ``int16`` data with ``BZERO = 32768``
and ``BSCALE = 1`` would be treated as ``uint16`` data.
Note, for backward compatibility, the kwarg **uint16** may
be used instead. The kwarg was renamed when support was
added for integers of any size.
- **ignore_missing_end** : bool
Do not issue an exception when opening a file that is
missing an ``END`` card in the last header.
- **checksum** : bool, str
If `True`, verifies that both ``DATASUM`` and
``CHECKSUM`` card values (when present in the HDU header)
match the header and data of all HDU's in the file. Updates to a
file that already has a checksum will preserve and update the
existing checksums unless this argument is given a value of
'remove', in which case the CHECKSUM and DATASUM values are not
checked, and are removed when saving changes to the file.
- **disable_image_compression** : bool
If `True`, treats compressed image HDU's like normal
binary table HDU's.
- **do_not_scale_image_data** : bool
If `True`, image data is not scaled using BSCALE/BZERO values
when read.
- **ignore_blank** : bool
If `True`, the BLANK keyword is ignored if present.
- **scale_back** : bool
If `True`, when saving changes to a file that contained scaled
image data, restore the data to the original type and reapply the
original BSCALE/BZERO values. This could lead to loss of accuracy
if scaling back to integer values after performing floating point
operations on the data.
Returns
-------
hdulist : an `HDUList` object
`HDUList` containing all of the header data units in the
file.
"""
if memmap is None:
from .. import conf
# distinguish between True (kwarg explicitly set)
# and None (preference for memmap in config, might be ignored)
memmap = None if conf.use_memmap else False
else:
memmap = bool(memmap)
if 'uint16' in kwargs and 'uint' not in kwargs:
kwargs['uint'] = kwargs['uint16']
del kwargs['uint16']
if not name:
raise ValueError('Empty filename: %s' % repr(name))
> return HDUList.fromfile(name, mode, memmap, save_backup, cache, **kwargs)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/hdu/hdulist.py:129:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.io.fits.hdu.hdulist.HDUList'>
fileobj = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'readonly', memmap = None
save_backup = False, cache = True, kwargs = {}
@classmethod
def fromfile(cls, fileobj, mode=None, memmap=None,
save_backup=False, cache=True, **kwargs):
"""
Creates an `HDUList` instance from a file-like object.
The actual implementation of ``fitsopen()``, and generally shouldn't
be used directly. Use :func:`open` instead (and see its
documentation for details of the parameters accepted by this method).
"""
return cls._readfrom(fileobj=fileobj, mode=mode, memmap=memmap,
> save_backup=save_backup, cache=cache, **kwargs)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/hdu/hdulist.py:271:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.io.fits.hdu.hdulist.HDUList'>
fileobj = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', data = None, mode = 'readonly', memmap = None
save_backup = False, cache = True, kwargs = {}
@classmethod
def _readfrom(cls, fileobj=None, data=None, mode=None,
memmap=None, save_backup=False, cache=True, **kwargs):
"""
Provides the implementations from HDUList.fromfile and
HDUList.fromstring, both of which wrap this method, as their
implementations are largely the same.
"""
if fileobj is not None:
if not isinstance(fileobj, _File):
# instantiate a FITS file object (ffo)
> ffo = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/hdu/hdulist.py:792:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'_File' object has no attribute '_file'") raised in repr()] _File object at 0x1128d1be0>
fileobj = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'readonly', memmap = True
clobber = False, cache = True
def __init__(self, fileobj=None, mode=None, memmap=None, clobber=False,
cache=True):
self.strict_memmap = bool(memmap)
memmap = True if memmap is None else memmap
if fileobj is None:
self._file = None
self.closed = False
self.binary = True
self.mode = mode
self.memmap = memmap
self.compression = None
self.readonly = False
self.writeonly = False
self.simulateonly = True
return
else:
self.simulateonly = False
if mode is None:
if _is_random_access_file_backed(fileobj):
fmode = fileobj_mode(fileobj)
# If the mode is unsupported just leave it as None; we'll
# catch this case below
mode = FILE_MODES.get(fmode)
else:
mode = 'readonly' # The default
if mode not in PYFITS_MODES:
raise ValueError("Mode '%s' not recognized" % mode)
if (isinstance(fileobj, string_types) and
mode not in ('ostream', 'append') and
_is_url(fileobj)): # This is an URL.
self.name = download_file(fileobj, cache=cache)
else:
self.name = fileobj_name(fileobj)
self.closed = False
self.binary = True
self.mode = mode
self.memmap = memmap
# Underlying fileobj is a file-like object, but an actual file object
self.file_like = False
# More defaults to be adjusted below as necessary
self.compression = None
self.readonly = False
self.writeonly = False
# Initialize the internal self._file object
if _is_random_access_file_backed(fileobj):
self._open_fileobj(fileobj, mode, clobber)
elif isinstance(fileobj, string_types):
> self._open_filename(fileobj, mode, clobber)
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/file.py:139:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'_File' object has no attribute '_file'") raised in repr()] _File object at 0x1128d1be0>
filename = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'readonly', clobber = False
def _open_filename(self, filename, mode, clobber):
"""Open a FITS file from a filename string."""
if mode == 'ostream':
self._overwrite_existing(clobber, None, True)
if os.path.exists(self.name):
with fileobj_open(self.name, 'rb') as f:
magic = f.read(4)
else:
magic = b('')
ext = os.path.splitext(self.name)[1]
if ext == '.gz' or magic.startswith(GZIP_MAGIC):
# Handle gzip files
> self._file = gzip.open(self.name, PYFITS_MODES[mode])
/Users/deil/Library/Python/3.4/lib/python/site-packages/astropy-1.1.dev12811-py3.4-macosx-10.10-x86_64.egg/astropy/io/fits/file.py:438:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filename = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'rb', compresslevel = 9
encoding = None, errors = None, newline = None
def open(filename, mode="rb", compresslevel=9,
encoding=None, errors=None, newline=None):
"""Open a gzip-compressed file in binary or text mode.
The filename argument can be an actual filename (a str or bytes object), or
an existing file object to read from or write to.
The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for
binary mode, or "rt", "wt", "xt" or "at" for text mode. The default mode is
"rb", and the default compresslevel is 9.
For binary mode, this function is equivalent to the GzipFile constructor:
GzipFile(filename, mode, compresslevel). In this case, the encoding, errors
and newline arguments must not be provided.
For text mode, a GzipFile object is created, and wrapped in an
io.TextIOWrapper instance with the specified encoding, error handling
behavior, and line ending(s).
"""
if "t" in mode:
if "b" in mode:
raise ValueError("Invalid mode: %r" % (mode,))
else:
if encoding is not None:
raise ValueError("Argument 'encoding' not supported in binary mode")
if errors is not None:
raise ValueError("Argument 'errors' not supported in binary mode")
if newline is not None:
raise ValueError("Argument 'newline' not supported in binary mode")
gz_mode = mode.replace("t", "")
if isinstance(filename, (str, bytes)):
> binary_file = GzipFile(filename, gz_mode, compresslevel)
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gzip.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'GzipFile' object has no attribute 'fileobj'") raised in repr()] GzipFile object at 0x1128d1588>
filename = '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz', mode = 'rb', compresslevel = 9, fileobj = None
mtime = None
def __init__(self, filename=None, mode=None,
compresslevel=9, fileobj=None, mtime=None):
"""Constructor for the GzipFile class.
At least one of fileobj and filename must be given a
non-trivial value.
The new class instance is based on fileobj, which can be a regular
file, an io.BytesIO object, or any other object which simulates a file.
It defaults to None, in which case filename is opened to provide
a file object.
When fileobj is not None, the filename argument is only used to be
included in the gzip file header, which may includes the original
filename of the uncompressed file. It defaults to the filename of
fileobj, if discernible; otherwise, it defaults to the empty string,
and in this case the original filename is not included in the header.
The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x', or
'xb' depending on whether the file will be read or written. The default
is the mode of fileobj if discernible; otherwise, the default is 'rb'.
A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
'wb', 'a' and 'ab', and 'x' and 'xb'.
The compresslevel argument is an integer from 0 to 9 controlling the
level of compression; 1 is fastest and produces the least compression,
and 9 is slowest and produces the most compression. 0 is no compression
at all. The default is 9.
The mtime argument is an optional numeric timestamp to be written
to the stream when compressing. All gzip compressed streams
are required to contain a timestamp. If omitted or None, the
current time is used. This module ignores the timestamp when
decompressing; however, some programs, such as gunzip, make use
of it. The format of the timestamp is the same as that of the
return value of time.time() and of the st_mtime member of the
object returned by os.stat().
"""
if mode and ('t' in mode or 'U' in mode):
raise ValueError("Invalid mode: {!r}".format(mode))
if mode and 'b' not in mode:
mode += 'b'
if fileobj is None:
> fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
E FileNotFoundError: [Errno 2] No such file or directory: '/Users/deil/code/ctapipe2/ctapipe-extra/datasets/hess_camgeom.fits.gz'
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gzip.py:181: FileNotFoundError
=============================================== 2 failed, 1 passed in 0.88 seconds ===============================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment