Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdc
kis_headers
Commits
6288a9b5
Commit
6288a9b5
authored
Apr 21, 2022
by
Taras Yakobchuk
Browse files
Merge branch 'patch_gris_headers' into 'master'
Allow NoneType key values in header validation See merge request
!5
parents
a7931bc9
fe34b335
Pipeline
#3851
passed with stage
in 50 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
kis_headers/process_header.py
View file @
6288a9b5
...
...
@@ -22,7 +22,9 @@ def validate_header(header, instrument):
for
key
in
templates_core
[
instrument
]:
if
key
in
header
:
if
type
(
header
[
key
]).
__name__
!=
templates_core
[
instrument
][
key
][
'Type'
]:
key_type
=
type
(
header
[
key
]).
__name__
if
key_type
!=
templates_core
[
instrument
][
key
][
'Type'
]
and
\
key_type
!=
'NoneType'
:
try
:
header
[
key
]
=
eval
(
templates_core
[
instrument
][
key
][
'Type'
])(
header
[
key
])
except
(
TypeError
,
ValueError
):
...
...
kis_headers/util.py
View file @
6288a9b5
...
...
@@ -5,9 +5,15 @@ Contains tools for header checking and manipulations
"""
import
re
import
astropy.io.fits
as
fitsio
from
astropy.wcs
import
FITSFixedWarning
import
warnings
from
kis_headers.templates
import
templates
,
templates_core
,
templates_ext
warnings
.
simplefilter
(
'ignore'
,
category
=
FITSFixedWarning
)
class
StatusRecorder
():
'''
Singleton class to store the status of the package.
...
...
@@ -20,13 +26,20 @@ def get_current_file():
"""return the current file, is updated in get_fits_header"""
return
util_status
.
current_file
def
get_fits_header
(
filename
):
"""
Returns header from associated fits file
"""
with
fitsio
.
open
(
filename
,
ignore_missing_end
=
True
,
output_verify
=
'silentfix'
)
as
f
:
header
=
f
[
0
].
header
util_status
.
current_file
=
filename
util_status
.
current_file
=
filename
fits_file
=
fitsio
.
open
(
filename
,
memmap
=
False
,
ignore_missing_end
=
True
)
try
:
hdu
=
fits_file
[
0
]
hdu
.
verify
(
"silentfix"
)
header
=
fits_file
[
hdu
].
header
except
IndexError
:
header
=
None
fits_file
.
close
()
return
header
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment