GBTAmmoniaSurvey / GAS

observing scripts and files related to the GBT Ammonia Survey (GAS, PI: Jaime E Pineda & Rachel Friesen)
MIT License
6 stars 13 forks source link

Missing beam information and spectral-cube error #157

Closed rfriesen closed 7 years ago

rfriesen commented 7 years ago

@keflavich @low-sky @jpinedaf came across an issue that some of the moment files for DR1 were missing beam info. I tried to rerun PropertyMaps.update_NH3_moment0 at Green Bank but get the below error when trying to read in the baselined cubes with pyspeckit. I did originally run this on my own machine (which died; am waiting for the replacement) and it appeared to run fine (albeit missing beam info?). The beam info is in the header of the input cubes. Looks like spectral-cube is where the issue lies. Checking my backup, I was using spectral-cube version 0.4.0 rather than 0.4.1.dev1308 on the GB machines.

Any ideas on how to fix?

In [5]: GAS.PropertyMaps.update_NH3_moment0()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-6d7afeb97565> in <module>()                               
----> 1 GAS.PropertyMaps.update_NH3_moment0()                              

/lustre/pipeline/scratch/GAS/python/GAS/GAS/PropertyMaps.pyc in update_NH3_moment0(region_name, file_extension, threshold, save_masked)                                                   
     48         file_temp='{0}/{0}_NH3_{2}_{1}_masked_temp.fits'.format(region_name,file_extension,line_i)                                                                                
     49         # Load pyspeckit cube                                                        
---> 50         pycube = pyspeckit.Cube(file_in)                                             
     51         if 'FITTYPE' in fits.getheader(fit_file):                                    
     52             # 'FITTYPE' is not present in old versions of the parameter files        

/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/pyspeckit-0.1.20.dev0-py2.7.egg/pyspeckit/cubes/SpectralCube.pyc in __init__(self, filename, cube, xarr, xunit, errorcube, header, x0, y0, maskmap, **kwargs)                                                 
    114                                                                                      
    115         if filename is not None:                                                     
--> 116             self.load_fits(filename)                                                 
    117             return                                                                   
    118         else:                                                                        

/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/pyspeckit-0.1.20.dev0-py2.7.egg/pyspeckit/cubes/SpectralCube.pyc in load_fits(self, fitsfile)                    
    226                               "spectral-cube.rtfd.org.")                             
    227         mycube = SpectralCube.read(fitsfile)                                         
--> 228         return self.load_spectral_cube(mycube)                                       
    229                                                                                      
    230     def load_spectral_cube(self, cube):                                              

/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/pyspeckit-0.1.20.dev0-py2.7.egg/pyspeckit/cubes/SpectralCube.pyc in load_spectral_cube(self, cube)               
    232         Load the cube from a spectral_cube.SpectralCube object                       
    233         """                                                                          
--> 234         self.__init__(cube=cube)                                                     
    235                                                                                      
    236     def __repr__(self):                                                              

/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/pyspeckit-0.1.20.dev0-py2.7.egg/pyspeckit/cubes/SpectralCube.pyc in __init__(self, filename, cube, xarr, xunit, errorcube, header, x0, y0, maskmap, **kwargs)
    119             if hasattr(cube, 'spectral_axis'):
    120                 # Load from a SpectralCube instance
--> 121                 self.cube = cube.hdu.data
    122                 if (cube.unit in ('undefined', units.dimensionless_unscaled)
    123                     and 'BUNIT' in cube._meta):

/lustre/pipeline/scratch/GAS/python/spectral-cube/spectral_cube/spectral_cube.pyc in hdu(self)
   2227         """
   2228         log.debug("Creating HDU")
-> 2229         hdu = PrimaryHDU(self.filled_data[:].value, header=self.header)
   2230         return hdu
   2231

/lustre/pipeline/scratch/GAS/python/spectral-cube/spectral_cube/spectral_cube.pyc in header(self)
   2216
   2217         if 'beam' in self._meta:
-> 2218             header = self._meta['beam'].attach_to_header(header)
   2219
   2220         # TODO: incorporate other relevant metadata here

/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/astropy/units/quantity.pyc in __getattr__(self, attr)
    861                 "'{0}' object has no '{1}' member".format(
    862                     self.__class__.__name__,
--> 863                     attr))
    864
    865         def get_virtual_unit_attribute():

AttributeError: 'Beam' object has no 'attach_to_header' member
keflavich commented 7 years ago

What version of radio_beam do you have? I don't think that's the issue, but I want to check.

jpinedaf commented 7 years ago

I just checked, and it does not look right

In [1]: import pyspeckit
pyspeckit.__version__

In [2]: pyspeckit.__version__
Out[2]: u'0.1.20.dev'

In [3]: import radio_beam

In [4]: radio_beam.__version__
Out[4]: '0.0'

In [5]: radio_beam
Out[5]: <module 'radio_beam' from '/lustre/pipeline/scratch/GAS/python/anaconda/lib/python2.7/site-packages/radio_beam/__init__.pyc'>
jpinedaf commented 7 years ago

OK, @rfriesen could you please check again? I removed an old version of radio beam

In [1]: import radio_beam
   ...: radio_beam.__version__
   ...: 
Out[1]: u'0.0.dev173'
jpinedaf commented 7 years ago

@keflavich is it possible to give a bump to the version number of radio beam? then we can put that as a requirement in GAS, what do you think?

keflavich commented 7 years ago

@jpinedaf yeah, that's a good idea. We need a new release. It's stable enough to deserve a v0.1 now.

rfriesen commented 7 years ago

@jpinedaf @keflavich Code is running now. I'll update when I see whether the beam info is kept in the moment maps. Thanks!

keflavich commented 7 years ago

@jpinedaf regarding versions: https://github.com/radio-astro-tools/radio_beam/issues/44

rfriesen commented 7 years ago

Problem solved. Thanks everyone!