Beispiel #1
0
    fname = arthern_bin + '/arthern_accumulation_bedmap2_grid.flt'
    accum = np.flipud(
        np.ma.masked_equal(
            np.reshape(np.fromfile(fname, dtype=np.float32), (N3b, N3a)),
            -9999.0))
    #fname = arthern_bin + '/arthern_accumulation_rms_bedmap2_grid.flt'
    print " range of accum = [%.2f, %.2f]" % (accum.min(), accum.max())
    accum_bm2 = np.zeros([N, N])
    accum_bm2 = accum[x0:x0 + N, y0:y0 + N]
    accum_bm2 = np.ma.masked_array(accum_bm2, mask=(accum_bm2 == -9999.))

    ### Write nc-file
    print "\nWriting NetCDF file '%s' ...\n" % ncbm2_name
    try:
        #nc = PNC(ncbm2_name, 'w', format='NETCDF3_CLASSIC')
        nc = PNC(ncbm2_name, 'w', format='NETCDF4_CLASSIC')
    except:
        print("can't open file %s for writing" % ncbm2_name)
        exit(1)

    dx = 1000.0  #m
    dy = 1000.0  #m
    x = np.linspace(0.0, (N - 1) * dx, N)
    y = np.linspace(0.0, (N - 1) * dy, N)
    nc.create_dimensions(x, y, time_dependent=False)

    print " writing topg ..."
    nc.define_2d_field("topg",
                       time_dependent=False,
                       attrs={
                           "long_name": "elevation of bedrock",
Beispiel #2
0
    fig = plt.figure(3)
    ax = plt.imshow(thk)
    fig.colorbar(ax)

    plt.show()

    sys.exit(0)

#err = abs(bed[msk<0.5] + thk[msk<0.5] - srf[msk<0.5])
# print err.max()

outname = 'ant1kmgeom.nc'

print("writing NetCDF file '%s' ..." % outname)
try:
    nc = PNC(outname, 'w', format='NETCDF3_CLASSIC')
except:
    print("can't open file %s for writing" % outname)
    exit(1)

print("  writing x,y ...")
dx = 1000.0
dy = 1000.0
x = np.linspace(0.0, (N - 1) * dx, N)
y = np.linspace(0.0, (N - 1) * dy, N)
nc.create_dimensions(x, y, time_dependent=False)

print("  writing topg ...")
nc.define_2d_field("topg",
                   time_dependent=False,
                   attrs={