def __plot(self, filename, lambdas, spectrum):

        ylabel = 'lg(S/S$\mathbf{_{max}}$)' if self._log_scale else 'S/S$\mathbf{_{max}}$'
        min_val, max_val = np.min(spectrum), np.max(spectrum)
        delta = 0.1 * (max_val - min_val)

        fig = plt.figure(figsize=(20, 10))
        plt.plot(lambdas,
                 spectrum,
                 color='black',
                 linewidth=7,
                 linestyle='solid')

        plt.ylim([min_val - delta, max_val + delta])

        plt.xticks(fontsize=40)
        plt.yticks(fontsize=40)

        plt.xlabel('$\mathbf{\lambda}$, nm', fontsize=55, fontweight='bold')
        plt.ylabel(ylabel, fontsize=55, fontweight='bold')

        plt.grid(linewidth=4, linestyle='dotted', color='gray', alpha=0.5)

        bbox = fig.bbox_inches.from_bounds(0, -0.4, 19, 10)

        plt.savefig(make_path(self._current_res_dir, filename),
                    bbox_inches=bbox)
        plt.close()
def included_roles():
    all_roles = set(os.listdir("/opt/iiab/iiab/roles"))
    excluded_roles = \
        map(str.rstrip,
            open(make_path("/opt/iiab/iiab/scripts",
                           "/opt/iiab/iiab/unmaintained-roles.txt")))
    included_roles = list(all_roles.difference(excluded_roles))
    included_roles.sort()
    return included_roles
Exemple #3
0
  def _print_escan_input():
    from os.path import join as make_path
    from pylada.physics import a0

    file = open(make_path(self.dir, self.vff_inputfile), "w")
    for i in xrange(3):
      for j in xrange(3):
        print >>file, structure.cell(i,j) * structure.scale / a0("A"),
      for j in xrange(3):
        print >>file, structure.cell(i,j)
      print >>file
Exemple #4
0
  def __call__(self, x):
    """ Returns value of function at x. """
    import numpy as np
    from os.path import join as make_path

    assert self._size is not None

    run_vff = self._setx(x)

    if run_vff:
      vff.evaluate()
      vff.print_escan_input( make_path(self.dir, self.vff_inputfile) )
    else: self._print_escan_input()

    return self.functional()
Exemple #5
0
 def store_opendota_json(self,data):
     filename = str(data['match_id']) + '.json'
     full_path = make_path(make_path(settings.PROJECT_ROOT,'data'),filename)
     with open(full_path,'w+') as f:
         f.write(json.dumps(data))
