avni.plots.models module#

avni.plots.models.plot_gcpaths(m, stlon: Union[float, numpy.ndarray], stlat: Union[float, numpy.ndarray], eplon: Union[float, numpy.ndarray], eplat: Union[float, numpy.ndarray], ifglobal: bool = False, **kwargs)[source]#

Plots great-circle paths from longitude and latitude arrays.

Parameters
m

An instance of mpl_toolkits.basemap Class

stlontp.Union[float,np.ndarray]

Longitudes of station location(s)

stlattp.Union[float,np.ndarray]

Latitudes of station location(s)

eplontp.Union[float,np.ndarray]

Longitudes of station location(s)

eplattp.Union[float,np.ndarray]

Latitudes of station location(s)

ifglobalbool, optional

Set extent to be global, by default False

**kwargsdict

Optional arguments for Basemap

Returns
m

Updated instance of mpl_toolkits.basemap Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.plot_hotspots(m, dbs_path: Union[None, str] = None, lon360: bool = False, **kwargs)[source]#

Reads hotspots.pkl from dbs_path and plots on to map instance

Earlier, the data was in pickle format, cross-platform compatibility required json # hotspots = pickle.load(open(‘%s/hotspots.pkl’ % (dbs_path), ‘rb’)) # tools.writejson(hotspots,’%s/hotspots.json’ % (dbs_path))

Parameters
m

An instance of mpl_toolkits.basemap Class

dbs_pathtp.Union[None,str], optional

path specified by user where hotspots.json is located. If not found, defaults to downloading the file from the AVNI server, by default None

lon360bool, optional

False if the no longitude above 180 is permitted and is wrapped around, by default False

**kwargsdict

Optional arguments for Basemap

Returns
m

Updated instance of mpl_toolkits.basemap Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.plot_plates(m, dbs_path: Union[None, str] = None, lon360: bool = False, boundtypes: list = ['ridge', 'transform', 'trench'], **kwargs)[source]#

Plots different types of tectonic plates on to a map object

Parameters
m

An instance of mpl_toolkits.basemap Class

dbs_pathtp.Union[None,str], optional

path specified by user where hotspots.json is located. If not found, defaults to downloading the file from the AVNI server, by default None

lon360bool, optional

False if the no longitude above 180 is permitted and is wrapped around, by default False

boundtypeslist, optional

Types of boundaries to plot, by default [‘ridge’, ‘transform’, ‘trench’]

**kwargsdict

Optional arguments for Basemap

Returns
m

Updated instance of mpl_toolkits.basemap Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.globalmap(ax, valarray: Union[list, numpy.ndarray], vmin: Union[float, int], vmax: Union[float, int], dbs_path: Union[None, str] = None, colorlabel: Union[None, str] = None, colorticks: bool = True, ticklabels: Union[None, list, numpy.ndarray] = None, colorpalette: str = 'avni', colorcontour=21, hotspots: bool = False, grid: Union[list, numpy.ndarray] = [30.0, 90.0], gridwidth: int = 0, shading: bool = False, model: Union[None, str] = None, resolution: str = 'l', field: str = 'z', **kwargs)[source]#

Plots a 2-D cross-section of a 3D model on a predefined axis

Parameters
ax

Axis handle number

valarraytp.Union[list,np.ndarray]

a named numpy array containing latitudes (lat), longitudes (lon) and values (val). Can be initialized from three numpy arrays lat, lon and val $ data = np.vstack((lat,lon,val)).transpose() $ dt = {‘names’:[‘latitude’, ‘longitude’, ‘value’], ‘formats’:[float, float, float]} $ valarray = np.zeros(len(data), dtype=dt) $ valarray[‘latitude’] = data[:,0]; valarray[‘longitude’] = data[:,1]; valarray[‘value’] = data[:,2]

vmin,vmaxtp.Union[float,int]

Minimum and maximum value of the color scale

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

colorlabeltp.Union[None,str], optional

Label to use for the colorbar. If None, no colorbar is plotted, by default None

colorticksbool, optional

Label and draw the ticks in the colorbar, by default True

ticklabelstp.Union[None,list,np.ndarray], optional

