## misc/

# pmb_spatial_temporal_limits.pro

Misc, Data Processing, Spatial Limit, Temporal Limit

Given arrays of times, x, y, and z, and corresponding limits, return a set of indices in which all the data falls within the given limits. This routine is handy when trying to limit data both spatially and temporally.

Basically, this routine is a wrapper for an operation I do quite often: given some data in time and space, limit the data to a particular field of view.

Although the parameters are named xyz, this certainly could be lat/lon values. See the example.

## Examples

This is pretty straightfoward:

```
npts = 100
lats = RANDOMU(1L, npts)*2 + 34 ;random nums between 34 and 36
lons = RANDOMU(2L, npts)*2 - 87 ;random nums between -87 and -85
alts = RANDOMU(2L, npts)*15 ;random nums between 0 and 15
times = FINDGEN(npts) ;an array of times
```

```
ind = PMB_SPATIAL_TEMPORAL_LIMITS(times, lats, lons, alts, $
X_LIMITS=[34.5, 35.5], Y_LIMITS=[-86.5, -85.2])
```

Plot the result:

```
cgPlot, lons, lats, PSYM=4, /YNO
cgCOLORFILL, [-86.5, -85.2, -85.2, -86.5], [34.5, 34.5, 35.5, 35.5] ;highlight the good region
cgPlots, lons[ind], lats[ind], PSYM=4, COLOR='red'
```

## Author information

- Author
Phillip M. Bitzer, University of Alabama in Huntsville, pm.bitzer "AT" uah.edu

- History
Modification History:

`First written: Nov 2, 2012 (Finally) added documentation and released. 20140424 PMB`

## Routines

## top pmb_spatial_temporal_limits

`result = pmb_spatial_temporal_limits(times, x, y, z [, T_limits=array] [, X_limits=array] [, Y_limits=array] [, Z_limits=array] [, Count=long integer])`

This function will limit spatial-temporal data within the given limits.

### Return value

Indices of the array(s) that all fall within the limits.

### Parameters

- times in required type=array
An n element array of times. Needs to be the same size as

`x`

,`y`

and`z`

.- x in required type=array
An n element array of times. Needs to be the same size as

`x`

and`y`

.- y in required type=array
An n element array of times. Needs to be the same size as

`x`

and`y`

.- z in required type=array
An n element array of times. Needs to be the same size as

`x`

and`y`

.

### Keywords

- T_limits in optional type=array default=[MIN(times), MAX(times)]
A two element array that specifies the min and max time to consider.

- X_limits in optional type=array default=[MIN(x),MAX(x)]
A two element array that specifies the min and max x to consider.

- Y_limits in optional type=array default=[MIN(y),MAX(y)]
A two element array that specifies the min and max y to consider.

- Z_limits in optional type=array default=[MIN(z),MAX(z)]
A two element array that specifies the min and max z to consider.

- Count out optional type=long integer
The number of elements that are within all limits.

## File attributes

Modification date: | Fri Feb 10 20:51:04 2017 |

Lines: | 40 |

Docformat: | rst rst |