import cv2 import numpy as np from astropy.io import fits import mwTools # Define the field to process fields = np.array([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, :] # 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 # Remove the negative values redData[redData < 0] = 0 blueData[blueData < 0] = 0 # Create the green dataset print('Creating green dataset...') greenData = (redData + blueData)/2.0 # Calculate the bgr colors print('Calculating bgr colors...') exponent = 0.5 minValue = 0.00 + 0.1 * mwTools.gaussianDistribution(field, 7 , 1.8) maxValue = 0.85 + 1.8 * mwTools.gaussianDistribution(field, 7 , 1.8) print('Singal range: (' + str(round(maxValue,2)) + ', ' + str(round(minValue, 2)) + ')') redData = mwTools.getColorIntensity(redData, minValue, maxValue, exponent) blueData = mwTools.getColorIntensity(blueData, minValue, maxValue, exponent) greenData = mwTools.getColorIntensity(greenData, minValue, maxValue, exponent) bgrData=cv2.merge([blueData, greenData, redData]) # Save the image scaleFactor = 0.1 #bgrData = cv2.resize(bgrData, None, fx=scaleFactor, fy=scaleFactor, interpolation=cv2.INTER_CUBIC) cv2.imwrite("field"+str(field) +".jpg", bgrData)