rwesson / ALFA

Automated Line Fitting Algorithm
http://www.nebulousresearch.org/codes/alfa/
GNU General Public License v3.0
12 stars 6 forks source link

ALFA error measuring spectrum past 10,000 Angstroms #27

Closed catherine-manea closed 4 years ago

catherine-manea commented 4 years ago

Hi there, I've been using ALFA to measure my low-resolution optical emission-line spectra, and it has worked great for me. My wavelength range goes from 3500 Ang to 10500 Ang. However, ALFA only successfully measures my lines when I trim off the final 500 Angstroms of my data and limit my wavelength range to <10,000 Angstroms. Here is the error I get when I try to measure the segment that runs from 10,000 Angstroms to 10,500 Ang. I've also included that segment of my data to this message in case it might be helpful to confirm that my data format is correct. I was wondering if you might have any advice for me? Perhaps I've missed something in your documentation. Thanks so much.

k3-60_ALFA_redend.txt

Error when running final 10000 Ang to 10500 Ang segment of data:

10:02:49 : starting code command line: alfa --clobber k3-60_ALFA_redend.txt ALFA is running with the following settings: file: k3-60_ALFA_redend.txt normalisation: using measured value of Hb continuum fitting: enabled continuum window: 101 spectrum fitted if max value > 0.00000000
Angstroms per wavelength unit: 1.00000000
multiple spectra: fitted individually velocity guess: 0.00000000
resolution guess: 0.00000000
first pass velocity tolerance: 179.875488
second pass velocity tolerance: 59.9584923
first pass resolution tolerance: 0.00000000
second pass resolution tolerance: 500.000000
sky line fitting: disabled strong line catalogue: /usr/local/share/alfa/optical_strong.cat deep line catalogue: /usr/local/share/alfa/optical_deep.cat number of generations: 500 population size: 30 pressure factor: 0.300000012
output directory: ./ output format: fits

        reading in file k3-60_ALFA_redend.txt:
        filename does not contain .fit or .FIT, so assuming plain text format
          number of data points:          714
          wavelength range:    10000.4004       10499.5000    

        reading in line catalogues

At line 505 of file source/readfiles.f90 (unit = 199, file = '/usr/local/share/alfa/sky_deep.cat') Fortran runtime error: Bad value during integer read

Here is the error when I run the full spectrum:

10:07:27 : starting code command line: alfa --clobber k3-60_ALFA.txt ALFA is running with the following settings: file: k3-60_ALFA.txt normalisation: using measured value of Hb continuum fitting: enabled continuum window: 101 spectrum fitted if max value > 0.00000000
Angstroms per wavelength unit: 1.00000000
multiple spectra: fitted individually velocity guess: 0.00000000
resolution guess: 0.00000000
first pass velocity tolerance: 179.875488
second pass velocity tolerance: 59.9584923
first pass resolution tolerance: 0.00000000
second pass resolution tolerance: 500.000000
sky line fitting: disabled strong line catalogue: /usr/local/share/alfa/optical_strong.cat deep line catalogue: /usr/local/share/alfa/optical_deep.cat number of generations: 500 population size: 30 pressure factor: 0.300000012
output directory: ./ output format: fits

        reading in file k3-60_ALFA.txt:
        filename does not contain .fit or .FIT, so assuming plain text format
          number of data points:         9784
          wavelength range:    3650.00000       10499.5000    

        reading in line catalogues

At line 505 of file source/readfiles.f90 (unit = 199, file = '/usr/local/share/alfa/sky_deep.cat') Fortran runtime error: Bad value during integer read

And here is my successful run when I limit the wavelength range to <10,000 Ang.:

10:10:13 : starting code command line: alfa --clobber k3-60_ALFA.txt ALFA is running with the following settings: file: k3-60_ALFA.txt normalisation: using measured value of Hb continuum fitting: enabled continuum window: 101 spectrum fitted if max value > 0.00000000
Angstroms per wavelength unit: 1.00000000
multiple spectra: fitted individually velocity guess: 0.00000000
resolution guess: 0.00000000
first pass velocity tolerance: 179.875488
second pass velocity tolerance: 59.9584923
first pass resolution tolerance: 0.00000000
second pass resolution tolerance: 500.000000
sky line fitting: disabled strong line catalogue: /usr/local/share/alfa/optical_strong.cat deep line catalogue: /usr/local/share/alfa/optical_deep.cat number of generations: 500 population size: 30 pressure factor: 0.300000012
output directory: ./ output format: fits

        reading in file k3-60_ALFA.txt:
        filename does not contain .fit or .FIT, so assuming plain text format
          number of data points:         9070
          wavelength range:    3650.00000       9999.70020    

        reading in line catalogues
        fitting continuum
        estimated spectrograph resolution assuming Nyquist sampling:    5215.64941    
        initial guesses for velocity and resolution:      0.0km/s, R= 5215.6
        estimating resolution and velocity using           15  lines

