Fits header values after image solver script

fredvanner

Well-known member
Apr 17, 2019
205
32
Wells, Somerset, UK
For information: the "flip and overwrite" method I describe above is not just theory, I've tried it before.
See also this previous post:
 

gnewell

Well-known member
Aug 19, 2018
61
2
I just spent a half hour trying to solve the image using astroimageJ, which uses nova, but lets you add constraints. I tried every combination of options with no luck.

scale and center hints, noise filtering, etc.

Here is the problematic image:

 

gnewell

Well-known member
Aug 19, 2018
61
2
0.4043 arcsec per pix. Pixels are 3.8 microns (or maybe 3.75, depending on what you read).
Focal Length is 1937mm
Dia is 12"
 

gnewell

Well-known member
Aug 19, 2018
61
2
That appears to be correct, based on this screen shot of M11 in Stellarium (rotated to almost the same orientation for comparison). The FOV is for the uncropped image.


M11_stellarium_screen_shot.jpg
I eyballed this star in the PI screen shot (marked in the orange circle above):

V369 Sct - HIP 92517 - SAO 142702 - HD 174553
Type: pulsating variable star (DSCT)
Magnitude: 9.35
RA/Dec (J2000.0): 18h51m16.87s/-6°21'11.4"
Rise: 18h38m
Transit: 0h54m
Set: 7h10m
IAU Constellation: Sct
Distance: 1370.40±35.01 ly

So PI is consistent within itself. The problem comes when using PI generated fits files outside of PI with astropy. I suspect there is more wrong, either with my approach and/or with the fits headers, than just being flipped vertically, because the wcs corners of the image from astropy come out crazy, even if I flip things.

I think I used the specific astropy wcs function that worked for nova solved fits files, and perhaps not in a more general case. There is a whole discussion of other possible functions here:


with links to more details...

...

By the way, where is the "fits file preferences" in PI? Is it no longer there? I can't find it.
 

pfile

PTeam Member
Nov 23, 2009
5,615
103
Format Explorer > FITS (double click FITS)

imo the stars in this image are distorted enough that astrometry's star extraction is not finding enough stars to form tight quads. i am messing around with it using the command line version and despite the software saying there are 7000 sources, there are very few stars actually circled in the -objs.png file. i don't know if that is normal or not, since i usually use ImageSolver and havent studied the -objs.png file too carefully in the past.

star profile-wise, i was thinking that the linear file might stand a better chance but i guess you already tried that with no luck. there is an astrometry forum so if you ask there and are lucky, dustin might comment about why this image won't solve (https://groups.google.com/forum/#!forum/astrometry)

rob
 

gnewell

Well-known member
Aug 19, 2018
61
2
@Rob I tried deconvolving the stars in the m11 image. It still won't solve on nova.

Returning to my m92 image, as an example of something that solves in both platforms, to illustrate the world coordinate problem with astropy and PI fits files, using the attached python we get:

solved in nova:
M92 WCS Plot from Nova.jpg

Solved in PI:

M92 WCS Plot from PI.jpg

So there are multiple problems.

The orientation is different, and the Galactic Longitude coordinates are 1) reversed and 2) shifted 180 degrees.

The Galactic Latitude is 1) reversed and 2) shifted by a few degrees.
 

Attachments

gnewell

Well-known member
Aug 19, 2018
61
2
FYI, changing the fits file preferences from up-bottom to bottom-up makes no difference in the world coordinates plot using astropy.
 

ngc1535

PTeam Member
Feb 1, 2014
526
65
AdamBlockStudios.com
I had to solve a similar problem manually once. I have no idea if this is related..but flipping one axis screws up RA. The sign of RA with respect to pixel coordinates matter. E.G. Normally RA increases to the East (left with North up and decreasing pixel coordinates on the screen). If you flip the vertical axis (perhaps Declination) the sign of RA is now backwards...I think. I had some scribbles I made a while ago. I believe Galactic Coordinates have the same sign convention. I could be wrong... just throwing it out there. I had to make certain in my arrays that in the case of RA I had the sign correct for both the screen coordinates and my internal array indices.
This same kind of issue arises with magnitudes where larger numbers mean smaller values and an axis is flipped accordingly.
-adam
 

