comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » continuum normalized spectra
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
continuum normalized spectra [message #83002] Sat, 02 February 2013 10:37 Go to next message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
Hi All,
I want to write a program to fit a linear local continuum of absorption line, and plot the spectrum with continuum drawn and the spectrum normalized by the continuum. And than I want to Fit a local continuum using data in the wavelength ranges 1800-1820 and 2020-2040 angstroms.

Does anyone know that how can I do that

thanks
Re: continuum normalized spectra [message #83091 is a reply to message #83002] Sun, 03 February 2013 13:43 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den söndagen den 3:e februari 2013 kl. 15:33:30 UTC+1 skrev idlhelp:
> On Sunday, February 3, 2013 3:22:54 PM UTC+1, Mats Löfdahl wrote:
>> Den söndagen den 3:e februari 2013 kl. 09:09:20 UTC+1 skrev idlhelp:
>>>> idlhelp writes:
>
>>>> > I want to write a program to fit a linear local continuum of absorption line, and plot the spectrum with continuum drawn and the spectrum normalized by the continuum. And than I want to Fit a local continuum using data in the wavelength ranges 1800-1820 and 2020-2040 angstroms.
>
>>>> > Does anyone know that how can I do that
>>>
>>> ok so here is the information. This is how I am doing :-)
>>> ; filename - the filename of the input spectrum
>>> ; column - the number of columns in the file
>>> ; row - the number of rows in the file
>>> ; boxsize - the size of the boxcar for the smoothing function
>>> ; dofit - the user keyword
>>> ; dofityes - the variable containing the input parameter
>>> data = fltarr(column, row)
>>> ; open the file as read only
>>> openr,lun,filename,/get_lun
>>> ; read the data from the file into the array
>>> readf,lun,data
>>> ; close the file
>>> close,/all
>>> wave=reform(data(0,*))
>>> flux=reform(data(1,*))
>>> ; This creates a new array containing the results generate
>>> ; by the smooth function.
>>> smoothed_flux = smooth(flux,boxsize)
>>> ; check to see if the user would like to fit the continuum
>>> if keyword_set(dofityes) then begin ; this check the dofit keyword
>>> ; fit velocity and smoothed_flux, using a 1st order polynomial.
>>> result = poly_fit(wave,smoothed_flux,1)
>>> ; generate the continuum with the results from the fit
>>> continuum = result(0) + result(1)*wave
>>> end
>
>>> But I am not sure that I am doing the continuum normalization to unity in a right way. Because when I make plots the contunum level is higher than the unity.
>
>> As far as I can see, you don't do any normalization at all. You calculate the fit, but you never operate on the original (or smoothed) spectrum with that fit. I guess you need to divide the spectrum with the fit.
>
> Ahh I forgot, I am dividing the spectrum by the continuum like that
> but still the continuum is far from unity
>
> ; for continuum normalization
>
> smoothed_flux = smoothed_flux/continuum

Alright. Next thing I wonder is where you do that selection of wavelength ranges you mentioned in your first posting. Is that already done in another part of the program, and stored that way in the file you read here? Because if you fit a straight line to the spectrum in an interval that includes the absorption line, then of course the fitted line will be lower than the continuum level.
Re: continuum normalized spectra [message #83096 is a reply to message #83002] Sun, 03 February 2013 06:33 Go to previous message
abc is currently offline  abc
Messages: 46
Registered: March 2011
Member
On Sunday, February 3, 2013 3:22:54 PM UTC+1, Mats Löfdahl wrote:
> Den söndagen den 3:e februari 2013 kl. 09:09:20 UTC+1 skrev idlhelp:
>
>> On Saturday, February 2, 2013 7:42:39 PM UTC+1, David Fanning wrote:
>
>>
>
>>> idlhelp writes:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>> I want to write a program to fit a linear local continuum of absorption line, and plot the spectrum with continuum drawn and the spectrum normalized by the continuum. And than I want to Fit a local continuum using data in the wavelength ranges 1800-1820 and 2020-2040 angstroms.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Does anyone know that how can I do that
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Yes, probably. But, not without a hell of a lot more information. :-)
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Cheers,
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> David
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> --
>
>>
>
>>>
>
>>
>
>>> David Fanning, Ph.D.
>
>>
>
>>>
>
>>
>
>>> Fanning Software Consulting, Inc.
>
>>
>
>>>
>
>>
>
>>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
>>
>
>>>
>
>>
>
>>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> Hi David,
>
>>
>
>> ok so here is the information. This is how I am doing :-)
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> ; filename - the filename of the input spectrum
>
>>
>
>> ; column - the number of columns in the file
>
>>
>
>> ; row - the number of rows in the file
>
>>
>
>> ; boxsize - the size of the boxcar for the smoothing function
>
>>
>
>> ; dofit - the user keyword
>
>>
>
>> ; dofityes - the variable containing the input parameter
>
>>
>
>>
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> data = fltarr(column, row)
>
>>
>
>>
>
>>
>
>> ; open the file as read only
>
>>
>
>> openr,lun,filename,/get_lun
>
>>
>
>>
>
>>
>
>> ; read the data from the file into the array
>
>>
>
>> readf,lun,data
>
>>
>
>>
>
>>
>
>> ; close the file
>
>>
>
>> close,/all
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> wave=reform(data(0,*))
>
>>
>
>> flux=reform(data(1,*))
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> ; This creates a new array containing the results generate
>
>>
>
>> ; by the smooth function.
>
>>
>
>> smoothed_flux = smooth(flux,boxsize)
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> ; check to see if the user would like to fit the continuum
>
>>
>
>> if keyword_set(dofityes) then begin ; this check the dofit keyword
>
>>
>
>>
>
>>
>
>> ; fit velocity and smoothed_flux, using a 1st order polynomial.
>
>>
>
>> result = poly_fit(wave,smoothed_flux,1)
>
>>
>
>>
>
>>
>
>> ; generate the continuum with the results from the fit
>
>>
>
>> continuum = result(0) + result(1)*wave
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> end
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> But I am not sure that I am doing the continuum normalization to unity in a right way. Because when I make plots the contunum level is higher than the unity.
>
>
>
> As far as I can see, you don't do any normalization at all. You calculate the fit, but you never operate on the original (or smoothed) spectrum with that fit. I guess you need to divide the spectrum with the fit.

Ahh I forgot, I am dividing the spectrum by the continuum like that
but still the continuum is far from unity

; for continuum normalization
smoothed_flux = smoothed_flux/continuum
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: reading/writing large files
Next Topic: IDL implementation of Kaczmarz method for solving AX=B

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:16:47 PDT 2025

Total time taken to generate the page: 0.02542 seconds