old_contents: 
  import os
  from spectral_cube import SpectralCube
  import astropy.units as u
  
  from basics.bubble_segment3D import BubbleFinder
  
  '''
  Create the bubble catalogue of M33 with the 14B-088 map
  '''
  
  data_path = "/media/eric/MyRAID/M33/14B-088/HI/full_imaging/"
  
  cube = \
      SpectralCube.read(os.path.join(data_path,
                                      "M33_14B-088_HI.clean.image.pbcov_gt_0.3_masked.fits"))
  
  # The first few channels have some emission in them. It's partially M33,
  # partially galactic HI. So estimate the noise level from the last channel
  # which is pretty much noise only. It gives 1.8 mJy/bm, which is right on.
  bub_find = BubbleFinder(cube, keep_threshold_mask=True,
                          empty_channel=cube.shape[0] - 1)
  
  bub_find.get_bubbles(verbose=True, overlap_frac=0.5, multiprocess=True,
                       refit=False, nsig=2.0, cut_val=0.5, min_channels=5,
                       distance=0.84 * u.Mpc, nprocesses=None)
  
  bub_find.visualize_bubbles()
  
new_contents: 
  import os
  from spectral_cube import SpectralCube
  import astropy.units as u
  from astropy.coordinates import SkyCoord
  import numpy as np
  
  from basics.bubble_segment3D import BubbleFinder
  
  '''
  Create the bubble catalogue of M33 with the 14B-088 map
  '''
  
  data_path = "/media/eric/MyRAID/M33/14B-088/HI/full_imaging/"
  
  cube = \
      SpectralCube.read(os.path.join(data_path,
                                      "M33_14B-088_HI.clean.image.pbcov_gt_0.3_masked.fits"))
  
  galaxy_props = {"center_coord":
                  SkyCoord(23.461667, 30.660194,
                           unit=(u.deg, u.deg), frame='fk5'),
                  "inclination": 56. * u.deg,
                  "position_angle": 201. * u.deg,
                  "scale_height": 100. * u.pc}
  
  
  scales = 3. * np.arange(1, 15, np.sqrt(2))
  
  # The first few channels have some emission in them. It's partially M33,
  # partially galactic HI. So estimate the noise level from the last channel
  # which is pretty much noise only. It gives 1.8 mJy/bm, which is right on.
  bub_find = BubbleFinder(cube, keep_threshold_mask=True,
                          empty_channel=cube.shape[0] - 1,
                          galaxy_props=galaxy_props,
                          distance=0.84 * u.Mpc)
  
  bub_find.get_bubbles(verbose=True, overlap_frac=0.5, multiprocess=True,
                       refit=False, nsig=1.0, min_corr=0.7, min_overlap=0.8,
                       min_channels=15, nprocesses=None, scales=scales)
  
  bub_find.visualize_bubbles()
  
  catalog = bub_find.to_catalog()
  
  catalog.write_table(os.path.expanduser("~/MyRAID/M33/14B-088/full_imaging/bubble_catalog.ecsv"))
  
subject: Update bubble finding script