Skip to content
Snippets Groups Projects
Select Git revision
  • a4acc2017ad7261d35a4acc61c5afcf572510d02
  • master default protected
  • fix_Makefile.mingw#2
  • update_Makefile.mingw
  • fix_Makefile.mingw
  • fix_API_for_C_apps
  • fix_procinfo_mac
  • boinccmd_gpu_mode_always_until_sigterm
  • fgrp_osx_hotfix
  • fix_boinc_master@f8250782
  • eah_wrapper_improvements
  • diagnostics_win-hotfix
  • diagnostics_win-hotfix-old
  • current_fgrp_apps
  • testing_gw_apps
  • gw_app_darwin_15
  • current_brp_apps
  • current_brp_apps_android10
  • current_gfx_apps
  • current_server
  • current_gw_apps
  • previous_fgrp_apps
  • previous_gw_apps
  • testing_brp_apps
  • apps_FGRP3_1.07
  • apps_FGRP3_1.08
26 results

boinc_api_fortran.cpp

Blame
  • maps.py 2.51 KiB
    import numpy
    
    
    class surfacemap:
        def __init__(self, name, maptype, size, center, step_size, scaling, data=None):
            
            self.name = name
            self.type = maptype
            self.center = center
            self.size = size
            self.step_size = step_size
            self.scaling = scaling
            self.data = data
            
        def write_map(self, filename):
            with open(filename,'w') as mapfile:
                
                mapfile.write("% Surface map\n")
                mapfile.write("% Name: {0}\n".format(self.name))
                mapfile.write("% Type: {0}\n".format(self.type))
                mapfile.write("% Size: {0} {1}\n".format(self.size[0], self.size[1]))
                mapfile.write("% Optical center (x,y): {0} {1}\n".format(self.center[0], self.center[1]))
                mapfile.write("% Step size (x,y): {0} {1}\n".format(self.step_size[0], self.step_size[1]))
                mapfile.write("% Scaling: {0}\n".format(float(self.scaling)))
                mapfile.write("\n\n")
                
                for i in range(0, self.data.shape[0]):
                    for j in range(0, self.data.shape[1]):
                        mapfile.write("%.15g " % self.data[i,j])
                    mapfile.write("\n")
        
        def plot(self):
            
            import pylab
            
            xrange = 100*self.step_size[0] * (numpy.array(range(0, self.data.shape[0]))- self.center[0])
            yrange = 100*self.step_size[1] * (numpy.array(range(0, self.data.shape[1]))- self.center[1])
            
            fig = pylab.figure()
            axes = pylab.imshow(self.data, extent=[min(xrange),max(xrange),min(yrange),max(yrange)])
            pylab.xlabel('x [cm]')
            pylab.ylabel('y [cm]')
            pylab.title('Surface map {0}, type {1}'.format(self.name, self.type))
            cbar = fig.colorbar(axes)
            pylab.show()
               
               
               
    def read_map(filename):
        with open(filename, 'r') as f:
            
            f.readline()
            name = f.readline().split(':')[1].strip()
            maptype = f.readline().split(':')[1].strip()
            size = tuple(map(lambda x: int(x), f.readline().split(':')[1].strip().split()))
            center = tuple(map(lambda x: float(x), f.readline().split(':')[1].strip().split()))
            step = tuple(map(lambda x: float(x), f.readline().split(':')[1].strip().split()))
            scaling = float(f.readline().split(':')[1].strip())
            
            
            
        data = numpy.loadtxt(filename, dtype=numpy.float64, skiprows=9,ndmin=2)    
            
        return surfacemap(name,maptype,size,center,step,scaling,data)