PyCVM Guide

From SCECpedia
Revision as of 23:04, 2 July 2014 by Davidgil (talk | contribs) (Created page with '== Introduction == UCVM 14.7.0 introduced a new Python interface for querying models and creating plots, including difference plots. This interface allows people who are somewha…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

UCVM 14.7.0 introduced a new Python interface for querying models and creating plots, including difference plots. This interface allows people who are somewhat familiar with Python to explore models in an intuitive manner.

Using PyCVM

API Documentation

For a quick reference of all the available PyCVM commands, please look at the API documentation.

Installing PyCVM

PyCVM is included with all versions of UCVM starting with 14.7.0. To install PyCVM, go to the utilities directory in your UCVM install directory (this will typically be something like /home/user/ucvm-14.7.0/utilities). Then run the following commands:

$ cd pycvm
$ python setup.py install

The Python installer will then install your package and make it available to your future Python scripts and commands.

Getting Started with PyCVM

PyCVM is easy to start using. We can query UCVM through the Python interface, using the query method:

from pycvm import *
u = UCVM()
print u.query(Point(-118, 34, 0), "cvms5")

If you run this script, you should see as output:

Vp: 824.18m/s, Vs: 195.00m/s, Density: 1520.50g/cm^3

We can also pass an array of points as well:

ret = u.query([Point(-118, 34, 0), Point(-119, 34, 0)], "cvms5")
print str(ret[0]) + " and " + str(ret[1])

If you run this command, you'll see output as follows:

Vp: 824.18m/s, Vs: 195.00m/s, Density: 1520.50g/cm^3 and Vp: 646.45m/s, Vs: 90.00m/s, Density: 1403.68g/cm^3