e-koch / FilFinder

Detection of filamentary structure in molecular clouds
http://fil-finder.readthedocs.io/en/latest
MIT License
41 stars 21 forks source link

example script #71

Open felialves opened 2 years ago

felialves commented 2 years ago

When running the example script in the example folder, I got the following error:

n [2]: run example_filament_profile.py

AttributeError Traceback (most recent call last) /usr/local/lib/python3.9/site-packages/FilFinder/examples/example_filament_profile.py in 45 # p.ion() 46 dists, profiles, extents, fit_table = \ ---> 47 filament_profile(labels == 3, noiseimg, hdr, max_dist=0.14u.pc, 48 distance=250.u.pc, bright_unit="", noise=None, 49 verbose=True) /usr/local/lib/python3.9/site-packages/fil_finder-1.7.2-py3.9.egg/fil_finder/width_profiles/profile_line_width.py in filament_profile(skeleton, image, pixscale, max_dist, distance, num_avg, verbose, bright_unit, noise, fit_profiles) 95 ''' 96 ---> 97 deg_per_pix = pixscale.to(u.deg) / u.pixel 98 99 if distance is not None: AttributeError: 'Header' object has no attribute 'to'

With some help from a friend, we figured that the problem is that the function filament_profile expected the pixscale as a variable with a unit, but instead had received the header object. So we changed "hdr" in line 47 to "abs(hdr['cdelt1'])" and it works. This is just a note that perhaps the example script should have this replacement.

e-koch commented 2 years ago

Thanks for reporting this @felialves! Your fix sounds right to me and I'll update this in the examples.