def main(): gravfile = 'Data/gmm3_120_sha.tab' topofile = 'Data/MarsTopo719.shape' densityfile = 'Data/dichotomy_359.sh' model_name = [ 'dwcold', 'dwhot_modif', 'dwhot_stairs', 'DWTh2Ref1', 'DWTh2Ref2', 'eh70cold', '"eh70hot', 'Gudkova' ] spec = 'Data/Mars-reference-interior-models/model_' interior_file = [spec + name for name in model_name] lmax_calc = 90 lmax = lmax_calc * 4 potcoefs, lmaxp, header = pyshtools.shio.shread(gravfile, header=True, lmax=lmax) potential = pyshtools.SHCoeffs.from_array(potcoefs) potential.r_ref = float(header[0]) * 1.e3 potential.gm = float(header[1]) * 1.e9 potential.mass = potential.gm / float(pyshtools.constant.grav_constant) print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(lmaxp)) print('Reference radius (km) = {:f}'.format(potential.r_ref / 1.e3)) print('GM = {:e}\n'.format(potential.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (km) = {:f}\n'.format(topo.r0 / 1.e3)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) lat_insight = 4.43 lon_insight = 135.84 filter = 1 half = 50 nmax = 7 lmax_hydro = 15 t0_sigma = 5. # maximum difference between minimum crustal thickness omega = float(pyshtools.constant.omega_mars) d_lith = 150.e3 t0 = 1.e3 # minimum crustal thickness model = 3 # identifier for the interior reference model # --- read 1D reference interior model --- print('=== Reading model {:s} ==='.format(model_name[model])) with open(interior_file[model], 'r') as f: lines = f.readlines() print(lines[0].strip()) data = lines[1].split() if float(data[2]) != 1: raise RuntimeError('Program not capable of reading polynomial ' + 'files') num = int(lines[2].split()[0]) crust_index = int(lines[2].split()[3]) mantle_index = int(lines[2].split()[3]) radius = np.zeros(num) rho = np.zeros(num) for i in range(0, num): data = lines[i + 3].split() radius[i] = float(data[0]) rho[i] = float(data[1]) r0_model = radius[num - 1] print('Surface radius of model (km) = {:f}'.format(r0_model / 1.e3)) for i in range(0, num): if radius[i] <= (r0_model - d_lith) and \ radius[i+1] > (r0_model - d_lith): if radius[i] == (r0_model - d_lith): i_lith = i elif (r0_model - d_lith) - radius[i] <= radius[i+1] -\ (r0_model - d_lith): i_lith = i else: i_lith = i + 1 break n = num - 1 rho[n] = 0. # the density above the surface is zero rho_mantle = rho[crust_index - 1] print('Mantle density (kg/m3) = {:f}'.format(rho_mantle)) print('Assumed depth of lithosphere (km) = {:f}'.format(d_lith / 1.e3)) print('Actual depth of lithosphere in discretized model (km) = {:f}'. format((r0_model - radius[i_lith]) / 1.e3)) # --- Compute gravity contribution from hydrostatic density interfaces --- if False: # compute values for a planet that is completely fluid hlm_fluid, clm_fluid, mass_model = \ HydrostaticShape(radius, rho, omega, potential.gm, potential.r_ref, finiteamplitude=True) print('--- Hydrostatic potential coefficients for a fluid planet ---') print('c20 = {:e}\nc40 = {:e}'.format(clm_fluid.coeffs[0, 2, 0], clm_fluid.coeffs[0, 4, 0])) print('--- Hydrostatic relief of surface for a fluid planet ---') print('h20 = {:e}\nh40 = {:e}'.format(hlm_fluid[n].coeffs[0, 2, 0], hlm_fluid[n].coeffs[0, 4, 0])) hlm, clm_hydro, mass_model = \ HydrostaticShapeLith(radius, rho, i_lith, potential, omega, lmax_hydro, finiteamplitude=False) print('Total mass of model (kg) = {:e}'.format(mass_model)) print('% of J2 arising from beneath lithosphere = {:f}'.format( clm_hydro.coeffs[0, 2, 0] / potential.coeffs[0, 2, 0] * 100.)) potential.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] -= \ clm_hydro.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] # --- Constant density model --- rho_c = 2900. print('-- Constant density model --\nrho_c = {:f}'.format(rho_c)) tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMoho(potential, topo, lmax, rho_c, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, nmax=nmax, quiet=True) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:f}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:f}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.data.min() tmax = thick_grid.data.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-1.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-1.png') # --- Model with variable density --- rho_south = 2900. rho_north = 2900. porosity = 0.0 print('-- Variable density model ---\n' + 'rho_south = {:f}\n'.format(rho_south) + 'rho_north = {:f}'.format(rho_north)) density = density * (rho_north - rho_south) density.coeffs[0, 0, 0] += rho_south tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMohoRho(potential, topo, density, porosity, lmax, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=True, nmax=nmax) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:e}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:e}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.data.min() tmax = thick_grid.data.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-2.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-2.png')
def main(): gravfile = 'Data/gmm3_120_sha.tab' topofile = 'Data/MarsTopo719.shape' densityfile = 'Data/dichotomy_359.sh' model_name = ['DWThot', 'DWThotCrust1', 'DWThotCrust1r', 'EH45Tcold', 'EH45TcoldCrust1', 'EH45TcoldCrust1r', 'EH45ThotCrust2', 'EH45ThotCrust2r', 'LFAK', 'SANAK', 'TAYAK', 'DWAK', 'ZG_DW'] spec = 'Data/Mars-reference-interior-models/Smrekar/' interior_file = [spec + name + '.deck' for name in model_name] lmax_calc = 90 lmax = lmax_calc * 4 potential = pyshtools.SHGravCoeffs.from_file(gravfile, header_units='km') print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(potential.lmax)) print('Reference radius (km) = {:f}'.format(potential.r0 / 1.e3)) print('GM = {:e}\n'.format(potential.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (km) = {:f}\n'.format(topo.r0 / 1.e3)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) lat_insight = 4.502384 lon_insight = 135.623447 filter = 1 half = 50 nmax = 7 lmax_hydro = 15 t0_sigma = 5. # maximum difference between minimum crustal thickness omega = pyshtools.constant.omega_mars.value d_lith = 150.e3 d_sigma = 45.e3 t0 = 1.e3 # minimum crustal thickness model = 10 # identifier for the interior reference model # --- read 1D reference interior model --- with open(interior_file[model], 'r') as f: lines = f.readlines() print(lines[0].strip()) data = lines[1].split() if float(data[2]) != 1: raise RuntimeError('Program not capable of reading polynomial ' + 'files') num_file = int(lines[2].split()[0]) crust_index_file = int(lines[2].split()[3]) core_index_file = int(lines[2].split()[2]) i_crust_file = crust_index_file - 1 i_core_file = core_index_file - 1 radius = np.zeros(num_file) rho = np.zeros(num_file) num = 0 for i in range(0, num_file-1): data = lines[i+3].split() rb = float(data[0]) rhob = float(data[1]) data = lines[i+4].split() rt = float(data[0]) rhot = float(data[1]) if rb == rt: if i == i_core_file: i_core = num if i == i_crust_file: i_crust = num else: radius[num] = rb rho[num] = (rhot + rhob) / 2. num += 1 radius[num] = rt rho[num] = 0. # the density above the surface is zero num += 1 n = num - 1 radius = radius[:n+1] rho = rho[:n+1] r0_model = radius[n] print('Surface radius of model (km) = {:f}'.format(r0_model / 1.e3)) for i in range(0, n+1): if radius[i] <= (r0_model - d_lith) and \ radius[i+1] > (r0_model - d_lith): if radius[i] == (r0_model - d_lith): i_lith = i elif (r0_model - d_lith) - radius[i] <= radius[i+1] -\ (r0_model - d_lith): i_lith = i else: i_lith = i + 1 break rho_mantle = rho[i_crust-1] rho_core = rho[i_core-1] print('Mantle density (kg/m3) = {:f}'.format(rho_mantle)) print('Mantle radius (km) = {:f}'.format(radius[i_crust]/1.e3)) print('Core density (kg/m3) = {:f}'.format(rho_core)) print('Core radius (km) = {:f}'.format(radius[i_core]/1.e3)) print('Assumed depth of lithosphere (km) = {:f}'.format(d_lith / 1.e3)) print('Actual depth of lithosphere in discretized model (km) = {:f}' .format((r0_model - radius[i_lith]) / 1.e3)) # --- Compute gravity contribution from hydrostatic density interfaces --- thickave = 44.e3 # initial guess of average crustal thickness r_sigma = topo.r0 - thickave rho_c = 2900. if True: # compute values for a planet that is completely fluid hlm_fluid, clm_fluid, mass_model = \ HydrostaticShape(radius, rho, omega, potential.gm, potential.r0) print('--- Hydrostatic potential coefficients for a fluid planet ---') print('c20 = {:e}\nc40 = {:e}'.format(clm_fluid.coeffs[0, 2, 0], clm_fluid.coeffs[0, 4, 0])) print('--- Hydrostatic relief of surface for a fluid planet ---') print('h20 = {:e}\nh40 = {:e}'.format(hlm_fluid[n].coeffs[0, 2, 0], hlm_fluid[n].coeffs[0, 4, 0])) hlm, clm_hydro, mass_model = \ HydrostaticShapeLith(radius, rho, i_lith, potential, topo, rho_c, r_sigma, omega, lmax_hydro) print('Total mass of model (kg) = {:e}'.format(mass_model)) print('% of J2 arising from beneath lithosphere = {:f}' .format(clm_hydro.coeffs[0, 2, 0]/potential.coeffs[0, 2, 0] * 100.)) potential.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] -= \ clm_hydro.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] # --- Constant density model --- rho_c = 2900. print('-- Constant density model --\nrho_c = {:f}'.format(rho_c)) tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMoho(potential, topo, lmax, rho_c, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, nmax=nmax, quiet=True) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:f}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:f}' .format((topo.pad(lmax) - moho.pad(lmax)) .expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.min() tmax = thick_grid.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-1.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-1.png') # --- Model with variable density --- rho_south = 2900. rho_north = 2900. porosity = 0.0 print('-- Variable density model ---\n' + 'rho_south = {:f}\n'.format(rho_south) + 'rho_north = {:f}'.format(rho_north)) density = density * (rho_north - rho_south) density.coeffs[0, 0, 0] += rho_south tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMohoRho(potential, topo, density, porosity, lmax, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=True, nmax=nmax) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:e}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:e}' .format((topo.pad(lmax) - moho.pad(lmax)) .expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.data.min() tmax = thick_grid.data.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-2.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-2.png')
def main(): lmax = 900 # determines spatial resolution of grids lmax_calc = 600 # maximum degree to use in calculations gravfile = 'Data/JGGRAIL_900C11A_SHA.TAB' topofile = 'Data/LOLA1500p.sh' densityfile = 'Data/density_no_mare_n3000_f3050_719.sh' pot = pyshtools.SHGravCoeffs.from_file(gravfile, header_units='km') print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(pot.lmax)) print('Reference radius (m) = {:e}'.format(pot.r0)) print('GM = {:e}\n'.format(pot.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (m) = {:e}\n'.format(topo.r0)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) rho_c0 = density.coeffs[0, 0, 0] # average grain density print('Average grain density of crust (kg/m3) = {:e}'.format(rho_c0)) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) a_12_14_lat = -3.3450 a_12_14_long = -20.450 # These parameters correspond to model 1 of Wieczorek et al. (2013). thickave = 34.e3 porosity = 0.12 rho_m = 3220.0 filter = 1 half = 80 print('Average thickness of the crust (km) = {:e}'.format(thickave / 1.e3)) print('Porosity (%)= {:e}'.format(porosity * 100)) print('Mantle density (kg/m3)= {:e}'.format(rho_m)) # Constant density model print('\n=== Constant density crust ===') rho_c = rho_c0 * (1. - porosity) # assumed constant density print('Bulk density of the crust(kg/m3)= {:e}'.format(rho_c * 100)) moho = pyMoho.pyMoho(pot, topo, lmax, rho_c, rho_m, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=False, delta_max=25.) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') thick_grid.plot(show=False, fname='Thick-Moon-1.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Moon-1.png') print('Crustal thickness at Apollo 12/14 landing sites (km) = {:e}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=a_12_14_lat, lon=a_12_14_long) / 1.e3)) # Model with variable density print('\n=== Variable density crust ===') moho = pyMoho.pyMohoRho(pot, topo, density, porosity, lmax, rho_m, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=False, delta_max=25.) thick_grid = (topo - moho.pad(topo.lmax)).expand(grid='DH2') thick_grid.plot(show=False, fname='Thick-Moon-2.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Moon-2.png') print('Crustal thickness at Apollo 12/14 landing sites (km) = {:e}'.format( (topo - moho.pad(topo.lmax)).expand(lat=a_12_14_lat, lon=a_12_14_long) / 1.e3))
def main(): lmax = 900 lmax_calc = 600 gravfile = 'Data/JGGRAIL_900C11A_SHA.TAB' topofile = 'Data/LOLA1500p.sh' densityfile = 'Data/density_no_mare_n3000_f3050_719.sh' potcoefs, lmaxp, header = pyshtools.shio.shread(gravfile, header=True, lmax=lmax) pot = pyshtools.SHCoeffs.from_array(potcoefs) pot.r_ref = float(header[0]) * 1.e3 pot.gm = float(header[1]) * 1.e9 pot.mass = pot.gm / float(pyshtools.constant.grav_constant) print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(lmaxp)) print('Reference radius (m) = {:e}'.format(pot.r_ref)) print('GM = {:e}\n'.format(pot.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (m) = {:e}\n'.format(topo.r0)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) rho_c = density.coeffs[0, 0, 0] print('Average grain density of crust (kg/m3) = {:e}'.format(rho_c)) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) a_12_14_lat = -3.3450 a_12_14_long = -20.450 # These parameters correspond to model 1 of Wieczorek et al. (2013). thickave = 34.e3 porosity = 0.12 rho_m = 3220.0 filter = 1 half = 80 # Constant density model rho_c = rho_c * (1. - 0.12) # assumed constant density moho = pyMoho.pyMoho(pot, topo, lmax, rho_c, rho_m, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=False) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') thick_grid.plot(show=False, fname='Thick-Moon-1.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Moon-1.png') print('Crustal thickness at Apollo 12/14 landing sites (km) = {:e}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=a_12_14_lat, lon=a_12_14_long) / 1.e3)) # Model with variable density moho = pyMoho.pyMohoRho(pot, topo, density, porosity, lmax, rho_m, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=False) thick_grid = (topo - moho.pad(topo.lmax)).expand(grid='DH2') thick_grid.plot(show=False, fname='Thick-Moon-2.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Moon-2.png') print('Crustal thickness at Apollo 12/14 landing sites (km) = {:e}'.format( (topo - moho.pad(topo.lmax)).expand(lat=a_12_14_lat, lon=a_12_14_long) / 1.e3))
def calc_crust(mantlefile, # filename for mantle profile input fnam_out_model, # Output file name for thickness map gravfile='Data/gmm3_120_sha.tab', topofile='Data/MarsTopo719.shape', densityfile='Data/dichotomy_359.sh', fnam_out_plot=None, # Output file name for plot of map t0=1.e3, # minimum crustal thickness d_lith=300.e3 # Lithosphere thickness ): lmax_calc = 90 lmax = lmax_calc * 4 potcoefs, lmaxp, header = pyshtools.shio.shread(gravfile, header=True, lmax=lmax) potential = pyshtools.SHCoeffs.from_array(potcoefs) potential.r_ref = float(header[0]) * 1.e3 potential.gm = float(header[1]) * 1.e9 potential.mass = potential.gm / float(pyshtools.constant.grav_constant) print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(lmaxp)) print('Reference radius (km) = {:f}'.format(potential.r_ref / 1.e3)) print('GM = {:e}\n'.format(potential.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (km) = {:f}\n'.format(topo.r0 / 1.e3)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) lat_insight = 4.43 lon_insight = 135.84 filter = 1 half = 50 nmax = 7 lmax_hydro = 15 t0_sigma = 5. # maximum difference between minimum crustal thickness omega = float(pyshtools.constant.omega_mars) # --- read 1D reference interior model --- print('=== Reading model {:s} ==='.format(mantlefile)) with open(mantlefile, 'r') as f: lines = f.readlines() ncomments = 4 # Remove initial four lines in AxiSEM files nlines = len(lines) nlayer = nlines - ncomments radius = np.zeros(nlayer) rho = np.zeros(nlayer) vp = np.zeros(nlayer) vs = np.zeros(nlayer) lines = lines[::-1] crust_index = nlayer - 6 for i in range(0, nlayer): data = lines[i].split() radius[i] = float(data[0]) rho[i] = float(data[1]) vp[i] = float(data[2]) vs[i] = float(data[3]) # Q = float(data[4]) # if (Q in (500, 600)) and Q_last not in (500, 600): # crust_index = i # Q_last = Q # Correct the sub-Moho parameters radius[-8] = radius[-7] # Calculate crustal density mass_crust = 0 for i in range(crust_index, nlayer-1): vol_layer = (radius[i+1] - radius[i]) * 1e3 * 4 * np.pi mass_crust += rho[i] * vol_layer vol_crust = (radius[-1] - radius[crust_index]) * 1e3 * 4 * np.pi rho_c = mass_crust / vol_crust print('Crustal density: = {:8.1f}'.format(rho_c)) r0_model = radius[nlayer-1] print('Surface radius of model (km) = {:8.1f}'.format(r0_model / 1.e3)) # Find layer at bottom of lithosphere for i in range(0, nlayer): if radius[i] <= (r0_model - d_lith) and \ radius[i+1] > (r0_model - d_lith): if radius[i] == (r0_model - d_lith): i_lith = i elif (r0_model - d_lith) - radius[i] <= \ radius[i+1] - (r0_model - d_lith): i_lith = i else: i_lith = i + 1 break n = nlayer - 1 rho[n] = 0. # the density above the surface is zero rho_mantle = rho[crust_index-1] print('Mantle density (kg/m3) = {:8.1f}'.format(rho_mantle)) print('Assumed depth of lithosphere (km) = {:6.1f}'.format(d_lith / 1.e3)) print('Actual depth of lithosphere in discretized model (km) = {:6.1f}' .format((r0_model - radius[i_lith]) / 1.e3)) # initial guess of average crustal thickness thickave = r0_model - radius[crust_index] print('Crustal thickness (km) = {:5.1f}'.format(thickave / 1e3)) print('Moho layer: {:d}'.format(crust_index)) # --- Compute gravity contribution from hydrostatic density interfaces --- hlm, clm_hydro, mass_model = HydrostaticShapeLith(radius, rho, i_lith, potential, omega, lmax_hydro, finiteamplitude=False) print('Total mass of model (kg) = {:e}'.format(mass_model)) print('% of J2 arising from beneath lithosphere = {:f}' .format(clm_hydro.coeffs[0, 2, 0]/potential.coeffs[0, 2, 0] * 100.)) potential.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] -= \ clm_hydro.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] # --- Constant density model --- print('-- Constant density model --\nrho_c = {:f}'.format(rho_c)) tmin = 1.e9 converged = False while not converged: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMoho(potential, topo, lmax, rho_c, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, nmax=nmax, quiet=True) thick = topo.pad(lmax) - moho.pad(lmax) print('Average crustal thickness (km) = {:6.2f}'.format(thickave / 1.e3)) thick_insight = thick.expand(lat=lat_insight, lon=lon_insight) print('Crustal thickness at InSight landing sites (km) = {:6.2f}' .format(thick_insight / 1.e3)) thick_grid = thick.expand(grid='DH2') tmin = thick_grid.data.min() tmax = thick_grid.data.max() print('Minimum thickness (km) = {:6.2f}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:6.2f}'.format(tmax / 1.e3)) if tmin - t0 < - t0_sigma: thickave += t0 - tmin else: converged = True if fnam_out_plot: thick_grid.plot(show=False, fname=fnam_out_plot, vmin=0.0, vmax=120.e3) # Write Model to disk # lmax_out = 17 # 89 # topo_grid = (topo.pad(lmax)).expand(grid='DH2', lmax=lmax_out) # moho_grid = (moho.pad(lmax)).expand(grid='DH2', lmax=lmax_out) # lats = topo_grid._lats() # lons = topo_grid._lons() lats = np.arange(-87.5, 90., 5.) lons = np.arange(0, 360, 5) # Apply tapered anti-aliasing filter to SH before transformation lmax_filter = 36 # 17 order = 2 lvals = np.zeros_like(topo.coeffs) for i in range(0, lvals.shape[1]): for j in range(0, lvals.shape[2]): l = np.max([i, j]) lvals[:, i, j] = np.exp(-2. * np.pi * l ** order / (2. * lmax_filter) ** order) topo.coeffs *= lvals lvals = np.zeros_like(moho.coeffs) for i in range(0, lvals.shape[1]): for j in range(0, lvals.shape[2]): l = np.max([i, j]) lvals[:, i, j] = np.exp(-2. * np.pi * l ** order / (2. * lmax_filter) ** order) moho.coeffs *= lvals #moho.plot_spectrum(show=False, fname='%s.png' % fnam_out_model) lats_grid, lons_grid = np.meshgrid(lats, lons) topo_grid = (topo).expand(lat=lats_grid, lon=lons_grid) moho_grid = (moho).expand(lat=lats_grid, lon=lons_grid) moho.expand(grid='DH2').plot(show=False, fname='%s_moho.png' % fnam_out_model) topo.expand(grid='DH2').plot(show=False, fname='%s_topo.png' % fnam_out_model) (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2').plot(show=False, fname='%s_thick.png' % fnam_out_model) with h5py.File(fnam_out_model, 'w') as f: print('Writing to %s' % fnam_out_model) grp_crust = f.create_group('crust') grp_crust.create_dataset('moho', data=moho_grid.data) grp_crust.create_dataset('topo', data=topo_grid.data) grp_crust.create_dataset('latitudes', data=lats) grp_crust.create_dataset('longitudes', data=lons) grp_mantle = f.create_group('mantle') grp_mantle.create_dataset('radius', data=radius) grp_mantle.create_dataset('rho', data=rho) grp_mantle.create_dataset('vp', data=vp) grp_mantle.create_dataset('vs', data=vs) grp_status = f.create_group('status') grp_status.create_dataset('thickness_insight', data=thick_insight) grp_status.create_dataset('thickness_average_pycrust', data=thickave) grp_status.create_dataset('thickness_average_input', data=r0_model - radius[crust_index]) grp_status.create_dataset('thickness_lithosphere', data=d_lith) grp_status.create_dataset('thickness_minimum', data=tmin) grp_status.create_dataset('thickness_maximum', data=tmax) grp_status.create_dataset('rho_crust', data=rho_c) grp_status.create_dataset('rho_mantle', data=rho_mantle)
def main(): gravfile = 'Data/gmm3_120_sha.tab' topofile = 'Data/MarsTopo719.shape' densityfile = 'Data/dichotomy_359.sh' model_name = [ 'DWThot', 'DWThotCrust1', 'DWThotCrust1r', 'EH45Tcold', 'EH45TcoldCrust1', 'EH45TcoldCrust1r', 'EH45ThotCrust2', 'EH45ThotCrust2r', 'LFAK', 'SANAK', 'TAYAK', 'DWAK', 'ZG_DW' ] spec = 'Data/Mars-reference-interior-models/Smrekar/' interior_file = [spec + name + '.deck' for name in model_name] lmax_calc = 90 lmax = lmax_calc * 4 potential = pyshtools.SHGravCoeffs.from_file(gravfile, header_units='km') print('Gravity file = {:s}'.format(gravfile)) print('Lmax of potential coefficients = {:d}'.format(potential.lmax)) print('Reference radius (km) = {:f}'.format(potential.r0 / 1.e3)) print('GM = {:e}\n'.format(potential.gm)) topo = pyshtools.SHCoeffs.from_file(topofile, lmax=lmax) topo.r0 = topo.coeffs[0, 0, 0] print('Topography file = {:s}'.format(topofile)) print('Lmax of topography coefficients = {:d}'.format(topo.lmax)) print('Reference radius (km) = {:f}\n'.format(topo.r0 / 1.e3)) density = pyshtools.SHCoeffs.from_file(densityfile, lmax=lmax) print('Lmax of density coefficients = {:d}\n'.format(density.lmax)) lat_insight = 4.502384 lon_insight = 135.623447 filter = 1 half = 50 nmax = 7 lmax_hydro = 15 t0_sigma = 5. # maximum difference between minimum crustal thickness omega = pyshtools.constant.omega_mars.value d_lith = 150.e3 d_sigma = 45.e3 t0 = 1.e3 # minimum crustal thickness model = 10 # identifier for the interior reference model # --- read 1D reference interior model --- radius, rho, i_crust, i_core, i_lith = ReadRefModel(interior_file[model], depth=d_lith, quiet=False) rho_mantle = rho[i_crust - 1] rho_core = rho[i_core - 1] n = len(radius) - 1 r0_model = radius[n] # --- Compute gravity contribution from hydrostatic density interfaces --- thickave = 44.e3 # initial guess of average crustal thickness r_sigma = topo.r0 - thickave rho_c = 2900. if True: # compute values for a planet that is completely fluid hlm_fluid, clm_fluid, mass_model = \ HydrostaticShape(radius, rho, omega, potential.gm, potential.r0) print('--- Hydrostatic potential coefficients for a fluid planet ---') print('c20 = {:e}\nc40 = {:e}'.format(clm_fluid.coeffs[0, 2, 0], clm_fluid.coeffs[0, 4, 0])) print('--- Hydrostatic relief of surface for a fluid planet ---') print('h20 = {:e}\nh40 = {:e}'.format(hlm_fluid[n].coeffs[0, 2, 0], hlm_fluid[n].coeffs[0, 4, 0])) hlm, clm_hydro, mass_model = \ HydrostaticShapeLith(radius, rho, i_lith, potential, topo, rho_c, r_sigma, omega, lmax_hydro) print('Total mass of model (kg) = {:e}'.format(mass_model)) print('% of J2 arising from beneath lithosphere = {:f}'.format( clm_hydro.coeffs[0, 2, 0] / potential.coeffs[0, 2, 0] * 100.)) potential.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] -= \ clm_hydro.coeffs[:, :lmax_hydro+1, :lmax_hydro+1] # --- Constant density model --- rho_c = 2900. print('-- Constant density model --\nrho_c = {:f}'.format(rho_c)) tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMoho(potential, topo, lmax, rho_c, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, nmax=nmax, quiet=True) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:f}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:f}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.min() tmax = thick_grid.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-1.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-1.png') # --- Model with variable density --- rho_south = 2900. rho_north = 2900. porosity = 0.0 print('-- Variable density model ---\n' + 'rho_south = {:f}\n'.format(rho_south) + 'rho_north = {:f}'.format(rho_north)) density = density * (rho_north - rho_south) density.coeffs[0, 0, 0] += rho_south tmin = 1.e9 thickave = 44.e3 # initial guess of average crustal thickness while abs(tmin - t0) > t0_sigma: # iterate to fit assumed minimum crustal thickness moho = pyMoho.pyMohoRho(potential, topo, density, porosity, lmax, rho_mantle, thickave, filter_type=filter, half=half, lmax_calc=lmax_calc, quiet=True, nmax=nmax) thick_grid = (topo.pad(lmax) - moho.pad(lmax)).expand(grid='DH2') print('Average crustal thickness (km) = {:e}'.format(thickave / 1.e3)) print('Crustal thickness at InSight landing sites (km) = {:e}'.format( (topo.pad(lmax) - moho.pad(lmax)).expand(lat=lat_insight, lon=lon_insight) / 1.e3)) tmin = thick_grid.data.min() tmax = thick_grid.data.max() print('Minimum thickness (km) = {:e}'.format(tmin / 1.e3)) print('Maximum thickness (km) = {:e}'.format(tmax / 1.e3)) thickave += t0 - tmin thick_grid.plot(show=False, fname='Thick-Mars-2.png') moho.plot_spectrum(show=False, fname='Moho-spectrum-Mars-2.png')