import time import numpy as np from astropy.io import fits import mwTools # Obtain the coverage information for all fields coverageLimitsList = [] coverageCenterList = [] for field in range(15): print('Processing field ', field) startTime = time.time() # Load the red and blue datasets redData = fits.open('mw' + str(field) + '-red.fits')[0].data[::-1, :] blueData = fits.open('mw' + str(field) + '-blue.fits')[0].data[::-1, :] # Obtain the coverage mask coverageMask = np.logical_and(redData != 0, blueData != 0) # Calculate the coverage limits for each column coverageLimits = [mwTools.getLimits(row) for row in coverageMask.T] # Take some special cases into consideration if field == 6: coverageLimits = [[max(row[0], 1500), row[1]] for row in coverageLimits] elif field == 9: coverageLimits = [[max(row[0], 1400), row[1]] for row in coverageLimits] elif field == 13: coverageLimits = [[row[0], min(row[1], 6200)] for row in coverageLimits] # Calculate the coverage center for each column coverageCenter = [(row[0] + row[1])/2 for row in coverageLimits] # Append the results coverageLimitsList.append(coverageLimits) coverageCenterList.append(coverageCenter) print('Ellapsed time:',time.time() - startTime) # Save the results np.savez('coverageInfo.npz', coverageLimitsList=coverageLimitsList, coverageCenterList=coverageCenterList)