def set_simple_fault_3D_geometry(w, src):
    """
    Set simple fault surface coordinates as shapefile geometry.

    :parameter w:
        Writer
    :parameter src:
        NRML source object
    """
    # Create an oq object for the source
    hc = HC(1., 10., 0.1, 50.)
    converter = sss.NrmlHazardlibConverter(hc)
    src_oq = converter._nrml_source_to_hazardlib(src)
    lon, lat = \
        SimpleFaultSurface.get_surface_vertexes(src_oq.fault_trace,
                                                src_oq.upper_seismogenic_depth,
                                                src_oq.lower_seismogenic_depth,
                                                src_oq.dip)
    # Reorder the vertexes
    print lon, lat
    lons = numpy.concatenate([lon[::2], numpy.flipud(lon[1::2])])
    lats = numpy.concatenate([lat[::2], numpy.flipud(lat[1::2])])
    depths = numpy.concatenate([numpy.ones_like(lon[::2]) *
                                src_oq.upper_seismogenic_depth,
                                numpy.ones_like(lon[::2]) *
                                src_oq.lower_seismogenic_depth])
    # Create the 3D polygon
    w.poly(parts=[[[tlon, tlat, tdep] for tlon, tlat, tdep
                  in zip(list(lons), list(lats), list(depths))]])
def set_simple_fault_3D_geometry(w, src):
    """
    Set simple fault surface coordinates as shapefile geometry.

    :parameter w:
        Writer
    :parameter src:
        NRML source object
    """
    # Create an oq object for the source
    converter = sss.NrmlHazardlibConverter(
        investigation_time=50.0, rupture_mesh_spacing=1.0, width_of_mfd_bin=0.1, area_source_discretization=10.0
    )
    src_oq = converter(src)
    lon, lat = SimpleFaultSurface.get_surface_vertexes(
        src_oq.fault_trace, src_oq.upper_seismogenic_depth, src_oq.lower_seismogenic_depth, src_oq.dip
    )
    # Reorder the vertexes
    lons = numpy.concatenate([lon[::2], numpy.flipud(lon[1::2])])
    lats = numpy.concatenate([lat[::2], numpy.flipud(lat[1::2])])
    depths = numpy.concatenate(
        [
            numpy.ones_like(lon[::2]) * src_oq.upper_seismogenic_depth,
            numpy.ones_like(lon[::2]) * src_oq.lower_seismogenic_depth,
        ]
    )
    # Create the 3D polygon
    w.poly(parts=[[[tlon, tlat, tdep] for tlon, tlat, tdep in zip(list(lons), list(lats), list(depths))]])