from herschel.pacs.spg.phot import PhotHelper """ Set the paths to the directories where the scripts are saved and where the data products should be saved. """ scriptsDir = "/the/scripts/directory/" dataDir = "/the/data/directory/" """ Save the frames in the dataDir. """ execfile(scriptsDir + "saveLMCfiles.py") execfile(scriptsDir + "saveLMCfilesWithAnomaly.py") """ Calculate the wcs for the full map """ execfile(scriptsDir + "lmcWcs.py") """ Define the tiles information """ tiles = [0, 1, 2, 3, 4, 5, 6, 7, 8] tileStartCol = [0, 9, 19, 0, 9, 19, 0, 9, 19] tileStartRow = [ 0, 0, 0, 9, 9, 9, 19, 19, 19] tileColSize = [11, 12, 11, 11, 12, 11, 11, 12, 11] tileRowSize =[ 11, 11, 11, 12, 12, 12, 11, 11, 11] nCols = 30 nRows = 30 """ Obtain the scans and cross scans for the different tiles """ fitsFile = dataDir + "LMCmap.fits" map = FitsArchive().load(fitsFile) wcs = map.getWcs() camera = "red" cameraName = "red" for tile in tiles: print "tile: " + str(tile) maskedMap = PhotHelper.createTileMask(map, tileStartCol[tile], tileStartRow[tile], tileColSize[tile], tileRowSize[tile], nCols, nRows) #Display(maskedMap) execfile(scriptsDir + "lmcCreateFramesTiles.py") camera = "blue" cameraName = "green" for tile in tiles: print "tile: " + str(tile) maskedMap = PhotHelper.createTileMask(map, tileStartCol[tile], tileStartRow[tile], tileColSize[tile], tileRowSize[tile], nCols, nRows) #Display(maskedMap) execfile(scriptsDir + "lmcCreateFramesTiles.py") """ Process the tiles """ calTree = getCalTree(obs=getObservation(1342195728, useHsa=True, instrument="PACS")) tiles = [3,4,5,6,7,8] camera = "red" cameraName = "red" for tile in tiles: print "tile: " + str(tile) execfile(scriptsDir + "lmcProcessTiles.py") camera = "blue" cameraName = "green" for tile in tiles: print "tile: " + str(tile) execfile(scriptsDir + "lmcProcessTiles.py") """ Align the tiles """ tiles = [4, 1, 3, 5, 0, 2, 7, 6, 8] referenceTiles = [4, 4, 4, 4, 1, 5, 4, 3, 5] tiles = [8] referenceTiles = [5] cameraName = "red" execfile(scriptsDir + "lmcAlignTiles.py") cameraName = "green" execfile(scriptsDir + "lmcAlignTiles.py") """ Project the tiles """ tiles = [0, 1, 2, 3, 4, 5, 6, 7, 8] tiles = [4, 3, 5, 0, 1, 2, 6] pixfrac = 0.1 outputPixelSize= 3.2 cameraName = "red" execfile(scriptsDir + "lmcProjectTiles.py") cameraName = "green" execfile(scriptsDir + "lmcProjectTiles.py") """ Combine the tiles """ tiles = [0, 1, 2, 3, 4, 5, 6, 7, 8] tileStartCol = [0, 10, 20, 0, 10, 20, 0, 10, 20] tileStartRow = [ 0, 0, 0, 10, 10, 10, 20, 20, 20] tileColSize = 10 tileRowSize = 10 nCols = 30 nRows = 30 cameraName = "red" execfile(scriptsDir + "lmcCombineTiles.py") cameraName = "green" execfile(scriptsDir + "lmcCombineTiles.py") """ Create the RGB nap """ fitsFile = dataDir + "lmc-map-red.fits" redMap = FitsArchive().load(fitsFile) fitsFile = dataDir + "lmc-map-green.fits" greenMap = FitsArchive().load(fitsFile) minimumRelativeCoverage = 0.1 boxSize = 80 redBackgroundOffset = PhotHelper.getBackgroundOffset(redMap, minimumRelativeCoverage, boxSize) redSignalLim = PhotHelper.getSignalLimits(redMap, minimumRelativeCoverage) greenBackgroundOffset = PhotHelper.getBackgroundOffset(greenMap, minimumRelativeCoverage, boxSize) greenSignalLim = PhotHelper.getSignalLimits(greenMap, minimumRelativeCoverage) print redBackgroundOffset print redSignalLim print greenBackgroundOffset print greenSignalLim PhotHelper.removeOffset(redMap, -0.00368210469806) PhotHelper.removeOffset(greenMap, 0.00179605947962) FitsArchive().save(dataDir + "lmc-red-corr.fits", redMap) d = Display(redMap) d.saveAsJPG(dataDir + "lmcRed.jpg") FitsArchive().save(dataDir + "lmc-green-corr.fits", greenMap) d = Display(greenMap) d.saveAsJPG(dataDir + "lmcGreen.jpg") maxSignal = 19 exponent = 1.0 multiplicativeFactor = 200 rgbMap = PhotHelper.createRgbMap(redMap, greenMap, maxSignal, exponent, multiplicativeFactor) d = Display(rgbMap) d.saveAsJPG(dataDir + "lmc-linear.jpg") d.saveAsPNG(dataDir + "lmc-linear.png")