In the CASJOBS Server, I created the following query for galaxies(DR12)

SELECT za.specObjID, za.bestObjID, za.class, za.subClass, za.z, za.zErr,
po.objID, po.type, po.flags, po.ra, po.dec, po.run, po.rerun, po.field, po.camcol,
(po.petroMag_r-po.extinction_r) as dered_petro_r,
zp.z as zphot, zp.zErr as dzphot,
zi.e_bv_sfd,zi.primtarget, zi.sectarget,zi.targettype,zi.spectrotype,zi.subclass

INTO MyDB.SDSS_DR12
FROM SpecObjAll za
JOIN PhotoObjAll po ON (po.objID = za.bestObjID)
JOIN Photoz zp ON (zp.objID = za.bestObjID)
JOIN galSpecInfo zi ON (zi.SpecObjID = za.specObjID)
WHERE
(za.z>0 AND za.zWarning=0)
AND (za.targetType='SCIENCE' AND za.survey='sdss')
AND (za.class='GALAXY' AND zi.primtarget>=64 AND zi.targettype='GALAXY')
AND ((po.petroMag_r-po.extinction_r)<=17.8)
AND za.z <= 0.4;


My Target is to get all the images related to this query. So, in the data release 12 of the SAS server, using the following link, I started downloading all the corrected frames for galaxies that I got (From the photoobj, I got the run number, rerun number, camcol,field no. etc)... The code to do that is here. Then for each galaxy, I got 'u', 'g', 'r', 'i', 'z' images as compressed fitz files. Finally, after getting the fits files, I wanted to resample the images using the swarp tool. with output size of 64. I ran the swarp tool in few sample images, the resulting image is all zeros in each and every pixel values(if we can call it that).

I have a couple of questions: 1. Is the method of downloading frames related to a galaxy based on run, rerun, field and camcol of the PhotoObjAll table in the SDSS casjobs server correct? 2. Why is the output of swarp tool always zero matrix regardless of which sample I give?

Here's my swarp.conf file:

# Default configuration file for SWarp 2.38.0
# EB 2019-08-08
#
#----------------------------------- Output -----------------------------------
WEIGHTOUT_NAME       coadd.weight.fits # Output weight-map filename

#------------------------------- Input Weights --------------------------------

WEIGHT_TYPE            NONE            # BACKGROUND,MAP_RMS,MAP_VARIANCE
# or MAP_WEIGHT
RESCALE_WEIGHTS        Y               # Rescale input weights/variances (Y/N)?
WEIGHT_SUFFIX          .weight.fits    # Suffix to use for weight-maps
WEIGHT_IMAGE                           # Weightmap filename if suffix not used
# (all or for each weight-map)

COMBINE                Y               # Combine resampled images (Y/N)?
COMBINE_TYPE           MEDIAN          # MEDIAN,AVERAGE,MIN,MAX,WEIGHTED,CLIPPED
# CHI-OLD,CHI-MODE,CHI-MEAN,SUM,
# WEIGHTED_WEIGHT,MEDIAN_WEIGHT,
# AND,NAND,OR or NOR
CLIP_AMPFRAC           0.3             # Fraction of flux variation allowed
# with clipping
CLIP_SIGMA             4.0             # RMS error multiple variation allowed
# with clipping
CLIP_WRITELOG          N               # Write output file with coordinates of
# clipped pixels (Y/N)
CLIP_LOGNAME           clipped.log     # Name of output file with coordinates
# of clipped pixels
BLANK_BADPIXELS        N               # Set to 0 pixels having a weight of 0

#-------------------------------- Astrometry ----------------------------------

CELESTIAL_TYPE         NATIVE          # NATIVE, PIXEL, EQUATORIAL,
# GALACTIC,ECLIPTIC, or SUPERGALACTIC
PROJECTION_TYPE        TAN             # Any WCS projection code or NONE
PROJECTION_ERR         0.001           # Maximum projection error (in output
# pixels), or 0 for no approximation
CENTER_TYPE            ALL             # MANUAL, ALL or MOST
CENTER         00:00:00.0, +00:00:00.0 # Coordinates of the image center
PIXELSCALE_TYPE        MEDIAN          # MANUAL,FIT,MIN,MAX or MEDIAN
PIXEL_SCALE            0.0             # Pixel scale
IMAGE_SIZE             64               # Image size (0 = AUTOMATIC)

