Пример #1
0
    def config(self, step):
        '''Generates a config file containing flags and parameters
        for a particular experiment and step.

        This takes care of flags and parameters that *cannot* be set using
        command-line options. (We try to use command-line options whenever we can.)
        '''

        filename = "MISMIP_conf_%s_A%s.nc" % (self.experiment, step)

        nc = NC(filename, 'w', format="NETCDF3_CLASSIC")

        var = nc.createVariable("pism_overrides", 'i')

        attrs = {
            "is_dry_simulation": "no",
            "include_bmr_in_continuity": "no",
            "compute_surf_grad_inward_ssa": "no",
            "ice_softness": MISMIP.A(self.experiment, step),
            "ice_density": MISMIP.rho_i(),
            "sea_water_density": MISMIP.rho_w(),
            "bootstrapping_geothermal_flux_value_no_var": 0.0,
            "Glen_exponent": MISMIP.n(),
            "standard_gravity": MISMIP.g(),
            "ocean_sub_shelf_heat_flux_into_ice": 0.0,
            "bed_smoother_range": 0.0,
        }

        for name, value in attrs.iteritems():
            var.setncattr(name, value)

        nc.close()

        return filename
Пример #2
0
    def config(self, step):
        '''Generates a config file containing flags and parameters
        for a particular experiment and step.

        This takes care of flags and parameters that *cannot* be set using
        command-line options. (We try to use command-line options whenever we can.)
        '''

        filename = "MISMIP_conf_%s_A%s.nc" % (self.experiment, step)

        nc = NC(filename, 'w', format="NETCDF3_CLASSIC")

        var = nc.createVariable("pism_overrides", 'i')

        attrs = {"is_dry_simulation": "no",
                 "include_bmr_in_continuity": "no",
                 "compute_surf_grad_inward_ssa": "no",
                 "ice_softness": MISMIP.A(self.experiment, step),
                 "ice_density": MISMIP.rho_i(),
                 "sea_water_density": MISMIP.rho_w(),
                 "bootstrapping_geothermal_flux_value_no_var": 0.0,
                 "Glen_exponent": MISMIP.n(),
                 "standard_gravity": MISMIP.g(),
                 "ocean_sub_shelf_heat_flux_into_ice": 0.0,
                 }

        if self.model != 1:
            attrs["bed_smoother_range"] = 0.0

        for name, value in attrs.iteritems():
            var.setncattr(name, value)

        nc.close()

        return filename
Пример #3
0
def plot_profile(in_file, out_file):
    print(
        "Reading %s to plot geometry profile for model %s, experiment %s, grid mode %s, step %s"
        % (in_file, model, experiment, mode, step))

    if out_file is None:
        out_file = os.path.splitext(in_file)[0] + "-profile.pdf"

    mask = read(in_file, 'mask')
    usurf = read(in_file, 'usurf')
    topg = read(in_file, 'topg')
    thk = read(in_file, 'thk')
    x = read(in_file, 'x')

    # theoretical grounding line position
    xg = MISMIP.x_g(experiment, step)
    # modeled grounding line position
    xg_PISM = find_grounding_line(x, topg, thk, mask)

    # mask out ice-free areas
    usurf = np.ma.array(usurf, mask=mask == 4)

    # compute the lower surface elevation
    lsrf = topg.copy()
    lsrf[mask == 3] = -MISMIP.rho_i() / MISMIP.rho_w() * thk[mask == 3]
    lsrf = np.ma.array(lsrf, mask=mask == 4)

    # convert x to kilometers
    x /= 1e3

    figure(1)
    ax = subplot(111)
    hold(True)
    plot(x, np.zeros_like(x), ls='dotted', color='red')
    plot(x, topg, color='black')
    plot(x, usurf, 'o', color='blue', markersize=4)
    plot(x, lsrf, 'o', color='blue', markersize=4)
    xlabel('distance from the divide, km')
    ylabel('elevation, m')
    title("MISMIP experiment %s, step %d" % (experiment, step))
    text(0.6,
         0.9,
         "$x_g$ (model) = %4.0f km" % (xg_PISM / 1e3),
         color='r',
         transform=ax.transAxes)
    text(0.6,
         0.85,
         "$x_g$ (theory) = %4.0f km" % (xg / 1e3),
         color='black',
         transform=ax.transAxes)

    _, _, ymin, ymax = axis(xmin=0, xmax=x.max())
    vlines(xg / 1e3, ymin, ymax, linestyles='dashed', color='black')
    vlines(xg_PISM / 1e3, ymin, ymax, linestyles='dashed', color='red')

    print("Saving '%s'...\n" % out_file)
    savefig(out_file)
