"""
Create a grounding line contour.
"""

from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput, MeshGenerator
from numpy import *
from mpl_toolkits.basemap import Basemap

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2()
db2 = DataInput(bedmap2)

# Get the grounding line by eliminating the shelves
db2.set_data_val('mask',1,127)

# Create a grounding line countour
mg = MeshGenerator(db2, 'mesh', '')
mg.create_contour('mask', 10, skip_pts=2)
mg.eliminate_intersections(dist=20)
cont = mg.longest_cont

# Convert (x,y) coordinates to (lon,lat)
cont_lons, cont_lats = db2.p(cont[:,0], cont[:,1], inverse = True)

# Convert (x,y) coordinates to (lon,lat)
cont_lons, cont_lats = db2.p(cont[:,0], cont[:,1], inverse = True)

# Convert to basemap coordinates
lat_0  = '-90'
lat_ts = '-71'
Esempio n. 2
0
from varglas.data.data_factory import DataFactory
from varglas.mesh.mesh_factory import MeshFactory
from varglas.utilities import DataInput
from varglas.model import Model
from varglas.solvers import SteadySolver, TransientSolver
from varglas.physical_constants import IceParameters
from varglas.helper import default_nonlin_solver_params
from fenics import set_log_active, parameters

set_log_active(True)

thklim = 50.0

vara = DataFactory.get_searise(thklim=thklim)
mesh = MeshFactory.get_greenland_coarse()
dsr = DataInput(vara, mesh=mesh)

S = dsr.get_spline_expression('S')
B = dsr.get_spline_expression('B')
SMB = dsr.get_spline_expression('adot')
T_s = dsr.get_spline_expression('T')
q_geo = dsr.get_spline_expression('q_geo')
U_ob = dsr.get_spline_expression('U_ob')
Tn = vara['Tn']['map_data']

# create the model :
model = Model()

model.set_mesh(mesh)
model.set_geometry(S, B, deform=True)
model.set_parameters(IceParameters())
Esempio n. 3
0
# -*- coding: utf-8 -*-
"""
Create a uniform mesh of Antarctica for plotting. 
"""

from varglas.utilities         import DataInput, MeshGenerator
from varglas.data.data_factory import DataFactory
from pylab                     import *

thklim = 0
# create meshgrid for contour :
bedmap2 = DataFactory.get_bedmap2()
# process the data :
dbm = DataInput(bedmap2, gen_space=False)
dbm.set_data_val("H", 32767, thklim)

m = MeshGenerator(dbm, 'mesh', '')

m.create_contour('H', 0.0, 5)
m.eliminate_intersections(dist=20)

m.write_gmsh_contour(1000, boundary_extend=False)
m.add_edge_attractor(1)

#field, ifield, lcMin, lcMax, distMin, distMax
m.add_threshold(2, 1, 3000, 3000, 1, 100000)
m.finish(4)

#m.create_2D_mesh('mesh') #FIXME: fails
#m.convert_msh_to_xml('mesh', 'mesh')
# Output directory
out_dir = 'results_dir3/'

#set_log_active(True)
parameters["allow_extrapolation"] = True

mesh = Mesh('data/meshes/ant_mesh.xml')

# Get a bunch of data to use in the simulation 
thklim = 100.0
measures  = DataFactory.get_ant_measures(res=900)
bedmap1   = DataFactory.get_bedmap1(thklim=thklim)
bedmap2   = DataFactory.get_bedmap2(thklim=thklim)

dm  = DataInput(measures, mesh=mesh)
db1 = DataInput(bedmap1,  mesh=mesh)
db2 = DataInput(bedmap2,  mesh=mesh)

# Fix some stuff?
db2.data['B'] = db2.data['S'] - db2.data['H']
db2.set_data_val('H', 32767, thklim)
db2.data['S'] = db2.data['B'] + db2.data['H']

S      = db2.get_spline_expression("S")
B      = db2.get_spline_expression("B")
T_s    = db1.get_spline_expression("srfTemp")
q_geo  = db1.get_spline_expression("q_geo")
adot   = db1.get_spline_expression("adot")