10:10:14 : estimated velocity and resolution: -92.9904022 3493.93408
fitting full spectrum with 582 lines fitting from 3650.0 to 3944.7 with 62 lines fitting from 3917.4 to 4224.7 with 56 lines fitting from 4197.4 to 4504.7 with 86 lines 10:10:15 : fitting from 4477.4 to 4784.7 with 62 lines fitting from 4757.4 to 5064.7 with 18 lines fitting from 5037.4 to 5344.7 with 4 lines fitting from 5317.4 to 5624.7 with 7 lines fitting from 5597.4 to 5904.7 with 11 lines fitting from 5877.4 to 6184.7 with 10 lines fitting from 6157.4 to 6464.7 with 9 lines 10:10:16 : fitting from 6437.4 to 6744.7 with 10 lines fitting from 6717.4 to 7024.7 with 3 lines fitting from 6997.4 to 7304.7 with 12 lines fitting from 7277.4 to 7584.7 with 13 lines fitting from 7557.4 to 7864.7 with 5 lines fitting from 7837.4 to 8144.7 with 17 lines fitting from 8117.4 to 8424.7 with 36 lines fitting from 8397.4 to 8704.7 with 27 lines fitting from 8677.4 to 8984.7 with 25 lines 10:10:17 : fitting from 8957.4 to 9264.7 with 26 lines fitting from 9237.4 to 9544.7 with 35 lines fitting from 9517.4 to 9824.7 with 31 lines Warning: some lines ended up outside the fitting region. Try reducing the value of vtol2, which is currently set to 59.9584923
fitting from 9797.4 to 9999.7 with 17 lines

        flagging blends
        estimating uncertainties

10:10:18 : H beta detected with flux 3.234E+02 - normalising to 100.0 Wrote fit to header FIT of output file ./k3-60_ALFA.txt_fit.fits Wrote line list to header LINES all done

rwesson commented 4 years ago

Hi, that was a problem I had never encountered before, as my test spectra do not extend beyond 10,000A. The cause was a fortran read statement which only expected enough digits for numbers <10,000. I have fixed that, and can now fit your >10,000A segment successfully.

I've updated the repository, and if you installed the code from the PPA, you'll get an update shortly. Hope it now works for you but let me know if you encounter any further problems!

catherine-manea commented 4 years ago

Thank you so much for your quick reply and help!! I just pulled your recent update from GitHub and confirmed that it went through to my version of ALFA. When I run ALFA on my data, for some strange reason, I'm still getting this same error. I've included my full spectrum this time just to ensure my data is not the problem. Thank you so much again for your help!

K3-60_ALFA.txt

My error: alfa --clobber k3-60_ALFA.txt ALFA, the Automated Line Fitting Algorithm version v2.0-42-gdae514b

13:47:38 : starting code command line: alfa --clobber k3-60_ALFA.txt ALFA is running with the following settings: file: k3-60_ALFA.txt normalisation: using measured value of Hb continuum fitting: enabled continuum window: 101 spectrum fitted if max value > 0.00000000
Angstroms per wavelength unit: 1.00000000
multiple spectra: fitted individually velocity guess: 0.00000000
resolution guess: 0.00000000
first pass velocity tolerance: 179.875488
second pass velocity tolerance: 59.9584923
first pass resolution tolerance: 0.00000000
second pass resolution tolerance: 500.000000
sky line fitting: disabled strong line catalogue: /usr/local/share/alfa/optical_strong.cat deep line catalogue: /usr/local/share/alfa/optical_deep.cat number of generations: 500 population size: 30 pressure factor: 0.300000012
output directory: ./ output format: fits

        reading in file k3-60_ALFA.txt:
        filename does not contain .fit or .FIT, so assuming plain text format
          number of data points:         9784
          wavelength range:    3650.00000       10499.5000    

        reading in line catalogues

At line 505 of file source/readfiles.f90 (unit = 199, file = '/usr/local/share/alfa/sky_deep.cat') Fortran runtime error: Bad value during integer read

rwesson commented 4 years ago

Thanks for testing it so quickly! The line catalogues had a wrong column width at >10,000A, but I forgot to include that directory in my previous commit. I've pushed that fix as well now. Hope it really does work now, but let me know if not!

catherine-manea commented 4 years ago

Thank you so much for that quick update!! Unfortunately, I'm still getting a similar (though slightly different) error. I can confirm that I've pulled your most recent update. Sorry for this hassle, and thank you again for the help:

alfa --clobber k3-60_ALFA.txt
 ALFA, the Automated Line Fitting Algorithm
 version v2.0-42-gdae514b

 14:41:22 : starting code
            command line: alfa --clobber k3-60_ALFA.txt
            ALFA is running with the following settings:
               file:                            k3-60_ALFA.txt
              normalisation:                    using measured value of Hb
              continuum fitting:                enabled
              continuum window:                          101
              spectrum fitted if max value >       0.00000000    
              Angstroms per wavelength unit:       1.00000000    
              multiple spectra:                  fitted individually
              velocity guess:                      0.00000000    
              resolution guess:                    0.00000000    
              first pass velocity tolerance:       179.875488    
              second pass velocity tolerance:      59.9584923    
              first pass resolution tolerance:     0.00000000    
              second pass resolution tolerance:    500.000000    
              sky line fitting:                 disabled
              strong line catalogue:            /usr/local/share/alfa/optical_strong.cat
              deep line catalogue:              /usr/local/share/alfa/optical_deep.cat
              number of generations:                     500
              population size:                            30
              pressure factor:                    0.300000012    
              output directory:                 ./
              output format:                    fits 

            reading in file k3-60_ALFA.txt:
            filename does not contain .fit or .FIT, so assuming plain text format
              number of data points:         9784
              wavelength range:    3650.00000       10499.5000    

            reading in line catalogues