Labels for ticks on the colorbar, by default None

colorpalettestr, optional

Matplotlib color scales or the AVNI one, by default ‘avni’

colorcontourint, optional

Number of contours for colors in the plot. Maximum is 520 and odd values are preferred so that mid value is at white/yellow or other neutral colors, by default 21

hotspotsbool, optional

Plot hotspots, by default False

gridtp.Union[list,np.ndarray], optional

Grid spacing in latitude and longitude, by default [30.,90.]

gridwidthint, optional

Width of the grid lines, by default 0

shadingbool, optional

Shade the plot based on topography, by default False

modeltp.Union[None,str], optional

Name of the topography file in NETCDF4 format, by default None so use constants.topography()

resolutionstr, optional

Resolution of boundary database to use in Basemap. Can be c (crude), l (low), i (intermediate), h (high), f (full), by default ‘l’

fieldstr, optional

Field name in the NETCDF4 file to use, by default ‘z’

**kwargsdict

Optional arguments for Basemap

Returns
m

Updated instance of mpl_toolkits.basemap() Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.backgroundmap(ax, dbs_path: Union[None, str] = None, plates: str = 'r', oceans: str = 'w', continents: str = 'darkgray', boundary: str = 'k', **kwargs)[source]#

Plots a background map of a 3D model on an axis handle.

Parameters
ax

Axis handle number

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

platesstr, optional

Color of tectonic plates, by default ‘r’

oceansstr, optional

Color of oceans, by default ‘w’

continentsstr, optional

Color of continents, by default ‘darkgray’

boundarystr, optional

Color of background around the map, by default ‘k’

**kwargsdict

Optional arguments for Basemap

Returns
m

Updated instance of mpl_toolkits.basemap() Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.insetgcpathmap(ax, lat1: Union[int, float], lon1: Union[int, float], azimuth: Union[int, float], gcdelta: Union[int, float], projection: str = 'ortho', width: float = 50.0, height: float = 50.0, dbs_path: Union[None, str] = None, numdegticks: int = 7, hotspots: bool = False)[source]#

Plots the great-circle path based on azimuth and delta from initial location.

Takes width/heght arguments in degrees if projection is Mercator, etc.

Parameters
ax

Axis handle number

lat1tp.Union[int,float]

Initial location latitude

lon1tp.Union[int,float]

Initial location longitude

azimuthtp.Union[int,float]

Azimuth to final location

gcdeltatp.Union[int,float]

Distance in degrees to final location

projectionstr, optional

Map projection, by default ‘ortho’

widthfloat, optional

Width of the inset map, by default 50.

heightfloat, optional

Height of the inset map, by default 50.

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

numdegticksint, optional

Number of ticks along great-circle path, by default 7

hotspotsbool, optional

Plot hotspots, by default False

Returns
m

Updated instance of mpl_toolkits.basemap() Class

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.setup_axes(fig, rect, theta: Union[list, numpy.ndarray], radius: Union[list, numpy.ndarray], numdegticks: int = 7, r_locs: list = [3480.0, 3871.0, 4371.0, 4871.0, 5371.0, 5871.0, 6346.6], r_labels: list = ['CMB', ' ', '2000', ' ', '1000', ' ', 'Moho'], fontsize: int = 12)[source]#

Setup the polar axis for a section plot

Parameters
fig

A figure hand from plt.figure()

rect

A 3-digit number for axis on a plot. Obtained as axis handle from gridspec.GridSpec() instance. $gs = gridspec.GridSpec(1, 2) $rect = gs[1]

thetatp.Union[list,np.ndarray]

Range of degrees to plot

radiustp.Union[list,np.ndarray]

Range of radius to plot

numdegticksint, optional

Number of ticks along great-circle path, by default 7

r_locslist, optional

Radius locations to plot as curves, by default [3480.,3871.,4371.,4871.,5371.,5871.,6346.6]

r_labelslist, optional

Labels for the radius locations, by default [‘CMB’,’ ‘,’2000’,’ ‘,’1000’,’ ‘,’Moho’]

fontsizeint, optional

Tick font size, by default 12

Returns
ax1, aux_ax