#-------------------------------- Resampling ----------------------------------

RESAMPLE               Y               # Resample input images (Y/N)?
RESAMPLE_DIR           .               # Directory path for resampled images
RESAMPLE_SUFFIX        .resamp.fits    # filename extension for resampled images

RESAMPLING_TYPE        LANCZOS3        # NEAREST,BILINEAR,LANCZOS2,LANCZOS3
# LANCZOS4 (1 per axis) or FLAGS
OVERSAMPLING           0               # Oversampling in each dimension
# (0 = automatic)
INTERPOLATE            N               # Interpolate bad input pixels (Y/N)?
# (all or for each image)

FSCALASTRO_TYPE        FIXED           # NONE,FIXED, or VARIABLE
FSCALE_KEYWORD         FLXSCALE        # FITS keyword for the multiplicative
# factor applied to each input image
FSCALE_DEFAULT         1.0             # Default FSCALE value if not in header

GAIN_KEYWORD           GAIN            # FITS keyword for effect. gain (e-/ADU)
GAIN_DEFAULT           0.0             # Default gain if no FITS keyword found
# 0 = infinity (all or for each image)
SATLEV_KEYWORD         SATURATE        # FITS keyword for saturation level (ADU)
SATLEV_DEFAULT         50000.0         # Default saturation if no FITS keyword

#--------------------------- Background subtraction ---------------------------

SUBTRACT_BACK          N               # Subtraction sky background (Y/N)?
# (all or for each image)

BACK_TYPE              AUTO            # AUTO or MANUAL
# (all or for each image)
BACK_DEFAULT           0.0             # Default background value in MANUAL
# (all or for each image)
BACK_SIZE              128             # Background mesh size (pixels)
# (all or for each image)
BACK_FILTERSIZE        3               # Background map filter range (meshes)
# (all or for each image)
BACK_FILTTHRESH        0.0             # Threshold above which the background-
# map filter operates

#------------------------------ Memory management -----------------------------

VMEM_DIR               .               # Directory path for swap files
VMEM_MAX               2047            # Maximum amount of virtual memory (MB)
MEM_MAX                2048             # Maximum amount of usable RAM (MB)
COMBINE_BUFSIZE        2048             # RAM dedicated to co-addition(MB)

#------------------------------ Miscellaneous ---------------------------------

DELETE_TMPFILES        Y               # Delete temporary resampled FITS files
# (Y/N)?
COPY_KEYWORDS          OBJECT          # List of FITS keywords to propagate
# from the input to the output headers
WRITE_FILEINFO         N               # Write information about each input
# file in the output image header?
WRITE_XML              N               # Write XML file (Y/N)?
XML_NAME               swarp.xml       # Filename for XML output
XSL_URL                file:///usr/local/share/swarp/swarp.xsl
# Filename for XSL style-sheet
VERBOSE_TYPE           NORMAL          # QUIET,LOG,NORMAL, or FULL
NNODES                 1               # Number of nodes (for clusters)
NODE_INDEX             0               # Node index (for clusters)

# the SMP version of SWarp
# 0 = automatic
NOPENFILES_MAX         512             # Maximum number of files opened by SWarp

$$$$
`
• After a lot of research, I found the answer to the second question, since the FITS files in sdss Images have more than 1 primary hdus, you have to pass the following fits images like an array *.fits[0] to the swarp program, where the first hdu in the fits file contains the image pixel. solution here Aug 10 '19 at 2:06
• This will be more helpful to others with the same problem if you post it as an answer. Aug 10 '19 at 16:08

After a lot of research, I found the answer to the second question, since the FITS files in sdss Images have more than 1 primary hdus, you have to pass the following fits images like an array *.fits[0] to the swarp program, where the first hdu in the fits file contains the image pixel. solution here

For the first question, yes the method to do that is correct. I also found that in order to get a re-sampled image that has the pixel of the galaxy at the center. You have to find the galactic coordinates in hmsdms format and feed it to the swarp tool by altering the following parameters in the swarp cofiguration file.

CENTER_TYPE: MANUAL
CENTER: HH:MM:SS.SS, $$\pm$$DD:MM:SS.SS

For the conversion, I used the astropy python library. I hope this helps.