Exemple #6
0
    def __plot(self, angles, lambdas, fas):

        ylabel = 'lg(S/S$\mathbf{_{max}}$)' if self._log_scale else 'S/S$\mathbf{_{max}}$'
        min_val, max_val = np.min(fas), np.max(fas)
        delta = 0.1 * (max_val - min_val)

        #
        # fas
        #

        fig, ax = plt.subplots(figsize=(15, 7))
        plot = plt.contourf(fas, cmap='gray', levels=100)

        x_ticks_labels = ['1.4', '1.6', '1.8', '2.0', '2.2', '2.4']
        dlambda = lambdas[1] - lambdas[0]
        x_ticks = [
            int((float(e) * 10**3 - lambdas[0]) / dlambda)
            for e in x_ticks_labels
        ]
        plt.xticks(x_ticks, x_ticks_labels, fontsize=30)

        y_ticks_labels = ['-0.02', ' 0.00', '+0.02']
        dangle = angles[1] - angles[0]
        max_angle = self.__max_angle if self.__max_angle else angles[-1]
        y_ticks = [
            int((float(e) + max_angle) / dangle) for e in y_ticks_labels
        ]
        plt.yticks(y_ticks, y_ticks_labels, fontsize=30)

        plt.xlabel('$\mathbf{\lambda}$, $\mathbf{\mu}$m',
                   fontsize=40,
                   fontweight='bold')
        plt.ylabel('$\mathbf{\\theta}$, rad', fontsize=40, fontweight='bold')

        plt.grid(linewidth=3, linestyle='dotted', color='white', alpha=0.5)

        n_ticks_colorbar_levels = 4
        dcb = (max_val - min_val) / n_ticks_colorbar_levels
        levels_ticks_colorbar = [
            min_val + i * dcb for i in range(n_ticks_colorbar_levels + 1)
        ]

        colorbar = fig.colorbar(plot,
                                ticks=levels_ticks_colorbar,
                                orientation='vertical',
                                aspect=10,
                                pad=0.05)
        colorbar.set_label(ylabel,
                           labelpad=-100,
                           y=1.2,
                           rotation=0,
                           fontsize=40,
                           fontweight='bold')
        ticks_cbar = [
            '%05.2f' % e if e != 0 else '00.00' for e in levels_ticks_colorbar
        ]
        colorbar.ax.set_yticklabels(ticks_cbar)
        colorbar.ax.tick_params(labelsize=30)

        plt.savefig(make_path(self._current_res_dir, 'fas'),
                    bbox_inches='tight',
                    dpi=300)
        plt.close()

        #
        # frequency spectra
        #

        frequency_spectra_path = make_path(self._current_res_dir,
                                           'frequency_spectra')
        mkdir(frequency_spectra_path)
        for i in tqdm(range(fas.shape[0] // 2 + 1),
                      desc='%s->frequency_spectra' % self._current_res_dir):
            spectrum = fas[i, :]

            plt.figure(figsize=(20, 10))
            plt.plot(lambdas,
                     spectrum,
                     color='black',
                     linewidth=5,
                     linestyle='solid')

            plt.ylim([min_val - delta, max_val + delta])

            plt.xticks(fontsize=20, fontweight='bold')
            plt.yticks(fontsize=20, fontweight='bold')

            plt.xlabel('$\mathbf{\lambda}$, nm',
                       fontsize=30,
                       fontweight='bold')
            plt.ylabel(ylabel, fontsize=30, fontweight='bold')

            plt.grid(linewidth=2, linestyle='dotted', color='gray', alpha=0.5)

            plt.savefig(
                make_path(frequency_spectra_path,
                          'angle=%.5frad.png' % abs(angles[i])))
            plt.close()

        #
        # angular spectra
        #

        angular_spectra_path = make_path(self._current_res_dir,
                                         'angular_spectra')
        mkdir(angular_spectra_path)
        for i in tqdm(range(0, fas.shape[1], self.__lambda_dn),
                      desc='%s->angular_spectra' % self._current_res_dir):
            spectrum = fas[:, i]

            plt.figure(figsize=(20, 10))
            plt.plot(angles,
                     spectrum,
                     color='black',
                     linewidth=5,
                     linestyle='solid')

            plt.ylim([min_val - delta, max_val + delta])

            plt.xticks(fontsize=20, fontweight='bold')
            plt.yticks(fontsize=20, fontweight='bold')

            plt.xlabel('$\mathbf{\\theta}$, rad',
                       fontsize=30,
                       fontweight='bold')
            plt.ylabel(ylabel, fontsize=30, fontweight='bold')

            plt.grid(linewidth=2, linestyle='dotted', color='gray', alpha=0.5)

            plt.savefig(
                make_path(
                    angular_spectra_path, 'lambda=%.1fnm.png' %
                    (lambdas[0] + i * (lambdas[1] - lambdas[0]))))
            plt.close()
#!/usr/bin/env python3
'''
This script checks every role in the (Internet-in-a-Box) project and prints its
name to stdout if (1) the role directory does not contain a README file, and
(2) the role is not listed in /opt/iiab/iiab/unmaintained-roles.txt

For ease of use, you can pipe the output of this script to a file or to a 
clipboard utility (e.g. pbcopy on macOS, xclip on Linux).
'''

import os
from os.path import join as make_path
from glob import glob


def included_roles():
    all_roles = set(os.listdir("/opt/iiab/iiab/roles"))
    excluded_roles = \
        map(str.rstrip,
            open(make_path("/opt/iiab/iiab/scripts",
                           "/opt/iiab/iiab/unmaintained-roles.txt")))
    included_roles = list(all_roles.difference(excluded_roles))
    included_roles.sort()
    return included_roles


for role in included_roles():
    readme = make_path("/opt/iiab/iiab/roles", role, "README.*")
    if not glob(readme):
        print(role)
    def _get_files(self):
        files = []
        for file in glob(make_path(self._data_dir, '*.dat')):
            files.append(file.replace('\\', '/'))

        return files