Axis and auxillary axis where the polar axis plot has been made

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.gettopotransect(lat1: Union[int, float], lon1: Union[int, float], azimuth: Union[int, float], gcdelta: Union[int, float], model: Union[None, str] = None, tree=None, dbs_path: Union[None, str] = None, numeval: int = 50, resolution: str = 'l', nearest: int = 1)[source]#

Get the topography transect based on azimuth and delta from initial location.

Parameters
lat1tp.Union[int,float]

Initial location latitude

lon1tp.Union[int,float]

Initial location longitude

azimuthtp.Union[int,float]

Azimuth to final location

gcdeltatp.Union[int,float]

Distance in degrees to final location

modeltp.Union[None,str], optional

Name of the topography file in NETCDF4 format, by default None so constants.topography()

tree

A scipy.spatial.cKDTree() read from an earlier run, by default None

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

numevalint, optional

Number of evaluations of topo/bathymetry along the transect, by default 50

resolutionstr, optional

Resolution of boundary database to use in Basemap. Can be c (crude), l (low), i (intermediate), h (high), f (full), by default ‘l’

nearestint, optional

Number of nearest values in the KD-tree to interpolated from, by default 1 so nearest

Returns
valselect,model,tree

Values along selected transect, topography model values, and a scipy.spatial.cKDTree()

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.plottopotransect(ax, theta_range: numpy.ndarray, elev, vexaggerate: int = 150)[source]#

Plot a topographic transect on an axis

Parameters
ax

Axis handle number

theta_rangenp.ndarray

Range of angles

elev_type_

Elevation from topgraphy file, usually in sparse.csc_matrix() format.

vexaggerateint, optional

Vertical exxageration to make the plot visible, by default 150

Returns
ax

Axis handle where the plot has been made

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.getmodeltransect(lat1: Union[int, float], lon1: Union[int, float], azimuth: Union[int, float], gcdelta: Union[int, float], model: str = 'S362ANI+M.BOX25km_PIX1X1.avni.nc4', tree=None, parameter: str = 'vs', radii: list = [3480.0, 6346.6], dbs_path: Union[None, str] = None, numevalx: int = 200, numevalz: int = 200, distnearthreshold: float = 500.0, nearest: int = 10)[source]#

Get the tomography slice from a AVNI NETCDF4 file

Parameters
lat1tp.Union[int,float]

Initial location latitude

lon1tp.Union[int,float]

Initial location longitude

azimuthtp.Union[int,float]

Azimuth to final location

gcdeltatp.Union[int,float]

Distance in degrees to final location

modelstr, optional

Name of the tomographic model file in NETCDF4 format, by default ‘S362ANI+M.BOX25km_PIX1X1.avni.nc4’

tree

A scipy.spatial.cKDTree() read from an earlier run, by default None

parameterstr, optional

Physical parameter field in the NETCDF4 file, by default ‘vs’

radiilist, optional

Range of radius to plot on the slice, by default [3480.,6346.6]

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

numevalxint, optional

Number of model evaluations along the horizontal direction, by default 200

numevalzint, optional

Number of model evaluations along the vertical direction, by default 200

distnearthresholdfloat, optional

Threshold points that are up to a distance away [NOT IMPLEMENTED], by default 500.

nearestint, optional

Number of nearest values in the KD-tree to interpolated from, by default 10 so averages nearest 10 points

Returns
xsec,model,tree

Values along selected section, toography model values, and a scipy.spatial.cKDTree()

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.section(fig, lat1: Union[int, float], lon1: Union[int, float], azimuth: Union[int, float], gcdelta: Union[int, float], model: str, parameter: str, vmin: Union[float, int], vmax: Union[float, int], dbs_path: Union[None, str] = None, modeltree=None, colorlabel: Union[None, str] = None, colorpalette: str = 'avni', colorcontour: int = 20, nelevinter: int = 100, radii: list = [3480.0, 6346.6], vexaggerate: int = 50, width_ratios: list = [1, 3], numevalx: int = 200, numevalz: int = 300, nearest: int = 10, topo: Union[None, str] = None, resolution: str = 'l', topotree=None, hotspots: bool = False, xsec_data=None)[source]#

