# Convert the list into a dictionary polAngImgs = dict(zip(polAngs, polAngImgs)) #aligned #********************************************************************** # Stokes I #********************************************************************** # Average the images to get stokes I stokesI = image_tools.combine_images([polAngImgs[0], polAngImgs[200], polAngImgs[400], polAngImgs[600]]) stokesI = 2 * stokesI # Perform astrometry to apply to the headers of all the other images... stokesI, success = image_tools.astrometry(stokesI) # Check if astrometry solution was successful if not success: pdb.set_trace() #********************************************************************** # Stokes Q #********************************************************************** # Subtract the images to get stokes Q A = polAngImgs[0] - polAngImgs[400] B = polAngImgs[0] + polAngImgs[400] # Divide the difference images stokesQ = A/B # Update the header to include the new astrometry
# It is only possible to "redo the astrometry" if the file on the disk # First make a copy of the average image tmpImg = avgImg.copy() # Replace NaNs with something finite and name the file "tmp.fits" tmpImg.arr = np.nan_to_num(tmpImg.arr) tmpImg.filename = 'tmp.fits' # Delete the sigma attribute if hasattr(tmpImg, 'sigma'): del tmpImg.sigma # Record the temporary file to disk for performing astrometry tmpImg.write() # Solve the stacked image astrometry avgImg1, success = image_tools.astrometry(tmpImg, override = True) # With successful astrometry, save result to disk if success: print('astrometry succeded') # Clean up temporary files # TODO update to by system independent # (use subprocess module and "del" command for Windows) # See AstroImage.astrometry for example del tmpImg if os.path.isfile('none'): os.system('rm none') if os.path.isfile('tmp.fits'):
aligned_posCount = image_tools.align_images( [IPPA_posCountDict[1], IPPA_posCountDict[2], IPPA_posCountDict[3], IPPA_posCountDict[4]], mode = 'wcs') # Compute the final intensity image first # Combine the two stokes I estimates to get an average stokes I image I_13 = alignedImgs[0] + alignedImgs[2] I_24 = alignedImgs[1] + alignedImgs[3] Iimg = 0.5*(I_13 + I_24) # Solve the astrometry of this image in order to properly map mask # positions Aimg positions Iimg.filename = 'tmp.fits' Iimg.write() Iimg, success = image_tools.astrometry(Iimg, override = True) if success: print('Astrometry for initial combination solved') # Delete the temporary file if 'win' in sys.platform: delCmd = 'del ' shellCmd = True else: delCmd = 'rm ' shellCmd = False # Perform the actual deletion rmProc = subprocess.Popen(delCmd + 'tmp.fits', shell=shellCmd) rmProc.wait() rmProc.terminate() else:
subPixel=True, padding=np.nan) # Convert the list into a dictionary polAngImgs = dict(zip(polAngs, polAngImgs)) #aligned #********************************************************************** # Stokes I #********************************************************************** # Average the images to get stokes I stokesI = image_tools.combine_images( [polAngImgs[0], polAngImgs[200], polAngImgs[400], polAngImgs[600]]) stokesI = 2 * stokesI # Perform astrometry to apply to the headers of all the other images... stokesI, success = image_tools.astrometry(stokesI) # Check if astrometry solution was successful if not success: pdb.set_trace() #********************************************************************** # Stokes Q #********************************************************************** # Subtract the images to get stokes Q A = polAngImgs[0] - polAngImgs[400] B = polAngImgs[0] + polAngImgs[400] # Divide the difference images stokesQ = A / B # Update the header to include the new astrometry
# Clear the astrometry values from the header tmpImg.clear_astrometry() # ReplaceNaNs with something finite and name the file "tmp.fits" tmpImg.arr = np.nan_to_num(tmpImg.arr) tmpImg.filename = "tmp.fits" # Delete the sigma attribute if hasattr(tmpImg, "sigma"): del tmpImg.sigma # Record the temporary file to disk for performing astrometry tmpImg.write() # Solve the stacked image astrometry avgImg1, success = image_tools.astrometry(tmpImg) # With successful astrometry, save result to disk if success: print("astrometry succeded") # Clean up temporary variable del tmpImg # Delete the temporary file # Test what kind of system is running if "win" in sys.platform: # If running in Windows, delCmd = "del " shellCmd = True else: