#NEWLINE# def set_hdu( self , idx ) : #NEWLINE# #INDENT# self . logger . debug ( ( 'Loading fits hdu #%d' % idx ) ) #NEWLINE# info = self . hdu_info [ idx ] #NEWLINE# aidx = ( info . name , info . extver ) #NEWLINE# sfx = ( '%s,%d' % aidx ) #NEWLINE# imname = self . get_name ( sfx ) #NEWLINE# chname = self . chname #NEWLINE# chinfo = self . chinfo #NEWLINE# if ( imname in chinfo . datasrc ) : #NEWLINE# #INDENT# self . curhdu = idx #NEWLINE# self . image = chinfo . datasrc [ imname ] #NEWLINE# self . fv . switch_name ( chname , imname ) #NEWLINE# hdu = self . fits_f [ idx ] #NEWLINE# dims = list ( hdu . data . shape ) #NEWLINE# dims . reverse ( ) #NEWLINE# self . build_naxis ( dims ) #NEWLINE# return #NEWLINE# #UNINDENT# self . logger . debug ( ( 'HDU %d not in memory; refreshing from file' % idx ) ) #NEWLINE# inherit_prihdr = self . fv . settings . get ( 'inherit_primary_header' , False ) #NEWLINE# image = AstroImage . AstroImage ( logger = self . logger , inherit_primary_header = inherit_prihdr ) #NEWLINE# self . image = image #NEWLINE# try : #NEWLINE# #INDENT# self . curhdu = idx #NEWLINE# dims = [ 0 , 0 ] #NEWLINE# hdu = self . fits_f [ idx ] #NEWLINE# if ( hdu . data is None ) : #NEWLINE# #INDENT# self . logger . warning ( ( 'Empty data part in HDU #%d' % idx ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( info [ 'htype' ] . lower ( ) not in ( 'imagehdu' , 'primaryhdu' ) ) : #NEWLINE# #INDENT# self . logger . warning ( ( 'HDU #%d is not an image' % idx ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dims = list ( hdu . data . shape ) #NEWLINE# dims . reverse ( ) #NEWLINE# #UNINDENT# #UNINDENT# image . load_hdu ( hdu , fobj = self . fits_f ) #NEWLINE# future = Future . Future ( ) #NEWLINE# future . freeze ( self . fv . load_image , self . path , idx = aidx ) #NEWLINE# image . set ( path = self . path , idx = aidx , name = imname , image_future = future ) #NEWLINE# self . fv . add_image ( imname , image , chname = chname ) #NEWLINE# self . build_naxis ( dims ) #NEWLINE# self . logger . debug ( ( 'HDU #%d loaded.' % idx ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# errmsg = ( 'Error loading FITS HDU #%d: %s' % ( idx , str ( e ) ) ) #NEWLINE# self . logger . error ( errmsg ) #NEWLINE# self . fv . show_error ( errmsg , raisetab = False )