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 + "saveSMCfiles.py") execfile(scriptsDir + "saveSMCfilesWithAnomaly.py") """ Calculate the wcs for the full map """ execfile(scriptsDir + "smcWcs.py") execfile(scriptsDir + "smcOnlyWcs.py") """ Process the bridge region """ part = "1" scansObsids = [1342192699, 1342205049] cscansObsids = [1342198863] usePrevious = [False, True] cameraName = "red" execfile(scriptsDir + "smcProcessBridge.py") cameraName = "green" execfile(scriptsDir + "smcProcessBridge.py") part = "2" scansObsids = [1342192698, 1342205050] cscansObsids = [1342198591] usePrevious = [False, True] cameraName = "red" execfile(scriptsDir + "smcProcessBridge.py") cameraName = "green" execfile(scriptsDir + "smcProcessBridge.py") """ Align the bridge region """ cameraName = "red" execfile(scriptsDir + "smcAlignBridge.py") cameraName = "green" execfile(scriptsDir + "smcAlignBridge.py") """ Define the tiles information """ tiles = [0, 1, 2, 3] tileStartCol = [0, 9, 0, 9] tileStartRow = [ 0, 0, 9, 9] tileColSize = [11, 11, 11, 11] tileRowSize =[ 11, 11, 11, 11] nCols = 20 nRows = 20 """ Obtain the scans and cross scans for the different tiles """ fitsFile = dataDir + "SMConlymap.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 + "smcCreateFramesTiles.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 + "smcCreateFramesTiles.py") """ Process the tiles """ calTree = getCalTree(obs=getObservation(1342205092, useHsa=True, instrument="PACS")) tiles = [0,1,2,3] camera = "red" cameraName = "red" for tile in tiles: print "tile: " + str(tile) execfile(scriptsDir + "smcProcessTiles.py") camera = "blue" cameraName = "green" for tile in tiles: print "tile: " + str(tile) execfile(scriptsDir + "smcProcessTiles.py") """ Align the first tile to the bridge """ cameraNames = ["red", "green"] for cameraName in cameraNames: referenceFitsFile = dataDir + "smc-bridge-part2-mergedScans-" + cameraName + "-aligned.fits" referenceFrames = FitsArchive().load(referenceFitsFile) fitsFile = dataDir + "smc-mergedScans-tile0-" + cameraName + ".fits" frames = FitsArchive().load(fitsFile) referenceFrames.setActive("Scanamorphos_NonOverlapMask", True) frames.setActive("Scanamorphos_NonOverlapMask", True) referenceFrames, frames = scanamorphosAlignFrames(referenceFrames, frames, calTree=calTree, createMask=False) frames.setActive("Scanamorphos_NonOverlapMask", False) outputFitsFile = dataDir + "smc-mergedScans-tile0-" + cameraName + "-aligned.fits" FitsArchive().save(outputFitsFile, frames) """ Align the tiles """ tiles = [2, 3, 1] referenceTiles = [0, 2, 3] cameraName = "red" execfile(scriptsDir + "smcAlignTiles.py") cameraName = "green" execfile(scriptsDir + "smcAlignTiles.py") """ Project the tiles """ fitsFile = dataDir + "SMCmap.fits" map = FitsArchive().load(fitsFile) wcs = map.getWcs() tiles = [0, 1, 2, 3] parts = [1, 2] pixfrac = 0.1 outputPixelSize= 3.2 cameraName = "red" execfile(scriptsDir + "smcProjectTiles.py") execfile(scriptsDir + "smcProjectBridge.py") cameraName = "green" execfile(scriptsDir + "smcProjectTiles.py") execfile(scriptsDir + "smcProjectBridge.py") """ Combine the tiles """ tiles = [0, 1, 2, 3] tileStartCol = [0, 152, 0, 152] tileStartRow = [ 0, 0, 120, 120] tileColSize = [152, 70, 152, 70] tileRowSize = [120, 120, 102, 102] nCols = 222 nRows = 222 cameraName = "red" execfile(scriptsDir + "smcCombineTiles.py") cameraName = "green" execfile(scriptsDir + "smcCombineTiles.py") """ Create the RGB nap """ fitsFile = dataDir + "smc-map-red.fits" redMap = FitsArchive().load(fitsFile) fitsFile = dataDir + "smc-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.0005) FitsArchive().save(dataDir + "smc-red-corr.fits", redMap) d = Display(redMap) d.saveAsJPG(dataDir + "smcRed.jpg") FitsArchive().save(dataDir + "smc-green-corr.fits", greenMap) d = Display(greenMap) d.saveAsJPG(dataDir + "smcGreen.jpg") maxSignal = 2 exponent = 1.0 multiplicativeFactor = 30 rgbMap = PhotHelper.createRgbMap(redMap, greenMap, maxSignal, exponent, multiplicativeFactor) d = Display(rgbMap) d.saveAsJPG(dataDir + "smc-linear.jpg") d.saveAsPNG(dataDir + "smc-linear.png")