Personal tools
You are here: Home Members azubrow's Home ioapiTools Modifying a Variable's Data
Document Actions

Modifying a Variable's Data


This tutorial describes a series of ways to modify the data portion of an iovar variable. 


1. Whole variable arithmetic

## Simply double every value in o3
o3_tmp1 = o3 * 2

## add a value (10ppb) to every value
o3_tmp2 = o3 + .010

## Do some spot checking
o3.getValue()[12,0,33]
o3_tmp1.getValue()[12,0,33]
o3_tmp2.getValue()[12,0,33]


  Table of Contents Contents

2. Slices and individual elements

## make a copy of the variable
o3_tmp3 = o3.IOclone()

## modify a single element
o3_tmp3[12,0,33,26] = .1

## Make another copy and
## add a constant to each time slice
o3_tmp4 = o3.IOclone()
for i in xrange(24):
o3_tmp4[i] += i

## Make a copy
## modify a subset of the rows and all the columns

## for a specific time and layer
o3_tmp5 = o3.IOclone()
o3_tmp5[12,0,30:] = o3[2,0,30:] * 2

The IOclone method makes a copy of the iovar object so that we don't modify the original values.  The method copies all the data and metadata to the new iovar object.



  Table of Contents Contents


3. Arithmetic with Multiple variables

## extract NO from the IOAPI file
no = f("no")

## Create an NOx variable
nox = no + no2

Variable arithmetic is an easy way to create new variables.  For this to work, the two variables must have the same domain.  The new variable, "nox", still needs to have its metadata modified (see "Modifying a Variable's Metadata")

  Table of Contents Previous Next
Contents Previous Next


Powered by Plone