measure = DataFactory.get_gre_measures() #bamber = DataFactory.get_bamber() direc = os.path.dirname(os.path.realpath(__file__)) # load a mesh : mesh = Mesh("../meshes/mesh.xml") # create data objects to use with varglas : dsr = DataInput(None, searise, mesh=mesh, create_proj=True) #dbm = DataInput(None, bamber, mesh=mesh) dms = DataInput(None, measure, mesh=mesh, create_proj=True, flip=True) dms.change_projection(dsr) dsr.set_data_min('H', 10.0, 10.0) H = dsr.get_projection("H") S = dsr.get_projection("h") adot = dsr.get_projection("adot") prb = VelocityBalance_2(mesh, H, S, adot, 12.0) prb.solve_forward() # File ouput do = DataOutput('results/greenland_balance_velocity_v2/') d_out = {'Ubmag' : prb.Ubmag, 'H' : prb.H, 'adot' : prb.adot, 'S' : prb.S,
from gmshpy import * from scipy.interpolate import RectBivariateSpline from src.utilities import DataInput #=============================================================================== # data preparation : thklim = 200.0 # collect the raw data : #measures = DataFactory.get_ant_measures() #bedmap1 = DataFactory.get_bedmap1(thklim=thklim) #bedmap2 = DataFactory.get_bedmap2(thklim=thklim) dbv = DataInput("../results/", ("v_mag.mat", ), gen_space=False) dbv.set_data_min('v_mag', 0.0, 0.0) dbv.set_data_max('v_mag', 400.0, 400.0) #db2 = DataInput(None, bedmap2, gen_space=False) # might want to refine off of thickness : #H = db2.data['H'].copy().T # ensure that there are no values less than 1 for taking log : #vel = dsr.data['U_ob'].copy().T vel = dbv.data['v_mag'].copy().T vel += 1 # invert the sections where the velocity is low to refine at divide : data = log(vel) #mv = data.max()
set_log_active(True) var_measures = DataFactory.get_ant_measures() var_bedmap1 = DataFactory.get_lebrocq() var_bedmap2 = DataFactory.get_bedmap2() mesh = MeshFactory.get_antarctica_coarse() flat_mesh = MeshFactory.get_antarctica_coarse() dm = DataInput(None, var_measures, mesh=mesh,flip=True) db1 = DataInput(None, var_bedmap1, mesh=mesh) db2 = DataInput(None, var_bedmap2, mesh=mesh, flip=True) thklim = 50.0 db2.set_data_min("H", thklim, thklim) db2.set_data_min("h", 0.0,0.0) db2.set_data_max("H",30000.,thklim) db2.set_data_max("h",30000.,0.0) db2.data['b'] = db2.data['h']-db2.data['H'] db1.data['srfTemp'] += 273.15 db1.data['q_geo'] *= 60**2*24*365 Surface = db2.get_spline_expression("h") Bed = db2.get_spline_expression("b") SurfaceTemperature = db1.get_spline_expression("srfTemp") BasalHeatFlux = db1.get_spline_expression("q_geo")
direc = os.path.dirname(os.path.realpath(__file__)) # load a mesh : mesh = Mesh("./mesh_5km.xml") # create data objects to use with varglas : dsr = DataInput(None, searise, mesh=mesh) dbam = DataInput(None, bamber, mesh=mesh) dms = DataInput(None, measure, mesh=mesh, flip=True) dms.change_projection(dsr) # Bound data to managable values MAX_V_ERR = 500 NO_DATA = -99 MAX_V = 1e5 dbam.set_data_min('H', 200.0, 200.0) dbam.set_data_min('h', 1.0, 1.0) dms.set_data_min('sp',0.0,-1.0) dms.set_data_min('ex',-MAX_V_ERR,NO_DATA) dms.set_data_max('ex',MAX_V_ERR,NO_DATA) dms.set_data_min('ey',-MAX_V_ERR,NO_DATA) dms.set_data_max('ey',MAX_V_ERR,NO_DATA) dms.set_data_min('vx',-MAX_V,NO_DATA) dms.set_data_max('vx',MAX_V,NO_DATA) dms.set_data_min('vy',-MAX_V,NO_DATA) dms.set_data_max('vy',MAX_V,NO_DATA) print "Projecting data onto mesh..." H = dbam.get_interpolation("H",kx=1,ky=1)
measure = DataFactory.get_gre_measures() bamber = DataFactory.get_bamber() direc = os.path.dirname(os.path.realpath(__file__)) # load a mesh : mesh = Mesh("./mesh.xml") # create data objects to use with varglas : dsr = DataInput(None, searise, mesh=mesh, create_proj=True) dbam = DataInput(None, bamber, mesh=mesh) dms = DataInput(None, measure, mesh=mesh, create_proj=True, flip=True) dms.change_projection(dsr) dbam.set_data_min('H', 200.0, 200.0) dbam.set_data_min('h', 1.0, 1.0) dms.set_data_min('sp',0.0,-2e9) H = dbam.get_projection("H") H0 = dbam.get_projection("H") S = dbam.get_projection("h") adot = dsr.get_projection("adot") Uobs = dms.get_projection("sp") Uobs.vector()[Uobs.vector().array()<0] = 0.0 U_sar_spline = dms.get_spline_expression("sp") insar_mask = CellFunctionSizet(mesh)
prb = VelocityBalance_2(mesh, H, S, adot, 12.0) prb.solve_forward() # File ouput do = DataOutput('results/greenland_balance_velocity_v2/') d_out = {'U_bal_mag' : prb.Ubmag, 'H' : prb.H, 'adot' : prb.adot, 'S' : prb.S, 'slope' : prb.slope, 'residual' : prb.residual} do.write_dict_of_files(d_out) do.write_dict_of_files(d_out, extension='.xml') do.write_one_file('sp', dms.get_projection('sp')) #do.write_matlab(dbm, prb.Ubmag, 'results/Ubmag.mat') dbv = DataInput('results/', ('Ubmag.mat',), mesh=mesh) dbv.set_data_min('Ubmag', 0.0, 0.0) ass = dbv.integrate_field('sp', dmss, 'Ubmag', val=50) do.write_one_file('Ubmag_measures', ass) #do.write_matlab(dbm, ass, 'results/Ubmag_measures.mat')
# collect the raw data : bamber = DataFactory.get_bamber(thklim = thklim) searise = DataFactory.get_searise(thklim = thklim) #meas_shf = DataFactory.get_shift_gre_measures() #dbv = DataInput("../results/", ("Ubmag_measures.mat", "Ubmag.mat"), # gen_space=False) dsr = DataInput(None, searise, gen_space=False) dbm = DataInput(None, bamber, gen_space=False) #dmss = DataInput(None, meas_shf, gen_space=False) #dbv.set_data_min('Ubmag', 0.0, 0.0) #dbv.set_data_max('Ubmag', 500.0, 500.0) dsr.change_projection(dbm) dsr.set_data_min('U_ob', 0.0, 0.0) dsr.set_data_max('U_ob', 400.0, 400.0) # might want to refine off of thickness : #H = dbm.data['H'].copy().T # ensure that there are no values less than 1 for taking log : #vel = dbv.data['Ubmag'].copy().T vel = dsr.data['U_ob'].copy().T vel += 1 # invert the sections where the velocity is low to refine at divide : data = log(vel) mv = data.max() k = 1 #data[2*data < k*mv] = -data[2*data < k*mv] + k*mv
measure = DataFactory.get_gre_measures() bamber = DataFactory.get_bamber() direc = os.path.dirname(os.path.realpath(__file__)) # load a mesh : mesh = Mesh("./mesh.xml") # create data objects to use with varglas : dsr = DataInput(None, searise, mesh=mesh, create_proj=True) dbam = DataInput(None, bamber, mesh=mesh) dms = DataInput(None, measure, mesh=mesh, create_proj=True, flip=True) dms.change_projection(dsr) dbam.set_data_min('H', 10.0, 10.0) dsr.set_data_min('U_ob',0.0,0.0) dms.set_data_val('sp',-0.1,-2e9) H = dbam.get_interpolation("H") S = dbam.get_interpolation("h") adot = dsr.get_interpolation("adot") #Uobs = dms.get_interpolation("sp",kx=1,ky=1) Uobs = dsr.get_interpolation("U_ob",kx=1,ky=1) Uobs.vector()[Uobs.vector().array()<0] = 0.0 U_sar_spline = dms.get_spline_expression("sp",kx=1,ky=1) insar_mask = CellFunctionSizet(mesh) insar_mask.set_all(0) for c in cells(mesh): x,y = c.midpoint().x(),c.midpoint().y()
thklim = 200.0 measures = DataFactory.get_ant_measures(res=900) bedmap1 = DataFactory.get_bedmap1(thklim=thklim) bedmap2 = DataFactory.get_bedmap2(thklim=thklim) mesh = MeshFactory.get_antarctica_coarse() dm = DataInput(None, measures, mesh=mesh) db1 = DataInput(None, bedmap1, mesh=mesh) db2 = DataInput(None, bedmap2, mesh=mesh) db2.set_data_val('H', 32767, thklim) db2.set_data_val('S', 32767, 0.0) dm.set_data_min('U_ob', 0.0, 0.0) Thickness = db2.get_spline_expression("H") Surface = db2.get_spline_expression("S") Bed = db2.get_spline_expression("B") Mask = db2.get_nearest_expression("mask") SurfaceTemperature = db1.get_spline_expression("srfTemp") BasalHeatFlux = db1.get_spline_expression("q_geo") adot = db1.get_spline_expression("adot") U_observed = dm.get_spline_expression("U_ob") model = model.Model() model.set_mesh(mesh) model.set_geometry(Surface, Bed, deform=True) model.set_parameters(pc.IceParameters()) model.initialize_variables()
bedmap1 = DataFactory.get_bedmap1(thklim=thklim) bedmap2 = DataFactory.get_bedmap2(thklim=thklim) mesh = Mesh('meshes/mesh_low.xml') flat_mesh = Mesh('meshes/mesh_low.xml') #mesh.coordinates()[:,2] /= 100000.0 #flat_mesh.coordinates()[:,2] /= 100000.0 dm = DataInput(None, measures, mesh=mesh) db1 = DataInput(None, bedmap1, mesh=mesh) db2 = DataInput(None, bedmap2, mesh=mesh) db2.set_data_val('H', 32767, thklim) db2.set_data_val('h', 32767, 0.0) dm.set_data_min('v_mag', 0.0, 0.0) #h = db2.get_projection('h') #H = db2.get_projection('H') #v_mag = dm.get_projection('v_mag') #surfTemp = db1.get_projection("srfTemp") #q_geo = db1.get_projection("q_geo") #File('tests/q_geo.pvd') << q_geo #File('tests/srfTemp.pvd') << surfTemp #File('tests/hf.pvd') << h #File('tests/Hf.pvd') << H #File('tests/v_magf.pvd') << v_mag Thickness = db2.get_spline_expression("H") Surface = db2.get_spline_expression("h")
m = MeshGenerator(dbm, 'mesh', '') m.create_contour('H', zero_cntr=200.0, skip_pts=2) m.eliminate_intersections(dist=40) #m.plot_contour() m.write_gmsh_contour(boundary_extend=False) m.extrude(h=100000, n_layers=10) m.close_file() #=============================================================================== # refine : thklim = 1250.0 #dsr.set_data_min('U_ob', boundary=0.0, val=0.0) #dsr.set_data_max('U_ob', boundary=400.0, val=400.0) dbm.set_data_min('H', boundary=thklim, val=thklim) #dbm.set_data_max('mask', 2, 0) # might want to refine off of thickness : H = dbm.data['H'] # ensure that there are no values less than 1 for taking log : vel = dsr.data['U_ob'] vel += 1 vel = log(vel) # plot to check : #imshow(H[::-1,:]) #colorbar() #show()
prb = VelocityBalance_2(mesh, H, S, adot, 12.0) prb.solve_forward() # File ouput do = DataOutput('results/greenland_balance_velocity_v2/') d_out = { 'U_bal_mag': prb.Ubmag, 'H': prb.H, 'adot': prb.adot, 'S': prb.S, 'slope': prb.slope, 'residual': prb.residual } do.write_dict_of_files(d_out) do.write_dict_of_files(d_out, extension='.xml') do.write_one_file('sp', dms.get_projection('sp')) #do.write_matlab(dbm, prb.Ubmag, 'results/Ubmag.mat') dbv = DataInput('results/', ('Ubmag.mat', ), mesh=mesh) dbv.set_data_min('Ubmag', 0.0, 0.0) ass = dbv.integrate_field('sp', dmss, 'Ubmag', val=50) do.write_one_file('Ubmag_measures', ass) #do.write_matlab(dbm, ass, 'results/Ubmag_measures.mat')
from gmshpy import * from scipy.interpolate import RectBivariateSpline from src.utilities import DataInput # =============================================================================== # data preparation : thklim = 200.0 # collect the raw data : # measures = DataFactory.get_ant_measures() # bedmap1 = DataFactory.get_bedmap1(thklim=thklim) # bedmap2 = DataFactory.get_bedmap2(thklim=thklim) dbv = DataInput("../results/", ("v_mag.mat",), gen_space=False) dbv.set_data_min("v_mag", 0.0, 0.0) dbv.set_data_max("v_mag", 400.0, 400.0) # db2 = DataInput(None, bedmap2, gen_space=False) # might want to refine off of thickness : # H = db2.data['H'].copy().T # ensure that there are no values less than 1 for taking log : # vel = dsr.data['U_ob'].copy().T vel = dbv.data["v_mag"].copy().T vel += 1 # invert the sections where the velocity is low to refine at divide : data = log(vel) # mv = data.max()
measure = DataFactory.get_gre_measures() bamber = DataFactory.get_bamber() direc = os.path.dirname(os.path.realpath(__file__)) # load a mesh : mesh = Mesh("./mesh.xml") # create data objects to use with varglas : dsr = DataInput(None, searise, mesh=mesh, create_proj=True) dbam = DataInput(None, bamber, mesh=mesh) dms = DataInput(None, measure, mesh=mesh, create_proj=True, flip=True) dms.change_projection(dsr) dbam.set_data_min("H", 200.0, 200.0) dbam.set_data_min("h", 1.0, 1.0) dms.set_data_min("sp", 0.0, -2e9) H = dbam.get_projection("H") H0 = dbam.get_projection("H") S = dbam.get_projection("h") adot = dsr.get_projection("adot") Uobs = dms.get_projection("sp") Uobs.vector()[Uobs.vector().array() < 0] = 0.0 U_sar_spline = dms.get_spline_expression("sp") insar_mask = CellFunctionSizet(mesh)