def test_DEC(coords, coord_types, ra, dec, new_dec, out_dec): my_wcs = makeWCS(coords=coords, coord_types=coord_types) image = AstroImage(wcs=my_wcs) assert image.ra == ra assert image.dec == dec image.dec = new_dec assert image.dec == out_dec
def test_addHistory(history): image = AstroImage() for item in history: image.addHistory(item) for item in history: assert item in image.history for item in image.history: assert item in history
def test_PA(pa_in, pa, scale, new_pa, pa_out): image = AstroImage(pa=pa_in, scale=scale) assert abs(image.pa - pa) < 1.e-4 assert abs(image.xscale - scale[0]) < 1.e-4 assert abs(image.yscale - scale[1]) < 1.e-4 image.pa = new_pa assert abs(image.pa - pa_out) < 1.e-4 assert abs(image.xscale - scale[0]) < 1.e-4 assert abs(image.yscale - scale[1]) < 1.e-4
def test_crop(input, size, offset, result): im1 = AstroImage(data=input) im1.crop(size[0], size[1], offset[0], offset[1]) verifyData(im1.data, result)
def test_rescale(input, scale, result): im1 = AstroImage(data=input) im1.rescale(scale) verifyData(im1.data, result) im1.rescale([1., 1.]) verifyData(im1.data, input)
def test_addWithAlignment(in1, in2, inputs, result): im1 = AstroImage(data=in1) im2 = AstroImage(data=in2, **inputs) im1.addWithAlignment(im2) verifyData(im1.data, result)
def test_addWithOffset(in1, in2, offset, inputs, result): im1 = AstroImage(data=in1, **inputs) im2 = AstroImage(data=in2) im1.addWithOffset(im2, offset[0], offset[1]) verifyData(im1.data, result)
def test_rotate(input, angle, output): image = AstroImage(data=input) image.rotate(angle) verifyData(image.data, output)
def test_convolve(input, kernel, result): input_image = AstroImage(data=input) kernel_image = AstroImage(data=kernel) input_image.convolve(kernel_image) verifyData(input_image.data, result)
S3dir = os.path.join(PPOL_dir, 'S3_Astrometry') # This is the location where all pyPol data will be saved pyPol_data = 'C:\\Users\\Jordan\\FITS_data\\Mimir_data\\pyPol_data' # This is the directory where the 2MASS tiles of the targets have been saved # Go to "http://hachi.ipac.caltech.edu/" to download 2MASS tiles TMASSdir = "C:\\Users\\Jordan\\Libraries\\python\\Mimir_pyPol\\2MASSimages" # Setup new directory for background subtracted data bkgSubDir = os.path.join(pyPol_data, 'bkgSubtracted') if (not os.path.isdir(bkgSubDir)): os.mkdir(bkgSubDir, 0o755) # Read in Kokopelli mask generated in previous step kokopelliMask = (AstroImage('kokopelliMask.fits').arr != 0) # Read in the indexFile data and select the filenames indexFile = os.path.join(pyPol_data, 'reducedFileIndex.csv') fileIndex = Table.read(indexFile, format='csv') # Grab the file basenames for later use fileIndexFileNames = np.array( [os.path.basename(file1) for file1 in fileIndex['Filename'].data]) # Modify the fileIndex to include rejections by residual value if 'Background Cut' not in fileIndex.keys(): fileIndex.add_column( Column(name='Background Cut', data=np.repeat(0, len(fileIndex)))) # Determine which parts of the fileIndex pertain to science images
def test_updateHeader(header_in, header_out): image = AstroImage() for k, v in header_in: image.updateHeader(k, v) for k, v in header_out: assert image.header[k] == v
def test_creation(inputs, results): image = AstroImage(**inputs) data = numpy.zeros((image.ysize, image.xsize)) verifyParameters(image, results) verifyData(image.data, data)
print('\tTarget : {0}'.format(thisTarget)) print('\tWaveband : {0}'.format(thisWaveband)) # Read in the polAng image fileCheck = True polAngImgs = [] polAngs = [] for polAng in range(0, 601, 200): fileName = os.path.join( polAngDir, '_'.join([thisTarget, thisWaveband, str(polAng)]) + '.fits') # If the file exists, then read it into a dictionary if os.path.isfile(fileName): polAngs.append(polAng) polAngImgs.append(AstroImage(fileName)) else: fileCheck = False # Check that all the necessarry files are present if not fileCheck: print("\tSome required Polaroid Angle files are missing.") continue # Use the "align_stack" method to align the newly created image list print('\nAligning images\n') polAngImgs = image_tools.align_images(polAngImgs, mode='cross_correlate', subPixel=True, padding=np.nan)
# Setup new directory for polarimetry data polarimetryDir = os.path.join(pyPol_data, 'Polarimetry') if (not os.path.isdir(polarimetryDir)): os.mkdir(polarimetryDir, 0o755) stokesDir = os.path.join(polarimetryDir, 'stokesImgs') if (not os.path.isdir(stokesDir)): os.mkdir(stokesDir, 0o755) # Setup Mimir detector properties read_noise = 19.0 # electrons effective_gain = 8.21 # electrons/ADU # Read in the Kokopelli mask if os.path.isfile('kokopelliMask.fits'): kokopelliMask = AstroImage('kokopelliMask.fits') else: print('Kokopelli Mask is not built... go back and build it with step 2.') pdb.set_trace() ################################################################################ # READ IN CALIBRATION DATA ################################################################################ # Read in the instrumental U and Q images (and associated uncertainties) # First do H-band # Q images H_calDir = os.path.join(PPOLcodeDir, 'H-Pol_Pinst_Default') H_Q_instFile = os.path.join(H_calDir, 'q_inst.fits') H_sQ_instFile = os.path.join(H_calDir, 'q_sig_inst.fits') H_Q_instImg = AstroImage(H_Q_instFile) H_sQ_instImg = AstroImage(H_sQ_instFile) H_Q_instImg.sigma = H_sQ_instImg.arr.copy()
def test_bin(input, bin, result): im1 = AstroImage(data=input) im1.bin(bin[0], bin[1]) verifyData(im1.data, result)
def test_addCatalogue(inputs, catalogue, final): image = AstroImage(**inputs) out_cat = image.addCatalogue(catalogue) if os.path.exists(out_cat): os.remove(out_cat) verifyData(image.data, final)
TMASSdir = "C:\\Users\\Jordan\\Libraries\\python\\Mimir_pyPol\\2MASSimages" # This dictionary specifies the angle range (degrees East of North) to include # in producing radial-brightness proflies. This is especially for NGC2023 angleDict = {'NGC2023': (0, 360)} # This is the location of the supersky images bkgImagesDir = os.path.join(pyPol_data, 'bkgImages') # Setup new directory for background subtracted data bkgSubDir = os.path.join(pyPol_data, 'bkgSubtracted') if (not os.path.isdir(bkgSubDir)): os.mkdir(bkgSubDir, 0o755) # Read in Kokopelli mask generated in previous step kokopelliMask = (AstroImage('kokopelliMask.fits').arr != 0) # Read in the indexFile data and select the filenames indexFile = os.path.join(pyPol_data, 'reducedFileIndex.csv') fileIndex = Table.read(indexFile, format='csv') # Check if the fileIndex already has a "Background" column. # If not, then add one. if 'Background' not in fileIndex.keys(): fileIndex.add_column(Column(name='Background', data = np.repeat(-99.9, len(fileIndex)))) # Determine which parts of the fileIndex pertain to science images useFiles = np.where(fileIndex['Use'] == 1) badFiles = np.where(fileIndex['Use'] == 0)
# Begin by initalizing some arrays to store the image classifications telRA = [] telDec = [] name = [] waveBand = [] HWPang = [] binType = [] expTime = [] night = [] fileCounter = 0 percentage = 0 #Loop through each file in the fileList variable for file in fileList: # Read in the image tmpImg = AstroImage(file) # Grab the RA and Dec from the header # Parse the pointing for this file tmpRA = coord.Angle(tmpImg.header['TELRA'], unit=u.hour) tmpDec = coord.Angle(tmpImg.header['TELDEC'], unit=u.degree) telRA.append(tmpRA.degree) telDec.append(tmpDec.degree) # Classify each file type and binning tmpName = tmpImg.header['OBJECT'] if len(tmpName) < 1: tmpName = 'blank' name.append(tmpName) # Parse the HWP number