Exemplo n.º 1
0
    def _read_values(cls, fname):
        """
        Load target definition from the specified file.        
        """

        f = open(fname, 'Ur')
        lines = [fileio._parseline(l) for l in f.readlines()]
        f.close()
    
        values = {}
        values['directive'] = lines[10]
        
        sh_param = []
        for s in lines[11].split():
            try:
                sh_param.append(int(s))
            except ValueError:
                sh_param.append(s)
        values['sh_param'] = tuple(sh_param)   

        n_mat = int(lines[12])
        values['material'] = lines[13: 13+n_mat]

        values['aeff'] = ranges.How_Range.fromstring(lines[29+n_mat])

        return values
Exemplo n.º 2
0
    def _read_values(self, fname):
        """
        Load the values for a new Settings object from the specified file. 
        
        :param fname: The filename of the ddscat.par file to loadfrom
        :returns: A dict of the values
        """

        f = open(fname, "Ur")
        lines = [fileio._parseline(l) for l in f.readlines()]
        f.close()

        # Process target.
        # This is discarded, only needed to determine line spacing and
        # style of scattering specifier
        n_mat = int(lines[12])
        target = targets.Target.fromfile(fname)
        del lines[9 : 13 + n_mat]

        # Process settings
        settings = {}
        settings["CMDTRQ"] = True if lines[2] == "DOTORQ" else False
        settings["CMDSOL"] = lines[3]
        settings["CMDFFT"] = lines[4]
        settings["CALPHA"] = lines[5]
        settings["CBINFLAG"] = lines[6]

        settings["InitialMalloc"] = np.array(map(int, lines[8].split()))
        settings["NRFLD"] = True if int(lines[10]) else False
        settings["NRFLD_EXT"] = np.array(map(float, lines[11].split()[:6]))

        settings["TOL"] = float(lines[13])
        settings["MXITER"] = int(lines[15])
        settings["GAMMA"] = float(lines[17])
        settings["ETASCA"] = float(lines[19])
        settings["wavelengths"] = ranges.How_Range.fromstring(lines[21])

        settings["NAMBIENT"] = float(lines[23])

        scale = ranges.How_Range.fromstring(lines[25])
        scale.last /= scale.first
        scale.first = 1.0
        settings["scale_range"] = scale

        settings["Epol"] = utils.str2complexV(lines[27])
        settings["IORTH"] = True if int(lines[28]) == 2 else False

        settings["IWRKSC"] = True if int(lines[30]) else False

        settings["beta"] = ranges.Lin_Range.fromstring(lines[32])
        settings["theta"] = ranges.Lin_Range.fromstring(lines[33])
        settings["phi"] = ranges.Lin_Range.fromstring(lines[34])

        if lines[36].find(",") != -1:
            settings["initial"] = map(int, lines[36].split(","))
        else:
            settings["initial"] = map(int, lines[36].split())

        settings["S_INDICES"] = map(int, lines[39].split())

        settings["CMDFRM"] = lines[41]
        n_scat = int(lines[42])

        if n_scat > 0:
            if not isinstance(target, targets.Periodic):  # Assume isolated finite target
                settings["scat_planes"] = [ranges.Scat_Range.fromstring(l) for l in lines[43 : 43 + n_scat]]
            else:
                if target.dimension == 1:
                    settings["scat_planes"] = [ranges.Scat_Range_1dPBC.fromstring(l) for l in lines[43 : 43 + n_scat]]
                elif target.dimension == 2:
                    settings["scat_planes"] = [ranges.Scat_Range_2dPBC.fromstring(l) for l in lines[43 : 43 + n_scat]]

        return settings
Exemplo n.º 3
0
    def _read_values(self, fname):
        """
        Load the values for a new Settings object from the specified file. 
        
        :param fname: The filename of the ddscat.par file to loadfrom
        :returns: A dict of the values
        """

        f = open(fname, 'Ur')
        lines = [fileio._parseline(l) for l in f.readlines()]
        f.close()

        # Process target.
        # This is discarded, only needed to determine line spacing and
        # style of scattering specifier
        n_mat = int(lines[12])
        target = targets.Target.fromfile(fname)
        del lines[9:13 + n_mat]

        # Process settings
        settings = {}
        settings['CMDTRQ'] = True if lines[2] == 'DOTORQ' else False
        settings['CMDSOL'] = lines[3]
        settings['CMDFFT'] = lines[4]
        settings['CALPHA'] = lines[5]
        settings['CBINFLAG'] = lines[6]

        settings['InitialMalloc'] = np.array(map(int, lines[8].split()))
        settings['NRFLD'] = True if int(lines[10]) else False
        settings['NRFLD_EXT'] = np.array(map(float, lines[11].split()[:6]))

        settings['TOL'] = float(lines[13])
        settings['MXITER'] = int(lines[15])
        settings['GAMMA'] = float(lines[17])
        settings['ETASCA'] = float(lines[19])
        settings['wavelengths'] = ranges.How_Range.fromstring(lines[21])

        settings['NAMBIENT'] = float(lines[23])

        scale = ranges.How_Range.fromstring(lines[25])
        scale.last /= scale.first
        scale.first = 1.0
        settings['scale_range'] = scale

        settings['Epol'] = utils.str2complexV(lines[27])
        settings['IORTH'] = True if int(lines[28]) == 2 else False

        settings['IWRKSC'] = True if int(lines[30]) else False

        settings['beta'] = ranges.Lin_Range.fromstring(lines[32])
        settings['theta'] = ranges.Lin_Range.fromstring(lines[33])
        settings['phi'] = ranges.Lin_Range.fromstring(lines[34])

        if lines[36].find(',') != -1:
            settings['initial'] = map(int, lines[36].split(','))
        else:
            settings['initial'] = map(int, lines[36].split())

        settings['S_INDICES'] = map(int, lines[39].split())

        settings['CMDFRM'] = lines[41]
        n_scat = int(lines[42])

        if n_scat > 0:
            if not isinstance(
                    target, targets.Periodic):  # Assume isolated finite target
                settings['scat_planes'] = [
                    ranges.Scat_Range.fromstring(l)
                    for l in lines[43:43 + n_scat]
                ]
            else:
                if target.dimension == 1:
                    settings['scat_planes'] = [
                        ranges.Scat_Range_1dPBC.fromstring(l)
                        for l in lines[43:43 + n_scat]
                    ]
                elif target.dimension == 2:
                    settings['scat_planes'] = [
                        ranges.Scat_Range_2dPBC.fromstring(l)
                        for l in lines[43:43 + n_scat]
                    ]

        return settings