# 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'
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)

cont_xs, cont_ys = m(cont_lons, cont_lats)
Esempio n. 2
0
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 the basemap plot
proj   = 'stere'
lat_0  = '-90'
lat_ts = '-71'
lon_0  = '0'
    
width = 3333500*2
height = 3333500*2

"""lon0, lat0 = (-139.72716740712372, -84.37814266271583)
lon1, lat1 = (-151.11913845599102, -84.38752263197189)
# 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)

# Create the basemap plot
proj = "stere"
lat_0 = "-90"
lat_ts = "-71"
lon_0 = "0"

width = 3333500 * 2
height = 3333500 * 2

# This is a bit of code that I used to cut off part of the rectangular domain
# over the transantarctic mountain and the ice shelf.
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)

# Save the ice shelf contours
savetxt('shelf1_cont.out', array(zip(shelf1_lons, shelf1_lats)))
savetxt('shelf2_cont.out', array(zip(shelf2_lons, shelf2_lats)))
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)

# Next, eliminate glaciers that are too far from the coast

# (x,y) coordinates of outlet glaciers for plotting
x_out = []
y_out = []

# The names, and (lon, lat) coordinates of the outlet glaciers, which we'll save
# to a file
names_out = []
lon_out = []
lat_out = []

for i in range(len(x)) :
  v = [x[i], y[i]]
""" 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])