;+ ; Flip the data end-to-end in the indicated index in the global data ; containers. ; ;

For line data the value of frequency_increment and reference_channel ; are also changed appropriately so that, as displayed, there will be ; no change in appearance. This is useful if you need to combine ; (e.g. average) two data containers where the frequency increments ; have opposite signs. ; ;

For continuum data (where the need to invert is less obvious), all ; of the time-dependent arrays are also flipped (utc, mjd, etc). ; ;

The invert is done in place. Use ; dcinvert to ; flip a data container that is not one of the global data containers. ; ; @keyword index {in}{required}{type=integer}{default=0} guide data container to ; use. ; ; @uses dcinvert ; ; @version $Id: invert.pro,v 1.1 2005/04/20 21:18:41 bgarwood Exp $ ;- pro invert, index=index compile_opt idl2 if n_elements(index) eq 0 then index=0 if !g.line then begin if index lt 0 or index gt n_elements(!g.s) then begin message,string(n_elements(!g.s),format='("Index must be between 0 and ",i2)'),/info return endif nch=data_valid(!g.s[index]) if nch le 0 then begin message, 'No valid data found to invert.',/info return endif *!g.s[index].data_ptr = reverse(*!g.s[index].data_ptr) !g.s[index].frequency_interval = -!g.s[index].frequency_interval !g.s[index].reference_channel = nch - 1 - !g.s[index].reference_channel endif else begin if index lt 0 or index gt n_elements(!g.c) then begin message,string(n_elements(!g.c),format='("Index must be between 0 and ", i2)'),/info return endif nch=data_valid(!g.c[index]) if nch le 0 then begin message, 'No valid data found to invert.',/info return endif *!g.c[index].data_ptr = reverse(*!g.c[index].data_ptr) *!g.c[index].date = reverse(*!g.c[index].date) *!g.c[index].utc = reverse(*!g.c[index].utc) *!g.c[index].mjd = reverse(*!g.c[index].mjd) *!g.c[index].longitude_axis = reverse(*!g.c[index].longitude_axis) *!g.c[index].latitude_axis = reverse(*!g.c[index].latitude_axis) *!g.c[index].lst = reverse(*!g.c[index].lst) *!g.c[index].azimuth = reverse(*!g.c[index].azimuth) *!g.c[index].elevation = reverse(*!g.c[index].elevation) endelse ; even though it won't appear to have changed, update the display ; anyway if not frozen so that what appears there is a faithful ; copy of the this data container. if not !g.frozen and index eq 0 then show end