GitLab system status is available here and here

Commit 29841fba authored by Ethan Yeung's avatar Ethan Yeung
Browse files

worked on opening fits file

parent fa7e35bf
%% Cell type:code id:6fad088d tags:
``` python
import numpy as np
import sep
```
%% Cell type:code id:11230211 tags:
``` python
from astropy.io import fits
import matplotlib.pyplot as plt
from matplotlib import rcParams
%matplotlib inline
rcParams['figure.figsize'] = [10., 8.]
```
%% Cell type:code id:ed382cbb tags:
``` python
data = fits.open("../image.fits")
data = fits.open("/home/eyeun/Documents/astr-19/final/image.fits")
```
%% Output
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 data = fits.open("../image.fits")
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/hdu/hdulist.py:176, in fitsopen(name, mode, memmap, save_backup, cache, lazy_load_hdus, ignore_missing_simple, **kwargs)
173 if not name:
174 raise ValueError(f'Empty filename: {name!r}')
--> 176 return HDUList.fromfile(name, mode, memmap, save_backup, cache,
177 lazy_load_hdus, ignore_missing_simple, **kwargs)
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/hdu/hdulist.py:411, in HDUList.fromfile(cls, fileobj, mode, memmap, save_backup, cache, lazy_load_hdus, ignore_missing_simple, **kwargs)
399 @classmethod
400 def fromfile(cls, fileobj, mode=None, memmap=None,
401 save_backup=False, cache=True, lazy_load_hdus=True,
402 ignore_missing_simple=False, **kwargs):
403 """
404 Creates an `HDUList` instance from a file-like object.
405
(...)
408 documentation for details of the parameters accepted by this method).
409 """
--> 411 return cls._readfrom(fileobj=fileobj, mode=mode, memmap=memmap,
412 save_backup=save_backup, cache=cache,
413 ignore_missing_simple=ignore_missing_simple,
414 lazy_load_hdus=lazy_load_hdus, **kwargs)
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/hdu/hdulist.py:1071, in HDUList._readfrom(cls, fileobj, data, mode, memmap, cache, lazy_load_hdus, ignore_missing_simple, **kwargs)
1068 if fileobj is not None:
1069 if not isinstance(fileobj, _File):
1070 # instantiate a FITS file object (ffo)
-> 1071 fileobj = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
1072 # The Astropy mode is determined by the _File initializer if the
1073 # supplied mode was None
1074 mode = fileobj.mode
File ~/.local/lib/python3.10/site-packages/astropy/utils/decorators.py:546, in deprecated_renamed_argument.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
543 msg += f'\n Use {alternative} instead.'
544 warnings.warn(msg, warning_type, stacklevel=2)
--> 546 return function(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/file.py:175, in _File.__init__(self, fileobj, mode, memmap, overwrite, cache)
173 self._open_fileobj(fileobj, mode, overwrite)
174 elif isinstance(fileobj, (str, bytes)):
--> 175 self._open_filename(fileobj, mode, overwrite)
176 else:
177 self._open_filelike(fileobj, mode, overwrite)
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/file.py:564, in _File._open_filename(self, filename, mode, overwrite)
561 ext = os.path.splitext(self.name)[1]
563 if not self._try_read_compressed(self.name, magic, mode, ext=ext):
--> 564 self._file = fileobj_open(self.name, IO_FITS_MODES[mode])
565 self.close_on_error = True
567 # Make certain we're back at the beginning of the file
568 # BZ2File does not support seek when the file is open for writing, but
569 # when opening a file for write, bz2.BZ2File always truncates anyway.
File ~/.local/lib/python3.10/site-packages/astropy/io/fits/util.py:388, in fileobj_open(filename, mode)
378 def fileobj_open(filename, mode):
379 """
380 A wrapper around the `open()` builtin.
381
(...)
385 a raw random-access file reader.
386 """
--> 388 return open(filename, mode, buffering=0)
FileNotFoundError: [Errno 2] No such file or directory: '../image.fits'
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 00:00:00> DATE = '1992-10-26' / Mon Oct 26, 1992 [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:04:08>-START EXPO EMMI RED / Start exp. on EMMI Red CC [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:04:09> EXPO EMMI RED NO = 24887 / Exp. num. on EMMI Red CCD [astropy.io.fits.card]
WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:
ESO-LOG 03:10:52>-STOP EXPO EMMI RED / Stop exp. on EMMI Red CCD [astropy.io.fits.card]
%% Cell type:code id:6c7086d0 tags:
``` python
m, s = np.mean(data), np.std(data)
plt.imshow(data, interpolation='nearest', cmap='gray', vmin=m-s, vmax=m+s, origin='lower')
plt.colorbar();
```
%% Output
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 m, s = np.mean(data), np.std(data)
2 plt.imshow(data, interpolation='nearest', cmap='gray', vmin=m-s, vmax=m+s, origin='lower')
3 plt.colorbar()
File <__array_function__ internals>:180, in mean(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/numpy/core/fromnumeric.py:3474, in mean(a, axis, dtype, out, keepdims, where)
3471 else:
3472 return mean(axis=axis, dtype=dtype, out=out, **kwargs)
-> 3474 return _methods._mean(a, axis=axis, dtype=dtype,
3475 out=out, **kwargs)
File ~/.local/lib/python3.10/site-packages/numpy/core/_methods.py:191, in _mean(a, axis, dtype, out, keepdims, where)
189 ret = ret.dtype.type(ret / rcount)
190 else:
--> 191 ret = ret / rcount
193 return ret
TypeError: unsupported operand type(s) for /: 'PrimaryHDU' and 'int'
%% Cell type:code id:c6cc10c3 tags:
``` python
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment