def physics_options(self, input_file, step): "Options corresponding to modeling choices." config_filename = self.config(step) options = [ "-energy none", # isothermal setup; allows selecting cold-mode flow laws "-ssa_flow_law isothermal_glen", # isothermal setup "-yield_stress constant", "-tauc %e" % MISMIP.C(self.experiment), "-pseudo_plastic", "-gradient eta", "-pseudo_plastic_q %e" % MISMIP.m(self.experiment), "-pseudo_plastic_uthreshold %e" % MISMIP.secpera(), "-calving ocean_kill", # calving at the present front "-ocean_kill_file %s" % input_file, "-config_override %s" % config_filename, "-ssa_method fd", "-cfbc", # calving front boundary conditions "-part_grid", # sub-grid front motion parameterization "-ssafd_ksp_rtol 1e-7", "-ys 0", "-ye %d" % MISMIP.run_length(self.experiment, step), "-options_left", ] if self.model == 1: options.extend(["-stress_balance ssa"]) else: options.extend([ "-stress_balance ssa+sia", "-sia_flow_law isothermal_glen", # isothermal setup ]) return options
def plot_flux(in_file, out_file): print( "Reading %s to plot ice flux 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] + "-flux.pdf" x = read(in_file, 'x') flux_mag = read(in_file, 'flux_mag') # plot positive xs only flux_mag = flux_mag[x >= 0] x = x[x >= 0] figure(2) hold(True) plot(x / 1e3, flux_mag, 'k.-', markersize=10, linewidth=2) plot(x / 1e3, x * MISMIP.a() * MISMIP.secpera(), 'r:', linewidth=1.5) title("MISMIP experiment %s, step %d" % (experiment, step)) xlabel("x ($\mathrm{km}$)", size=14) ylabel(r"flux ($\mathrm{m}^2\,\mathrm{a}^{-1}$)", size=14) print("Saving '%s'...\n" % out_file) savefig(out_file, dpi=300, facecolor='w', edgecolor='w')
def physics_options(self, input_file, step): "Options corresponding to modeling choices." config_filename = self.config(step) options = ["-energy none", # isothermal setup; allows selecting cold-mode flow laws "-ssa_flow_law isothermal_glen", # isothermal setup "-yield_stress constant", "-tauc %e" % MISMIP.C(self.experiment), "-pseudo_plastic", "-gradient eta", "-pseudo_plastic_q %e" % MISMIP.m(self.experiment), "-pseudo_plastic_uthreshold %e" % MISMIP.secpera(), "-calving ocean_kill", # calving at the present front "-ocean_kill_file %s" % input_file, "-config_override %s" % config_filename, "-ssa_method fd", "-cfbc", # calving front boundary conditions "-part_grid", # sub-grid front motion parameterization "-ssafd_ksp_rtol 1e-7", "-ys 0", "-ye %d" % MISMIP.run_length(self.experiment, step), "-options_left", ] if self.model == 1: options.extend(["-stress_balance ssa"]) else: options.extend(["-stress_balance ssa+sia", "-sia_flow_law isothermal_glen", # isothermal setup ]) return options
def plot_flux(in_file, out_file): print("Reading %s to plot ice flux 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] + "-flux.pdf" x = read(in_file, 'x') flux_mag = read(in_file, 'flux_mag') # plot positive xs only flux_mag = flux_mag[x >= 0] x = x[x >= 0] figure(2) hold(True) plot(x / 1e3, flux_mag, 'k.-', markersize=10, linewidth=2) plot(x / 1e3, x * MISMIP.a() * MISMIP.secpera(), 'r:', linewidth=1.5) title("MISMIP experiment %s, step %d" % (experiment, step)) xlabel("x ($\mathrm{km}$)", size=14) ylabel(r"flux ($\mathrm{m}^2\,\mathrm{a}^{-1}$)", size=14) print("Saving '%s'...\n" % out_file) savefig(out_file, dpi=300, facecolor='w', edgecolor='w')
def physics_options(self, step): "Options corresponding to modeling choices." config_filename = self.config(step) options = [ "-cold", # allow selecting cold-mode flow laws "-sia_flow_law isothermal_glen", # isothermal setup "-ssa_flow_law isothermal_glen", # isothermal setup "-no_energy", # isothermal setup "-ssa_sliding", # use SSA "-hold_tauc", "-tauc %e" % MISMIP.C(self.experiment), "-pseudo_plastic", "-gradient eta", "-pseudo_plastic_q %e" % MISMIP.m(self.experiment), "-pseudo_plastic_uthreshold %e" % MISMIP.secpera(), "-ocean_kill", # calving at the present front "-config_override %s" % config_filename, "-ssa_method fd", # use the FD solver that includes PIK improvements "-cfbc", # calving front boundary conditions "-part_grid", # sub-grid front motion parameterization "-ksp_rtol 1e-7", "-ys 0", "-ye %f" % MISMIP.run_length(self.experiment, step), "-options_left", ] if self.model == 1: options.extend(["-no_sia"]) else: options.extend(["-sia"]) if self.mode in (2, 3): options.extend(["-skip", "-skip_max 10"]) return options
def pism_bootstrap_file(filename, step, v0, H0, calving_front=1750e3, N=None, p="default"): import PISMNC xx = x(N) yy = y(xx) print("dx", xx[1] - xx[0]) v0 = v0 / MISMIP.secpera() #H0 = 800.0 Q0 = H0 * v0 topg = bed_topography(xx) thk = thickness(xx, step, Q0, H0, calving_front, p) smb = surface_mass_balance(xx) temp = ice_surface_temp(xx) vel = Q0 / np.maximum(thk, eps) * MISMIP.secpera() vel[thk == 0.0] = 0.0 #vel = np.nan_to_num(Q0/thk)*MISMIP.secpera() bcm = bcmask(xx) vel0 = np.zeros_like(vel) okill = ocean_kill(thk) nc = PISMNC.PISMDataset(filename, 'w', format="NETCDF3_CLASSIC") nc.create_dimensions(xx, yy) nc.define_2d_field('topg', attrs={ 'units': 'm', 'long_name': 'bedrock surface elevation', 'standard_name': 'bedrock_altitude' }) nc.write('topg', topg) nc.define_2d_field('thk', attrs={ 'units': 'm', 'long_name': 'ice thickness', 'standard_name': 'land_ice_thickness' }) nc.write('thk', thk) nc.define_2d_field( 'climatic_mass_balance', attrs={ 'units': 'kg m-2 / s', 'long_name': 'ice-equivalent surface mass balance (accumulation/ablation) rate', 'standard_name': 'land_ice_surface_specific_mass_balance_flux' }) nc.write('climatic_mass_balance', smb) nc.define_2d_field( 'ice_surface_temp', attrs={ 'units': 'Kelvin', 'long_name': 'annual average ice surface temperature, below firn processes' }) nc.write('ice_surface_temp', temp) nc.define_2d_field('land_ice_area_fraction_retreat', attrs={ 'units': '', 'long_name': 'mask where -ocean_kill cuts off ice' }) nc.write('land_ice_area_fraction_retreat', okill) nc.define_2d_field('u_ssa_bc', attrs={'units': 'm/yr'}) nc.write('u_ssa_bc', vel) nc.define_2d_field('v_ssa_bc', attrs={'units': 'm/yr'}) nc.write('v_ssa_bc', vel0) nc.define_2d_field('bc_mask', attrs={}) nc.write('bc_mask', bcm) nc.close()