Plot one section across a pair of points based on azimuth and delta from initial location.

Parameters
fig

A figure hand from plt.figure()

lat1tp.Union[int,float]

Initial location latitude

lon1tp.Union[int,float]

Initial location longitude

azimuthtp.Union[int,float]

Azimuth to final location

gcdeltatp.Union[int,float]

Distance in degrees to final location

modelstr

Name of the tomographic model file in NETCDF4 format e.g. ‘S362ANI+M.BOX25km_PIX1X1.avni.nc4’

parameterstr

Physical parameter field in the NETCDF4 file, by default ‘vs’

vmin,vmaxtp.Union[float,int]

Minimum and maximum value of the color scale

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

modeltree, optional

A scipy.spatial.cKDTree() of tomograhic model read from an earlier run, by default None

colorlabeltp.Union[None,str], optional

Label to use for the colorbar. If None, no colorbar is plotted, by default None

colorpalettestr, optional

Matplotlib color scales or the AVNI one, by default ‘avni’

colorcontourint, optional

Number of contours for colors in the plot. Maximum is 520 and odd values are preferred so that mid value is at white/yellow or other neutral colors, by default 20

nelevinterint, optional

Number of evaluations of topo/bathymetry along the transect, by default 100

radiilist, optional

Range of radius to plot on the slice, by default [3480.,6346.6]

vexaggerateint, optional

Vertical exxageration to make the plot visible, by default 50

width_ratioslist, optional

Width ratios of the great circle and section subplots, by default [1,3]

numevalxint, optional

Number of model evaluations along the horizontal direction, by default 200

numevalzint, optional

Number of model evaluations along the vertical direction, by default 300

nearestint, optional

Number of nearest values in the KD-tree to interpolated from, by default 10 so averages nearest 10 points

topotp.Union[None,str], optional

Name of the topography file in NETCDF4 format, by default None so constants.topography()

resolutionstr, optional

Resolution of boundary database to use in Basemap. Can be c (crude), l (low), i (intermediate), h (high), f (full), by default ‘l’

topotree_type_, optional

A scipy.spatial.cKDTree() of topography read from an earlier run, by default None

hotspotsbool, optional

Plot hotspots on top of the plot [NOT IMPLEMENTED], by default False

xsec_data, optional

Interpolated data along a section found from an earlier run, by default None

Returns
fig,topo,topotree,model,modeltree

Figure handle, topography values, tomographic model values and the corresponding scipy.spatial.cKDTree()

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.plot1section(latitude: Union[int, float], longitude: Union[int, float], azimuth: Union[int, float], gcdelta: Union[int, float], model: str, parameter: str, vmin: Union[float, int], vmax: Union[float, int], figuresize: Union[list, numpy.ndarray] = [8, 4], outfile: Optional[str] = None, **kwargs)[source]#

Plot one section across a pair of points based on azimuth and delta from initial location..

Parameters
latitudetp.Union[int,float]

Initial location latitude

longitudetp.Union[int,float]

Initial location longitude

azimuthtp.Union[int,float]

Azimuth to final location

gcdeltatp.Union[int,float]

Distance in degrees to final location

modelstr

Name of the tomographic model file in NETCDF4 format e.g. ‘S362ANI+M.BOX25km_PIX1X1.avni.nc4’

parameterstr

Physical parameter field in the NETCDF4 file, by default ‘vs’

vmin,vmaxtp.Union[float,int]

Minimum and maximum value of the color scale

figuresizetp.Union[list, np.ndarray], optional

Figure size, by default [8,4]

outfilestr, optional

Output file to use in fig.savefig(), by default None

**kwargsdict

Optional arguments for Basemap

Returns
topo,topotree,model,modeltree

Topography values, tomographic model values and the corresponding scipy.spatial.cKDTree()

Authors

Raj Moulik (moulik@caa.columbia.edu)

Last Modified

2023.02.16 5.00

avni.plots.models.plot1globalmap(epixarr: numpy.ndarray, vmin: Union[float, int], vmax: Union[float, int], dbs_path: Union[None, str] = None, colorpalette: str = 'rainbow2', projection: str = 'robin', colorlabel: str = 'Anomaly (%)', lat_0: Union[int, float] = 0, lon_0: Union[int, float] = 150, outfile: Optional[str] = None, shading: bool = False)[source]#