# Create a model for the sole purpose of deforming the full continent mesh
# Get the full continent mesh
""" Script that takes in lat,lon gps coordinates and returns the x,y coordinates."""
from pylab import *
from mpl_toolkits.basemap import Basemap
from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput
from fenics import *

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2(thklim=200)
data = bedmap2["mask"]["map_data"][::-1]
db2 = DataInput(bedmap2)

# These are the original coordinates of the domain
x0 = -376234
y0 = -456870

x1 = -291856
y1 = -505791

x2 = 102477
y2 = 177085

x3 = 17833
y3 = 225849

# Convert to (lon, lat) coordinates
lon0, lat0 = db2.p(x0, y0, inverse=True)
lon1, lat1 = db2.p(x1, y1, inverse=True)
lon2, lat2 = db2.p(x2, y2, inverse=True)
lon3, lat3 = db2.p(x3, y3, inverse=True)
Esempio n. 6
0
""" Script that takes in lat,lon gps coordinates and returns the x,y coordinates."""
from pylab import *
from mpl_toolkits.basemap import Basemap
from varglas.data.data_factory    import DataFactory
from varglas.utilities            import DataInput
from fenics                       import *

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2(thklim = 200)

data = bedmap2['mask']['map_data'][::-1]

db2 = DataInput(bedmap2)

x0 = -376234
y0 = -456870

x1 = -291856
y1 = -505791

x2 = 102477
y2 = 177085

x3 = 17833
y3 = 225849

lon0, lat0 = db2.p(x0,y0,inverse = True)
lon1, lat1 = db2.p(x1,y1,inverse = True)
lon2, lat2 = db2.p(x2,y2,inverse = True)
lon3, lat3 = db2.p(x3,y3,inverse = True)
"""
Create a continent contour.
"""

from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput, MeshGenerator
from numpy import *
from mpl_toolkits.basemap import Basemap

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2()
db2 = DataInput(bedmap2)

# Create a grounding line countour
mg = MeshGenerator(db2, 'mesh', '')
mg.create_contour('mask', 10, skip_pts=2)
mg.eliminate_intersections(dist=20)
cont = mg.longest_cont

# Convert (x,y) coordinates to (lon,lat)
cont_lons, cont_lats = db2.p(cont[:,0], cont[:,1], inverse = True)

# Convert to basemap coordinates
lat_0  = '-90'
lat_ts = '-71'
lon_0  = '0'
height = 3333500*2
width = 3333500*2

m = Basemap(width=width, height=height, resolution='h',
            projection="stere", lat_ts=lat_ts, lon_0=lon_0, lat_0=lat_0)
"""
Create contours for the Antarctic ice shelves so we can plot them. 
"""

from pylab import *
from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput, MeshGenerator
from numpy import *

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2()
db2 = DataInput(bedmap2)
# Just get the ice shelves
db2.set_data_val('mask',127,0)

mg = MeshGenerator(db2, 'mesh', '')
mg.create_contour('mask', 0, skip_pts=2)
mg.eliminate_intersections(dist=20)

# Get the two longest contours, which I'm assuming are the two major ice shelves
cl = mg.c.allsegs[0]
contour_lens = array(map(len, cl))
sorted_indexes = contour_lens.argsort()

shelf1 = cl[sorted_indexes[-1]]
shelf2 = cl[sorted_indexes[-2]]

# Convert to (lon, lat coordinates)
shelf1_lons, shelf1_lats = db2.p(shelf1[:,0], shelf1[:,1], inverse = True)
shelf2_lons, shelf2_lats = db2.p(shelf2[:,0], shelf2[:,1], inverse = True)
Esempio n. 9
0
import varglas.model              as model

# Output directory
out_dir = 'age_bp/'

set_log_active(True)

# Load my mesh
mesh = Mesh('data/meshes/ant_mesh.xml')

# Get a bunch of data to use in the simulation 
thklim = 100.0
bedmap1   = DataFactory.get_bedmap1(thklim=thklim)
bedmap2   = DataFactory.get_bedmap2(thklim=thklim)

db1 = DataInput(bedmap1,  mesh=mesh)
db2 = DataInput(bedmap2,  mesh=mesh)

# This code is 
db2.data['B'] = db2.data['S'] - db2.data['H']
db2.set_data_val('H', 32767, thklim)
db2.data['S'] = db2.data['B'] + db2.data['H']

