def atd6(): """ Verify that a MosaicAD method can create a block from a given extension name. The test creates a mosaic ndarray from the MosaicAD method mosaic_image_data with the block parameter value (0,0), indicating to output the lower left block. NOTE: Having one amp per block, the actual extension data is not the same as the block since it would be trim by the DATASEC image section. gmos_file='../data/gS20120420S0033.fits' gsaoi_file='../data/guS20120413S0048.fits' """ from astrodata import AstroData from gempy.adlibrary.mosaicAD import MosaicAD # This is the default Mosaic function from gempy.mosaic.gemMosaicFunction import gemini_mosaic_function print '\n atd6 REQUIREMENT.......' print ('***** From a given AstroData object, the system shall create a block from ' 'a given extension name') gmos_file='../data/gS20120420S0033.fits' gsaoi_file='../data/guS20120413S0048.fits' for file in [gmos_file,gsaoi_file]: ad = AstroData(file) print 'Instrument: ',ad.instrument() mo = MosaicAD(ad, gemini_mosaic_function) # Now use the mosaic_image_data method to generate # an output block by using the parameter block and # value as a tuple (col,row) (0-based) of the block # you want returned. For GMOS the block values are # (0,0), (1,0), (2,0). block=(1,0) block_data = mo.mosaic_image_data(block=block,tile=True) # Get the shape: (height, width) in pixels. print 'block_data.shape:',block_data.shape extn = block[0] + block[1]*mo.geometry.mosaic_grid[0] + 1 print 'Input shape for 1-amp per detector:',ad['SCI',extn].data.shape # Check values of the lower 2x2 pixels print 'Output block [0:2,0:2] pixels:\n',block_data[:2,:2] if ad.instrument() == 'GSAOI': # GSAOI FITS extension 1 correspond to block (1,0) # and extension 2 to block (0,0). DETSEC image section # indicates this. extn = [2,1,3,4][extn-1] # To get the correct segment we need to look at # DATASEC, in case the data is trimm -as it appears in data_list. x1,x2,y1,y2 = ad.data_section().as_dict()['SCI',extn] print 'Input amp DATASEC[x1:x1+2 pixels:\n',\ ad['SCI',extn].data[x1:x1+2,y1:y1+2] print '\n'