fredvanner

Well-known member
Apr 17, 2019
205
32
Wells, Somerset, UK
I'm not surprised that changing the FITS input convention doesn't fix problems with PI output (it cerainly didn't help me). Because the orientation of the (RA, Dec) axes with respect to the image (x,y) varies from image to image, the y-axis convention does not have any regualr relationship to either the RA or Dec values. (it is possible for the RA axis to be aligned with the x axis, the y axis, or anything in between).
 

gnewell

Well-known member
Aug 19, 2018
61
2

m92 fit from nova
m92 fits from PI, up-bottom and bottom-up
The python for plotting the fits files in galactic coordinates using astropy (filename is hardcoded)

It just occurred to me I should update astropy and check again. I will do that presently.
 

gnewell

Well-known member
Aug 19, 2018
61
2
No change after updating astropy.

By the way, if you uncomment the lines at the bottom of the world_cor_plot.py file it will plot both Equatorial and Galactic coordinates on the same plot.
 

fredvanner

Well-known member
Apr 17, 2019
205
32
Wells, Somerset, UK
As an aside - PI FITS coorinate origin options: "bottom-up" means the y-axis is numbered for the bottom of the image upwards. The opposite convention is clearly "top-down". "up-bottom" is completely meaningless and confusing (I can only assume it is deliberately selected to discourage you from using FITS) - just mentally convert it to "top-down".
This option only influences the input of files. Unless there is some option I don't know about, FITS files are always output with the "top-down" convention (presumably because this is how images are indexed in PI). This means PI ImageSolver always solves the image in "top-down" orientation.
If you export a solved image from PI to a FITS file and import it into a default "bottom-up" application, then the solution is not correct...
...but...
The solution should have the correct centre, and have approximately the right image extent (i.e. image scaling). I can't see any reason for the garbled corner coordinates.
Comparing the nova and PI solution headers:
The reference ("centre") RA/Dec are near enough the same; the scaling matrix is near enough the same (bar the Y-axis inversion).
The nova solution includes SIP distortion - which if anything is more likely to lead to problems. PI produces a linear solution - which is good enough for most purposes (unless you are doing wide field mosaics or something like that). PI includes the (spurious) PV1_1 and PV1_2 (lat, long) which should have no effect on display (but for safety you could delete these keywords).
I don't have Astropy (yet), so I can't follow up beyond this point.
If you at least want a FITS image output from PI compatible with a "bottom-up" application, you can use the "flip and overwrite" rigmarole I describe above. But I can't see that fixing this Astropy interface problem.
 

gnewell

Well-known member
Aug 19, 2018
61
2
OK thanks.

FYI on astropy; anaconda is an easy python distribution system that supports all platforms, although if you're on mac on linux I guess you can just add to the native python with pip.

 

fredvanner

Well-known member
Apr 17, 2019
205
32
Wells, Somerset, UK
gnewell: I'd like to try running your py script. (My PC is Windows 10 64bit) I've installed anaconda3 and updated astropy - but I have no experience running python scripts. What is the easiest way to run the script (I tried the obvious of "double-clicking" the file: the screen blinked but nothing else happened).
 

gnewell

Well-known member
Aug 19, 2018
61
2
Well I am away from computers this morning but can provide a batch script and file name mode so you can just drag and drop.
In the meantime, you should have an anaconda prompt icon on your desk top, that will open a command window with your python environment initialized. You would cd to the directory with the script and input files, use a text editor to change the file name in the script (or just rename the fits file to match what is hard coded in the script). Then enter “python scriptname.py” (without the quotes) in the cmd window.
Sorry I don’t remember the exact script name.

The script and input files may need to be in %userprofile%\Anaconda3\

directory.
 

fredvanner

Well-known member
Apr 17, 2019
205
32
Wells, Somerset, UK
Thanks. I now have the script running, with output exactly as you display above. I now want to run under PyCharm to debug the problem, but I'm having teething troubles with the setup (pycharm can't see the python v. 3 that anaconda uses). I'm working on it...