S      = db2.get_spline_expression("S")
B      = db2.get_spline_expression("B")
adot   = db1.get_spline_expression("adot")

# Setup the model
model = model.Model()
model.set_mesh(mesh)
model.set_geometry(S, B, deform=True)
Esempio n. 10
0
"""
Created on Fri Jul 25 10:48:09 2014

@author: jake
"""
from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput
from fenics import *

# Load a mesh
mesh = Mesh("meshes/mesh_5km.xml")
# plot(mesh, interactive = True)

# create meshgrid for contour :
bedmap2 = DataFactory.get_bedmap2()
# process the data :
dbm = DataInput(bedmap2)

# Project some data onto the mesh
print "Here."
# bed = dbm.get_interpolation("B",near = True,kx=1,ky=1)

# bed = dbm.get_projection("B",near = False,kx=1,ky=1)

bed = dbm.get_spline_expression("B")
Q = FunctionSpace(mesh, "CG", 1)

bed = project(bed, Q)

File("data/bed_5km.xml") << bed
from varglas.mesh.mesh_factory import MeshFactory
from varglas.utilities import DataInput
from fenics import *
import varglas.model as model

# Have to set this to true because my mesh doesn't match up with Evan's pefectly
# due to different levels of refinement
parameters["allow_extrapolation"] = True

# Load my mesh
mesh = Mesh("meshes/ant_mesh.xml")

# Use bedmap for surface and bed elevation
thklim = 100.0
bedmap2 = DataFactory.get_bedmap2(thklim=thklim)
db2 = DataInput(bedmap2, mesh=mesh)

# Deform the mesh so it matches Evan's
db2.data["B"] = db2.data["S"] - db2.data["H"]
db2.set_data_val("H", 32767, thklim)
db2.data["S"] = db2.data["B"] + db2.data["H"]

S = db2.get_spline_expression("S")
B = db2.get_spline_expression("B")

# Create a model for the sole purpose of deforming the full continent mesh
full_mesh = MeshFactory.get_antarctica_3D_gradS_detailed()
mesh_model = model.Model()
mesh_model.set_mesh(full_mesh)
mesh_model.set_geometry(S, B, deform=True)
"""
Created on Mon Jul 28 16:12:36 2014

@author: jake
"""

from pylab import *
from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput, MeshGenerator
from numpy import *

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2(thklim = 200)

# Create a countour of the continent - without the ice shelves
db2 = DataInput(bedmap2)
db2.set_data_val('mask',1,127)
mg = MeshGenerator(db2, 'mesh', '')
mg.create_contour('mask', 0, skip_pts=4)
mg.eliminate_intersections(dist=40)
# Get the longest contour, which will be the coastline 
cont = mg.longest_cont

# Load the glacier data
glacier_data = loadtxt('glacier_data.out', delimiter = '|', dtype = 'str')
names = array(glacier_data[:,0], dtype = 'str')
lons = array(glacier_data[:,1], dtype = 'f')
lats = array(glacier_data[:,2], dtype = 'f')

# Convert lons and lats to x, y coordinates
x, y = db2.p(lons,lats)
Esempio n. 13
0
""" Script that takes in lat,lon gps coordinates and returns the x,y coordinates."""
from pylab import *
from mpl_toolkits.basemap import Basemap
from varglas.data.data_factory import DataFactory
from varglas.utilities import DataInput
from fenics import *

# Get the Antarctica data sets
bedmap2 = DataFactory.get_bedmap2()
db2 = DataInput(bedmap2)

# Load the domain coordinates
domain_coords = loadtxt("data/new_domain.out")
domain_lons, domain_lats = db2.p(domain_coords[:, 0], domain_coords[:, 1], inverse=True)

# Setup the basemap projection
proj = "stere"
lat_0 = "-90"
lat_ts = "-71"
lon_0 = "0"
width = 3333500 * 2
height = 3333500 * 2

# Plot all the points
m = Basemap(width=width, height=height, resolution="h", projection="stere", lat_ts=lat_ts, lon_0=lon_0, lat_0=lat_0)

# Convert the domain (lon, lat) coordinates to basemap coordinates
domain_xs, domain_ys = m(domain_lons, domain_lats)
# Close the rectangle
domain_xs = append(domain_xs, domain_xs[0])
domain_ys = append(domain_ys, domain_ys[0])