Exemple #1
0
    def get_ions(self,
                 use_Nfile=False,
                 idict=None,
                 update_zvlim=True,
                 linelist=None,
                 verbose=True):
        """Parse the ions for each Subsystem

        And put them together for the full system
        Fills ._ionN with a QTable

        Parameters
        ----------
        idict : dict, optional
          dict containing the IonClms info
        use_Nfile : bool, optional
          Parse ions from a .clm file (JXP historical)
          NOTE: This ignores velocity constraints on components (i.e. skip_vel=True)
        update_zvlim : bool, optional
          Update zvlim from lines in .clm (as applicable)
        linelist : LineList
        """
        if use_Nfile:
            clm_fil = self.tree + self._datdict['Abund file']
            # Read
            self._clmdict = igmau.read_clmfile(clm_fil, linelist=linelist)
            #pdb.set_trace()
            # Build components
            components = ltiu.build_components_from_dict(self._clmdict,
                                                         coord=self.coord,
                                                         chk_vel=False)
            # Read .ion file and fill in components
            ion_fil = self.tree + self._clmdict['ion_fil']
            self._indiv_ionclms = igmau.read_ion_file(ion_fil, components)
            # Parse .all file
            all_file = ion_fil.split('.ion')[0] + '.all'
            self.all_file = all_file  #MF: useful
            _ = igmau.read_all_file(all_file, components=components)
            # Build table
            self._ionN = ltiu.iontable_from_components(components,
                                                       ztbl=self.zabs)
            # Add to AbsSystem
            for comp in components:
                self.add_component(comp)
        elif idict is not None:
            table = dict_to_ions(idict)
            self._ionN = table
        else:
            raise IOError("Not ready for this")
Exemple #2
0
    def get_ions(self, use_Nfile=False, idict=None, update_zvlim=True,
                 linelist=None, verbose=True):
        """Parse the ions for each Subsystem

        And put them together for the full system
        Fills ._ionN with a QTable

        Parameters
        ----------
        idict : dict, optional
          dict containing the IonClms info
        use_Nfile : bool, optional
          Parse ions from a .clm file (JXP historical)
          NOTE: This ignores velocity constraints on components (i.e. skip_vel=True)
        update_zvlim : bool, optional
          Update zvlim from lines in .clm (as applicable)
        linelist : LineList
        """
        if use_Nfile:
            clm_fil = self.tree+self._datdict['Abund file']
            # Read
            self._clmdict = igmau.read_clmfile(clm_fil, linelist=linelist)
            #pdb.set_trace()
            # Build components
            components = ltiu.build_components_from_dict(self._clmdict,
                                                         coord=self.coord,
                                                         chk_vel=False)
            # Read .ion file and fill in components
            ion_fil = self.tree+self._clmdict['ion_fil']
            self._indiv_ionclms = igmau.read_ion_file(ion_fil, components)
            # Parse .all file
            all_file = ion_fil.split('.ion')[0]+'.all'
            self.all_file=all_file  #MF: useful to have
            _ = igmau.read_all_file(all_file, components=components)
            # Build table
            self._ionN = ltiu.iontable_from_components(components, ztbl=self.zabs)
            # Add to AbsSystem
            for comp in components:
                self.add_component(comp)
        elif idict is not None:
            table = dict_to_ions(idict)
            self._ionN = table
        else:
            raise IOError("Not ready for this")
