Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Split the huge CCCP sourcelist into
- ;just IR matched sources and further
- ;into their classifications
- pro split_cccp_xspec_sourcelist,ir_sav,all_srclist,srclist_out,subset_type
- ;SUBSET_TYPE = 1 for all IR matches, 2 for IMPS, 3 for TTauri
- ;4 for AB, 5 for OB and 6 for unc.
- ;test call--> split_cccp_xspec_sourcelist,'xsed_collation_cccp.sav','all.srclist','test',2
- if n_params() lt 3 then begin
- print, 'Syntax --> split_cccp_sourcelist,ir_sav,all_srclist,srclist_out,subset_type = 1,2,3,4 or 5'
- return
- endif
- if not keyword_set(subset_type) then begin
- print, 'Define subset_type, 1 = all_ir, 2, = IMPS, 3 = OB, 4 =TTauri, 5 = AB'
- return
- endif
- ;Restoring variable with ir sources
- restore,ir_sav,/verbose
- ;Reading in all sources from sourcelist
- openr,lun,all_srclist,/get_lun
- all_sources = ''
- rows = ''
- while not EOF(lun) do begin
- readf,lun,rows
- all_sources = [all_sources,rows]
- endwhile
- free_lun, lun
- ;To hold convention of 0 being first element
- all_sources = all_sources[1:*]
- print, 'There are '+strmid(string(n_elements(all_sources)),2)+' sources'
- ;We now want to iterate through xname for matches to all_sources, since the
- ;arrays are not the same length we must hold xname constant and compare to all_sources
- count = 0
- for i = 0,n_elements(xname)-1 do begin
- ;All IR only sourcelist
- case subset_type of
- 1: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] ne '-',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- ;IMPS only sourcelist
- 2: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] eq 'IMPS',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- ;TTauri only sourcelist
- 3: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] eq 'TTauri',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- ;AB only sourcelist
- 4: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] eq 'AB',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- ;OB only sourcelist
- 5: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] eq 'OB',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- ;unc. only sourcelist
- 6: begin
- ind_match = where(strmid(all_sources,0,18) eq strtrim(xname[i],2) and impsclass[i] eq 'unc.',n_match)
- if n_match ne 0 then begin
- if count eq 0 then begin
- ind_all = ind_match
- endif else begin
- ind_all = [ind_all, ind_match ]
- endelse
- count++
- endif
- end
- endcase
- endfor
- sorted_ir_sources = all_sources[ind_all]
- n_sorted_ir_sources = n_elements(sorted_ir_sources)
- ;Defining ending of output textfile nomenclature
- out_suffix = ['', '_all_IR', '_IMPS', '_TTauri', '_AB', '_OB', '_unc'] + '.srclist'
- out_suffix = out_suffix[subset_type]
- print, 'There are '+strtrim(string(n_sorted_ir_sources),2)+' '+out_suffix+' sources'
- print, 'Output name is '+srclist_out+out_suffix
- ;Printing sources to a new text file
- openw,1,srclist_out+out_suffix
- for i=0L,n_sorted_ir_sources-1 do printf,1,sorted_ir_sources[i]
- close,/all
- end
Add Comment
Please, Sign In to add comment