X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 28 Oct 2011 12:55 PM by  anon
What does this code do?
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
28 Oct 2011 12:55 PM
    Hi, I am new to IDL, and I am trying to figure out what this script is doing, any help will be very highly appreciated: if !d.name ne 'PS' then begin device,Pseudo_color=8 Device, Get_Visual_Depth=thisDepth IF thisDepth GT 8 THEN Device, Decomposed=0 ENDIF close, /all ;window,0,retain=2,xsize=750,ysize=750 ;!p.multi=[0,2,2,0,0] !P.charsize=1.5 angstrom = '!6!sA!r!u!9 %!6!n' red_lam=dblarr(18) red_alam_av=dblarr(18) header_str=' ' openr,lun,'reddening_law_seaton.dat', /get_lun readf,lun,header_str nlinha=0L WHILE NOT EOF(lun) DO BEGIN readf,lun, lambd, alam_av red_lam(nlinha)= lambd red_alam_av(nlinha)= alam_av nlinha=nlinha+1L ENDWHILE Thanks in advance!

    Deleted User



    New Member


    Posts:
    New Member


    --
    28 Oct 2011 03:35 PM
    This code is demonstrating how IDL programs were written in the 1970s. No one does it this way any more, I hope. http://www.idlcoyote.com/.../coyote_graphics.php Basically, it puts IDL into the brain-dead mode of using color indices, and it reads an ASCII data file until the loop finds the end of the file, storing the information it finds there into arrays. These days you would find out how many lines are in the file by using the FILE_LINES function and read the data directly into arrays of the proper size: rows = File_Lines('reddening_law_seaton.dat') data = DblArr(2,rows) header = "" OpenR, lun, ,'reddening_law_seaton.dat', /Get_Lun ReadF, lun, header ReadF, lun, data Free_Lun, lun red_lam = Transpose(data[0,*]) red_alam_av = Transpose(data[1,*]) I wouldn't use the code you are showing us as an example of how to write an IDL program. :-)

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Oct 2011 04:35 AM
    Thank you for your reply! Indeed this is an old script that I got from someone who is not using it anymore and doesn't even remember the details of it :-( .. That's why I am trying to understand it and write it in a way I can apply it and modify it if needed. This is the part that I am looking at, I think that I understand the first part, but I am not sure what the other part is doing: ======================= f_5870=f_s(ind_lam_norm) for i=0,lin-4 do begin f_s(i)=f_s(i)/f_5870 endfor ======================== red_interp = SPLINE (red_lam,red_alam_av,lambda) This looks like an interpolation and a spline function is used but what is it interpolating? I don't understand what this expression is used for... any idea? red_interp_5870=spline(red_lam,red_alam_av,5870) I think this is the same as the one above but it uses a specific value for lambda, correct? Thanks again!

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Oct 2011 09:19 AM
    [QUOTE]NGC1983 wrote Thank you for your reply! Indeed this is an old script that I got from someone who is not using it anymore and doesn't even remember the details of it :-( .. That's why I am trying to understand it and write it in a way I can apply it and modify it if needed. This is the part that I am looking at, I think that I understand the first part, but I am not sure what the other part is doing: ======================= f_5870=f_s(ind_lam_norm) for i=0,lin-4 do begin f_s(i)=f_s(i)/f_5870 endfor ======================== red_interp = SPLINE (red_lam,red_alam_av,lambda) This looks like an interpolation and a spline function is used but what is it interpolating? I don't understand what this expression is used for... any idea? red_interp_5870=spline(red_lam,red_alam_av,5870) I think this is the same as the one above but it uses a specific value for lambda, correct? Thanks again! [/QUOTE] Is my question clear? Does it need more clarification/details? Thanks in advance!

    Deleted User



    New Member


    Posts:
    New Member


    --
    01 Nov 2011 06:56 AM
    Your question is clear, but very few people read this forum. If you want IDL questions answered quickly, you should ask them on the IDL newsgroup (comp.lang.idl-pvwave), where there is a whole community of IDL experts who can respond quickly. :-) f_5870=f_s(ind_lam_norm) In these old scripts, and in a script fragment, it is difficult to say exactly what this is. I can't tell, for example, whether f_s is a function that is smoothing its argument, ind_lam_norm, or an array that is being subscripted by an index, ind_lam_norm. If I were doing the work, I would put a break point in the code at this point and look around a little bit with the Print and Help commands. In your own code, you should always use square bracket subscripting for arrays to eliminate this kind of confusion. red_interp = SPLINE (red_lam,red_alam_av,lambda) This looks like an interpolation and a spline function is used but what is it interpolating? I don't understand what this expression is used for... any idea? Yes, this is a spline interpolation. To see what it is interpolating, you need to find the SPLINE function in the IDL on-line help and read the description of the arguments. Basically, what this function does is calculate a relatively "stiff" line though the values given by red_lam and red_alam, at the locations specified by the variable lambda. I would say the purpose of this routine is to give a smoothly varying function though noisy data.
    You are not authorized to post a reply.