Changeset 25178


Ignore:
Timestamp:
06/29/20 12:39:59 (5 years ago)
Author:
jdquinn
Message:

BUG: Corrected test2010.py; results output precison for runme.py to match runme.m

Location:
issm/trunk-jpl/test/NightlyRun
Files:
2 edited

Legend:

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

    r25168 r25178  
    11#!/usr/bin/env python
     2import argparse
     3from glob import glob
    24import os
    3 import argparse
     5from sys import float_info
     6from traceback import format_exc
     7
    48import numpy as np
    5 from traceback import format_exc
    6 from sys import float_info
    7 from glob import glob
    8 from GetIds import *
     9
    910try:
    1011    from parallelrange import parallelrange
     
    1213    import devpath
    1314    from parallelrange import parallelrange
    14 from IdToName import IdToName
    1515from arch import archread
    1616from arch import archwrite
     17from GetIds import *
     18from IdToName import IdToName
    1719
    1820
     
    182184                        # Matlab uses base 1, so use base 1 in labels
    183185                        archive = np.array(archread(archive_file, archive_name + '_field' + str(k + 1)))
    184                         #Because np.array is weird (str(np.array(None)) becomes 'None' but np.array(None) is never equal to None, it basically becomes a type of string in an array):
     186                        # NOTE: str(np.array(None)) becomes 'None' but np.array(None) is never equal to None: it basically becomes a type of string in an array
    185187                        if str(archive) == 'None':
    186188                            raise NameError("Field name '" + archive_name + '_field' + str(k + 1) + "' does not exist in archive file.")
     
    196198                        #disp test result
    197199                        if (np.any(error_diff > tolerance) or np.isnan(error_diff)):
    198                             print(('ERROR   difference: {} > {} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname)))
     200                            print(('ERROR   difference: {:7.2g} > {:7.2g} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname)))
    199201                            errorcount += 1
    200202                            erroredtest_list.append(id)
    201203                        else:
    202                             print(('SUCCESS difference: {} < {} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname)))
     204                            print(('SUCCESS difference: {:7.2g} < {:7.2g} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname)))
    203205
    204206                    except Exception as message:
  • issm/trunk-jpl/test/NightlyRun/test2010.py

    r25168 r25178  
    1919#parameterize solidearth solution:
    2020#solidearth loading:  {{{
    21 late = sum(md.mesh.lat[md.mesh.elements - 1], 1) / 3
    22 longe = sum(md.mesh.long[md.mesh.elements - 1], 1) / 3
     21late = md.mesh.lat[md.mesh.elements - 1].sum(axis=1) / 3
     22longe = md.mesh.long[md.mesh.elements - 1].sum(axis=1) / 3
    2323
    24 md.solidearth.surfaceload.icethicknesschange = np.zeros(md.mesh.numberofelements)
     24md.solidearth.surfaceload.icethicknesschange = np.zeros((md.mesh.numberofelements, 1))
    2525pos = np.intersect1d(np.array(np.where(late < -75)), np.array(np.where(longe > 0)))
    26 #python does not include last element in array slices, (6:7) -> [5:7]
     26#NOTE: Python does not include last element in array slices: (6:7) -> [5:7]
    2727md.solidearth.surfaceload.icethicknesschange[pos[5:7]] = -1
    2828
    2929md.solidearth.sealevel = np.zeros(md.mesh.numberofvertices)
    3030md.dsl.global_average_thermosteric_sea_level_change = np.zeros((2, 1))
    31 md.dsl.sea_surface_height_change_above_geoid = np.zeros(md.mesh.numberofvertices + 1)
    32 md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros(md.mesh.numberofvertices + 1)
     31md.dsl.sea_surface_height_change_above_geoid = np.zeros((md.mesh.numberofvertices + 1, 1))
     32md.dsl.sea_water_pressure_change_at_sea_floor = np.zeros((md.mesh.numberofvertices + 1, 1))
    3333
    3434md.solidearth.ocean_area_scaling = 1
     
    4040#mask:  {{{
    4141mask = gmtmask(md.mesh.lat, md.mesh.long)
    42 icemask = np.ones(md.mesh.numberofvertices)
     42icemask = np.ones((md.mesh.numberofvertices, 1))
    4343pos = np.where(mask == 0)
    4444icemask[pos[0]] = -1
    45 pos = np.where(np.sum(mask[md.mesh.elements - 1], 1) < 3)
     45pos = np.where(mask[md.mesh.elements - 1].sum(axis=1) < 3)[0]
    4646icemask[md.mesh.elements[pos, :] - 1] = -1
    4747md.mask.ice_levelset = icemask
     
    5050#make sure that the elements that have loads are fully grounded
    5151pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0]
    52 md.mask.ocean_levelset = -np.ones(md.mesh.numberofvertices)
     52md.mask.ocean_levelset[md.mesh.elements[pos, :] - 1] = 1
    5353
    5454#make sure wherever there is an ice load, that the mask is set to ice:
     55md.mask.ice_levelset = np.ones((md.mesh.numberofvertices, 1))
    5556#pos = np.nonzero(md.solidearth.surfaceload.icethicknesschange)[0] # Do we need to do this twice?
    56 md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = 1
    57 
    58 #make sure wherever there is an ice load, that the mask is set to ice
    59 md.mask.ice_levelset = np.ones(md.mesh.numberofvertices)
    60 icemask[md.mesh.elements[pos, :] - 1] = -1
    61 md.mask.ice_levelset = icemask
     57md.mask.ice_levelset[md.mesh.elements[pos, :] - 1] = -1
    6258# }}}
    6359
    6460#geometry {{{
    6561di = md.materials.rho_ice / md.materials.rho_water
    66 md.geometry.thickness = np.ones(md.mesh.numberofvertices)
    67 md.geometry.surface = (1 - di) * np.zeros(md.mesh.numberofvertices)
     62md.geometry.thickness = np.ones((md.mesh.numberofvertices, 1))
     63md.geometry.surface = (1 - di) * np.zeros((md.mesh.numberofvertices, 1))
    6864md.geometry.base = md.geometry.surface - md.geometry.thickness
    6965md.geometry.bed = md.geometry.base
    7066# }}}
    7167#materials {{{
    72 md.initialization.temperature = 273.25 * np.ones(md.mesh.numberofvertices)
     68md.initialization.temperature = 273.25 * np.ones((md.mesh.numberofvertices, 1))
    7369md.materials.rheology_B = paterson(md.initialization.temperature)
    74 md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements)
     70md.materials.rheology_n = 3 * np.ones((md.mesh.numberofelements, 1))
    7571# }}}
    7672#Miscellaneous {{{
Note: See TracChangeset for help on using the changeset viewer.