#!/usr/bin/python

import glimcdf
import numpy
import sys
import math
from getopt import gnu_getopt

#Get command-line arguments that specify specifics of the experiment
optlist, args = gnu_getopt(sys.argv, '', ["smooth-beta", "dirichlet-center", "sloped"])

optdict = dict(optlist)

#Parse the config file to determine how to set up the netcdf file
nc, shape = glimcdf.nc_from_config(args[1])

#Create variables for topography and ice thickness
topg = glimcdf.setup_variable(nc, "topg")
thk = glimcdf.setup_variable(nc, "thk")
beta = glimcdf.setup_variable(nc, "beta", staggered=True)

if "--dirichlet-center" in optdict:
    uvelbc = glimcdf.setup_variable(nc, "uvelbc", staggered=True, useZ=True)
    vvelbc = glimcdf.setup_variable(nc, "vvelbc", staggered=True, useZ=True)

#Determine the total length of the domain
L = shape.nx*shape.dx

for i in range(shape.nx):
    x = shape.dx * (i-shape.nx/2)
    xhat = float(i)/(shape.nx-1)
#!/usr/bin/python

import glimcdf
import numpy
import sys
import math

#Parse the config file to determine how to set up the netcdf file
nc, shape = glimcdf.nc_from_config(sys.argv[1])

#Create variables for topography and ice thickness
topg = glimcdf.setup_variable(nc, "topg")
thk = glimcdf.setup_variable(nc, "thk")
beta = glimcdf.setup_variable(nc, "beta", staggered=True)
uvelbc = glimcdf.setup_variable(nc, "uvelbc", staggered=True, useZ=True)
vvelbc = glimcdf.setup_variable(nc, "vvelbc", staggered=True, useZ=True)
#Determine the total length of the domain
L = shape.nx*shape.dx

for i in range(shape.nx):
    xhat = float(i)/(shape.nx-1)
    for j in range(shape.ny):
        yhat = float(j)/(shape.ny-1)
        topg.put_1((0,j,i), -2000) #Everything at sea level
        
        #Kilometer-thick ice in a circle
        if (i > 2 and i < shape.nx-2 and j > 2 and j < shape.ny-2):
            thk.put_1((0,j,i), 1000)
        else:
            thk.put_1((0,i,j), 0)
            
            zprime = alpha*points[currentInterpIndex+1][2] + (1-alpha)*points[currentInterpIndex][2]
        newPoints.append((x,y,zprime))
    return newPoints

def xzPlot(points):
    xs = []
    zs = []
    for x,y,z in points:
        xs.append(x)
        zs.append(z)
    pylab.show(pylab.plot(xs,zs))

if __name__ == "__main__":

    nc, shape = glimcdf.nc_from_config("ishom.f.config")
    topg = glimcdf.setup_variable(nc, "topg")
    thk  = glimcdf.setup_variable(nc, "thk" )

    nx = shape.nx
    ny = shape.ny

    points = createBumpPoints(nx, ny)

    lineDict = collectYCoordinateLines(points)
    lines = sorted(list(lineDict.items()), lambda l1, l2:cmp(l1[0], l2[0]))

    j = 0

    topg_field = numpy.zeros((nx, ny))
    thck_field = numpy.zeros((nx, ny))