Exemple #3
0
    def get_ions(self, use_Nfile=False, idict=None, update_zvlim=True, linelist=None):
        """Parse the ions for each Subsystem

        And put them together for the full system
        Fills ._ionN with a QTable

        Parameters
        ----------
        idict : dict, optional
          dict containing the IonClms info
        use_Nfile : bool, optional
          Parse ions from a .clm file (JXP historical)
          NOTE: This ignores velocity constraints on components (i.e. skip_vel=True)
        update_zvlim : bool, optional
          Update zvlim from lines in .clm (as applicable)
        linelist : LineList
        """
        if idict is not None:
            table = dict_to_ions(idict)
            self._ionN = table
        elif use_Nfile:
            # Subsystems
            if self.nsub > 0:  # This speeds things up (but is rarely used)
                linelist = LineList('ISM')
            for lbl in self.subsys.keys():
                clm_fil = self.tree+self.subsys[lbl]._datdict['clm_file']
                # Parse .clm file
                self.subsys[lbl]._clmdict = igmau.read_clmfile(clm_fil, linelist=linelist)
                # Build components from lines
                components = ltiu.build_components_from_dict(self.subsys[lbl]._clmdict,
                                                             coord=self.coord, skip_vel=True)
                self.subsys[lbl]._components = components
                # Update z, vlim
                if update_zvlim:
                    self.update_vlim(sub_system=lbl)
                    self.subsys[lbl].zabs = self.subsys[lbl]._clmdict['zsys']
                # Read .ion file and fill in components
                ion_fil = self.tree+self.subsys[lbl]._clmdict['ion_fil']
                self.subsys[lbl]._indiv_ionclms = igmau.read_ion_file(ion_fil, components)
                # Parse .all file
                all_file = ion_fil.split('.ion')[0]+'.all'
                self.subsys[lbl].all_file=all_file #MF: useful to have
                _ = igmau.read_all_file(all_file, components=components)
                # Build table
                self.subsys[lbl]._ionN = ltiu.iontable_from_components(components,ztbl=self.subsys[lbl].zabs)
                # Add to IGMSystem
                for comp in components:
                    self.add_component(comp)

            # Combine
            if self.nsub == 1:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                #xdb.set_trace()
            elif self.nsub == 0:
                raise ValueError('lls_utils.get_ions: Cannot have 0 subsystems..')
            else:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                warnings.warn('lls_utils.get_ions: Need to update multiple subsystems!! Taking A.')
        else:
            raise ValueError("Need an option in get_ions")
Exemple #4
0
    def get_ions(self,
                 use_Nfile=False,
                 idict=None,
                 update_zvlim=True,
                 linelist=None,
                 verbose=True):
        """Parse the ions for each Subsystem

        And put them together for the full system
        Fills ._ionN with a QTable

        Parameters
        ----------
        idict : dict, optional
          dict containing the IonClms info
        use_Nfile : bool, optional
          Parse ions from a .clm file (JXP historical)
          NOTE: This ignores velocity constraints on components (i.e. chk_vel=False)
        update_zvlim : bool, optional
          Update zvlim from lines in .clm (as applicable)
        linelist : LineList
        """
        if idict is not None:
            table = dict_to_ions(idict)
            self._ionN = table
        elif use_Nfile:
            # Subsystems
            if self.nsub > 0:  # This speeds things up (but is rarely used)
                linelist = LineList('ISM')
            for lbl in self.subsys.keys():
                clm_fil = self.tree + self.subsys[lbl]._datdict['clm_file']
                # Parse .clm file
                self.subsys[lbl]._clmdict = igmau.read_clmfile(
                    clm_fil, linelist=linelist)
                # Build components from lines
                components = ltiu.build_components_from_dict(
                    self.subsys[lbl]._clmdict, coord=self.coord, chk_vel=False)
                self.subsys[lbl]._components = components
                # Update z, vlim
                if update_zvlim:
                    self.update_vlim(sub_system=lbl)
                    self.subsys[lbl].zabs = self.subsys[lbl]._clmdict['zsys']
                # Read .ion file and fill in components
                ion_fil = self.tree + self.subsys[lbl]._clmdict['ion_fil']
                self.subsys[lbl]._indiv_ionclms = igmau.read_ion_file(
                    ion_fil, components)
                # Parse .all file
                all_file = ion_fil.split('.ion')[0] + '.all'
                self.subsys[lbl].all_file = all_file  #MF: useful to have
                _ = igmau.read_all_file(all_file, components=components)
                # Build table
                self.subsys[lbl]._ionN = ltiu.iontable_from_components(
                    components, ztbl=self.subsys[lbl].zabs)
                # Add to IGMSystem
                for comp in components:
                    self.add_component(comp)

            # Combine
            if self.nsub == 1:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                #xdb.set_trace()
            elif self.nsub == 0:
                raise ValueError(
                    'lls_utils.get_ions: Cannot have 0 subsystems..')
            else:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                warnings.warn(
                    'lls_utils.get_ions: Need to update multiple subsystems!! Taking A.'
                )
        else:
            raise ValueError("Need an option in get_ions")
