Ignore:
Timestamp:
03/13/19 03:17:46 (6 years ago)
Author:
bdef
Message:

pep8 compliance of NTs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/test1206.py

    r23707 r23793  
    1414"""
    1515
    16 printingflag=False
     16printingflag = False
    1717
    18 numlayers=10
    19 resolution=30000.
     18numlayers = 10
     19resolution = 30000.
    2020
    2121#To begin with the numerical model
    22 md=model()
    23 md=roundmesh(md,750000.,resolution)
    24 md=setmask(md,'','')    #We can not test iceshelves nor ice rises with this analytical solution
    25 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.py')
     22md = model()
     23md = roundmesh(md, 750000., resolution)
     24md = setmask(md, '', '')    #We can not test iceshelves nor ice rises with this analytical solution
     25md = parameterize(md, '../Par/RoundSheetStaticEISMINT.py')
    2626
    2727#Calculation of the analytical 2d velocity field
    28 constant=0.3
    29 vx_obs=constant/2.*md.mesh.x*(md.geometry.thickness)**-1
    30 vy_obs=constant/2.*md.mesh.y*(md.geometry.thickness)**-1
    31 vel_obs=np.sqrt((md.inversion.vx_obs)**2+(md.inversion.vy_obs)**2)
     28constant = 0.3
     29vx_obs = constant / 2. * md.mesh.x * (md.geometry.thickness)**-1
     30vy_obs = constant / 2. * md.mesh.y * (md.geometry.thickness)**-1
     31vel_obs = np.sqrt((md.inversion.vx_obs)**2 + (md.inversion.vy_obs)**2)
    3232
    3333#We extrude the model to have a 3d model
    34 md.extrude(numlayers,1.)
    35 md=setflowequation(md,'HO','all')
     34md.extrude(numlayers, 1.)
     35md = setflowequation(md, 'HO', 'all')
    3636
    3737#Spc the nodes on the bed
    38 pos=np.where(md.mesh.vertexonbase)
    39 md.stressbalance.spcvx[pos]=0.
    40 md.stressbalance.spcvy[pos]=0.
    41 md.stressbalance.spcvz[pos]=0.
     38pos = np.where(md.mesh.vertexonbase)
     39md.stressbalance.spcvx[pos] = 0.
     40md.stressbalance.spcvy[pos] = 0.
     41md.stressbalance.spcvz[pos] = 0.
    4242
    43 #Now we can solve the problem 
    44 md.cluster=generic('name',gethostname(),'np',8)
    45 md=solve(md,'Stressbalance')
     43#Now we can solve the problem
     44md.cluster = generic('name', gethostname(), 'np', 8)
     45md = solve(md, 'Stressbalance')
    4646
    4747#Calculate the depth averaged velocity field (2d):
    48 vx=md.results.StressbalanceSolution.Vx
    49 vy=md.results.StressbalanceSolution.Vy
    50 vel=np.zeros((md.mesh.numberofvertices2d))
     48vx = md.results.StressbalanceSolution.Vx
     49vy = md.results.StressbalanceSolution.Vy
     50vel = np.zeros((md.mesh.numberofvertices2d))
    5151
    52 for i in range(0,md.mesh.numberofvertices2d):
    53         node_vel=0.
    54         for j in range(0,md.mesh.numberoflayers-1):
    55                 node_vel=node_vel+1./(2.*(md.mesh.numberoflayers-1))*\
    56                         (np.sqrt(vx[i+(j+1)*md.mesh.numberofvertices2d,0]**2+vy[i+(j+1)*md.mesh.numberofvertices2d,0]**2)+\
    57                         np.sqrt(vx[i+j*md.mesh.numberofvertices2d,0]**2+vy[i+j*md.mesh.numberofvertices2d,0]**2))
    58         vel[i]=node_vel
     52for i in range(0, md.mesh.numberofvertices2d):
     53    node_vel = 0.
     54    for j in range(0, md.mesh.numberoflayers - 1):
     55        node_vel = node_vel + 1. / (2. * (md.mesh.numberoflayers - 1)) * (np.sqrt(vx[i + (j + 1) * md.mesh.numberofvertices2d, 0]**2 + vy[i + (j + 1) * md.mesh.numberofvertices2d, 0]**2) + np.sqrt(vx[i + j * md.mesh.numberofvertices2d, 0]**2 + vy[i + j * md.mesh.numberofvertices2d, 0]**2))
     56    vel[i] = node_vel
    5957
    6058#Plot of the velocity from the exact and calculated solutions
    6159#figure(1)
    62 #subplot(2,2,1)
    63 #p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
    64 #vel,'FaceColor','interp','EdgeColor','none')
    65 #title('Modelled velocity','FontSize',14,'FontWeight','bold')
    66 #colorbar
    67 #caxis([0 200])
    68    
    69 #subplot(2,2,2)
    70 #p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
    71 #vel_obs,'FaceColor','interp','EdgeColor','none')
    72 #title('Analytical velocity','FontSize',14,'FontWeight','bold')
    73 #colorbar
     60#subplot(2, 2, 1)
     61#p = patch('Faces', md.mesh.elements2d, 'Vertices',[md.mesh.x2d md.mesh.y2d], 'FaceVertexCData',...
     62#vel, 'FaceColor', 'interp', 'EdgeColor', 'none')
     63#title('Modelled velocity', 'FontSize', 14, 'FontWeight', 'bold')
     64#colorbar
    7465#caxis([0 200])
    7566
    76 #subplot(2,2,3)
     67#subplot(2, 2, 2)
     68#p = patch('Faces', md.mesh.elements2d, 'Vertices',[md.mesh.x2d md.mesh.y2d], 'FaceVertexCData',...
     69#vel_obs, 'FaceColor', 'interp', 'EdgeColor', 'none')
     70#title('Analytical velocity', 'FontSize', 14, 'FontWeight', 'bold')
     71#colorbar
     72#caxis([0 200])
     73
     74#subplot(2, 2, 3)
    7775#hold on
    78 #plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2+(md.mesh.y(1:md.mesh.numberofvertices2d)).^2),vel,'r.')
    79 #plot(sqrt((md.mesh.x2d).^2+(md.mesh.y2d).^2),vel_obs,'b.')
    80 #title('Analytical vs calculated velocity','FontSize',14,'FontWeight','bold')
    81 #xlabel('distance to the center of the icesheet [m]','FontSize',14,'FontWeight','bold')
    82 #ylabel('velocity [m/yr]','FontSize',14,'FontWeight','bold')
    83 #legend('calculated velocity','exact velocity')
     76#plot(sqrt((md.mesh.x(1:md.mesh.numberofvertices2d)).^2+(md.mesh.y(1:md.mesh.numberofvertices2d)).^2), vel, 'r.')
     77#plot(sqrt((md.mesh.x2d).^2+(md.mesh.y2d).^2), vel_obs, 'b.')
     78#title('Analytical vs calculated velocity', 'FontSize', 14, 'FontWeight', 'bold')
     79#xlabel('distance to the center of the icesheet [m]', 'FontSize', 14, 'FontWeight', 'bold')
     80#ylabel('velocity [m/yr]', 'FontSize', 14, 'FontWeight', 'bold')
     81#legend('calculated velocity', 'exact velocity')
    8482#axis([0 750000 0 200])
    8583#hold off
    8684
    87 #subplot(2,2,4)
    88 #p=patch('Faces',md.mesh.elements2d,'Vertices',[md.mesh.x2d md.mesh.y2d],'FaceVertexCData',...
    89 #abs(vel-vel_obs)./vel_obs*100,'FaceColor','interp','EdgeColor','none')
    90 #title('Relative misfit [%]','FontSize',14,'FontWeight','bold')
     85#subplot(2, 2, 4)
     86#p = patch('Faces', md.mesh.elements2d, 'Vertices',[md.mesh.x2d md.mesh.y2d], 'FaceVertexCData',...
     87#abs(vel-vel_obs)./vel_obs*100, 'FaceColor', 'interp', 'EdgeColor', 'none')
     88#title('Relative misfit [%]', 'FontSize', 14, 'FontWeight', 'bold')
    9189#colorbar
    9290#caxis([0 100])
    9391
    9492if printingflag:
    95         pass
    96 #       set(gcf,'Color','w')
    97 #       printmodel('HOstatic','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off')
    98 #       system(['mv HOstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet'])
     93    pass
     94#       set(gcf, 'Color', 'w')
     95#       printmodel('HOstatic', 'png', 'margin', 'on', 'marginsize', 25, 'frame', 'off', 'resolution', 0.7, 'hardcopy', 'off')
     96#       system(['mv HOstatic.png ' ISSM_DIR '/website/doc_pdf/validation/Images/EISMINT/IceSheet'])
    9997
    10098#Fields and tolerances to track changes
    101 field_names     =['Vx','Vy','Vel']
    102 field_tolerances=[1e-12,1e-12,1e-12]
    103 field_values=[vx,vy,vel]
     99field_names = ['Vx', 'Vy', 'Vel']
     100field_tolerances = [1e-12, 1e-12, 1e-12]
     101field_values = [vx, vy, vel]
Note: See TracChangeset for help on using the changeset viewer.