Trouble getting a value of a keyword in a FITS file.
3 views (last 30 days)
Show older comments
Chris Anast
on 4 Feb 2018
Commented: Chris Anast
on 5 Feb 2018
I have a FITS file named sun.fits. With fitsinfo('sun.fits'), the structure in the image below is output.

The Image header at the end contains the structure seen in the image below.

There is a specific keyword, 'EXPTIME', in the Keywords header at the end that contains a value that I want, as seen in the third image below.

fitsread('sun.fits', image) just images the data encoded in the DataType of the second image. I tried to find a way to access that specific keyword that I need in a script but couldn't find any. Of course, I can just double click on the Keywords and just find and see the value from there but I want to write code that returns it when I know the keyword that I'm looking for.
Thanks in advance, Chris
0 Comments
Accepted Answer
Walter Roberson
on 5 Feb 2018
info = fitsinfo('sun.fits');
keywords = info.Keywords;
[tf, idx] = ismember('EXPTIME', keywords(:,1));
if tf
exposure_time = keywords{idx,2};
else
tf = nan;
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!