; $Id: davedat2d__transpose.pro,v 1.2 2005/02/08 17:17:34 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveDat2D
;
; PURPOSE:
;   This class encapsulates a DAVE formated dataset containing 2D
;   data.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   DaveDat
;
; PUBLIC METHODS:
;   Clone
;   Get
;   Print
;   Rebin
;   ResetData
;   Restore
;   Set
;   Transpose
;   XSpec
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Oct, 2002
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################



;===============================================================================
; DaveDat2D::transpose
; 
; PURPOSE:
;   Transpose the current object's data and swap x and y axes.
;
; PARAMETERS:
;
; KEYWORDS:
;
; RETURN VALUE: 
;   0 => failure
;   1 => success
;
function DaveDat2D::transpose

; reset !error_state structure, ie clear all errors
message,/reset

; Get data 
if (~self->get(xVal=xval,xLabel=xlabel,xType=xtype,xUnits=xunits,xDir=xDir $
               ,yVal=yval,yLabel=ylabel,yType=ytype,yUnits=yunits,yDir=yDir $
               ,zval=zval, zerr=zerr,treatment=trmt,transpose=trp)) then return, 0

;; modify treatment info accordingly
line = '=================================================='
trmt = [trmt, $
        line, $
        'Transpose data and swap independent axes']


; re-insert the data with the x,y axes swapped and the data
; transposed. NB: transpose setting is toggled.
if (~self->set(xVal=yval,xLabel=ylabel,xType=ytype,xUnits=yunits,xDir=yDir $
               ,yVal=xval,yLabel=xlabel,yType=xtype,yUnits=xunits,yDir=xDir $
               ,zval=transpose(zval),zerr=transpose(zerr),treatment=trmt $
               ,transpose=1-trp)) then return, 0

return, 1
end
;_______________________________________________________________________________