Пример #4
0
Файл: plot.py Проект: pism/pism
def plot_profile(in_file, out_file):
    print("Reading %s to plot geometry profile for model %s, experiment %s, grid mode %s, step %s" % (
        in_file, model, experiment, mode, step))

    if out_file is None:
        out_file = os.path.splitext(in_file)[0] + "-profile.pdf"

    mask = read(in_file, 'mask')
    usurf = read(in_file, 'usurf')
    topg = read(in_file, 'topg')
    thk = read(in_file, 'thk')
    x = read(in_file, 'x')

    # theoretical grounding line position
    xg = MISMIP.x_g(experiment, step)
    # modeled grounding line position
    xg_PISM = find_grounding_line(x, topg, thk, mask)

    # mask out ice-free areas
    usurf = np.ma.array(usurf, mask=mask == 4)

    # compute the lower surface elevation
    lsrf = topg.copy()
    lsrf[mask == 3] = -MISMIP.rho_i() / MISMIP.rho_w() * thk[mask == 3]
    lsrf = np.ma.array(lsrf, mask=mask == 4)

    # convert x to kilometers
    x /= 1e3

    figure(1)
    ax = subplot(111)
    hold(True)
    plot(x, np.zeros_like(x), ls='dotted', color='red')
    plot(x, topg, color='black')
    plot(x, usurf, 'o', color='blue', markersize=4)
    plot(x, lsrf,  'o', color='blue', markersize=4)
    xlabel('distance from the divide, km')
    ylabel('elevation, m')
    title("MISMIP experiment %s, step %d" % (experiment, step))
    text(0.6, 0.9, "$x_g$ (model) = %4.0f km" % (xg_PISM / 1e3), color='r',
         transform=ax.transAxes)
    text(0.6, 0.85, "$x_g$ (theory) = %4.0f km" % (xg / 1e3), color='black',
         transform=ax.transAxes)

    _, _, ymin, ymax = axis(xmin=0, xmax=x.max())
    vlines(xg / 1e3, ymin, ymax, linestyles='dashed', color='black')
    vlines(xg_PISM / 1e3, ymin, ymax, linestyles='dashed', color='red')

    print("Saving '%s'...\n" % out_file)
    savefig(out_file)
Пример #5
0
    def config(self, step):
        '''Generates a config file containing flags and parameters
        for a particular experiment and step.

        This takes care of flags and parameters that *cannot* be set using
        command-line options. (We try to use command-line options whenever we can.)
        '''

        filename = "MISMIP_conf_%s_A%s.nc" % (self.experiment, step)

        nc = NC(filename, 'w', format="NETCDF3_CLASSIC")

        var = nc.createVariable("pism_overrides", 'i')

        attrs = {
            "ocean.always_grounded":
            "no",
            "geometry.update.use_basal_melt_rate":
            "no",
            "stress_balance.ssa.compute_surface_gradient_inward":
            "no",
            "flow_law.isothermal_Glen.ice_softness":
            MISMIP.A(self.experiment, step),
            "constants.ice.density":
            MISMIP.rho_i(),
            "constants.sea_water.density":
            MISMIP.rho_w(),
            "bootstrapping.defaults.geothermal_flux":
            0.0,
            "stress_balance.ssa.Glen_exponent":
            MISMIP.n(),
            "constants.standard_gravity":
            MISMIP.g(),
            "ocean.sub_shelf_heat_flux_into_ice":
            0.0,
        }

        if self.model != 1:
            attrs["stress_balance.sia.bed_smoother.range"] = 0.0

        for name, value in attrs.items():
            var.setncattr(name, value)

        nc.close()

        return filename
Пример #6
0
def thickness(x, step, Q0, H0, calving_front=1750e3, perturbation='default'):

    # we expect x to have an odd number of grid points so that one of them is
    # at 0
    if x.size % 2 != 1:
        raise ValueError("x has to have an odd number of points, got %d",
                         x.size)

    dx = x[1] - x[0]

    A0 = MISMIP.A('1a', step)
    print(A0, A0**(-1.0 / 3.0))
    B0 = A0**(-1.0 / MISMIP.n())
    #C = (900.0*9.8/(4.0*B0)*(1.0-900.0/1000.0))**3.0
    C = (MISMIP.rho_i() * MISMIP.g() / (4.0 * B0) *
         (1.0 - MISMIP.rho_i() / MISMIP.rho_w()))**MISMIP.n()

    thk = (4.0 * C * np.maximum(x - 100e3, eps) / Q0 + H0**(-4.0))**(-0.25)
    #thk = (x-100e3)*(-1e-4) + 800.0
    thk[x < 100e3] = 800.0
    thk[0] = 0.0
    if perturbation == 'p1':
        #perturbation i
        thk[x > calving_front - 1 * dx] -= 50.0
    elif perturbation == 'p2':
        #perutbation i-1
        thk[x > calving_front - 2 * dx] -= 50.0
        thk[x > calving_front - 1 * dx] += 50.0
    elif perturbation == 'p3':
        #perutbation i-2
        thk[x > calving_front - 3 * dx] -= 50.0
        thk[x > calving_front - 2 * dx] += 50.0
    #perutbation gli+1
    #thk[ x > 100e3 + 0.5*dx ] -= 200.0
    #thk[ x > 100e3+1.5*dx ] += 200.0
    #perutbation gli+2
    #thk[ x > 100e3 + 1.5*dx ] -= 200.0
    #thk[ x > 100e3+2.5*dx ] += 200.0

    thk[x > calving_front] = 0.0

    return np.tile(thk, (3, 1))
Пример #7
0
 def f(j):
     "See equation (7) in Pattyn et al, 'Role of transition zones in marine ice sheet dynamics', 2005."
     z_sl = 0
     return (z_sl - topg[j]) * MISMIP.rho_w() / (MISMIP.rho_i() * thk[j])
Пример #8
0
Файл: plot.py Проект: pism/pism
 def f(j):
     "See equation (7) in Pattyn et al, 'Role of transition zones in marine ice sheet dynamics', 2005."
     z_sl = 0
     return (z_sl - topg[j]) * MISMIP.rho_w() / (MISMIP.rho_i() * thk[j])