2D Plot in IDL with shading? [message #71450] |
Fri, 18 June 2010 12:36  |
Ally
Messages: 13 Registered: June 2010
|
Junior Member |
|
|
Hi,
I have three arrays-sun elevation, azimuth, and diode response, for
each of 12 sun sensors and I'm trying to create a 2D plot in IDL with
elevation on the x-axis, azimuth on the y-axis and the diode response
color coded on a gradient scale. It would kind of be like a birds-eye
view of what a 3D graph with elevation shading would look like. I've
been searching for two days now and can't seem to find anything online
that shows me how to make a graph like this. Any help is appreciated.
Thank you,
Allison Deshler
|
|
|
Re: 2D Plot in IDL with shading? [message #71493 is a reply to message #71450] |
Tue, 22 June 2010 09:10  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jun 22, 11:23 am, Ally <ally.desh...@gmail.com> wrote:
> My data isn't organized that way. It's real time data from a balloon
> flight so the azimuth and elevation of the sun are constantly
> changing. Does this mean they are not regular and I should let the
> gridding wizard interpolate them?
Yes. Or you can interpolate and the pass the result to the itools, in
case you do not want to do things interactively every time:
triangulate,elevation,azimuth,tr
response_2D=trigrid(elevation,azimuth,response,tr,xgrid=el_g rid,ygrid=az_grid,nx=200,ny=200)
(just guessing at 200 grid points, obviously; you need to find out
which grid resolution is most appropriate)
then you could do
iimage,response_2D,el_grid,az_grid
Or similarly with isurface or icontour.
|
|
|
Re: 2D Plot in IDL with shading? [message #71497 is a reply to message #71450] |
Tue, 22 June 2010 07:23  |
Ally
Messages: 13 Registered: June 2010
|
Junior Member |
|
|
On Jun 21, 4:16 pm, pp <pp.pente...@gmail.com> wrote:
> On Jun 21, 4:59 pm, Ally <ally.desh...@gmail.com> wrote:
>
>> I'm sorry, now I'm even more confused. I have my 3 data sets, which
>> are all arrays with one column and 5273670 rows. I'm trying to plot
>> them in this 3D graph as (x,y,z) points. I understand why you're
>> saying that I need to reform the response (hadn't thought about the
>> connectivity before) but don't understand the fastest-varying
>> dimension concept.
>
> You have 5273670 points for response, which are the product of some
> number of azimuths (I will call it n_az), by some number of elevations
> (I will call it n_el). It was written to the file as a 1D array, which
> can be done in one of two usual ways:
>
> 1) elevations varying fastest: responses for all elevations are given
> for the first azimuth, followed by the responses for all elevations of
> the next azimuth, and so on. In this case, you would reform it to
>
> response_2D=reform(response,n_el,n_az)
>
> 2) azimuths vary the fastest: responses for all azimuths are given for
> the first elevation, followed by the responses for all azimuths of the
> next elevation, and so on. In this case, the reform would be
>
> response_2D=reform(response,n_az,n_el)
>
>> I tried reform(response, 2, 5273670) and
>> reform(response, 5273670, 2) and got an error that said 'new
>> subscripts must not change the number elements in response' each
>> time. What dimension am I trying to add to reform exactly?
>
> Reform() only changes the dimensions of something, it preserves the
> number of elements. So the products of all dimensions you give to
> reform() must be the same as the number of elements of the array you
> are reforming. You were trying to make an array with two columns and
> 5273670 rows (and 5273670 columns and 2 rows), which is not the shape
> your response should have, nor is the same number of elements. The
> shape should be either (n_az,n_el), or (n_el,n_az), depending on how
> it was written to that file.
>
> If you inspect the values of the azimuths and elevations you can find
> out which is the order. If the first few (n_el) elements of azimuth
> are the same, then then fastest varying dimension is the elevation,
> and response should be reformed to (n_el,n_az).
My data isn't organized that way. It's real time data from a balloon
flight so the azimuth and elevation of the sun are constantly
changing. Does this mean they are not regular and I should let the
gridding wizard interpolate them?
|
|
|
Re: 2D Plot in IDL with shading? [message #71513 is a reply to message #71450] |
Mon, 21 June 2010 13:16  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jun 21, 4:59 pm, Ally <ally.desh...@gmail.com> wrote:
> I'm sorry, now I'm even more confused. I have my 3 data sets, which
> are all arrays with one column and 5273670 rows. I'm trying to plot
> them in this 3D graph as (x,y,z) points. I understand why you're
> saying that I need to reform the response (hadn't thought about the
> connectivity before) but don't understand the fastest-varying
> dimension concept.
You have 5273670 points for response, which are the product of some
number of azimuths (I will call it n_az), by some number of elevations
(I will call it n_el). It was written to the file as a 1D array, which
can be done in one of two usual ways:
1) elevations varying fastest: responses for all elevations are given
for the first azimuth, followed by the responses for all elevations of
the next azimuth, and so on. In this case, you would reform it to
response_2D=reform(response,n_el,n_az)
2) azimuths vary the fastest: responses for all azimuths are given for
the first elevation, followed by the responses for all azimuths of the
next elevation, and so on. In this case, the reform would be
response_2D=reform(response,n_az,n_el)
> I tried reform(response, 2, 5273670) and
> reform(response, 5273670, 2) and got an error that said 'new
> subscripts must not change the number elements in response' each
> time. What dimension am I trying to add to reform exactly?
Reform() only changes the dimensions of something, it preserves the
number of elements. So the products of all dimensions you give to
reform() must be the same as the number of elements of the array you
are reforming. You were trying to make an array with two columns and
5273670 rows (and 5273670 columns and 2 rows), which is not the shape
your response should have, nor is the same number of elements. The
shape should be either (n_az,n_el), or (n_el,n_az), depending on how
it was written to that file.
If you inspect the values of the azimuths and elevations you can find
out which is the order. If the first few (n_el) elements of azimuth
are the same, then then fastest varying dimension is the elevation,
and response should be reformed to (n_el,n_az).
|
|
|
Re: 2D Plot in IDL with shading? [message #71514 is a reply to message #71450] |
Mon, 21 June 2010 12:59  |
Ally
Messages: 13 Registered: June 2010
|
Junior Member |
|
|
On Jun 21, 3:15 pm, pp <pp.pente...@gmail.com> wrote:
> On Jun 21, 3:41 pm, Ally <ally.desh...@gmail.com> wrote:
>
>
>
>> On Jun 21, 11:14 am, pp <pp.pente...@gmail.com> wrote:
>
>>> On Jun 21, 12:09 pm, Ally <ally.desh...@gmail.com> wrote:
>
>>>> Great, that's exactly what I needed! I'm working on creating it right
>>>> now. Out of curiosity, is there any way to make a graph like that in
>>>> 2D to start with, without a z-axis and just response plotted in color
>>>> vs azimuth and elevation?
>
>>> That is what would be called an image, which can be made with
>
>>> iimage,response,elevation,azimuth
>
>> I keep trying but can't seem to get isurface to graph it. I may be
>> missing something basic but I've been reading through different
>> examples and can't figure it out. Here is what I have:
>
>> rows = 5273670
>> OPENR, lun1, 'ss_raw_06.dat', /GET_LUN
>> data = DBLARR(2,rows)
>> READF, lun1, data
>> response= data(1,*)
>
>> OPENR, lun2, 'az.dat', /GET_LUN
>> data2=DBLARR(2, rows)
>> READF, lun2, data2
>> az_g= data2(1,*)
>
>> OPENR, lun3, 'sun_el_and_az.dat', /GET_LUN
>> data3=DBLARR(2,rows)
>> READF, lun3, data3
>> az_s=data3(1,*)
>> elevation=data3(0,*)
>
>> azimuth=(az_s)-(az_g)
>
>> isurface, response, elevation, azimuth
>
>> It runs fine and the iSurface tool opens, there's just nothing
>> graphed.
>
> Have you checked that the data look right? You can check the
> dimensions with
>
> help,response,elevation,azimuth
>
> And maybe min()/max() may be useful to tell if the values seem to make
> sense.
>
> You are reading all 3 arrays as 1D. You indicated above that you have
> one response for each elevation and azimuth, which indicates that
> response should be reformed to 2D, with the proper dimensions:
>
> response_2D=reform(response,nx,ny)
>
> Where nx is the length of the fastest-varying dimension (leftmost),
> and ny is the other dimension. For this to be consistent with the way
> you called isurface, the fastest-varying dimension in the file where
> you read response from would have to be elevation, and the other would
> be the azimuth.
>
> If you do not provide response as a 2D array, the itools will not know
> the connectivity of your points, and thus will start the gridding
> wizard, to interpolate them, guessing they were not on a regular grid,
> which is not your case.
I'm sorry, now I'm even more confused. I have my 3 data sets, which
are all arrays with one column and 5273670 rows. I'm trying to plot
them in this 3D graph as (x,y,z) points. I understand why you're
saying that I need to reform the response (hadn't thought about the
connectivity before) but don't understand the fastest-varying
dimension concept. I tried reform(response, 2, 5273670) and
reform(response, 5273670, 2) and got an error that said 'new
subscripts must not change the number elements in response' each
time. What dimension am I trying to add to reform exactly?
|
|
|