Exemple #5
0
    def get_ions(self, use_Nfile=False, idict=None, update_zvlim=True, linelist=None):
        """Parse the ions for each Subsystem

        And put them together for the full system
        Fills ._ionN with a QTable

        Parameters
        ----------
        idict : dict, optional
          dict containing the IonClms info
        use_Nfile : bool, optional
          Parse ions from a .clm file (JXP historical)
        update_zvlim : bool, optional
          Update zvlim from lines in .clm (as applicable)
        linelist : LineList
        """
        if idict is not None:
            # Manipulate for astropy Table
            #  Could probably use add_row or dict instantiation
            table = None
            for ion in idict.keys():
                Zion = ltai.name_ion(ion)
                if table is None:
                    tkeys = idict[ion].keys()
                    lst = [[idict[ion][tkey]] for tkey in tkeys]
                    table = Table(lst, names=tkeys)
                    # Extra columns
                    if 'Z' not in tkeys:
                        table.add_column(Column([Zion[0]], name='Z'))
                        table.add_column(Column([Zion[1]], name='ion'))
                else:
                    tdict = idict[ion]
                    tkeys = idict[ion].keys()
                    if 'Z' not in tkeys:
                        tdict['Z'] = Zion[0]
                        tdict['ion'] = Zion[1]
                    # Add
                    table.add_row(tdict)
            # Finish
            try:  # Historical keys
                table.rename_column('clm', 'logN')
            except:
                pass
            else:
                table.rename_column('sig_clm', 'sig_logN')
                table.rename_column('flg_clm', 'flag_N')
            self._ionN = table
        elif use_Nfile:
            # Subsystems
            if self.nsub > 0:  # This speeds things up (but is rarely used)
                linelist = LineList('ISM')
            for lbl in self.subsys.keys():
                clm_fil = self.tree+self.subsys[lbl]._datdict['clm_file']
                # Parse .clm file
                self.subsys[lbl]._clmdict = igmau.read_clmfile(clm_fil, linelist=linelist)
                # Build components from lines
                components = igmau.build_components_from_abslines([], clmdict=self.subsys[lbl]._clmdict, coord=self.coord)
                # Update z, vlim
                if update_zvlim:
                    vmin,vmax = 9999., -9999.
                    for component in components:
                        vmin = min(vmin, component.vlim[0].value)
                        vmax = max(vmax, component.vlim[1].value)
                    self.subsys[lbl].zabs = self.subsys[lbl]._clmdict['zsys']
                    self.subsys[lbl].vlim = [vmin, vmax]*u.km/u.s
                # Read .ion file and fill in components
                ion_fil = self.tree+self.subsys[lbl]._clmdict['ion_fil']
                self.subsys[lbl]._indiv_ionclms = igmau.read_ion_file(ion_fil, components)
                # Parse .all file
                all_file = ion_fil.split('.ion')[0]+'.all'
                self.subsys[lbl].all_file=all_file #MF: useful to have
                _ = igmau.read_all_file(all_file, components=components)
                # Build table
                self.subsys[lbl]._ionN = igmau.iontable_from_components(components,ztbl=self.subsys[lbl].zabs)
                # Add to IGMSystem
                for comp in components:
                    self.add_component(comp)

            # Combine
            if self.nsub == 1:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                #xdb.set_trace()
            elif self.nsub == 0:
                raise ValueError('lls_utils.get_ions: Cannot have 0 subsystems..')
            else:
                self._ionN = self.subsys['A']._ionN
                self._clmdict = self.subsys['A']._clmdict
                warnings.warn('lls_utils.get_ions: Need to update multiple subsystems!! Taking A.')
        else:
            raise ValueError("Need an option in get_ions")