[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string manipulation

I have been thinking about the following problem, but have been pretty

I have input keyword/value strings of the following form.  People may
recognize this from a FITS file.

TTYPE2  = 'X1LSpecPcu0'        / X1LSpecPcu0 : Histogram
TUNIT2  = 'count   '
1CPIX2  = '0~4,5:53,(54~135;2),(136~237;3),(238~249;4),250~255'
12CD2A  = 1.25
^name^^   ^value^^^^^^^

All of the keyword names have a trailing "2" which indicates that they
are describing column number 2 in a FITS table.  Note that in the name
"12CD2A", only the *final* 2 refers to the column number.

The interesting question happens when I want to change the column
number, say from "2" to "50".  Is there a straightforward way to do
this in "vectoral" sort of way?

I am able to find the string positions of the 2's, so that's not
really a problem.  I do this by making a byte array of the strings,
and blanking out any alphabetic characters and any leading numeric
characters.  Here I appreciate STRPOS is (partially) vectorized.

However, when it comes to resubstituting the "50" back in, that's when
I get stymied.  This is primarily because STRMID and STRPUT are not
vectorized at all.  Well STRMID *is* vectorized, but not with a sane
behavior.  For example, what I'd like to do is:

NEWKEY = STRMID(KEY,0,P1) + '50' + STRMID(KEY,P2,100)

Where KEY, P1, and P2 are vectors.  Obviously this doesn't work.  Any


Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response