Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting a resampled image to a desired size in pixels
05-20-2009, 20:14
Post: #1
Getting a resampled image to a desired size in pixels
Hi,

I am trying to resample one fits image (im555.fits) taken with the ACS on HST to match another HST/ACS image (im814.fits), with the intention of running SExtractor in dual-image mode with im814.fits as the detection image and im555.fits as the measurement image. I have run scamp on both files to compute astrometric solutions and found valid solutions for both images. I have verified the validity of the astrometric solution by swarping each image and then using ds9's "match WCS" facility to compare the two output images.

The problem comes when I try to give im555.fits the same size in pixels as im814. I have tried doing this with an external header (coadd.head) which I have created by extracting the relevant WCS keywords from the im814.fits header. coadd.head contains:

CRVAL1 = 3.177148503E+02 / World coordinate on this axis
CRVAL2 = 2.152741919E+01 / World coordinate on this axis
CRPIX1 = 5.031000000E+03 / Reference pixel on this axis
CRPIX2 = 5.011000000E+03 / Reference pixel on this axis
CD1_1 = -8.282221643E-06 / Linear projection matrix
CD1_2 = 0.000000000E+00 / Linear projection matrix
CD2_1 = 0.000000000E+00 / Linear projection matrix
CD2_2 = 8.282221643E-06 / Linear projection matrix
NAXIS = 2 /
NAXIS1 = 10081 / NUMBER OF ELEMENTS ALONG THIS AXIS
NAXIS2 = 10019 / NUMBER OF ELEMENTS ALONG THIS AXIS

When I run swarp, the output resampled image (im555_swarp.fits) has dimensions 10081x9999 rather than the desired 10081x10019. Strangely, this exact same approach produces output images of identical sizes when I apply it to other pairs of fits files. I had similar problems when I tried to set the output image size via the configuration file, namely by setting CENTER_TYPE and PIXELSCALE_TYPE to MANUAL, and entering the appropriate numbers for PIXEL_SCALE, IMAGE_SIZE, and CENTER. In that case, the swarped output image had the correct pixel scale and center, but not the correct image size (although it worked for some choices of IMAGE_SIZE).

Any hints? I am running swarp on Apple computers, and get the exact same incorrect image size whether I am using my G4 laptop or my Intel MacPro desktop.

Regards,

Chris
Find all posts by this user
Quote this message in a reply
05-20-2009, 20:24
Post: #2
RE: Getting a resampled image to a desired size in pixels
Hi there,

is your output image really called im555_swarp.fits (set by -IMAGEOUT_NAME)? Then the external header has to be called im555_swarp.head.

Does swarp warn, that an external header ist used during resampling?

Best regards Jan
Find all posts by this user
Quote this message in a reply
05-20-2009, 20:57
Post: #3
RE: Getting a resampled image to a desired size in pixels
Hi Jan,

Aha, this was an error in my post and not in my setup (I rename the swarped file after it has been created). Swarp _does_ see the external header and knows that it is using it. It reports the proper size in the external header, but then only resamples up to line 9999. One thing that I did not note in my original post is that the input file (im555.fits) also has an external header, in this case created by scamp. Below is the output of running swarp. You can see that it finds the size of the output image in the external header to be 10081x10019, just as I want, but still produces an output image (which is called im555.resamp.fits, since I don't actually coadd the resampled image with any other image) with 10081x9999 pixels. I worry that I am missing something obvious, but I can't figure out what it is.

Thanks,

Chris

------------------------------------

glorfindel-248: swarp im555.fits -c im555.config
----- SWarp 2.17.1-MP started on 2009-05-20 at 12:53:07 with 4 threads

> Looking for im555.fits
> WARNING: im555.fits has flux scale = 0: I will take 1 instead

> Creating NEW output image...
> WARNING: FITS header data read in coadd.head

------- Output File coadd.fits:
"no ident" WEIGHTED EXT. HEADER 10081x10019 32 bits (floats)
Center: 21:10:51.54 +21:31:38.7 5.01'x4.98' Scale: 0.02982 ''/pixel
Gain: 0 e-/ADU Flux scaling (astrom/photom): 1 X / 1 X
-------------- File im555.fits:
"no ident" WEIGHTED EXT. HEADER 7038x7081 32 bits (floats)
Center: 21:10:51.64 +21:31:39.1 3.5'x3.52' Scale: 0.02982 ''/pixel
Gain: 0 e-/ADU Flux scaling (astrom/photom): 0.9995 X / 1 X
Background: -2.26055e-05 RMS: 0.002260556 Weight scale: 1
> All done (in 26 s)
Find all posts by this user
Quote this message in a reply
05-21-2009, 01:49 (This post was last modified: 05-21-2009 01:56 by Jan Kohnert.)
Post: #4
RE: Getting a resampled image to a desired size in pixels
Ah, ok. So it could be bug... Smile

Could you please provide the image and the header file, if possible? I'm using a self written cfitsio based programme to create the headers and never had problems, so I don't know how tolerant swarp is when using text input headers, which ist what I assume you are using.

I'll attach a header which I just created from your values for you to test (I'm using the coordinates you gave as central values of the output image, I don't know, if that ist correct for you. Note: since cfitsio outputs a complete fits file with zero content, the header is quite large while containing nothing, so I just packed it to save space).

Best regards Jan


Attached File(s)
.gz  coadd.head.gz (Size: 383.69 KB / Downloads: 581)
Find all posts by this user
Quote this message in a reply
05-21-2009, 17:50
Post: #5
RE: Getting a resampled image to a desired size in pixels
Hi Jan,

Thanks for the header file. I tried it out and I got the same result (10081x9999). So, this seems to imply one of two problems:
1. There is something wrong with my configuration file or the external header for the input file. I just used default values for most of the configuration file parameters so there is a decent chance that something is not correct there.
2. There is something wrong with my installation of swarp, either due to something incorrect that I did when I installed it or an actual bug.

One additional thing to note. In running this recently, I once forgot the input header from scamp (im555.head), and I got an incorrectly-sized output image again, but this time it had a y-dimension of 10000 rather than 9999.

Unfortunately, the fits files are too big to upload to Terapix, even gzipped. I have attached the gzipped configuration file (im555.swarp.gz) and external header for the fits file (produced by scamp, im555.head.gz), just in case they contain some fundamental error that is causing the problem.

In the meantime, I will play around and see if I can reproduce the error on smaller fits files that I might be able to upload to this forum.

Thanks for all of your help!

Chris


Attached File(s)
.gz  im555.swarp.gz (Size: 1.54 KB / Downloads: 610)
.gz  im555.head.gz (Size: 974 bytes / Downloads: 582)
Find all posts by this user
Quote this message in a reply
10-06-2009, 04:01
Post: #6
RE: Getting a resampled image to a desired size in pixels
Hi,

I am reviving this thread because I recently encountered a very similar problem when reprojecting to a 36000x18000 plate carrée projection. Many resampled images were a few pixels smaller than they should have been, leaving dark borders in the final image. Emmanuel Bertin correctly diagnosed the problem. Here is what he wrote me:

Quote:The reason for this problem is that SWarp tries to detect the limits occupied by a frame in the output raster using a grid sampling (a full sampling would take too much time at this stage). The density of the grid is set by WCS_NRANGEPOINTS in fitswcs.h. 32 samples per axis is the default. You might want to increase this number and recompile SWarp.

I changed WCS_NRANGEPOINTS to 2048, and this indeed fixed the problem for me.
Thanks, Emmanuel!

Axel
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)