comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Create new variable with subset of 4D array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Create new variable with subset of 4D array [message #87625] Wed, 19 February 2014 10:13 Go to next message
morganlsilverman is currently offline  morganlsilverman
Messages: 46
Registered: February 2013
Member
Hello,

I have a 4d array of data (lat,lon,altitude,time) that I need to extract a certain subset from. I typically use where to search for data.

for i=0,n_elements(houram)-1 do begin
index = where(lat(*,*,0,i) gt 38.996 and lat(*,*,0,i) lt 39.43 $
and lon(*,*,0,i) gt -76.95 and lon(*,*,0,i) lt -76.56)
lat_new(0:n_elements(index),i) = lat(index)
endfor

I'm running into problems creating new variables with only the found index data points. I keep getting the error 'Array subscript for LAT_NEW must have same size as source expression'. I understand that the indexed result is a 1d array and I'm trying to then pull those indexes from a 4d array, which won't work. The only way I can think to make this work though is to add 2 more for loops to go through latitude and longitude and provide a 4d result in some way. This seems really inefficient though. I know IDL must have a more efficient way to search for this data and create a new variable with it.

I hope this makes sense. Thank you.

Sincerely,
Morgan
Re: Create new variable with subset of 4D array [message #87626 is a reply to message #87625] Wed, 19 February 2014 10:32 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Try replacing

> lat_new(0:n_elements(index),i) = lat(index)

with

lat_new(0:n_elements(index)-1, i) = lat(index)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: read a multi-line string in IDL? or, read numeric values sequentially without automatic <CR>?
Next Topic: Phoenician aleph

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:06:48 PDT 2025

Total time taken to generate the page: 0.00468 seconds