def get_spectra_from_cube(self, coordinate, angle=0, prefix=None, accuracy=2, region=False): r""" Extracts one spectra at the position of coordinates from a spectral cube. Parameters ---------- coordinate: list Equatorial coordinates, e.g. ['1:34:7.00', '+30:47:52.00'] angle: float If the cube was rotated before the angle has to be specified to calculate the correct offset. prefix: string The new path where the averaged spectrum will be stored. accuracy: float The tolerance in arcsec to find a spectra corresponding to the given coordinate. region: True or False Returns either all spectra found ``True`` or only the first ``False``. Returns ------- 30m file With the first spectrum in the list of spectra within the accuracy range with the given coordinate. """ if prefix is None: _prefix = self.prefix if prefix is not None: _prefix = prefix offset = astFunc.calc_offset(self.central_coordinate_equatorial, coordinate, angle, output_unit='arcsec') self.set_defaults() print self.central_coordinate_equatorial print offset pyclass.comm('file in ' + self.map_name) self.log('file in ' + self.map_name) pyclass.comm('set offset ' + str(offset[0]) + ' ' + str(offset[1])) self.log('set offset ' + str(offset[0]) + ' ' + str(offset[1])) while True: pyclass.comm('set match ' + str(accuracy)) self.log('set match ' + str(accuracy)) pyclass.comm('find') try: pyclass.comm('get f') except KeyboardInterrupt: raise KeyboardInterrupt except: print '###\nNothing found, raising tolerance by 1 arsec.\n###' accuracy = accuracy + 1 else: print ('###\nFound a spectra in a ' + str(accuracy) + ' arcsec ' 'radius.\n###') break if not region: print 'asdsa',_prefix return_name = self.returnName(prefix = _prefix, comments=['extract']) pyclass.comm('file out ' + return_name + ' single /overwrite') pyclass.comm('write') if region: return_name = self.returnName(prefix = _prefix, comments=['region']) pyclass.comm('file out ' + return_name + ' single /overwrite') pyclass.comm('find') pyclass.comm('copy') return ClassSpectra(return_name)