astropy WCS infomation different to header values in fits files
I am having an issue while working with fits files. The problem has to do with the wcs and the header of my file, and for information, the axes of my fits files are velocity and degrees.
The problem is that there is a discrepancy between what WCS says and what my header (which is correct) says.
In particular, if I do:
fits.open('file.fits')[0].header['CRVAL2']
, I get 6012.0, and for
fits.open('pv749290_gu.fits')[0].header['CDELT2']
, I get 4.0
So far so good. The problem arises when I do
w = WCS('file.fits')
, because I get:
CRVAL : 0.0 6012000.0
CDELT : 2.999833375699044 4000.0
So, as you can see the values that I originally had for CRVAL2 and CDELT2 are suddenly 3 orders of magnitude larger, and then this affects then plotting my image because I use "w" as a projection to plot my axes.
Could someone help me to solve this problem? Thanks in advance!
python header astropy fits pyfits
add a comment |
I am having an issue while working with fits files. The problem has to do with the wcs and the header of my file, and for information, the axes of my fits files are velocity and degrees.
The problem is that there is a discrepancy between what WCS says and what my header (which is correct) says.
In particular, if I do:
fits.open('file.fits')[0].header['CRVAL2']
, I get 6012.0, and for
fits.open('pv749290_gu.fits')[0].header['CDELT2']
, I get 4.0
So far so good. The problem arises when I do
w = WCS('file.fits')
, because I get:
CRVAL : 0.0 6012000.0
CDELT : 2.999833375699044 4000.0
So, as you can see the values that I originally had for CRVAL2 and CDELT2 are suddenly 3 orders of magnitude larger, and then this affects then plotting my image because I use "w" as a projection to plot my axes.
Could someone help me to solve this problem? Thanks in advance!
python header astropy fits pyfits
What are the units of the WCS (CUNIT1
andCUNIT2
) ? Do you have an older style WCS withCDELT
andCROTA
or a newer style with aCDi_j
matrix ? Can you post the full WCS somewhere...?
– astrosnapper
Nov 13 '18 at 1:00
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48
add a comment |
I am having an issue while working with fits files. The problem has to do with the wcs and the header of my file, and for information, the axes of my fits files are velocity and degrees.
The problem is that there is a discrepancy between what WCS says and what my header (which is correct) says.
In particular, if I do:
fits.open('file.fits')[0].header['CRVAL2']
, I get 6012.0, and for
fits.open('pv749290_gu.fits')[0].header['CDELT2']
, I get 4.0
So far so good. The problem arises when I do
w = WCS('file.fits')
, because I get:
CRVAL : 0.0 6012000.0
CDELT : 2.999833375699044 4000.0
So, as you can see the values that I originally had for CRVAL2 and CDELT2 are suddenly 3 orders of magnitude larger, and then this affects then plotting my image because I use "w" as a projection to plot my axes.
Could someone help me to solve this problem? Thanks in advance!
python header astropy fits pyfits
I am having an issue while working with fits files. The problem has to do with the wcs and the header of my file, and for information, the axes of my fits files are velocity and degrees.
The problem is that there is a discrepancy between what WCS says and what my header (which is correct) says.
In particular, if I do:
fits.open('file.fits')[0].header['CRVAL2']
, I get 6012.0, and for
fits.open('pv749290_gu.fits')[0].header['CDELT2']
, I get 4.0
So far so good. The problem arises when I do
w = WCS('file.fits')
, because I get:
CRVAL : 0.0 6012000.0
CDELT : 2.999833375699044 4000.0
So, as you can see the values that I originally had for CRVAL2 and CDELT2 are suddenly 3 orders of magnitude larger, and then this affects then plotting my image because I use "w" as a projection to plot my axes.
Could someone help me to solve this problem? Thanks in advance!
python header astropy fits pyfits
python header astropy fits pyfits
asked Nov 12 '18 at 21:36
EnriqueEnrique
235
235
What are the units of the WCS (CUNIT1
andCUNIT2
) ? Do you have an older style WCS withCDELT
andCROTA
or a newer style with aCDi_j
matrix ? Can you post the full WCS somewhere...?
– astrosnapper
Nov 13 '18 at 1:00
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48
add a comment |
What are the units of the WCS (CUNIT1
andCUNIT2
) ? Do you have an older style WCS withCDELT
andCROTA
or a newer style with aCDi_j
matrix ? Can you post the full WCS somewhere...?
– astrosnapper
Nov 13 '18 at 1:00
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48
What are the units of the WCS (
CUNIT1
and CUNIT2
) ? Do you have an older style WCS with CDELT
and CROTA
or a newer style with a CDi_j
matrix ? Can you post the full WCS somewhere...?– astrosnapper
Nov 13 '18 at 1:00
What are the units of the WCS (
CUNIT1
and CUNIT2
) ? Do you have an older style WCS with CDELT
and CROTA
or a newer style with a CDi_j
matrix ? Can you post the full WCS somewhere...?– astrosnapper
Nov 13 '18 at 1:00
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48
add a comment |
1 Answer
1
active
oldest
votes
So, if anyone ever has the same problem one day:
The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).
In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)
1
Well, you should always try to make the data/FITS header as clear as possible... If you setCUNIT2
to'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive
– astrosnapper
Nov 13 '18 at 16:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270456%2fastropy-wcs-infomation-different-to-header-values-in-fits-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So, if anyone ever has the same problem one day:
The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).
In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)
1
Well, you should always try to make the data/FITS header as clear as possible... If you setCUNIT2
to'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive
– astrosnapper
Nov 13 '18 at 16:12
add a comment |
So, if anyone ever has the same problem one day:
The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).
In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)
1
Well, you should always try to make the data/FITS header as clear as possible... If you setCUNIT2
to'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive
– astrosnapper
Nov 13 '18 at 16:12
add a comment |
So, if anyone ever has the same problem one day:
The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).
In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)
So, if anyone ever has the same problem one day:
The problem was that, in my attempt to be as clear as possible, I was adding a value to CUNIT2 of my file, even when originally that keyword was not in the header. In this case, I was using hdr['CUNIT2']='KM/S', but when looking at WCS(file.fits), the value of CRVAL2 seemed to be in m/s instead of km/s, so I think there was some tension between the defaults of WCS and the units I was giving(?).
In any case, by removing again the label of CUNIT2 of the header, and reading again WCS(file.fits) the discrepancies between WCS and the header were gone and the file has now the correct dimension, although the units are not specified in a keyword (but of course you can add a comment to CRVAL2 explicitly saying the units.)
answered Nov 13 '18 at 9:54
EnriqueEnrique
235
235
1
Well, you should always try to make the data/FITS header as clear as possible... If you setCUNIT2
to'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive
– astrosnapper
Nov 13 '18 at 16:12
add a comment |
1
Well, you should always try to make the data/FITS header as clear as possible... If you setCUNIT2
to'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive
– astrosnapper
Nov 13 '18 at 16:12
1
1
Well, you should always try to make the data/FITS header as clear as possible... If you set
CUNIT2
to 'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive– astrosnapper
Nov 13 '18 at 16:12
Well, you should always try to make the data/FITS header as clear as possible... If you set
CUNIT2
to 'm/s'
(lower case), does it work ? According to github.com/astropy/astropy/issues/367 from 2012, the units in FITS headers are case sensitive– astrosnapper
Nov 13 '18 at 16:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270456%2fastropy-wcs-infomation-different-to-header-values-in-fits-files%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What are the units of the WCS (
CUNIT1
andCUNIT2
) ? Do you have an older style WCS withCDELT
andCROTA
or a newer style with aCDi_j
matrix ? Can you post the full WCS somewhere...?– astrosnapper
Nov 13 '18 at 1:00
Hi @astrosnapper, many thanks for willing to help. Actually your comment made me think a bit more on my CUNITn and I found the problem!
– Enrique
Nov 13 '18 at 9:48