PyCVM Guide

From SCECpedia
Revision as of 23:15, 2 July 2014 by Davidgil (talk | contribs)
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 and have CVM-S5 installed, 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

Getting Properties at CyberShake Sites

We can also get properties at CyberShake sites. Included with PyCVM are the CyberShake 14.2 study sites for easy access. For example, to get the Vs30 data at the Del Amo CyberShake site, we would do the following:

from pycvm import *
u = UCVM()
u.vs30_query(CyberShake.getsitebycode("DLA"), "cvms5") # Retreives Vs30 value from CVM-S5 at the Del Amo site.

This will return "213.607" which is the average Vs value in the top 30 meters in CVM-S5 at the Del Amo site.

We can use the same method to get Z1.0 and Z2.5 values:

u.basin_depth(CyberShake.getsitebycode("DLA"), "cvms5", 1000) # Retreives Z1.0 (Vs = 1000m/s) depth from CVM-S5 at the Del Amo site.

This will return "660.0" which means that Vs first goes above 1000m/s at 660 meters below the surface.