Plot one global map

Parameters
epixarrnp.ndarray

Array containing (latitude, longitude, pixel_size, value)

vmin,vmaxtp.Union[float,int]

Minimum and maximum value of the color scale

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

colorpalettestr, optional

Matplotlib color scales or the AVNI one, by default ‘rainbow2’

projectionstr, optional

Map projection, by default ‘robin’

colorlabelstr, optional

Label to use for the colorbar. If None, no colorbar is plotted, by default “Anomaly (%)”

lat_0tp.Union[int,float], optional

Center latitude for the plot, by default 0

lon_0tp.Union[int,float], optional

Center longitude for the plot, by default 150

outfilestr, optional

Output file to use in fig.savefig(), by default None

shadingbool, optional

Shade the plot based on topography, by default False

avni.plots.models.plot1hitmap(hitfile: str, dbs_path: Union[None, str] = None, projection: str = 'robin', lat_0: Union[int, float] = 0, lon_0: Union[int, float] = 150, colorcontour: list = [0, 25, 100, 250, 400, 600, 800, 1000, 1500, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000], colorpalette: str = 'Blues', outformat: str = '.pdf', ifshow: bool = True)[source]#

Plot one hit count map

Parameters
hitfilestr

A file containg named columns - “latitude”, “longitude”, “value”

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

projectionstr, optional

Map projection, by default ‘robin’

lat_0tp.Union[int,float], optional

Center latitude for the plot, by default 0

lon_0tp.Union[int,float], optional

Center longitude for the plot, by default 150

colorcontourlist, optional

Number of contours for colors in the plot, by default [0,25,100,250,400,600,800,1000,1500,2500,5000,7500,10000,15000,20000,25000,30000,35000,40000,45000,50000]

colorpalettestr, optional

Matplotlib color scales or the AVNI one, by default ‘Blues’

outformatstr, optional

Output file format, by default ‘.pdf’

ifshowbool, optional

Display the plot before writing a file, by default True

avni.plots.models.plotreference1d(ref1d, figuresize: list = [7, 12], height_ratios: list = [2, 2, 1], ifshow: bool = True, format: str = '.eps', isotropic: bool = False, zoomdepth: list = [0.0, 1000.0])[source]#

Plot the ref1d object array in a PREM like plot

Parameters
ref1d

An instance of the Reference1D class.

figuresizelist, optional

Figure size, by default [7,12]

height_ratioslist, optional

Height ratios of the three subplots, by default [2, 2, 1]

ifshowbool, optional

Display the plot before writing a file, by default True

formatstr, optional

Output file format, by default ‘.eps’

isotropicbool, optional

Whether model is isotropic so seperate curves for Vsh and Vsv, by default False

zoomdepthlist, optional

Zoom into a depth extent in km, by default [0.,1000.]

avni.plots.models.plotmodel3d(model3d, dbs_path: Union[None, str] = None, x: int = 0, percent_or_km: str = '%', colormin: Union[int, float] = - 6.0, colormax: Union[int, float] = 6.0, depth: Union[None, list, numpy.ndarray] = None, resolution: int = 0, realization: int = 0)[source]#

Plots interactively a model slice of a variable at a given depth till an invalid depth is input by the user

Parameters
model3d

An instance of the Model3D class.

dbs_pathtp.Union[None,str], optional

Path specified by user where database containing hotpot locations, coastlines is located. If not found, defaults to downloading the files from the AVNI server, by default None so uses tools.get_filedir().

xint, optional

Index for variable to plot, by default 0

percent_or_kmstr, optional

Plot in percent (relative) or km/s (absolute) [NOT IMPLEMENTED], by default ‘%’

colormin, colormaxtp.Union[int,float], optional

Minimum and maximum value of the color scale, by default -6 and 6.

depthtp.Union[None,list,np.ndarray], optional

Depth to plot, by default None

resolutionint, optional

Resolution index in the Model3D instance, by default 0

realizationint, optional

Realization index in the Model3D instance, by default 0