Пример #1
0
    def identify_line_GUI(self):
        if self.label == 'None':
            self.label = 'LLS Small'
        data = line.read_line_list(self.label)
        Transition_List = []
        wavelist = []
        for i in range(0, len(data)):
            Transition_List.append(data[i]['ion'])
            wavelist.append(data[i]['wrest'])

        layout = [[sg.Text('Please select the transition and LineList')],
                  [
                      sg.Listbox(values=Transition_List,
                                 size=(30, 6),
                                 key='_Transition_')
                  ],
                  [
                      sg.Text('LineList', size=(15, 1)),
                      sg.Drop(values=(self.label, 'LLS', 'LLS Small', 'DLA'),
                              size=(15, 1),
                              key='_Menu_')
                  ], [sg.Button('Reset'),
                      sg.Button('Submit')]]

        window = sg.Window('Line Identification',
                           layout,
                           font=("Helvetica", 12))

        while True:  # Event Loop
            event, values = window.Read()

            if event is None or event == 'Submit':
                break
            self.label = values['_Menu_']
            data = line.read_line_list(self.label)
            Transition_List = []
            wavelist = []
            for i in range(0, len(data)):
                Transition_List.append(data[i]['ion'])
                wavelist.append(data[i]['wrest'])
            window.Element('_Transition_').Update(Transition_List)
        window.Close()

        Transition_List = np.array(Transition_List)
        wavelist = np.array(wavelist)

        Transition_rest = values['_Transition_']
        qq = np.where(Transition_List == Transition_rest)
        #ipdb.set_trace()
        lambda_rest = wavelist[qq][0]
        LineList = values['_Menu_']
        return lambda_rest, LineList
Пример #2
0
    def draw_any_linelist(self):
        # Now make a smaller linelist within the current xaxes range.
        #plt.figure(self.fig.number)
        xlim = self.ax.get_xlim()
        ylim = self.ax.get_ylim()

        #Hardcoding that only 10 independent absorber systems can be plotted
        for i in range(0, 10):
            if self.zabs_list['color'][i] != 'None':
                zabs = np.double(self.zabs_list['zabs'][i])
                linelist = self.zabs_list['List'][i]
                lineclr = self.zabs_list['color'][i]

                data = line.read_line_list(linelist)
                for i in range(0, len(data)):
                    if ((data[i]['wrest'] * (1. + zabs) >= np.double(xlim[0]))
                            & (data[i]['wrest'] *
                               (1. + zabs) <= np.double(xlim[1]))):
                        xdata = [
                            data[i]['wrest'] * (1. + zabs),
                            data[i]['wrest'] * (1. + zabs)
                        ]
                        ss = self.ax.transData.transform((0, .9))
                        ydata = [0, ylim[1]]
                        lineplot_list, = self.ax.plot(xdata,
                                                      ydata,
                                                      '--',
                                                      color=lineclr)
                        tt_list = self.ax.text(xdata[0],
                                               0.75 * ylim[1],
                                               data[i]['ion'] + ' ' +
                                               np.str('%.5f' % zabs),
                                               rotation=90)
        #print('Target Redshfit set at : ' + np.str(self.zabs))
        plt.draw()
Пример #3
0
    def DrawLineList(self, label):
        del self.ax.lines[1:len(self.ax.lines)]
        self.ax.texts = []
        self.label = label
        if label == 'None':
            lineplot, = self.ax.plot([0], [0], 'k--')
        else:
            data = line.read_line_list(label)

            # Now make a smaller linelist within the current xaxes range.

            xlim = self.ax.get_xlim()
            ylim = self.ax.get_ylim()

            for i in range(0, len(data)):
                if ((data[i]['wrest'] * (1. + self.zabs) >= np.double(xlim[0]))
                        & (data[i]['wrest'] *
                           (1. + self.zabs) <= np.double(xlim[1]))):
                    xdata = [
                        data[i]['wrest'] * (1. + self.zabs),
                        data[i]['wrest'] * (1. + self.zabs)
                    ]
                    ss = self.ax.transData.transform((0, .9))
                    ydata = [0, ylim[1]]
                    lineplot, = self.ax.plot(
                        xdata,
                        ydata,
                        'k--',
                    )
                    tt = self.ax.text(xdata[0],
                                      0.75 * ylim[1],
                                      data[i]['ion'] + ' ' + np.str(self.zabs),
                                      rotation=90)
        #print('Target Redshfit set at : ' + np.str(self.zabs))
        plt.draw()
Пример #4
0
    def _get_linelist_df(self, linelist_name):
        llist = pd.DataFrame(columns=['wave', 'name'])
        tmp = read_line_list(linelist_name)

        #need a line to append wrest to name if it doesn't have one
        if any(map(str.isdigit, tmp[1]['ion'])):
            # if name column has wrest
            for li in tmp:
                newrow = {'wave': li['wrest'], 'name': li['ion']}
                llist = llist.append(newrow, ignore_index=True)
        else:
            # if name column doesn't have wrest, need to append
            for li in tmp:
                newrow = {
                    'wave': li['wrest'],
                    'name': li['ion'] + ' ' + str(round(li['wrest']))
                }
                llist = llist.append(newrow, ignore_index=True)

        return llist
Пример #5
0
def prepare_absorber_object(z_abs,wave,flux,error,line_flg='LLS',vlim=[-1000,1000]):
    
    # Read the full linelist
    data=line.read_line_list(line_flg)
    wavelist=[]
    for i in range(0,len(data)):
        wavelist.append(data[i]['wrest'])
        
        
    wavelist=np.array(wavelist)

    
    # select the lines within the wavelength range only
    q= np.where((wavelist > np.min(wave)/(1.+z_abs)) &  (wavelist < (np.max(wave)/(1.+z_abs))));
    
    # Total transitions visible within the wavelength window
    nTot= len(q[0]);
    
    wavelist_selected=wavelist[q]
    
    absys=A.Absorber(z_abs,wave,flux,error,list(wavelist_selected),window_lim=vlim,nofrills=True)   
    
    return absys.ions