def main(): """ """ dir_path='.' ocean=0 proj='ortho' euler_file='' cont='ind.asc' Poles=[] lat_0,lon_0=0.,0. fmt='svg' lon_0=45. lat_0=20. euler_file='polerots.ind' f=open(euler_file,'rU') edata=f.readlines() for line in edata: rec=line.split() Poles.append([float(rec[0]),float(rec[1]),float(rec[2])]) FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) # read in er_sites file lats,lons=[],[] data=continents.get_continent(cont) for line in data: lats.append(float(line[0])) lons.append(float(line[1])) Opts={'latmin':-90,'latmax':90,'lonmin':0.,'lonmax':360.,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'details':0,'sym':'r-','padlat':0,'padlon':0,'res':'i'} pmagplotlib.plotMAP(FIG['map'],lats,lons,Opts) pmagplotlib.drawFIGS(FIG) plats=[90.] plons=[0.] Opts['sym']='ro' pmagplotlib.plotMAP(FIG['map'],plats,plons,Opts) pmagplotlib.drawFIGS(FIG) newlats,newlons=[],[] for lat in plats:newlats.append(lat) for lon in plons:newlons.append(lon) for pole in Poles: Rlats,Rlons=pmag.PTrot(pole,newlats,newlons) pmagplotlib.plotMAP(FIG['map'],Rlats,Rlons,Opts) pmagplotlib.drawFIGS(FIG) newlats,newlons=[],[] for lat in Rlats:newlats.append(lat) for lon in Rlons:newlons.append(lon) files={} for key in FIG.keys(): files[key]='pole_rot'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['eq']='Site Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files)
def main(): """ NAME vgpmap_magic.py DESCRIPTION makes a map of vgps and a95/dp,dm for site means in a pmag_results table SYNTAX vgpmap_magic.py [command line options] OPTIONS -h prints help and quits -eye ELAT ELON [specify eyeball location], default is 90., 0. -f FILE pmag_results format file, [default is pmag_results.txt] -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -prj PROJ, specify one of the following: ortho = orthographic lcc = lambert conformal moll = molweide merc = mercator -sym SYM SIZE: choose a symbol and size, examples: ro 5 : small red circles bs 10 : intermediate blue squares g^ 20 : large green triangles -ell plot dp/dm or a95 ellipses -rev RSYM RSIZE : flip reverse poles to normal antipode -S: plot antipodes of all poles -age : plot the ages next to the poles -crd [g,t] : choose coordinate system, default is to plot all site VGPs DEFAULTS FILE: pmag_results.txt res: c prj: mercator ELAT,ELON = 0,0 SYM SIZE: ro 8 RSYM RSIZE: g^ 8 """ dir_path='.' res,ages='c',0 proj='npstere' results_file='pmag_results.txt' ell,flip=0,0 lat_0,lon_0=90.,0. fmt='pdf' sym,size='ro',8 rsym,rsize='g^',8 anti=0 coord="" if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] if '-h' in sys.argv: print main.__doc__ sys.exit() if '-S' in sys.argv:anti=1 if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] if '-rev' in sys.argv: flip=1 ind = sys.argv.index('-rev') rsym=(sys.argv[ind+1]) rsize=int(sys.argv[ind+2]) if '-sym' in sys.argv: ind = sys.argv.index('-sym') sym=(sys.argv[ind+1]) size=int(sys.argv[ind+2]) if '-eye' in sys.argv: ind = sys.argv.index('-eye') lat_0=float(sys.argv[ind+1]) lon_0=float(sys.argv[ind+2]) if '-ell' in sys.argv: ell=1 if '-age' in sys.argv: ages=1 if '-f' in sys.argv: ind = sys.argv.index('-f') results_file=sys.argv[ind+1] if '-crd' in sys.argv: ind = sys.argv.index('-crd') crd=sys.argv[ind+1] if crd=='g':coord='0' if crd=='t':coord='100' results_file=dir_path+'/'+results_file data,file_type=pmag.magic_read(results_file) if file_type!='pmag_results': print "bad results file" sys.exit() FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) # read in er_sites file lats,lons,dp,dm,a95=[],[],[],[],[] Pars=[] dates,rlats,rlons=[],[],[] Results=[] for rec in data: if 'pmag_result_name' in rec.keys(): name=rec['pmag_result_name'].split() if 'Site' in name: if coord=="" or rec['tilt_correction']==coord:Results.append(rec) elif coord=="" or rec['tilt_correction']==coord:Results.append(rec) for rec in Results: if 'vgp_lat' in rec.keys() and rec['vgp_lat']!="" and 'vgp_lon' in rec.keys() and rec['vgp_lon']!="": if 'average_age' in rec.keys() and rec['average_age']!="" and ages==1: dates.append(rec['average_age']) lat=float(rec['vgp_lat']) lon=float(rec['vgp_lon']) if flip==0: lats.append(lat) lons.append(lon) elif flip==1: if lat<0: rlats.append(-lat) lon=lon+180. if lon>360:lon=lon-360. rlons.append(lon) else: lats.append(lat) lons.append(lon) elif anti==1: lats.append(-lat) lon=lon+180. if lon>360:lon=lon-360. lons.append(lon) ppars=[] ppars.append(lon) ppars.append(lat) ell1,ell2="","" if 'vgp_dm' in rec.keys() and rec['vgp_dm']!="":ell1=float(rec['vgp_dm']) if 'vgp_dp' in rec.keys() and rec['vgp_dp']!="":ell2=float(rec['vgp_dp']) if 'vgp_alpha95' in rec.keys() and rec['vgp_alpha95']!="":ell1,ell2=float(rec['vgp_alpha95']),float(rec['vgp_alpha95']) if ell1!="" and ell2!="": ppars=[] ppars.append(lons[-1]) ppars.append(lats[-1]) ppars.append(ell1) ppars.append(lons[-1]) isign=abs(lats[-1])/lats[-1] ppars.append(lats[-1]-isign*90.) ppars.append(ell2) ppars.append(lons[-1]+90.) ppars.append(0.) Pars.append(ppars) Opts={'latmin':-90,'latmax':90,'lonmin':0.,'lonmax':360.,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'sym':'bs','symsize':3,'pltgrid':0,'res':res,'boundinglat':0.} Opts['details']={'coasts':1,'rivers':0, 'states':0, 'countries':0,'ocean':1} pmagplotlib.plotMAP(FIG['map'],[90.],[0.],Opts) # make the base map with a blue triangle at the pole` Opts['details']={'coasts':0,'rivers':0, 'states':0, 'countries':0,'ocean':0} Opts['pltgrid']=-1 Opts['sym']=sym Opts['symsize']=size if len(dates)>0:Opts['names']=dates if len(lats)>0:pmagplotlib.plotMAP(FIG['map'],lats,lons,Opts) # add the lats and lons of the poles Opts['names']=[] if len(rlats)>0: Opts['sym']=rsym Opts['symsize']=rsize pmagplotlib.plotMAP(FIG['map'],rlats,rlons,Opts) # add the lats and lons of the poles pmagplotlib.drawFIGS(FIG) if ell==1: # add ellipses if desired. Opts['details']={'coasts':0,'rivers':0, 'states':0, 'countries':0,'ocean':0} Opts['pltgrid']=-1 # turn off meridian replotting Opts['symsize']=2 Opts['sym']='g-' for ppars in Pars: if ppars[2]!=0: PTS=pmagplotlib.plotELL(FIG['map'],ppars,'g.',0,0) elats,elons=[],[] for pt in PTS: elons.append(pt[0]) elats.append(pt[1]) pmagplotlib.plotMAP(FIG['map'],elats,elons,Opts) # make the base map with a blue triangle at the pole` pmagplotlib.drawFIGS(FIG) files={} for key in FIG.keys(): files[key]='VGP_map'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['eq']='VGP Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files) else: print "Good bye" sys.exit()
def main(): """ """ dir_path = '.' ocean = 0 proj = 'ortho' euler_file = '' cont = 'ind.asc' Poles = [] lat_0, lon_0 = 0., 0. fmt = 'svg' lon_0 = 45. lat_0 = 20. euler_file = 'polerots.ind' f = open(euler_file, 'rU') edata = f.readlines() for line in edata: rec = line.split() Poles.append([float(rec[0]), float(rec[1]), float(rec[2])]) FIG = {'map': 1} pmagplotlib.plot_init(FIG['map'], 6, 6) # read in er_sites file lats, lons = [], [] data = continents.get_continent(cont) for line in data: lats.append(float(line[0])) lons.append(float(line[1])) Opts = { 'latmin': -90, 'latmax': 90, 'lonmin': 0., 'lonmax': 360., 'lat_0': lat_0, 'lon_0': lon_0, 'proj': proj, 'details': 0, 'sym': 'r-', 'padlat': 0, 'padlon': 0, 'res': 'i' } pmagplotlib.plotMAP(FIG['map'], lats, lons, Opts) pmagplotlib.drawFIGS(FIG) plats = [90.] plons = [0.] Opts['sym'] = 'ro' pmagplotlib.plotMAP(FIG['map'], plats, plons, Opts) pmagplotlib.drawFIGS(FIG) newlats, newlons = [], [] for lat in plats: newlats.append(lat) for lon in plons: newlons.append(lon) for pole in Poles: Rlats, Rlons = pmag.PTrot(pole, newlats, newlons) pmagplotlib.plotMAP(FIG['map'], Rlats, Rlons, Opts) pmagplotlib.drawFIGS(FIG) newlats, newlons = [], [] for lat in Rlats: newlats.append(lat) for lon in Rlons: newlons.append(lon) files = {} for key in FIG.keys(): files[key] = 'pole_rot' + '.' + fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles = {} titles['eq'] = 'Site Map' FIG = pmagplotlib.addBorders(FIG, titles, black, purple) pmagplotlib.saveP(FIG, files) else: ans = raw_input(" S[a]ve to save plot, Return to quit: ") if ans == "a": pmagplotlib.saveP(FIG, files)
def main(): """ NAME cont_rot.py DESCRIPTION rotates continental fragments according to specified Euler pole SYNTAX cont_rot.py [command line options] OPTIONS -h prints help and quits -con [af, congo, kala, aus, balt, eur, ind, sam, ant, grn, lau, nam, gond] , specify colon delimited list of continents to be displayed, e.g., af, af:aus], etc -age use finite rotations of Torsvik et al. 2008 for specific age (5 Ma increments <325Ma) rotates to paleomagnetic reference frame available conts: [congo kala aus eur ind sam ant grn nam] -sac include rotation of south african craton to pmag reference -sym [ro, bs, g^, r., b-, etc.] [1,5,10] symbol and size for continent colors are r=red,b=blue,g=green, etc. symbols are '.' for points, ^, for triangle, s for square, etc. -, for lines, -- for dotted lines, see matplotlib online documentation for plot() -eye ELAT ELON [specify eyeball location] -pfr PLAT PLON OMEGA [specify pole of finite rotation lat,lon and degrees] -ffr FFILE, specifies series of finite rotations vector in tab delimited file -sr treat poles as sequential rotations -fpp PFILE, specifies series of paleopoles from which euler poles can be calculated: vector in tab delimited file -pt LAT LON, specify a point to rotate along with continent -fpt PTFILE, specifies file with a series of points to be plotted -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -prj PROJ, specify one of the supported projections: (see basemap.py online documentation) aeqd = Azimuthal Equidistant poly = Polyconic gnom = Gnomonic moll = Mollweide tmerc = Transverse Mercator nplaea = North-Polar Lambert Azimuthal mill = Miller Cylindrical merc = Mercator stere = Stereographic npstere = North-Polar Stereographic geos = Geostationary laea = Lambert Azimuthal Equal Area sinu = Sinusoidal spstere = South-Polar Stereographic lcc = Lambert Conformal npaeqd = North-Polar Azimuthal Equidistant eqdc = Equidistant Conic cyl = Cylindrical Equidistant omerc = Oblique Mercator aea = Albers Equal Area spaeqd = South-Polar Azimuthal Equidistant ortho = Orthographic cass= Cassini-Soldner splaea = South-Polar Lambert Azimuthal robin = Robinson DEFAULTS con: nam res: c prj: mollweide ELAT,ELON = 0,0 NB: high resolution or lines can be very slow """ dir_path='.' ocean=0 res='c' proj='moll' euler_file='' Conts=[] Poles=[] PTS=[] lat_0,lon_0=0.,0. fmt='pdf' sym='r.' symsize=5 SEQ,age,SAC=0,0,0 rconts=['af','congo','kala','aus','eur','ind','sam','ant','grn','nam'] if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] if '-h' in sys.argv: print main.__doc__ sys.exit() if '-con' in sys.argv: ind = sys.argv.index('-con') Conts=sys.argv[ind+1].split(':') if '-age' in sys.argv: ind = sys.argv.index('-age') age=int(sys.argv[ind+1]) if age%5!=0 and age>320: print main.__doc__ print 'age must be multiple of 5 less than 325' sys.exit() import frp if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if res!= 'c' and res!='l': print 'this resolution will take a while - be patient' if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] if '-eye' in sys.argv: ind = sys.argv.index('-eye') lat_0=float(sys.argv[ind+1]) lon_0=float(sys.argv[ind+2]) if '-pt' in sys.argv: ind = sys.argv.index('-pt') pt_lat=float(sys.argv[ind+1]) pt_lon=float(sys.argv[ind+2]) PTS.append([pt_lat,pt_lon]) if '-sym' in sys.argv: ind = sys.argv.index('-sym') sym=sys.argv[ind+1] symsize=int(sys.argv[ind+2]) # if '-rsym' in sys.argv: # ind = sys.argv.index('-rsym') # rsym=sys.argv[ind+1] # rsymsize=int(sys.argv[ind+2]) if '-sr' in sys.argv: SEQ=1 if '-sac' in sys.argv: SAC=1 if '-pfr' in sys.argv: ind = sys.argv.index('-pfr') Poles.append([float(sys.argv[ind+1]),float(sys.argv[ind+2]),float(sys.argv[ind+3])]) elif '-ffr' in sys.argv: ind = sys.argv.index('-ffr') file=dir_path+'/'+sys.argv[ind+1] f=open(file,'rU') edata=f.readlines() for line in edata: rec=line.split() Poles.append([float(rec[0]),float(rec[1]),float(rec[2])]) elif '-fpp' in sys.argv: ind = sys.argv.index('-fpp') file=dir_path+'/'+sys.argv[ind+1] f=open(file,'rU') pdata=f.readlines() for line in pdata: rec=line.split() # transform paleopole to Euler pole taking shortest route Poles.append([0.,float(rec[1])-90.,90.-float(rec[0])]) if '-fpt' in sys.argv: ind = sys.argv.index('-fpt') file=dir_path+'/'+sys.argv[ind+1] f=open(file,'rU') ptdata=f.readlines() for line in ptdata: rec=line.split() PTS.append([float(rec[0]),float(rec[1])]) FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) # read in er_sites file if res=='c':skip=8 if res=='l':skip=5 if res=='i':skip=2 if res=='h':skip=1 cnt=0 Opts={'latmin':-90,'latmax':90,'lonmin':0.,'lonmax':360.,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'sym':sym,'symsize':3,'pltgrid':0,'res':res,'boundinglat':0.} if proj=='merc': Opts['latmin']=-70 Opts['latmax']=70 Opts['lonmin']=-180 Opts['lonmax']=180 pmagplotlib.plotMAP(FIG['map'],[],[],Opts) # plot the basemap Opts['pltgrid']=-1 # turn off replotting of gridlines if '-pt' in sys.argv: Opts['sym']=sym Opts['symsize']=symsize pmagplotlib.plotMAP(FIG['map'],[pt_lat],[pt_lon],Opts) pmagplotlib.drawFIGS(FIG) for cont in Conts: Opts['sym']=sym lats,lons=[],[] if age!=0: Poles=[] rcont=cont if rcont not in rconts: print main.__doc__ print rcont print 'continents must be one of following: ' print rconts sys.exit() if rcont=='congo':rcont='nwaf' if rcont=='kala':rcont='neaf' if rcont=='sam':rcont='sac' if rcont=='ant':rcont='eant' if rcont!='af': Poles.append(frp.get_pole(rcont,age)) else: Poles.append([0,0,0]) if SAC==1:Poles.append(frp.get_pole('saf',age)) SEQ=1 if Poles[-1]=='NONE': print 'continent does not exist for rotation, try again ' sys.exit() data=continents.get_continent(cont+'.asc') for line in data: if float(line[0])==0 and float(line[1])==0:line[0]='100.' # change stupid 0,0s to delimeters with lat=100 if float(line[0])>90: lats.append(float(line[0])) lons.append(float(line[1])) elif cnt%skip==0: lats.append(float(line[0])) lons.append(float(line[1])) cnt+=1 if len(lats)>0 and len(Poles)==0: pmagplotlib.plotMAP(FIG['map'],lats,lons,Opts) pmagplotlib.drawFIGS(FIG) newlats,newlons=[],[] for lat in lats:newlats.append(lat) for lon in lons:newlons.append(lon) Opts['pltgrid']=-1 # turns off replotting of meridians and parallels for pole in Poles: Rlats,Rlons=pmag.PTrot(pole,newlats,newlons) Opts['sym']=sym Opts['symsize']=3 if SEQ==0: pmagplotlib.plotMAP(FIG['map'],Rlats,Rlons,Opts) elif pole==Poles[-1]: # plot only last pole for sequential rotations pmagplotlib.plotMAP(FIG['map'],Rlats,Rlons,Opts) pmagplotlib.drawFIGS(FIG) if SEQ==1: # treat poles as sequential rotations newlats,newlons=[],[] for lat in Rlats:newlats.append(lat) for lon in Rlons:newlons.append(lon) for pt in PTS: pt_lat=pt[0] pt_lon=pt[1] Opts['sym']='r*' Opts['symsize']=5 pmagplotlib.plotMAP(FIG['map'],[pt[0]],[pt[1]],Opts) pmagplotlib.drawFIGS(FIG) Opts['pltgrid']=-1 # turns off replotting of meridians and parallels for pole in Poles: Opts['sym']=sym Opts['symsize']=symsize Rlats,Rlons=pmag.PTrot(pole,[pt_lat],[pt_lon]) print Rlats,Rlons pmagplotlib.plotMAP(FIG['map'],Rlats,Rlons,Opts) pmagplotlib.drawFIGS(FIG) Opts['sym']='g^' Opts['symsize']=5 pmagplotlib.plotMAP(FIG['map'],[pole[0]],[pole[1]],Opts) pmagplotlib.drawFIGS(FIG) files={} for key in FIG.keys(): files[key]='Cont_rot'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['eq']='Site Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files)
def main(): """ NAME plot_geomagia.py DESCRIPTION makes a map and VADM plot of geomagia download file SYNTAX plot_geomagia.py [command line options] OPTIONS -h prints help message and quits -f FILE, specify geomagia download file -res [c,l,i,h] specify resolution (crude,low,intermediate,high) -etp plot the etopo20 topographic mesh -pad [LAT LON] pad bounding box by LAT/LON (default is [.5 .5] degrees) -grd SPACE specify grid spacing -prj [lcc] , specify projection (lcc=lambert conic conformable), default is mercator -o color ocean blue/land green (default is not) -d plot details of rivers, boundaries, etc. -sav save plot and quit quietly -fmt [png,svg,eps,jpg,pdf] specify format for output, default is pdf DEFAULTS resolution: intermediate saved images are in pdf """ dir_path='.' names,res,proj,locs,padlon,padlat,fancy,gridspace,details=[],'l','lcc','',0,0,0,15,1 Age_bounds=[-5000,2000] Lat_bounds=[20,45] Lon_bounds=[15,55] fmt='pdf' if '-h' in sys.argv: print main.__doc__ sys.exit() if '-f' in sys.argv: ind = sys.argv.index('-f') sites_file=sys.argv[ind+1] if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if '-etp' in sys.argv:fancy=1 if '-o' in sys.argv:ocean=1 if '-d' in sys.argv:details=1 if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] if '-fmt' in sys.argv: ind = sys.argv.index('-fmt') fmt=sys.argv[ind+1] verbose=pmagplotlib.verbose if '-sav' in sys.argv: verbose=0 if '-pad' in sys.argv: ind = sys.argv.index('-pad') padlat=float(sys.argv[ind+1]) padlon=float(sys.argv[ind+2]) if '-grd' in sys.argv: ind = sys.argv.index('-grd') gridspace=float(sys.argv[ind+1]) if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] sites_file=dir_path+'/'+sites_file geo_in=open(sites_file,'rU').readlines() Age,AgeErr,Vadm,VadmErr,slats,slons=[],[],[],[],[],[] for line in geo_in[2:]: # skip top two rows` rec=line.split() if float(rec[0])>Age_bounds[0] and float(rec[0])<Age_bounds[1] \ and float(rec[12])>Lat_bounds[0] and float(rec[12]) < Lat_bounds[1]\ and float(rec[13])>Lon_bounds[0] and float(rec[13])<Lon_bounds[1]: Age.append(float(rec[0])) AgeErr.append(float(rec[1])) Vadm.append(10.*float(rec[6])) VadmErr.append(10.*float(rec[7])) slats.append(float(rec[12])) slons.append(float(rec[13])) FIGS={'map':1,'vadms':2} pmagplotlib.plot_init(FIGS['map'],6,6) pmagplotlib.plot_init(FIGS['vadms'],6,6) Opts={'res':res,'proj':proj,'loc_name':locs,'padlon':padlon,'padlat':padlat,'latmin':numpy.min(slats)-padlat,'latmax':numpy.max(slats)+padlat,'lonmin':numpy.min(slons)-padlon,'lonmax':numpy.max(slons)+padlon,'sym':'ro','boundinglat':0.,'pltgrid':1} Opts['lon_0']=int(0.5*(numpy.min(slons)+numpy.max(slons))) Opts['lat_0']=int(0.5*(numpy.min(slats)+numpy.max(slats))) Opts['gridspace']=gridspace if details==1: Opts['details']={'coasts':1,'rivers':0,'states':1,'countries':1,'ocean':1} else: Opts['details']={'coasts':1,'rivers':0,'states':0,'countries':0,'ocean':1} Opts['details']['fancy']=fancy pmagplotlib.plotMAP(FIGS['map'],slats,slons,Opts) pmagplotlib.plotXY(FIGS['vadms'],Age,Vadm,sym='bo',xlab='Age (Years CE)',ylab=r'VADM (ZAm$^2$)') if verbose:pmagplotlib.drawFIGS(FIGS) files={} for key in FIGS.keys(): files[key]=key+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['map']='Map' titles['vadms']='VADMs' FIG = pmagplotlib.addBorders(FIGS,titles,black,purple) pmagplotlib.saveP(FIGS,files) elif verbose: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIGS,files) else: pmagplotlib.saveP(FIGS,files)
def main(): """ NAME cont_rot.py DESCRIPTION rotates continental fragments according to specified Euler pole SYNTAX cont_rot.py [command line options] OPTIONS -h prints help and quits -con [af, aus, eur, ind, sam, ant, grn, lau, nam] -eye ELAT ELON [specify eyeball location] -eul PLAT PLON OMEGA [specify euler rotation vector] -feu EFILE, specifies series of euler rotations vector in tab delimited file -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -prj PROJ, specify one of the following: stere = Stereographic geos = geostationary lcc = lambert conformal robin = Robinson moll = molweide merc = mercator laea = Lambert azimuthal equal area DEFAULTS con: nam res: i prj: mercator ELAT,ELON = 0,0 NB: MUST have either -eul or -feu set """ dir_path = '.' ocean = 0 proj = 'ortho' euler_file = '' cont = 'waf.asc' Poles = [] lat_0, lon_0 = 0., 0. fmt = 'svg' lon_0 = 45. lat_0 = 20. euler_file = 'polerots' f = open(euler_file, 'rU') edata = f.readlines() for line in edata: rec = line.split() Poles.append([float(rec[0]), float(rec[1]), float(rec[2])]) FIG = {'map': 1} pmagplotlib.plot_init(FIG['map'], 6, 6) # read in er_sites file lats, lons = [], [] data = continents.get_continent(cont) for line in data: lats.append(float(line[0])) lons.append(float(line[1])) Opts = { 'latmin': -90, 'latmax': 90, 'lonmin': 0., 'lonmax': 360., 'lat_0': lat_0, 'lon_0': lon_0, 'proj': proj, 'details': 0, 'sym': 'r-', 'padlat': 0, 'padlon': 0, 'res': 'i' } pmagplotlib.plotMAP(FIG['map'], lats, lons, Opts) pmagplotlib.drawFIGS(FIG) gclats = range(20, 91) gclons = [] for lat in gclats: gclons.append(355.) Opts['sym'] = 'b-' pmagplotlib.plotMAP(FIG['map'], gclats, gclons, Opts) pmagplotlib.drawFIGS(FIG) newlats, newlons = [], [] for lat in gclats: newlats.append(lat) for lon in gclons: newlons.append(lon) for pole in Poles: Opts['sym'] = 'b-' Rlats, Rlons = pmag.PTrot(pole, newlats, newlons) pmagplotlib.plotMAP(FIG['map'], Rlats, Rlons, Opts) Opts['sym'] = 'bo' pmagplotlib.plotMAP(FIG['map'], [Rlats[-1]], [Rlons[-1]], Opts) pmagplotlib.drawFIGS(FIG) Opts['sym'] = 'b-' newlats, newlons = [], [] for lat in Rlats: newlats.append(lat) for lon in Rlons: newlons.append(lon) files = {} for key in FIG.keys(): files[key] = 'pole_rot' + '.' + fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles = {} titles['eq'] = 'Site Map' FIG = pmagplotlib.addBorders(FIG, titles, black, purple) pmagplotlib.saveP(FIG, files) else: ans = raw_input(" S[a]ve to save plot, Return to quit: ") if ans == "a": pmagplotlib.saveP(FIG, files)
def main(): """ NAME basemap_magic.py NB: this program no longer maintained - use plot_mapPTS.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message and quits -f SFILE, specify er_sites.txt or pmag_results.txt format file -res [c,l,i,h] specify resolution (crude,low,intermediate,high) -etp plot the etopo20 topographic mesh -pad [LAT LON] pad bounding box by LAT/LON (default is [.5 .5] degrees) -grd SPACE specify grid spacing -prj [lcc] , specify projection (lcc=lambert conic conformable), default is mercator -n print site names (default is not) -l print location names (default is not) -o color ocean blue/land green (default is not) -R don't plot details of rivers -B don't plot national/state boundaries, etc. -sav save plot and quit quietly -fmt [png,svg,eps,jpg,pdf] specify format for output, default is pdf DEFAULTS SFILE: 'er_sites.txt' resolution: intermediate saved images are in pdf """ dir_path='.' sites_file='er_sites.txt' ocean=0 res='i' proj='merc' prn_name=0 prn_loc=0 fancy=0 rivers,boundaries=0,0 padlon,padlat,gridspace,details=.5,.5,.5,1 fmt='pdf' if '-h' in sys.argv: print main.__doc__ sys.exit() if '-f' in sys.argv: ind = sys.argv.index('-f') sites_file=sys.argv[ind+1] if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if '-etp' in sys.argv:fancy=1 if '-n' in sys.argv:prn_name=1 if '-l' in sys.argv:prn_loc=1 if '-o' in sys.argv:ocean=1 if '-R' in sys.argv:rivers=0 if '-B' in sys.argv:boundaries=0 if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] if '-fmt' in sys.argv: ind = sys.argv.index('-fmt') fmt=sys.argv[ind+1] verbose=pmagplotlib.verbose if '-sav' in sys.argv: verbose=0 if '-pad' in sys.argv: ind = sys.argv.index('-pad') padlat=float(sys.argv[ind+1]) padlon=float(sys.argv[ind+2]) if '-grd' in sys.argv: ind = sys.argv.index('-grd') gridspace=float(sys.argv[ind+1]) if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] sites_file=dir_path+'/'+sites_file location="" FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) # read in er_sites file Sites,file_type=pmag.magic_read(sites_file) if 'results' in file_type: latkey='average_lat' lonkey='average_lon' namekey='pmag_result_name' lockey='er_location_names' else: latkey='site_lat' lonkey='site_lon' namekey='er_site_name' lockey='er_location_name' lats,lons=[],[] slats,slons=[],[] names,locs=[],[] for site in Sites: if prn_loc==1 and location=="":location=site['er_location_name'] lats.append(float(site[latkey])) l=float(site[lonkey]) if l<0:l=l+360. # make positive lons.append(l) if prn_name==1:names.append(site[namekey]) if prn_loc==1:locs.append(site[lockey]) for lat in lats:slats.append(lat) for lon in lons:slons.append(lon) Opts={'res':res,'proj':proj,'loc_name':locs,'padlon':padlon,'padlat':padlat,'latmin':numpy.min(slats)-padlat,'latmax':numpy.max(slats)+padlat,'lonmin':numpy.min(slons)-padlon,'lonmax':numpy.max(slons)+padlon,'sym':'ro','boundinglat':0.,'pltgrid':1.} Opts['lon_0']=0.5*(numpy.min(slons)+numpy.max(slons)) Opts['lat_0']=0.5*(numpy.min(slats)+numpy.max(slats)) Opts['names']=names Opts['gridspace']=gridspace Opts['details']={'coasts':1,'rivers':1,'states':1,'countries':1,'ocean':0} if ocean==1:Opts['details']['ocean']=1 if rivers==1: Opts['details']['rivers']=0 if boundaries==1: Opts['details']['states']=0 Opts['details']['countries']=0 Opts['details']['fancy']=fancy pmagplotlib.plotMAP(FIG['map'],lats,lons,Opts) if verbose:pmagplotlib.drawFIGS(FIG) files={} for key in FIG.keys(): files[key]='Site_map'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['map']='Site Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) elif verbose: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files) else: pmagplotlib.saveP(FIG,files)
def main(): """ NAME plot_mapPTS.py DESCRIPTION plots points on map SYNTAX plot_mapPTS.py [command line options] OPTIONS -h prints help and quits -sym [ro, bs, g^, r., b-, etc.] [1,5,10] symbol and size for points colors are r=red,b=blue,g=green, etc. symbols are '.' for points, ^, for triangle, s for square, etc. -, for lines, -- for dotted lines, see matplotlib online documentation for plot() -eye ELAT ELON [specify eyeball location] -f FILE, specify input file -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -prj PROJ, specify one of the supported projections: (see basemap.py online documentation) aeqd = Azimuthal Equidistant poly = Polyconic gnom = Gnomonic moll = Mollweide tmerc = Transverse Mercator nplaea = North-Polar Lambert Azimuthal mill = Miller Cylindrical merc = Mercator stere = Stereographic npstere = North-Polar Stereographic geos = Geostationary laea = Lambert Azimuthal Equal Area sinu = Sinusoidal spstere = South-Polar Stereographic lcc = Lambert Conformal npaeqd = North-Polar Azimuthal Equidistant eqdc = Equidistant Conic cyl = Cylindrical Equidistant omerc = Oblique Mercator aea = Albers Equal Area spaeqd = South-Polar Azimuthal Equidistant ortho = Orthographic cass= Cassini-Soldner splaea = South-Polar Lambert Azimuthal robin = Robinson INPUTS space delimited LON LAT data DEFAULTS res: c prj: mollweide ELAT,ELON = 0,0 NB: high resolution or lines can be very slow """ dir_path='.' ocean=0 res='c' proj='moll' Lats,Lons=[],[] lat_0,lon_0=0.,0. fmt='pdf' sym='ro' symsize=5 if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] if '-h' in sys.argv: print main.__doc__ sys.exit() if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if res!= 'c' and res!='l': print 'this resolution will take a while - be patient' if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] if '-eye' in sys.argv: ind = sys.argv.index('-eye') lat_0=float(sys.argv[ind+1]) lon_0=float(sys.argv[ind+2]) if '-sym' in sys.argv: ind = sys.argv.index('-sym') sym=sys.argv[ind+1] symsize=int(sys.argv[ind+2]) if '-f' in sys.argv: ind = sys.argv.index('-f') file=dir_path+'/'+sys.argv[ind+1] f=open(file,'rU') ptdata=f.readlines() for line in ptdata: rec=line.split() if len(rec)>1: Lons.append(float(rec[0])) Lats.append(float(rec[1])) else: print "input file must be specified" sys.exit() FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) if res=='c':skip=8 if res=='l':skip=5 if res=='i':skip=2 if res=='h':skip=1 cnt=0 Opts={'latmin':-90,'latmax':90,'lonmin':0.,'lonmax':360.,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'sym':sym,'symsize':3,'pltgrid':0,'res':res,'boundinglat':0.} Opts['details']={} Opts['details']['coasts']=1 Opts['details']['rivers']=0 Opts['details']['states']=0 Opts['details']['countries']=0 Opts['details']['ocean']=0 if proj=='merc': Opts['latmin']=-70 Opts['latmax']=70 Opts['lonmin']=-180 Opts['lonmax']=180 print 'please wait to draw points' Opts['sym']=sym Opts['symsize']=symsize pmagplotlib.plotMAP(FIG['map'],Lats,Lons,Opts) pmagplotlib.drawFIGS(FIG) files={} for key in FIG.keys(): files[key]='Map_PTS'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['eq']='PT Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files)
def main(): """ NAME plot_mapPTS.py DESCRIPTION plots points on map SYNTAX plot_mapPTS.py [command line options] OPTIONS -h prints help and quits -sym [ro, bs, g^, r., b-, etc.] [1,5,10] symbol and size for points colors are r=red,b=blue,g=green, etc. symbols are '.' for points, ^, for triangle, s for square, etc. -, for lines, -- for dotted lines, see matplotlib online documentation for plot() -eye ELAT ELON [specify eyeball location] -etp put on topography -f FILE, specify input file -o color ocean blue/land green (default is not) -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -fmt [pdf,eps, png] specify output format (default is pdf) -R don't plot details of rivers -B don't plot national/state boundaries, etc. -pad [LAT LON] pad bounding box by LAT/LON (default is not) -grd SPACE specify grid spacing -sav save plot and quit -prj PROJ, specify one of the supported projections: (see basemap.py online documentation) aeqd = Azimuthal Equidistant poly = Polyconic gnom = Gnomonic moll = Mollweide tmerc = Transverse Mercator nplaea = North-Polar Lambert Azimuthal mill = Miller Cylindrical merc = Mercator stere = Stereographic npstere = North-Polar Stereographic geos = Geostationary laea = Lambert Azimuthal Equal Area sinu = Sinusoidal spstere = South-Polar Stereographic lcc = Lambert Conformal npaeqd = North-Polar Azimuthal Equidistant eqdc = Equidistant Conic cyl = Cylindrical Equidistant omerc = Oblique Mercator aea = Albers Equal Area spaeqd = South-Polar Azimuthal Equidistant ortho = Orthographic cass= Cassini-Soldner splaea = South-Polar Lambert Azimuthal robin = Robinson Special codes for MagIC formatted input files: -n -l INPUTS space or tab delimited LON LAT data OR: standard MagIC formatted er_sites or pmag_results table DEFAULTS res: c prj: mollweide; lcc for MagIC format files ELAT,ELON = 0,0 pad LAT,LON=0,0 NB: high resolution or lines can be very slow """ dir_path='.' plot=0 ocean=0 res='c' proj='moll' Lats,Lons=[],[] fmt='pdf' sym='ro' symsize=5 fancy=0 rivers,boundaries,ocean=1,1,0 latmin,latmax,lonmin,lonmax,lat_0,lon_0=-90,90,0.,360.,0.,0. padlat,padlon,gridspace=0,0,30 lat_0,lon_0="","" prn_name,prn_loc,names,locs=0,0,[],[] if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path=sys.argv[ind+1] if '-h' in sys.argv: print main.__doc__ sys.exit() if '-fmt' in sys.argv: ind = sys.argv.index('-fmt') fmt=sys.argv[ind+1] if '-res' in sys.argv: ind = sys.argv.index('-res') res=sys.argv[ind+1] if res!= 'c' and res!='l': print 'this resolution will take a while - be patient' if '-etp' in sys.argv: fancy=1 if '-sav' in sys.argv: plot=1 if '-R' in sys.argv:rivers=0 if '-B' in sys.argv:boundaries=0 if '-o' in sys.argv:ocean=1 if '-grd' in sys.argv: ind = sys.argv.index('-grd') gridspace=float(sys.argv[ind+1]) if '-eye' in sys.argv: ind = sys.argv.index('-eye') lat_0=float(sys.argv[ind+1]) lon_0=float(sys.argv[ind+2]) if '-sym' in sys.argv: ind = sys.argv.index('-sym') sym=sys.argv[ind+1] symsize=int(sys.argv[ind+2]) if '-pad' in sys.argv: ind = sys.argv.index('-pad') padlat=float(sys.argv[ind+1]) padlon=float(sys.argv[ind+2]) if '-f' in sys.argv: ind = sys.argv.index('-f') file=dir_path+'/'+sys.argv[ind+1] header=open(file,'rU').readlines()[0].split('\t') if 'tab' in header[0]: if '-n' in sys.argv:prn_name=1 if '-l' in sys.argv:prn_loc=1 proj='lcc' if 'results' in header[1]: latkey='average_lat' lonkey='average_lon' namekey='pmag_result_name' lockey='er_location_names' elif 'sites' in header[1]: latkey='site_lat' lonkey='site_lon' namekey='er_site_name' lockey='er_location_name' else: print 'file type not supported' print main.__doc__ sys.exit() Sites,file_type=pmag.magic_read(file) Lats=pmag.get_dictkey(Sites,latkey,'f') Lons=pmag.get_dictkey(Sites,lonkey,'f') if prn_name==1:names=pmag.get_dictkey(Sites,namekey,'') if prn_loc==1:names=pmag.get_dictkey(Sites,lockey,'') else: f=open(file,'rU') ptdata=numpy.loadtxt(file) Lons=ptdata.transpose()[0] Lats=ptdata.transpose()[1] latmin=numpy.min(Lats)-padlat lonmin=numpy.min(Lons)-padlon latmax=numpy.max(Lats)+padlat lonmax=numpy.max(Lons)+padlon if lon_0=="": lon_0=0.5*(lonmin+lonmax) lat_0=0.5*(latmin+latmax) else: print "input file must be specified" sys.exit() if '-prj' in sys.argv: ind = sys.argv.index('-prj') proj=sys.argv[ind+1] FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) if res=='c':skip=8 if res=='l':skip=5 if res=='i':skip=2 if res=='h':skip=1 cnt=0 Opts={'latmin':latmin,'latmax':latmax,'lonmin':lonmin,'lonmax':lonmax,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'sym':sym,'symsize':3,'pltgrid':1,'res':res,'boundinglat':0.,'padlon':padlon,'padlat':padlat,'gridspace':gridspace} Opts['details']={} Opts['details']['coasts']=1 Opts['details']['rivers']=rivers Opts['details']['states']=boundaries Opts['details']['countries']=boundaries Opts['details']['ocean']=ocean Opts['details']['fancy']=fancy if len(names)>0:Opts['names']=names if len(locs)>0:Opts['loc_name']=locs if proj=='merc': Opts['latmin']=-70 Opts['latmax']=70 Opts['lonmin']=-180 Opts['lonmax']=180 print 'please wait to draw points' Opts['sym']=sym Opts['symsize']=symsize pmagplotlib.plotMAP(FIG['map'],Lats,Lons,Opts) files={} for key in FIG.keys(): files[key]='Map_PTS'+'.'+fmt if pmagplotlib.isServer or plot: black = '#000000' purple = '#800080' titles={} titles['eq']='PT Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: pmagplotlib.drawFIGS(FIG) ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files)
def main(): """ NAME cont_rot.py DESCRIPTION rotates continental fragments according to specified Euler pole SYNTAX cont_rot.py [command line options] OPTIONS -h prints help and quits -con [af, aus, eur, ind, sam, ant, grn, lau, nam] -eye ELAT ELON [specify eyeball location] -eul PLAT PLON OMEGA [specify euler rotation vector] -feu EFILE, specifies series of euler rotations vector in tab delimited file -res [c,l,i,h] specify resolution (crude, low, intermediate, high] -prj PROJ, specify one of the following: stere = Stereographic geos = geostationary lcc = lambert conformal robin = Robinson moll = molweide merc = mercator laea = Lambert azimuthal equal area DEFAULTS con: nam res: i prj: mercator ELAT,ELON = 0,0 NB: MUST have either -eul or -feu set """ dir_path='.' ocean=0 proj='ortho' euler_file='' cont='waf.asc' Poles=[] lat_0,lon_0=0.,0. fmt='svg' lon_0=45. lat_0=20. euler_file='polerots' f=open(euler_file,'rU') edata=f.readlines() for line in edata: rec=line.split() Poles.append([float(rec[0]),float(rec[1]),float(rec[2])]) FIG={'map':1} pmagplotlib.plot_init(FIG['map'],6,6) # read in er_sites file lats,lons=[],[] data=continents.get_continent(cont) for line in data: lats.append(float(line[0])) lons.append(float(line[1])) Opts={'latmin':-90,'latmax':90,'lonmin':0.,'lonmax':360.,'lat_0':lat_0,'lon_0':lon_0,'proj':proj,'details':0,'sym':'r-','padlat':0,'padlon':0,'res':'i'} pmagplotlib.plotMAP(FIG['map'],lats,lons,Opts) pmagplotlib.drawFIGS(FIG) gclats=range(20,91) gclons=[] for lat in gclats:gclons.append(355.) Opts['sym']='b-' pmagplotlib.plotMAP(FIG['map'],gclats,gclons,Opts) pmagplotlib.drawFIGS(FIG) newlats,newlons=[],[] for lat in gclats:newlats.append(lat) for lon in gclons:newlons.append(lon) for pole in Poles: Opts['sym']='b-' Rlats,Rlons=pmag.PTrot(pole,newlats,newlons) pmagplotlib.plotMAP(FIG['map'],Rlats,Rlons,Opts) Opts['sym']='bo' pmagplotlib.plotMAP(FIG['map'],[Rlats[-1]],[Rlons[-1]],Opts) pmagplotlib.drawFIGS(FIG) Opts['sym']='b-' newlats,newlons=[],[] for lat in Rlats:newlats.append(lat) for lon in Rlons:newlons.append(lon) files={} for key in FIG.keys(): files[key]='pole_rot'+'.'+fmt if pmagplotlib.isServer: black = '#000000' purple = '#800080' titles={} titles['eq']='Site Map' FIG = pmagplotlib.addBorders(FIG,titles,black,purple) pmagplotlib.saveP(FIG,files) else: ans=raw_input(" S[a]ve to save plot, Return to quit: ") if ans=="a": pmagplotlib.saveP(FIG,files)