Exemple #1
0
def test_get_snaps_steps():
    case_dir = os.path.join(test_source_dir, 'foo')
    
    # call function for graphical outputs
    snaps, times, steps = Parse.GetSnapsSteps(case_dir)
    # assertions
    assert(snaps == [6, 7, 8, 9])
    assert(times == [0.0, 100000.0, 200000.0, 300000.0])
    assert(steps == [0, 104, 231, 373])
    
    # call function for particle outputs
    snaps, times, steps = Parse.GetSnapsSteps(case_dir, 'particle')
    # assertions
    assert(snaps == [0, 1])
    assert(times == [0.0, 2e5])
    assert(steps == [0, 231])
Exemple #2
0
def SlabMorph(case_dir, kwargs={}):
    """
    Slab morphology
    Inputs:
        case_dir(str): directory of case
        kwargs(dict): options
    """
    case_output_dir = os.path.join(case_dir, 'output')
    case_morph_dir = os.path.join(case_output_dir, 'slab_morphs')

    # Initiation
    Visit_Xyz = VISIT_XYZ()

    # a header for interpreting file format
    # note that 'col' starts form 0
    header = {
        'x': {
            'col': 1,
            'unit': 'm'
        },
        'y': {
            'col': 2,
            'unit': 'm'
        },
        'id': {
            'col': 4
        }
    }

    # depth range
    # this is for computing dip angles with different ranges
    depth_ranges = kwargs.get('depth_ranges',
                              [[0, 100e3], [100e3, 400e3], [400e3, 6371e3]])
    my_assert(
        type(depth_ranges) == list, TypeError, "depth_ranges mush be a list")

    # remove older results
    ofile = os.path.join(case_output_dir, 'slab_morph')
    if os.path.isfile(ofile):
        os.remove(ofile)

    #   loop for every snap and call function
    snaps, times, _ = Parse.GetSnapsSteps(case_dir, 'particle')

    for i in snaps:
        visit_xyz_file = os.path.join(case_morph_dir,
                                      'visit_particles_%06d.xyz' % i)
        Visit_Xyz(visit_xyz_file,
                  header=header,
                  ofile=ofile,
                  depth_ranges=depth_ranges,
                  time=times[i])