desihub / fastspecfit

Fast spectral synthesis and emission-line fitting of DESI spectra.
https://fastspecfit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Spike in sigma distribution of some narrow lines at ~600 #122

Closed VFawcett closed 8 months ago

VFawcett commented 1 year ago

Exploring the sigma distribution for some of the narrow lines there seems to be a strange peak at ~600. This is especially prominent in [OIII] and [OII].

OII_sigma NII_sigma OIII_sigma

Some example sources: [39627631057962664, 'special', 'dark', 25463] [39627637076787376, 'special', 'dark', 26146] [39628239173321503, 'special', 'dark', 27987] [39627601714610456, 'special', 'dark', 44996] [39628492240849767, 'special', 'dark', 9328] [39628512960711724, 'special', 'dark', 9336] [39628512956520409, 'special', 'dark', 9336] [39633179044218807, 'sv2', 'dark', 10955] [39633170546557400, 'sv2', 'dark', 10976] [39633304214834237, 'sv2', 'dark', 11007] [39633274842120987, 'sv2', 'dark', 11002] [39633349047747989, 'sv2', 'dark', 11193] [39633321927378204, 'sv2', 'dark', 11175] [39633335667920174, 'sv2', 'dark', 11186] [39633318404163394, 'sv2', 'dark', 11177] [39633345738442330, 'sv2', 'dark', 11187] [39633325408652474, 'sv2', 'dark', 11184] [39633304231611292, 'sv2', 'dark', 11176] [39633345776192464, 'sv2', 'dark', 11167] [39633365351008432, 'sv2', 'dark', 11214] [39633345813939941, 'sv2', 'dark', 11203]

moustakas commented 1 year ago

Thanks for reporting this issue @VFawcett. I drilled down on the first object in your list and I think I understand what's going on.

In the code, there are two rounds of fitting (neglecting the broad-line fitting):

For the narrow lines, the prior on sigma is [1,750] kms and the prior on vshift is [-500,+500] km/s. Initial values are set based on a quick estimate of the line-widths (if possible); in the case of the first object in your list, the initial line-width could not be determined and so it was set to a default of 200 km/s (I know this is large, but convergence isn't too sensitive to this value and this value is also used for masking during continuum-fitting, so it's intentionally conservative / large).

After the initial fitting round, if any parameter remains at its initial value it is dropped. (I played around with other choices like: "drop the line if it's within X% of its lower/upper bounds" but found that real lines were being dropped this way.)

In your first example, sigma for [OIII] 5007 is 749.7799 km/s, i.e., barely below the max allowed value of 750 km/s. Then going into the final fitting round, the prior becomes [599.8239, 899.7359] km/s (+/-20% of its initial value) and the final optimization ends with a value of 599.8310 km/s.

So: this logic explains not only your spike at ~600 km/s but also the one at ~900 km/s (which surprised me at first because I knew the prior was 750 km/s!). (In fact, I think this means that all line-widths >750 km/s should be suspect).

The good news is that, looking at the QA figure below, [OIII] is not significant, so we should be able to remove these warts by demanding well-detected lines, e.g., OIII_5007_AMP*sqrt(OIII_5007_IVAR)>2 (or 1.5 or 3, whatever), but keep in mind that there are likely to be real lines which have these values which we'll want to try to recover.

Going forward, I would be grateful for any thoughts you (or anyone else) may have for "cleaning up" issues like these. And if you could also report (in this ticket) how you're going to decide to proceed, that'd be helpful.

To generate the QA below:

source /global/cfs/cdirs/desi/software/desi_environment.sh 23.1
module swap desispec/0.57.0
module load fastspecfit/2.1.2

fastspecfit-qa $DESI_ROOT/spectro/fastspecfit/fuji/v2.0/healpix/special/dark/254/25463/fastspec-special-dark-25463.fits.gz \
  --targetids 39627631057962664
Screenshot 2023-04-29 at 9 03 06 AM
moustakas commented 8 months ago

@VFawcett here's the distribution of line-widths for the forbidden lines based on the latest (2.5.0) tag. I think things look pretty good now, but please feel free to reopen (or open a new ticket) if you find any other issues--

Image