#NEWLINE# def is_casalike( filename , **kwargs ) : #NEWLINE# #INDENT# '\n    Check if a FITS file is a CASA like cube,\n    with (P, P, V, Stokes) layout\n    ' #NEWLINE# from astropy.io import fits #NEWLINE# if ( not is_fits ( filename ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# with fits . open ( filename , ignore_missing_end = True ) as hdulist : #NEWLINE# #INDENT# if ( len ( w ) != 1 ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( hdulist [ 0 ] . header [ 'NAXIS' ] != 4 ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# from astropy.wcs import WCS #NEWLINE# w = WCS ( hdulist [ 0 ] . header ) #NEWLINE# #UNINDENT# ax = [ a . get ( 'coordinate_type' ) for a in w . get_axis_types ( ) ] #NEWLINE# return ( ax == [ 'celestial' , 'celestial' , 'spectral' , 'stokes' ] )