import numpy as np from astropy.io import fits import mwTools # Define the fields to process fields = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] for field in fields: print('Processing field ' + str(field)) # Load the fits files print('Loading fits files...') redData = fits.open('mw' + str(field) + '-red.fits')[0].data[::-1, :] blueData = fits.open('mw' + str(field) + '-blue.fits')[0].data[::-1, :] # Fill holes with zero coverage print('Filling zero coverage holes...') for row in redData.T: mwTools.fillHoles(row) for row in blueData.T: mwTools.fillHoles(row) # Obtain the zero coverage mask print('Calculating the zero coverage mask...') zeroCoverageMask = np.logical_or(redData == 0, blueData == 0) # Shift a bit the images to remove most of the negative values print('Shifting data values...') redData = redData + 0.005 blueData = blueData + 0.005 redData[zeroCoverageMask] = 0.0 blueData[zeroCoverageMask] = 0.0 # Save the results print('Saving clean file...') np.savez('fied'+str(field)+'-clean.npz', redData=redData, blueData=blueData)