At line 505 of file source/readfiles.f90 (unit = 199, file = '/usr/local/share/alfa/optical_strong.cat')
Fortran runtime error: Bad value during integer read

However, when I trim my data below 10,000 Ang, ALFA works great as usual:

alfa --clobber k3-60_ALFA.txt
 ALFA, the Automated Line Fitting Algorithm
 version v2.0-42-gdae514b

 17:44:39 : starting code
            command line: alfa --clobber k3-60_ALFA.txt
            ALFA is running with the following settings:
               file:                            k3-60_ALFA.txt
              normalisation:                    using measured value of Hb
              continuum fitting:                enabled
              continuum window:                          101
              spectrum fitted if max value >       0.00000000    
              Angstroms per wavelength unit:       1.00000000    
              multiple spectra:                  fitted individually
              velocity guess:                      0.00000000    
              resolution guess:                    0.00000000    
              first pass velocity tolerance:       179.875488    
              second pass velocity tolerance:      59.9584923    
              first pass resolution tolerance:     0.00000000    
              second pass resolution tolerance:    500.000000    
              sky line fitting:                 disabled
              strong line catalogue:            /usr/local/share/alfa/optical_strong.cat
              deep line catalogue:              /usr/local/share/alfa/optical_deep.cat
              number of generations:                     500
              population size:                            30
              pressure factor:                    0.300000012    
              output directory:                 ./
              output format:                    fits 

            reading in file k3-60_ALFA.txt:
            filename does not contain .fit or .FIT, so assuming plain text format
              number of data points:         9070
              wavelength range:    3650.00000       9999.70020    

            reading in line catalogues
            fitting continuum
            estimated spectrograph resolution assuming Nyquist sampling:    5215.64941    
            initial guesses for velocity and resolution:      0.0km/s, R= 5215.6
            estimating resolution and velocity using           14  lines
            estimated velocity and resolution:   -92.0969467       3406.92896    
            fitting full spectrum with          582  lines
            fitting from  3650.0 to  3944.7 with  62 lines
            fitting from  3917.4 to  4224.7 with  56 lines
 17:44:40 : fitting from  4197.4 to  4504.7 with  86 lines
            fitting from  4477.4 to  4784.7 with  62 lines
 17:44:41 : fitting from  4757.4 to  5064.7 with  18 lines
            fitting from  5037.4 to  5344.7 with   4 lines
            fitting from  5317.4 to  5624.7 with   7 lines
            fitting from  5597.4 to  5904.7 with  11 lines
            fitting from  5877.4 to  6184.7 with  10 lines
            fitting from  6157.4 to  6464.7 with   9 lines
            fitting from  6437.4 to  6744.7 with  10 lines
            fitting from  6717.4 to  7024.7 with   3 lines
            fitting from  6997.4 to  7304.7 with  12 lines
            fitting from  7277.4 to  7584.7 with  13 lines
            fitting from  7557.4 to  7864.7 with   5 lines
            fitting from  7837.4 to  8144.7 with  16 lines
            fitting from  8117.4 to  8424.7 with  37 lines
 17:44:42 : fitting from  8397.4 to  8704.7 with  27 lines
            fitting from  8677.4 to  8984.7 with  25 lines
            fitting from  8957.4 to  9264.7 with  26 lines
            fitting from  9237.4 to  9544.7 with  35 lines
 17:44:43 : fitting from  9517.4 to  9824.7 with  31 lines
               Warning: some lines ended up outside the fitting region.
               Try reducing the value of vtol2, which is currently set to    59.9584923    
            fitting from  9797.4 to  9999.7 with  17 lines

            flagging blends
            estimating uncertainties
            H beta detected with flux 3.280E+02 - normalising to 100.0
            Wrote fit to header FIT of output file ./k3-60_ALFA.txt_fit.fits
            Wrote line list to header LINES
            all done
rwesson commented 4 years ago

That is strange because I can now analyse your full wavelength range file without errors. But I think you might be calling an old executable: your output says it's version v2.0-42-gdae514b, but the most recent update was v2.0-48-g655ce31. To be sure you are using the right version and the updated data files, I recommend that you do

make new && sudo make install

Then check that typing alfa gives you the right version. It will then also definitely be using the updated line catalogues. Let me know if there are still problems!

catherine-manea commented 4 years ago

Thank you so much, @rwesson! Finally got the correct version and all is working perfectly. Very excited to be measuring my full spectral range. Thank you again for your extremely quick help!!

rwesson commented 4 years ago

Glad to know it's working! Thanks for reporting the issue and good luck with the analysis.